How to use name method of Plugins Package

Best Inspec_ruby code snippet using Plugins.name

config.rb

Source:config.rb Github

copy

Full Screen

...42 # == Safe Mode43 #44 # YARD supports running in safe-mode. By doing this, it will avoid executing45 # any user code such as require files or queries. Plugins will still be46 # loaded with safe mode on, because plugins are properly namespaced with47 # a 'yard-' prefix, must be installed as a gem, and therefore cannot be48 # touched by the user. To specify safe mode, use the +safe_mode+ key.49 #50 # == Plugin Specific Configuration51 #52 # Additional settings can be defined within the configuration file53 # specifically to provide configuration for a plugin. A plugin that utilizes54 # the YARD configuration is strongly encouraged to utilize namespacing of55 # their configuration content.56 #57 # !!!yaml58 # load_plugins: true # Auto-load plugins when YARD starts59 # ignored_plugins:60 # - yard-broken61 # - broken2 # yard- prefix not necessary62 # autoload_plugins:63 # - yard-rspec64 # # Plugin Specific Configuration65 # yard-sample-plugin:66 # show-results-inline: true67 #68 # As the configuration is available system wide, it can be69 # accessed within the plugin code.70 #71 #72 # if YARD::Config.options['yard-sample-plugin'] and73 # YARD::Config.options['yard-sample-plugin']['show-results-inline']74 # # ... perform the action that places the results inline ...75 # else76 # # ... do the default behavior of not showing the results inline ...77 # end78 #79 # When accessing the configuration, be aware that this file is user managed80 # so configuration keys and values may not be present. Make no assumptions and81 # instead ensure that you check for the existence of keys before proceeding to82 # retrieve values.83 #84 # @since 0.6.285 # @see options86 class Config87 class << self88 # The system-wide configuration options for YARD89 # @return [SymbolHash] a map a key-value pair settings.90 # @see DEFAULT_CONFIG_OPTIONS91 attr_accessor :options92 end93 # The location where YARD stores user-specific settings94 CONFIG_DIR = File.expand_path('~/.yard')95 # The main configuration YAML file.96 CONFIG_FILE = File.join(CONFIG_DIR, 'config')97 # File listing all ignored plugins98 # @deprecated Set `ignored_plugins` in the {CONFIG_FILE} instead.99 IGNORED_PLUGINS = File.join(CONFIG_DIR, 'ignored_plugins')100 # Default configuration options101 DEFAULT_CONFIG_OPTIONS = {102 :load_plugins => false, # Whether to load plugins automatically with YARD103 :ignored_plugins => [], # A list of ignored plugins by name104 :autoload_plugins => [], # A list of plugins to be automatically loaded105 :safe_mode => false # Does not execute or eval any user-level code106 }107 # The prefix used for YARD plugins. Name your gem with this prefix108 # to allow it to be used as a plugin.109 YARD_PLUGIN_PREFIX = /^yard[-_]/110 # Loads settings from {CONFIG_FILE}. This method is called by YARD at111 # load time and should not be called by the user.112 # @return [void]113 def self.load114 self.options = SymbolHash.new(false)115 options.update(DEFAULT_CONFIG_OPTIONS)116 options.update(read_config_file)117 load_commandline_safemode118 add_ignored_plugins_file119 translate_plugin_names120 load_plugins121 rescue => e122 log.error "Invalid configuration file, using default options."123 log.backtrace(e)124 options.update(DEFAULT_CONFIG_OPTIONS)125 end126 # Saves settings to {CONFIG_FILE}.127 # @return [void]128 def self.save129 require 'yaml'130 Dir.mkdir(CONFIG_DIR) unless File.directory?(CONFIG_DIR)131 File.open(CONFIG_FILE, 'w') {|f| f.write(YAML.dump(options)) }132 end133 # Loads gems that match the name 'yard-*' (recommended) or 'yard_*' except134 # those listed in +~/.yard/ignored_plugins+. This is called immediately135 # after YARD is loaded to allow plugin support.136 #137 # @return [Boolean] true if all plugins loaded successfully, false otherwise.138 def self.load_plugins139 load_gem_plugins &&140 load_autoload_plugins &&141 load_commandline_plugins ? true : false142 end143 # Loads an individual plugin by name. It is not necessary to include the144 # +yard-+ plugin prefix here.145 #146 # @param [String] name the name of the plugin (with or without +yard-+ prefix)147 # @return [Boolean] whether the plugin was successfully loaded148 def self.load_plugin(name)149 name = translate_plugin_name(name)150 return false if options[:ignored_plugins].include?(name)151 return false if name =~ /^yard-doc-/152 log.debug "Loading plugin '#{name}'..."153 require name154 true155 rescue LoadError => e156 load_plugin_failed(name, e)157 end158 # Load gem plugins if :load_plugins is true159 def self.load_gem_plugins160 return true unless options[:load_plugins]161 require 'rubygems'162 result = true163 YARD::GemIndex.each do |gem|164 begin165 next true unless gem.name =~ YARD_PLUGIN_PREFIX166 load_plugin(gem.name)167 rescue Gem::LoadError => e168 tmp = load_plugin_failed(gem.name, e)169 result = tmp unless tmp170 end171 end172 result173 rescue LoadError174 log.debug "RubyGems is not present, skipping plugin loading"175 false176 end177 # Load plugins set in :autoload_plugins178 def self.load_autoload_plugins179 options[:autoload_plugins].each {|name| load_plugin(name) }180 end181 # Load plugins from {arguments}182 def self.load_commandline_plugins183 with_yardopts do184 arguments.each_with_index do |arg, i|185 next unless arg == '--plugin'186 load_plugin(arguments[i + 1])187 end188 end189 end190 # Check for command-line safe_mode switch in {arguments}191 def self.load_commandline_safemode192 with_yardopts do193 arguments.each_with_index do |arg, _i|194 options[:safe_mode] = true if arg == '--safe'195 end196 end197 end198 # Print a warning if the plugin failed to load199 # @return [false]200 def self.load_plugin_failed(name, exception)201 log.error "Error loading plugin '#{name}'"202 log.backtrace(exception) if $DEBUG203 false204 end205 # Legacy support for {IGNORED_PLUGINS}206 def self.add_ignored_plugins_file207 if File.file?(IGNORED_PLUGINS)208 options[:ignored_plugins] += File.read(IGNORED_PLUGINS).split(/\s+/)209 end210 end211 # Translates plugin names to add yard- prefix.212 def self.translate_plugin_names213 options[:ignored_plugins].map! {|name| translate_plugin_name(name) }214 options[:autoload_plugins].map! {|name| translate_plugin_name(name) }215 end216 # Loads the YAML configuration file into memory217 # @return [Hash] the contents of the YAML file from disk218 # @see CONFIG_FILE219 def self.read_config_file220 if File.file?(CONFIG_FILE)221 require 'yaml'222 YAML.load_file(CONFIG_FILE)223 else224 {}225 end226 end227 # Sanitizes and normalizes a plugin name to include the 'yard-' prefix.228 # @param [String] name the plugin name229 # @return [String] the sanitized and normalized plugin name.230 def self.translate_plugin_name(name)231 name = name.delete('/') # Security sanitization232 name = "yard-" + name unless name =~ YARD_PLUGIN_PREFIX233 name234 end235 # Temporarily loads .yardopts file into @yardopts236 def self.with_yardopts237 yfile = CLI::Yardoc::DEFAULT_YARDOPTS_FILE238 @yardopts = File.file?(yfile) ? File.read_binary(yfile).shell_split : []239 result = yield240 @yardopts = nil241 result242 end243 # @return [Array<String>] arguments from commandline and yardopts file244 def self.arguments245 ARGV + @yardopts246 end247 end...

Full Screen

Full Screen

plugins_helper.rb

Source:plugins_helper.rb Github

copy

Full Screen

...39 # @param [String] query40 # A query string that corresponds to a valid RegExp pattern.41 #42 # @param [Bool] full_text_search43 # false only searches in the plugin's name.44 # true searches in the plugin's name, author and description.45 #46 # @return [Array] all plugins matching the query47 #48 def self.matching_plugins(query, full_text_search)49 query_regexp = /#{query}/i50 known_plugins.reject do |plugin|51 texts = [plugin['name']]52 if full_text_search53 texts << plugin['author'] if plugin['author']54 texts << plugin['description'] if plugin['description']55 end56 texts.grep(query_regexp).empty?57 end58 end59 # Display information about a plugin60 #61 # @param [Hash] plugin62 # The hash describing the plugin63 #64 # @param [Bool] verbose65 # If true, will also print the author of the plugins.66 # Defaults to false.67 #68 def self.print_plugin(plugin, verbose = false)69 plugin_colored_name = plugin_title(plugin)70 UI.title(plugin_colored_name, '', 1) do71 UI.puts_indented plugin['description']72 ljust = verbose ? 16 : 1173 UI.labeled('Gem', plugin['gem'], ljust)74 UI.labeled('URL', plugin['url'], ljust)75 print_verbose_plugin(plugin, ljust) if verbose76 end77 end78 #----------------#79 private80 # Smaller helper to print out the verbose details81 # for a plugin.82 #83 # @param [Hash] plugin84 # The hash describing the plugin85 #86 # @param [Integer] ljust87 # The left justification that is passed into UI.labeled88 #89 def self.print_verbose_plugin(plugin, ljust)90 UI.labeled('Author', plugin['author'], ljust)91 unless GemHelper.cache.specs.empty?92 versions = GemHelper.versions_string(plugin['gem'])93 UI.labeled('Versions', versions, ljust)94 end95 end96 # Parse the given JSON data, handling parsing errors if any97 #98 # @param [String] json_str99 # The string representation of the JSON to parse100 #101 def self.parse_json(json_str)102 JSON.parse(json_str)103 rescue JSON::ParserError => e104 raise Informative, "Invalid plugins list from cocoapods-plugins: #{e}"105 end106 # Format the title line to print the plugin info with print_plugin107 # coloring it according to whether the plugin is installed or not108 #109 # @param [Hash] plugin110 # The hash describing the plugin111 #112 # @return [String] The formatted and colored title113 #114 def self.plugin_title(plugin)115 plugin_name = "-> #{plugin['name']}"116 if GemHelper.gem_installed?(plugin['gem'])117 plugin_name += " (#{GemHelper.installed_version(plugin['gem'])})"118 plugin_name.green119 else120 plugin_name.yellow121 end122 end123 end124 end125end...

Full Screen

Full Screen

installed.rb

Source:installed.rb Github

copy

Full Screen

...26 end27 end28 private29 # Print the given plugins as a compact list, one line30 # per plugin with only its name & version31 #32 # @param [Array<Gem::Specification>] plugins33 # The list of plugins to print34 #35 def print_compact_list(plugins)36 max_length = plugins.map { |p| p.name.length }.max37 plugins.each do |plugin|38 name_just = plugin.name.ljust(max_length)39 hooks = registered_hooks(plugin)40 hooks_list = ''41 unless hooks.empty?42 suffix = 'hook'.pluralize(hooks.count)43 hooks_list = " (#{hooks.to_sentence} #{suffix})"44 end45 UI.puts_indented " - #{name_just} : #{plugin.version}#{hooks_list}"46 end47 end48 # Print the given plugins as a verbose list, with name, version,49 # homepage and summary for each plugin.50 #51 # @param [Array<Gem::Specification>] plugins52 # The list of plugins to print53 #54 def print_verbose_list(plugins)55 plugins.each do |plugin|56 hooks = registered_hooks(plugin)57 UI.title(plugin.name)58 UI.labeled('Version', plugin.version.to_s)59 UI.labeled('Hooks', hooks) unless hooks.empty?60 unless plugin.homepage.empty?61 UI.labeled('Homepage', plugin.homepage)62 end63 UI.labeled('Summary', plugin.summary)64 end65 end66 # Names of the registered hook(s) (if any) for the given plugin67 #68 # @return [Array<String>]69 # Names of the hooks the given plugin did register for.70 #71 def registered_hooks(plugin)72 registrations = Pod::HooksManager.registrations73 return [] if registrations.nil?74 registrations.reduce([]) do |list, (name, hooks)|75 list.push(name) if hooks.any? { |h| h.plugin_name == plugin.name }76 list77 end78 end79 end80 end81 end82end...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Inspec_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful