bialy-dataset / coderank /units /thor.jsonl
paintedwolf-ai's picture
Release open1-b5-e4-bialy
24918f7 verified
Raw History Blame Contribute Delete
365 kB
{"repo":"thor","file":"Thorfile","line":6,"symbol":"Default","kind":"class","lang":"ruby","code":"class Default < Thor\n include Thor::RakeCompat\n Bundler::GemHelper.install_tasks\n\n desc \"build\", \"Build thor-#{Thor::VERSION}.gem into the pkg directory\"\n def build\n Rake::Task[\"build\"].execute\n end\n\n desc \"install\", \"Build and install thor-#{Thor::VERSION}.gem into system gems\"\n def install\n Rake::Task[\"install\"].execute\n end\n\n desc \"release\", \"Create tag v#{Thor::VERSION} and build and push thor-#{Thor::VERSION}.gem to Rubygems\"\n def release\n Rake::Task[\"release\"].invoke\n end\n\n desc \"spec\", \"Run RSpec code examples\"\n def spec\n exec \"bundle exec rspec spec\"\n end\nend"}
{"repo":"thor","file":"Thorfile","line":11,"symbol":"build","kind":"method","lang":"ruby","code":"def build\n Rake::Task[\"build\"].execute\n end"}
{"repo":"thor","file":"Thorfile","line":16,"symbol":"install","kind":"method","lang":"ruby","code":"def install\n Rake::Task[\"install\"].execute\n end"}
{"repo":"thor","file":"Thorfile","line":21,"symbol":"release","kind":"method","lang":"ruby","code":"def release\n Rake::Task[\"release\"].invoke\n end"}
{"repo":"thor","file":"Thorfile","line":26,"symbol":"spec","kind":"method","lang":"ruby","code":"def spec\n exec \"bundle exec rspec spec\"\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n # Create a new file relative to the destination root with the given data,\n # which is the return value of a block or a data string.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # data<String|NilClass>:: the data to append to the file.\n # config<Hash>:: give :verbose => false to not log the status.\n #\n # ==== Examples\n #\n # create_file \"lib/fun_party.rb\" do\n # hostname = ask(\"What is the virtual hostname I should use?\")\n # \"vhost.name = #{hostname}\"\n # end\n #\n # create_file \"config/apache.conf\", \"your apache config\"\n #\n def create_file(destination, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n data = args.first\n action CreateFile.new(self, destination, block || data.to_s, config)\n end\n alias_method :add_file, :create_file\n\n # CreateFile is a subset of Template, which instead of rendering a file with\n # ERB, it gets the content from the user.\n #\n class CreateFile < EmptyDirectory #:nodoc:\n attr_reader :data\n\n def initialize(base, destination, data, config = {})\n @data = data\n "}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":4,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n # Create a new file relative to the destination root with the given data,\n # which is the return value of a block or a data string.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # data<String|NilClass>:: the data to append to the file.\n # config<Hash>:: give :verbose => false to not log the status.\n #\n # ==== Examples\n #\n # create_file \"lib/fun_party.rb\" do\n # hostname = ask(\"What is the virtual hostname I should use?\")\n # \"vhost.name = #{hostname}\"\n # end\n #\n # create_file \"config/apache.conf\", \"your apache config\"\n #\n def create_file(destination, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n data = args.first\n action CreateFile.new(self, destination, block || data.to_s, config)\n end\n alias_method :add_file, :create_file\n\n # CreateFile is a subset of Template, which instead of rendering a file with\n # ERB, it gets the content from the user.\n #\n class CreateFile < EmptyDirectory #:nodoc:\n attr_reader :data\n\n def initialize(base, destination, data, config = {})\n @data = data\n super("}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":22,"symbol":"create_file","kind":"method","lang":"ruby","doc":"hostname = ask(\"What is the virtual hostname I should use?\") \"vhost.name = #{hostname}\" end create_file \"config/apache.conf\", \"your apache config\"","code":"def create_file(destination, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n data = args.first\n action CreateFile.new(self, destination, block || data.to_s, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":32,"symbol":"CreateFile","kind":"class","lang":"ruby","doc":"CreateFile is a subset of Template, which instead of rendering a file with ERB, it gets the content from the user.","code":"class CreateFile < EmptyDirectory #:nodoc:\n attr_reader :data\n\n def initialize(base, destination, data, config = {})\n @data = data\n super(base, destination, config)\n end\n\n # Checks if the content of the file at the destination is identical to the rendered result.\n #\n # ==== Returns\n # Boolean:: true if it is identical, false otherwise.\n #\n def identical?\n # binread uses ASCII-8BIT, so to avoid false negatives, the string must use the same\n exists? && File.binread(destination) == String.new(render).force_encoding(\"ASCII-8BIT\")\n end\n\n # Holds the content to be added to the file.\n #\n def render\n @render ||= if data.is_a?(Proc)\n data.call\n else\n data\n end\n end\n\n def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n FileUtils.mkdir_p(File.dirname(destination))\n File.open(destination, \"wb\", config[:perm]) { |f| f.write render }\n end\n given_destination\n end\n\n protected\n\n # Now on conflict we check if the file is identical or not.\n #\n def on_conflict_behavior(&block)\n "}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":35,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(base, destination, data, config = {})\n @data = data\n super(base, destination, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":45,"symbol":"identical?","kind":"method","lang":"ruby","doc":"Checks if the content of the file at the destination is identical to the rendered result. ==== Returns Boolean:: true if it is identical, false otherwise.","code":"def identical?\n # binread uses ASCII-8BIT, so to avoid false negatives, the string must use the same\n exists? && File.binread(destination) == String.new(render).force_encoding(\"ASCII-8BIT\")\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":52,"symbol":"render","kind":"method","lang":"ruby","doc":"Holds the content to be added to the file.","code":"def render\n @render ||= if data.is_a?(Proc)\n data.call\n else\n data\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":60,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n FileUtils.mkdir_p(File.dirname(destination))\n File.open(destination, \"wb\", config[:perm]) { |f| f.write render }\n end\n given_destination\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":73,"symbol":"on_conflict_behavior","kind":"method","lang":"ruby","doc":"Now on conflict we check if the file is identical or not.","code":"def on_conflict_behavior(&block)\n if identical?\n say_status :identical, :blue\n else\n options = base.options.merge(config)\n force_or_skip_or_conflict(options[:force], options[:skip], &block)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":86,"symbol":"force_or_skip_or_conflict","kind":"method","lang":"ruby","doc":"If force is true, run the action, otherwise check if it's not being skipped. If both are false, show the file_collision menu, if the menu returns true, force it, otherwise skip.","code":"def force_or_skip_or_conflict(force, skip, &block)\n if force\n say_status :force, :yellow\n yield unless pretend?\n elsif skip\n say_status :skip, :yellow\n else\n say_status :conflict, :red\n force_or_skip_or_conflict(force_on_collision?, true, &block)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/create_file.rb","line":100,"symbol":"force_on_collision?","kind":"method","lang":"ruby","doc":"Shows the file collision menu to the user and gets the result.","code":"def force_on_collision?\n base.shell.file_collision(destination) { render }\n end"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n # Create a new file relative to the destination root from the given source.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # source<String|NilClass>:: the relative path to the source root.\n # config<Hash>:: give :verbose => false to not log the status.\n # :: give :symbolic => false for hard link.\n #\n # ==== Examples\n #\n # create_link \"config/apache.conf\", \"/etc/apache.conf\"\n #\n def create_link(destination, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n source = args.first\n action CreateLink.new(self, destination, source, config)\n end\n alias_method :add_link, :create_link\n\n # CreateLink is a subset of CreateFile, which instead of taking a block of\n # data, just takes a source string from the user.\n #\n class CreateLink < CreateFile #:nodoc:\n attr_reader :data\n\n # Checks if the content of the file at the destination is identical to the rendered result.\n #\n # ==== Returns\n # Boolean:: true if it is identical, false otherwise.\n #\n def identical?\n source = File.expand_path(render, File.dirna"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":4,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n # Create a new file relative to the destination root from the given source.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # source<String|NilClass>:: the relative path to the source root.\n # config<Hash>:: give :verbose => false to not log the status.\n # :: give :symbolic => false for hard link.\n #\n # ==== Examples\n #\n # create_link \"config/apache.conf\", \"/etc/apache.conf\"\n #\n def create_link(destination, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n source = args.first\n action CreateLink.new(self, destination, source, config)\n end\n alias_method :add_link, :create_link\n\n # CreateLink is a subset of CreateFile, which instead of taking a block of\n # data, just takes a source string from the user.\n #\n class CreateLink < CreateFile #:nodoc:\n attr_reader :data\n\n # Checks if the content of the file at the destination is identical to the rendered result.\n #\n # ==== Returns\n # Boolean:: true if it is identical, false otherwise.\n #\n def identical?\n source = File.expand_path(render, File.dirname(destinatio"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":17,"symbol":"create_link","kind":"method","lang":"ruby","doc":":: give :symbolic => false for hard link. ==== Examples create_link \"config/apache.conf\", \"/etc/apache.conf\"","code":"def create_link(destination, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n source = args.first\n action CreateLink.new(self, destination, source, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":27,"symbol":"CreateLink","kind":"class","lang":"ruby","doc":"CreateLink is a subset of CreateFile, which instead of taking a block of data, just takes a source string from the user.","code":"class CreateLink < CreateFile #:nodoc:\n attr_reader :data\n\n # Checks if the content of the file at the destination is identical to the rendered result.\n #\n # ==== Returns\n # Boolean:: true if it is identical, false otherwise.\n #\n def identical?\n source = File.expand_path(render, File.dirname(destination))\n exists? && File.identical?(source, destination)\n end\n\n def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n FileUtils.mkdir_p(File.dirname(destination))\n # Create a symlink by default\n config[:symbolic] = true if config[:symbolic].nil?\n File.unlink(destination) if exists?\n if config[:symbolic]\n File.symlink(render, destination)\n else\n File.link(render, destination)\n end\n end\n given_destination\n end\n\n def exists?\n super || File.symlink?(destination)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":35,"symbol":"identical?","kind":"method","lang":"ruby","doc":"Checks if the content of the file at the destination is identical to the rendered result. ==== Returns Boolean:: true if it is identical, false otherwise.","code":"def identical?\n source = File.expand_path(render, File.dirname(destination))\n exists? && File.identical?(source, destination)\n end"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":40,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n FileUtils.mkdir_p(File.dirname(destination))\n # Create a symlink by default\n config[:symbolic] = true if config[:symbolic].nil?\n File.unlink(destination) if exists?\n if config[:symbolic]\n File.symlink(render, destination)\n else\n File.link(render, destination)\n end\n end\n given_destination\n end"}
{"repo":"thor","file":"lib/thor/actions/create_link.rb","line":56,"symbol":"exists?","kind":"method","lang":"ruby","code":"def exists?\n super || File.symlink?(destination)\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n # Copies recursively the files from source directory to root directory.\n # If any of the files finishes with .tt, it's considered to be a template\n # and is placed in the destination without the extension .tt. If any\n # empty directory is found, it's copied and all .empty_directory files are\n # ignored. If any file name is wrapped within % signs, the text within\n # the % signs will be executed as a method and replaced with the returned\n # value. Let's suppose a doc directory with the following files:\n #\n # doc/\n # components/.empty_directory\n # README\n # rdoc.rb.tt\n # %app_name%.rb\n #\n # When invoked as:\n #\n # directory \"doc\"\n #\n # It will create a doc directory in the destination with the following\n # files (assuming that the `app_name` method returns the value \"blog\"):\n #\n # doc/\n # components/\n # README\n # rdoc.rb\n # blog.rb\n #\n # <b>Encoded path note:</b> Since Thor internals use Object#respond_to? to check if it can\n # expand %something%, this `something` should be a public method in the class calling\n # #directory. If a m"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":4,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n # Copies recursively the files from source directory to root directory.\n # If any of the files finishes with .tt, it's considered to be a template\n # and is placed in the destination without the extension .tt. If any\n # empty directory is found, it's copied and all .empty_directory files are\n # ignored. If any file name is wrapped within % signs, the text within\n # the % signs will be executed as a method and replaced with the returned\n # value. Let's suppose a doc directory with the following files:\n #\n # doc/\n # components/.empty_directory\n # README\n # rdoc.rb.tt\n # %app_name%.rb\n #\n # When invoked as:\n #\n # directory \"doc\"\n #\n # It will create a doc directory in the destination with the following\n # files (assuming that the `app_name` method returns the value \"blog\"):\n #\n # doc/\n # components/\n # README\n # rdoc.rb\n # blog.rb\n #\n # <b>Encoded path note:</b> Since Thor internals use Object#respond_to? to check if it can\n # expand %something%, this `something` should be a public method in the class calling\n # #directory. If a method is priv"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":49,"symbol":"directory","kind":"method","lang":"ruby","doc":"==== Examples directory \"doc\" directory \"doc\", \"docs\", :recursive => false","code":"def directory(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n action Directory.new(self, source, destination || source, config, &block)\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":55,"symbol":"Directory","kind":"class","lang":"ruby","code":"class Directory < EmptyDirectory #:nodoc:\n attr_reader :source\n\n def initialize(base, source, destination = nil, config = {}, &block)\n @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)\n @block = block\n super(base, destination, {recursive: true}.merge(config))\n end\n\n def invoke!\n base.empty_directory given_destination, config\n execute!\n end\n\n def revoke!\n execute!\n end\n\n protected\n\n def execute!\n lookup = Util.escape_globs(source)\n lookup = config[:recursive] ? File.join(lookup, \"**\") : lookup\n lookup = file_level_lookup(lookup)\n\n files(lookup).sort.each do |file_source|\n next if File.directory?(file_source)\n next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern])\n file_destination = File.join(given_destination, file_source.gsub(source, \".\"))\n file_destination.gsub!(\"/./\", \"/\")\n\n case file_source\n when /\\.empty_directory$/\n dirname = File.dirname(file_destination).gsub(%r{/\\.$}, \"\")\n next if dirname == given_destination\n "}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":58,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(base, source, destination = nil, config = {}, &block)\n @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)\n @block = block\n super(base, destination, {recursive: true}.merge(config))\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":64,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n base.empty_directory given_destination, config\n execute!\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":69,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n execute!\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":75,"symbol":"execute!","kind":"method","lang":"ruby","code":"def execute!\n lookup = Util.escape_globs(source)\n lookup = config[:recursive] ? File.join(lookup, \"**\") : lookup\n lookup = file_level_lookup(lookup)\n\n files(lookup).sort.each do |file_source|\n next if File.directory?(file_source)\n next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern])\n file_destination = File.join(given_destination, file_source.gsub(source, \".\"))\n file_destination.gsub!(\"/./\", \"/\")\n\n case file_source\n when /\\.empty_directory$/\n dirname = File.dirname(file_destination).gsub(%r{/\\.$}, \"\")\n next if dirname == given_destination\n base.empty_directory(dirname, config)\n when /#{TEMPLATE_EXTNAME}$/\n base.template(file_source, file_destination[0..-4], config, &@block)\n else\n base.copy_file(file_source, file_destination, config, &@block)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":99,"symbol":"file_level_lookup","kind":"method","lang":"ruby","code":"def file_level_lookup(previous_lookup)\n File.join(previous_lookup, \"*\")\n end"}
{"repo":"thor","file":"lib/thor/actions/directory.rb","line":103,"symbol":"files","kind":"method","lang":"ruby","code":"def files(lookup)\n Dir.glob(lookup, File::FNM_DOTMATCH)\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n # Creates an empty directory.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # config<Hash>:: give :verbose => false to not log the status.\n #\n # ==== Examples\n #\n # empty_directory \"doc\"\n #\n def empty_directory(destination, config = {})\n action EmptyDirectory.new(self, destination, config)\n end\n\n # Class which holds create directory logic. This is the base class for\n # other actions like create_file and directory.\n #\n # This implementation is based in Templater actions, created by Jonas Nicklas\n # and Michael S. Klishin under MIT LICENSE.\n #\n class EmptyDirectory #:nodoc:\n attr_reader :base, :destination, :given_destination, :relative_destination, :config\n\n # Initializes given the source and destination.\n #\n # ==== Parameters\n # base<Thor::Base>:: A Thor::Base instance\n # source<String>:: Relative path to the source of this file\n # destination<String>:: Relative path to the destination of this file\n # config<Hash>:: give :verbose => false to not log the status.\n #\n def initialize(base, destination"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":2,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n # Creates an empty directory.\n #\n # ==== Parameters\n # destination<String>:: the relative path to the destination root.\n # config<Hash>:: give :verbose => false to not log the status.\n #\n # ==== Examples\n #\n # empty_directory \"doc\"\n #\n def empty_directory(destination, config = {})\n action EmptyDirectory.new(self, destination, config)\n end\n\n # Class which holds create directory logic. This is the base class for\n # other actions like create_file and directory.\n #\n # This implementation is based in Templater actions, created by Jonas Nicklas\n # and Michael S. Klishin under MIT LICENSE.\n #\n class EmptyDirectory #:nodoc:\n attr_reader :base, :destination, :given_destination, :relative_destination, :config\n\n # Initializes given the source and destination.\n #\n # ==== Parameters\n # base<Thor::Base>:: A Thor::Base instance\n # source<String>:: Relative path to the source of this file\n # destination<String>:: Relative path to the destination of this file\n # config<Hash>:: give :verbose => false to not log the status.\n #\n def initialize(base, destination, config = {}"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":13,"symbol":"empty_directory","kind":"method","lang":"ruby","doc":"config<Hash>:: give :verbose => false to not log the status. ==== Examples empty_directory \"doc\"","code":"def empty_directory(destination, config = {})\n action EmptyDirectory.new(self, destination, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":23,"symbol":"EmptyDirectory","kind":"class","lang":"ruby","doc":"Class which holds create directory logic. This is the base class for other actions like create_file and directory. This implementation is based in Templater actions, created by Jonas Nicklas and Michael S. Klishin under MIT LICENSE.","code":"class EmptyDirectory #:nodoc:\n attr_reader :base, :destination, :given_destination, :relative_destination, :config\n\n # Initializes given the source and destination.\n #\n # ==== Parameters\n # base<Thor::Base>:: A Thor::Base instance\n # source<String>:: Relative path to the source of this file\n # destination<String>:: Relative path to the destination of this file\n # config<Hash>:: give :verbose => false to not log the status.\n #\n def initialize(base, destination, config = {})\n @base = base\n @config = {verbose: true}.merge(config)\n self.destination = destination\n end\n\n # Checks if the destination file already exists.\n #\n # ==== Returns\n # Boolean:: true if the file exists, false otherwise.\n #\n def exists?\n ::File.exist?(destination)\n end\n\n def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n ::FileUtils.mkdir_p(destination)\n end\n end\n\n def revoke!\n say_status :remove, :red\n require \"fileutils\"\n ::FileUtils.rm_rf(destination) if !pretend? && exists?\n given_destination\n end\n\n pr"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":34,"symbol":"initialize","kind":"method","lang":"ruby","doc":"==== Parameters base<Thor::Base>:: A Thor::Base instance source<String>:: Relative path to the source of this file destination<String>:: Relative path to the destination of this file config<Hash>:: give :verbose => false to not log the status.","code":"def initialize(base, destination, config = {})\n @base = base\n @config = {verbose: true}.merge(config)\n self.destination = destination\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":45,"symbol":"exists?","kind":"method","lang":"ruby","doc":"Checks if the destination file already exists. ==== Returns Boolean:: true if the file exists, false otherwise.","code":"def exists?\n ::File.exist?(destination)\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":49,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n invoke_with_conflict_check do\n require \"fileutils\"\n ::FileUtils.mkdir_p(destination)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":56,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n say_status :remove, :red\n require \"fileutils\"\n ::FileUtils.rm_rf(destination) if !pretend? && exists?\n given_destination\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":67,"symbol":"pretend?","kind":"method","lang":"ruby","doc":"Shortcut for pretend.","code":"def pretend?\n base.options[:pretend]\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":103,"symbol":"convert_encoded_instructions","kind":"method","lang":"ruby","doc":"return value (should be String) of #file_name: user.rb The method referenced can be either public or private.","code":"def convert_encoded_instructions(filename)\n filename.gsub(/%(.*?)%/) do |initial_string|\n method = $1.strip\n base.respond_to?(method, true) ? base.send(method) : initial_string\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":113,"symbol":"invoke_with_conflict_check","kind":"method","lang":"ruby","doc":"Receives a hash of options and just execute the block if some conditions are met.","code":"def invoke_with_conflict_check(&block)\n if exists?\n on_conflict_behavior(&block)\n else\n yield unless pretend?\n say_status :create, :green\n end\n\n destination\n rescue Errno::EISDIR, Errno::EEXIST\n on_file_clash_behavior\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":126,"symbol":"on_file_clash_behavior","kind":"method","lang":"ruby","code":"def on_file_clash_behavior\n say_status :file_clash, :red\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":132,"symbol":"on_conflict_behavior","kind":"method","lang":"ruby","doc":"What to do when the destination file already exists.","code":"def on_conflict_behavior\n say_status :exist, :blue\n end"}
{"repo":"thor","file":"lib/thor/actions/empty_directory.rb","line":138,"symbol":"say_status","kind":"method","lang":"ruby","doc":"Shortcut to say_status shell method.","code":"def say_status(status, color)\n base.shell.say_status status, relative_destination, color if config[:verbose]\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n # Copies the file from the relative source to the relative destination. If\n # the destination is not given it's assumed to be equal to the source.\n #\n # ==== Parameters\n # source<String>:: the relative path to the source root.\n # destination<String>:: the relative path to the destination root.\n # config<Hash>:: give :verbose => false to not log the status, and\n # :mode => :preserve, to preserve the file mode from the source.\n #\n # ==== Examples\n #\n # copy_file \"README\", \"doc/README\"\n #\n # copy_file \"doc/README\"\n #\n def copy_file(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n source = File.expand_path(find_in_source_paths(source.to_s))\n\n resulting_destination = create_file destination, nil, config do\n content = File.binread(source)\n content = yield(content) if block\n content\n end\n if config[:mode] == :preserve\n mode = File.stat(source).mode\n chmod(resulting_destination, mode, config)\n end\n end\n\n # Links the file from the relative source to the relative d"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":4,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n # Copies the file from the relative source to the relative destination. If\n # the destination is not given it's assumed to be equal to the source.\n #\n # ==== Parameters\n # source<String>:: the relative path to the source root.\n # destination<String>:: the relative path to the destination root.\n # config<Hash>:: give :verbose => false to not log the status, and\n # :mode => :preserve, to preserve the file mode from the source.\n #\n # ==== Examples\n #\n # copy_file \"README\", \"doc/README\"\n #\n # copy_file \"doc/README\"\n #\n def copy_file(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n source = File.expand_path(find_in_source_paths(source.to_s))\n\n resulting_destination = create_file destination, nil, config do\n content = File.binread(source)\n content = yield(content) if block\n content\n end\n if config[:mode] == :preserve\n mode = File.stat(source).mode\n chmod(resulting_destination, mode, config)\n end\n end\n\n # Links the file from the relative source to the relative destination. I"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":20,"symbol":"copy_file","kind":"method","lang":"ruby","doc":"==== Examples copy_file \"README\", \"doc/README\" copy_file \"doc/README\"","code":"def copy_file(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n source = File.expand_path(find_in_source_paths(source.to_s))\n\n resulting_destination = create_file destination, nil, config do\n content = File.binread(source)\n content = yield(content) if block\n content\n end\n if config[:mode] == :preserve\n mode = File.stat(source).mode\n chmod(resulting_destination, mode, config)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":50,"symbol":"link_file","kind":"method","lang":"ruby","doc":"==== Examples link_file \"README\", \"doc/README\" link_file \"doc/README\"","code":"def link_file(source, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source\n source = File.expand_path(find_in_source_paths(source.to_s))\n\n create_link destination, source, config\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":81,"symbol":"get","kind":"method","lang":"ruby","doc":"get \"http://gist.github.com/103208\", \"doc/README\", :http_headers => {\"Content-Type\" => \"application/json\"} get \"http://gist.github.com/103208\" do |content| content.split(\"\\n\").first end","code":"def get(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first\n\n render = if source =~ %r{^https?\\://}\n require \"open-uri\"\n URI.send(:open, source, config.fetch(:http_headers, {})) { |input| input.binmode.read }\n else\n source = File.expand_path(find_in_source_paths(source.to_s))\n File.open(source) { |input| input.binmode.read }\n end\n\n destination ||= if block_given?\n block.arity == 1 ? yield(render) : yield\n else\n File.basename(source)\n end\n\n create_file destination, render, config\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":117,"symbol":"template","kind":"method","lang":"ruby","doc":"==== Examples template \"README\", \"doc/README\" template \"doc/README\"","code":"def template(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, \"\")\n\n source = File.expand_path(find_in_source_paths(source.to_s))\n context = config.delete(:context) || instance_eval(\"binding\")\n\n create_file destination, nil, config do\n capturable_erb = CapturableERB.new(::File.binread(source), trim_mode: \"-\", eoutvar: \"@output_buffer\")\n content = capturable_erb.tap do |erb|\n erb.filename = source\n end.result(context)\n content = yield(content) if block\n content\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":145,"symbol":"chmod","kind":"method","lang":"ruby","doc":"config<Hash>:: give :verbose => false to not log the status. ==== Example chmod \"script/server\", 0755","code":"def chmod(path, mode, config = {})\n return unless behavior == :invoke\n path = File.expand_path(path, destination_root)\n say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true)\n unless options[:pretend]\n require \"fileutils\"\n FileUtils.chmod_R(mode, path)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":170,"symbol":"prepend_to_file","kind":"method","lang":"ruby","doc":"prepend_to_file 'config/environments/test.rb', 'config.gem \"rspec\"' prepend_to_file 'config/environments/test.rb' do 'config.gem \"rspec\"' end","code":"def prepend_to_file(path, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:after] = /\\A/\n insert_into_file(path, *(args << config), &block)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":192,"symbol":"append_to_file","kind":"method","lang":"ruby","doc":"append_to_file 'config/environments/test.rb', 'config.gem \"rspec\"' append_to_file 'config/environments/test.rb' do 'config.gem \"rspec\"' end","code":"def append_to_file(path, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:before] = /\\z/\n insert_into_file(path, *(args << config), &block)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":216,"symbol":"inject_into_class","kind":"method","lang":"ruby","doc":"inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\", \" filter_parameter :password\\n\" inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\" do \" filter_parameter :password\\n\" end","code":"def inject_into_class(path, klass, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:after] = /class #{klass}\\n|class #{klass} .*\\n/\n insert_into_file(path, *(args << config), &block)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":239,"symbol":"inject_into_module","kind":"method","lang":"ruby","doc":"inject_into_module \"app/helpers/application_helper.rb\", \"ApplicationHelper\", \" def help; 'help'; end\\n\" inject_into_module \"app/helpers/application_helper.rb\", \"ApplicationHelper\" do \" def help; 'help'; end\\n\" end","code":"def inject_into_module(path, module_name, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:after] = /module #{module_name}\\n|module #{module_name} .*\\n/\n insert_into_file(path, *(args << config), &block)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":263,"symbol":"gsub_file!","kind":"method","lang":"ruby","doc":"gsub_file! 'app/controllers/application_controller.rb', /#\\s*(filter_parameter_logging :password)/, '\\1' gsub_file! 'README', /rake/, :green do |match| match << \" no more. Use thor!\" end","code":"def gsub_file!(path, flag, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n\n return unless behavior == :invoke || config.fetch(:force, false)\n\n path = File.expand_path(path, destination_root)\n say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)\n\n actually_gsub_file(path, flag, args, true, &block) unless options[:pretend]\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":291,"symbol":"gsub_file","kind":"method","lang":"ruby","doc":"gsub_file 'app/controllers/application_controller.rb', /#\\s*(filter_parameter_logging :password)/, '\\1' gsub_file 'README', /rake/, :green do |match| match << \" no more. Use thor!\" end","code":"def gsub_file(path, flag, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n\n return unless behavior == :invoke || config.fetch(:force, false)\n\n path = File.expand_path(path, destination_root)\n say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)\n\n actually_gsub_file(path, flag, args, false, &block) unless options[:pretend]\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":314,"symbol":"uncomment_lines","kind":"method","lang":"ruby","doc":"config<Hash>:: give :verbose => false to not log the status. ==== Example uncomment_lines 'config/initializers/session_store.rb', /active_record/","code":"def uncomment_lines(path, flag, *args)\n flag = flag.respond_to?(:source) ? flag.source : flag\n\n gsub_file(path, /^(\\s*)#[[:blank:]]?(.*#{flag})/, '\\1\\2', *args)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":333,"symbol":"comment_lines","kind":"method","lang":"ruby","doc":"config<Hash>:: give :verbose => false to not log the status. ==== Example comment_lines 'config/initializers/session_store.rb', /cookie_store/","code":"def comment_lines(path, flag, *args)\n flag = flag.respond_to?(:source) ? flag.source : flag\n\n gsub_file(path, /^(\\s*)([^#\\n]*#{flag})/, '\\1# \\2', *args)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":350,"symbol":"remove_file","kind":"method","lang":"ruby","doc":"==== Example remove_file 'README' remove_file 'app/controllers/application_controller.rb'","code":"def remove_file(path, config = {})\n return unless behavior == :invoke\n path = File.expand_path(path, destination_root)\n\n say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)\n if !options[:pretend] && (File.exist?(path) || File.symlink?(path))\n require \"fileutils\"\n ::FileUtils.rm_rf(path)\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":367,"symbol":"concat","kind":"method","lang":"ruby","code":"def concat(string)\n @output_buffer.concat(string)\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":371,"symbol":"capture","kind":"method","lang":"ruby","code":"def capture(*args)\n with_output_buffer { yield(*args) }\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":375,"symbol":"with_output_buffer","kind":"method","lang":"ruby","code":"def with_output_buffer(buf = \"\".dup) #:nodoc:\n raise ArgumentError, \"Buffer cannot be a frozen object\" if buf.frozen?\n old_buffer = output_buffer\n self.output_buffer = buf\n yield\n output_buffer\n ensure\n self.output_buffer = old_buffer\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":385,"symbol":"actually_gsub_file","kind":"method","lang":"ruby","code":"def actually_gsub_file(path, flag, args, error_on_no_change, &block)\n content = File.binread(path)\n success = content.gsub!(flag, *args, &block)\n\n if success.nil? && error_on_no_change\n raise Thor::Error, \"The content of #{path} did not change\"\n end\n\n File.open(path, \"wb\") { |file| file.write(content) }\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":398,"symbol":"CapturableERB","kind":"class","lang":"ruby","doc":"Thor::Actions#capture depends on what kind of buffer is used in ERB. Thus CapturableERB fixes ERB to use String buffer.","code":"class CapturableERB < ERB\n def set_eoutvar(compiler, eoutvar = \"_erbout\")\n compiler.put_cmd = \"#{eoutvar}.concat\"\n compiler.insert_cmd = \"#{eoutvar}.concat\"\n compiler.pre_cmd = [\"#{eoutvar} = ''.dup\"]\n compiler.post_cmd = [eoutvar]\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/file_manipulation.rb","line":399,"symbol":"set_eoutvar","kind":"method","lang":"ruby","code":"def set_eoutvar(compiler, eoutvar = \"_erbout\")\n compiler.put_cmd = \"#{eoutvar}.concat\"\n compiler.insert_cmd = \"#{eoutvar}.concat\"\n compiler.pre_cmd = [\"#{eoutvar} = ''.dup\"]\n compiler.post_cmd = [eoutvar]\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n WARNINGS = {unchanged_no_flag: \"File unchanged! Either the supplied flag value not found or the content has already been inserted!\"}\n\n # Injects the given content into a file, raising an error if the contents of\n # the file are not changed. Different from gsub_file, this method is reversible.\n #\n # ==== Parameters\n # destination<String>:: Relative path to the destination root\n # data<String>:: Data to add to the file. Can be given as a block.\n # config<Hash>:: give :verbose => false to not log the status and the flag\n # for injection (:after or :before) or :force => true for\n # insert two or more times the same content.\n #\n # ==== Examples\n #\n # insert_into_file \"config/environment.rb\", \"config.gem :thor\", :after => \"Rails::Initializer.run do |config|\\n\"\n #\n # insert_into_file \"config/environment.rb\", :after => \"Rails::Initializer.run do |config|\\n\" do\n # gems = ask \"Which gems would you like to add?\"\n # gems.split(\" \").map{ |gem| \" config.gem :#{gem}\" }.join(\"\\n\")\n # end\n #\n def insert_into_file!(destination, *args, &block)\n data = block_giv"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":4,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n WARNINGS = {unchanged_no_flag: \"File unchanged! Either the supplied flag value not found or the content has already been inserted!\"}\n\n # Injects the given content into a file, raising an error if the contents of\n # the file are not changed. Different from gsub_file, this method is reversible.\n #\n # ==== Parameters\n # destination<String>:: Relative path to the destination root\n # data<String>:: Data to add to the file. Can be given as a block.\n # config<Hash>:: give :verbose => false to not log the status and the flag\n # for injection (:after or :before) or :force => true for\n # insert two or more times the same content.\n #\n # ==== Examples\n #\n # insert_into_file \"config/environment.rb\", \"config.gem :thor\", :after => \"Rails::Initializer.run do |config|\\n\"\n #\n # insert_into_file \"config/environment.rb\", :after => \"Rails::Initializer.run do |config|\\n\" do\n # gems = ask \"Which gems would you like to add?\"\n # gems.split(\" \").map{ |gem| \" config.gem :#{gem}\" }.join(\"\\n\")\n # end\n #\n def insert_into_file!(destination, *args, &block)\n data = block_given? ? block :"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":26,"symbol":"insert_into_file!","kind":"method","lang":"ruby","doc":"insert_into_file \"config/environment.rb\", :after => \"Rails::Initializer.run do |config|\\n\" do gems = ask \"Which gems would you like to add?\" gems.split(\" \").map{ |gem| \" config.gem :#{gem}\" }.join(\"\\n\") end","code":"def insert_into_file!(destination, *args, &block)\n data = block_given? ? block : args.shift\n\n config = args.shift || {}\n config[:after] = /\\z/ unless config.key?(:before) || config.key?(:after)\n config = config.merge({error_on_no_change: true})\n\n action InjectIntoFile.new(self, destination, data, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":56,"symbol":"insert_into_file","kind":"method","lang":"ruby","doc":"insert_into_file \"config/environment.rb\", :after => \"Rails::Initializer.run do |config|\\n\" do gems = ask \"Which gems would you like to add?\" gems.split(\" \").map{ |gem| \" config.gem :#{gem}\" }.join(\"\\n\") end","code":"def insert_into_file(destination, *args, &block)\n data = block_given? ? block : args.shift\n\n config = args.shift || {}\n config[:after] = /\\z/ unless config.key?(:before) || config.key?(:after)\n\n action InjectIntoFile.new(self, destination, data, config)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":66,"symbol":"InjectIntoFile","kind":"class","lang":"ruby","code":"class InjectIntoFile < EmptyDirectory #:nodoc:\n attr_reader :replacement, :flag, :behavior\n\n def initialize(base, destination, data, config)\n super(base, destination, {verbose: true}.merge(config))\n\n @behavior, @flag = if @config.key?(:after)\n [:after, @config.delete(:after)]\n else\n [:before, @config.delete(:before)]\n end\n\n @replacement = data.is_a?(Proc) ? data.call : data\n @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)\n @error_on_no_change = @config.fetch(:error_on_no_change, false)\n end\n\n def invoke!\n content = if @behavior == :after\n '\\0' + replacement\n else\n replacement + '\\0'\n end\n\n if exists?\n if replace!(/#{flag}/, content, config[:force])\n say_status(:invoke)\n elsif @error_on_no_change\n raise Thor::Error, \"The content of #{destination} did not change\"\n elsif replacement_present?\n say_status(:unchanged, color: :blue)\n else\n say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)\n end\n else\n unless pretend?\n "}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":69,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(base, destination, data, config)\n super(base, destination, {verbose: true}.merge(config))\n\n @behavior, @flag = if @config.key?(:after)\n [:after, @config.delete(:after)]\n else\n [:before, @config.delete(:before)]\n end\n\n @replacement = data.is_a?(Proc) ? data.call : data\n @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)\n @error_on_no_change = @config.fetch(:error_on_no_change, false)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":83,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n content = if @behavior == :after\n '\\0' + replacement\n else\n replacement + '\\0'\n end\n\n if exists?\n if replace!(/#{flag}/, content, config[:force])\n say_status(:invoke)\n elsif @error_on_no_change\n raise Thor::Error, \"The content of #{destination} did not change\"\n elsif replacement_present?\n say_status(:unchanged, color: :blue)\n else\n say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)\n end\n else\n unless pretend?\n raise Thor::Error, \"The file #{ destination } does not appear to exist\"\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":107,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n say_status :revoke\n\n regexp = if @behavior == :after\n content = '\\1\\2'\n /(#{flag})(.*)(#{Regexp.escape(replacement)})/m\n else\n content = '\\2\\3'\n /(#{Regexp.escape(replacement)})(.*)(#{flag})/m\n end\n\n replace!(regexp, content, true)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":123,"symbol":"say_status","kind":"method","lang":"ruby","code":"def say_status(behavior, warning: nil, color: nil)\n status = if behavior == :invoke\n if flag == /\\A/\n :prepend\n elsif flag == /\\z/\n :append\n else\n :insert\n end\n elsif warning\n warning\n elsif behavior == :unchanged\n :unchanged\n else\n :subtract\n end\n\n super(status, (color || config[:verbose]))\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":143,"symbol":"content","kind":"method","lang":"ruby","code":"def content\n @content ||= File.read(destination)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":147,"symbol":"replacement_present?","kind":"method","lang":"ruby","code":"def replacement_present?\n content.include?(replacement)\n end"}
{"repo":"thor","file":"lib/thor/actions/inject_into_file.rb","line":153,"symbol":"replace!","kind":"method","lang":"ruby","doc":"Adds the content to the file.","code":"def replace!(regexp, string, force)\n if force || !replacement_present?\n success = content.gsub!(regexp, string)\n\n File.open(destination, \"wb\") { |file| file.write(content) } unless pretend?\n success\n end\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":8,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Actions\n attr_accessor :behavior\n\n def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end\n\n module ClassMethods\n # Hold source paths for one Thor instance. source_paths_for_search is the\n # method responsible to gather source_paths from this current class,\n # inherited paths and the source root.\n #\n def source_paths\n @_source_paths ||= []\n end\n\n # Stores and return the source root for this class\n def source_root(path = nil)\n @_source_root = path if path\n @_source_root ||= nil\n end\n\n # Returns the source paths in the following order:\n #\n # 1) This class source paths\n # 2) Source root\n # 3) Parents source paths\n #\n def source_paths_for_search\n paths = []\n paths += source_paths\n paths << source_root if source_root\n paths += from_superclass(:source_paths, [])\n paths\n end\n\n # Add runtime options that help actions execution.\n #\n def add_runtime_options!\n class_option :force, type: :boolean, aliases: \"-f\", group: :runtime,\n desc: \"O"}
{"repo":"thor","file":"lib/thor/actions.rb","line":9,"symbol":"Actions","kind":"module","lang":"ruby","code":"module Actions\n attr_accessor :behavior\n\n def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end\n\n module ClassMethods\n # Hold source paths for one Thor instance. source_paths_for_search is the\n # method responsible to gather source_paths from this current class,\n # inherited paths and the source root.\n #\n def source_paths\n @_source_paths ||= []\n end\n\n # Stores and return the source root for this class\n def source_root(path = nil)\n @_source_root = path if path\n @_source_root ||= nil\n end\n\n # Returns the source paths in the following order:\n #\n # 1) This class source paths\n # 2) Source root\n # 3) Parents source paths\n #\n def source_paths_for_search\n paths = []\n paths += source_paths\n paths << source_root if source_root\n paths += from_superclass(:source_paths, [])\n paths\n end\n\n # Add runtime options that help actions execution.\n #\n def add_runtime_options!\n class_option :force, type: :boolean, aliases: \"-f\", group: :runtime,\n desc: \"Overwrite file"}
{"repo":"thor","file":"lib/thor/actions.rb","line":12,"symbol":"included","kind":"method","lang":"ruby","code":"def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":17,"symbol":"ClassMethods","kind":"module","lang":"ruby","code":"module ClassMethods\n # Hold source paths for one Thor instance. source_paths_for_search is the\n # method responsible to gather source_paths from this current class,\n # inherited paths and the source root.\n #\n def source_paths\n @_source_paths ||= []\n end\n\n # Stores and return the source root for this class\n def source_root(path = nil)\n @_source_root = path if path\n @_source_root ||= nil\n end\n\n # Returns the source paths in the following order:\n #\n # 1) This class source paths\n # 2) Source root\n # 3) Parents source paths\n #\n def source_paths_for_search\n paths = []\n paths += source_paths\n paths << source_root if source_root\n paths += from_superclass(:source_paths, [])\n paths\n end\n\n # Add runtime options that help actions execution.\n #\n def add_runtime_options!\n class_option :force, type: :boolean, aliases: \"-f\", group: :runtime,\n desc: \"Overwrite files that already exist\"\n\n class_option :pretend, type: :boolean, aliases: \"-p\", group: :runtime,\n desc: \"Run"}
{"repo":"thor","file":"lib/thor/actions.rb","line":22,"symbol":"source_paths","kind":"method","lang":"ruby","doc":"Hold source paths for one Thor instance. source_paths_for_search is the method responsible to gather source_paths from this current class, inherited paths and the source root.","code":"def source_paths\n @_source_paths ||= []\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":27,"symbol":"source_root","kind":"method","lang":"ruby","doc":"Stores and return the source root for this class","code":"def source_root(path = nil)\n @_source_root = path if path\n @_source_root ||= nil\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":38,"symbol":"source_paths_for_search","kind":"method","lang":"ruby","doc":"Returns the source paths in the following order: 1) This class source paths 2) Source root 3) Parents source paths","code":"def source_paths_for_search\n paths = []\n paths += source_paths\n paths << source_root if source_root\n paths += from_superclass(:source_paths, [])\n paths\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":48,"symbol":"add_runtime_options!","kind":"method","lang":"ruby","doc":"Add runtime options that help actions execution.","code":"def add_runtime_options!\n class_option :force, type: :boolean, aliases: \"-f\", group: :runtime,\n desc: \"Overwrite files that already exist\"\n\n class_option :pretend, type: :boolean, aliases: \"-p\", group: :runtime,\n desc: \"Run but do not make any changes\"\n\n class_option :quiet, type: :boolean, aliases: \"-q\", group: :runtime,\n desc: \"Suppress status output\"\n\n class_option :skip, type: :boolean, aliases: \"-s\", group: :runtime,\n desc: \"Skip files that already exist\"\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":72,"symbol":"initialize","kind":"method","lang":"ruby","doc":"behavior<Symbol>:: The actions default behavior. Can be :invoke or :revoke. It also accepts :force, :skip and :pretend to set the behavior and the respective option. destination_root<String>:: The root directory needed for some actions.","code":"def initialize(args = [], options = {}, config = {})\n self.behavior = case config[:behavior].to_s\n when \"force\", \"skip\"\n _cleanup_options_and_set(options, config[:behavior])\n :invoke\n when \"revoke\"\n :revoke\n else\n :invoke\n end\n\n super\n self.destination_root = config[:destination_root]\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":89,"symbol":"action","kind":"method","lang":"ruby","doc":"Wraps an action object and call it accordingly to the thor class behavior.","code":"def action(instance) #:nodoc:\n if behavior == :revoke\n instance.revoke!\n else\n instance.invoke!\n end\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":99,"symbol":"destination_root","kind":"method","lang":"ruby","doc":"Returns the root for this thor class (also aliased as destination root).","code":"def destination_root\n @destination_stack.last\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":114,"symbol":"relative_to_original_destination_root","kind":"method","lang":"ruby","doc":"Returns the given path relative to the absolute root (ie, root where the script started).","code":"def relative_to_original_destination_root(path, remove_dot = true)\n root = @destination_stack[0]\n if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, \"\"].include?(path[root.size..root.size])\n path = path.dup\n path[0...root.size] = \".\"\n remove_dot ? (path[2..-1] || \"\") : path\n else\n path\n end\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":127,"symbol":"source_paths","kind":"method","lang":"ruby","doc":"Holds source paths in instance so they can be manipulated.","code":"def source_paths\n @source_paths ||= self.class.source_paths_for_search\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":133,"symbol":"find_in_source_paths","kind":"method","lang":"ruby","doc":"Receives a file or directory and search for it in the source paths.","code":"def find_in_source_paths(file)\n possible_files = [file, file + TEMPLATE_EXTNAME]\n relative_root = relative_to_original_destination_root(destination_root, false)\n\n source_paths.each do |source|\n possible_files.each do |f|\n source_file = File.expand_path(f, File.join(source, relative_root))\n return source_file if File.exist?(source_file)\n end\n end\n\n message = \"Could not find #{file.inspect} in any of your source paths. \".dup\n\n unless self.class.source_root\n message << \"Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. \"\n end\n\n message << if source_paths.empty?\n \"Currently you have no source paths.\"\n else\n \"Your current source paths are: \\n#{source_paths.join(\"\\n\")}\"\n end\n\n raise Error, message\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":170,"symbol":"inside","kind":"method","lang":"ruby","doc":"Returns the value yielded by the block. ==== Parameters dir<String>:: the directory to move to. config<Hash>:: give :verbose => true to log and use padding.","code":"def inside(dir = \"\", config = {}, &block)\n verbose = config.fetch(:verbose, false)\n pretend = options[:pretend]\n\n say_status :inside, dir, verbose\n shell.padding += 1 if verbose\n @destination_stack.push File.expand_path(dir, destination_root)\n\n # If the directory doesn't exist and we're not pretending\n if !File.exist?(destination_root) && !pretend\n require \"fileutils\"\n FileUtils.mkdir_p(destination_root)\n end\n\n result = nil\n if pretend\n # In pretend mode, just yield down to the block\n result = block.arity == 1 ? yield(destination_root) : yield\n else\n require \"fileutils\"\n FileUtils.cd(destination_root) { result = block.arity == 1 ? yield(destination_root) : yield }\n end\n\n @destination_stack.pop\n shell.padding -= 1 if verbose\n result\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":200,"symbol":"in_root","kind":"method","lang":"ruby","doc":"Goes to the root and execute the given block.","code":"def in_root\n inside(@destination_stack.first) { yield }\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":216,"symbol":"apply","kind":"method","lang":"ruby","doc":"==== Examples apply \"http://gist.github.com/103208\" apply \"recipes/jquery.rb\"","code":"def apply(path, config = {})\n verbose = config.fetch(:verbose, true)\n is_uri = path =~ %r{^https?\\://}\n path = find_in_source_paths(path) unless is_uri\n\n say_status :apply, path, verbose\n shell.padding += 1 if verbose\n\n contents = if is_uri\n require \"open-uri\"\n URI.open(path, \"Accept\" => \"application/x-thor-template\", &:read)\n else\n File.open(path, &:read)\n end\n\n instance_eval(contents, path)\n shell.padding -= 1 if verbose\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":248,"symbol":"run","kind":"method","lang":"ruby","doc":"==== Example inside('vendor') do run('ln -s ~/edge rails') end","code":"def run(command, config = {})\n return unless behavior == :invoke\n\n destination = relative_to_original_destination_root(destination_root, false)\n desc = \"#{command} from #{destination.inspect}\"\n\n if config[:with]\n desc = \"#{File.basename(config[:with].to_s)} #{desc}\"\n command = \"#{config[:with]} #{command}\"\n end\n\n say_status :run, desc, config.fetch(:verbose, true)\n\n return if options[:pretend]\n\n env_splat = [config[:env]] if config[:env]\n\n if config[:capture]\n require \"open3\"\n result, status = Open3.capture2e(*env_splat, command.to_s)\n success = status.success?\n else\n result = system(*env_splat, command.to_s)\n success = result\n end\n\n abort if !success && config.fetch(:abort_on_failure, self.class.exit_on_failure?)\n\n result\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":285,"symbol":"run_ruby_script","kind":"method","lang":"ruby","doc":"Executes a ruby script (taking into account WIN32 platform quirks). ==== Parameters command<String>:: the command to be executed. config<Hash>:: give :verbose => false to not log the status.","code":"def run_ruby_script(command, config = {})\n return unless behavior == :invoke\n run command, config.merge(with: Thor::Util.ruby_command)\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":308,"symbol":"thor","kind":"method","lang":"ruby","doc":"thor :install, \"http://gist.github.com/103208\" #=> thor install http://gist.github.com/103208 thor :list, :all => true, :substring => 'rails' #=> thor list --all --substring=rails","code":"def thor(command, *args)\n config = args.last.is_a?(Hash) ? args.pop : {}\n verbose = config.key?(:verbose) ? config.delete(:verbose) : true\n pretend = config.key?(:pretend) ? config.delete(:pretend) : false\n capture = config.key?(:capture) ? config.delete(:capture) : false\n\n args.unshift(command)\n args.push Thor::Options.to_switches(config)\n command = args.join(\" \").strip\n\n run command, with: :thor, verbose: verbose, pretend: pretend, capture: capture\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":325,"symbol":"_shared_configuration","kind":"method","lang":"ruby","doc":"Allow current root to be shared between invocations.","code":"def _shared_configuration #:nodoc:\n super.merge!(destination_root: destination_root)\n end"}
{"repo":"thor","file":"lib/thor/actions.rb","line":329,"symbol":"_cleanup_options_and_set","kind":"method","lang":"ruby","code":"def _cleanup_options_and_set(options, key) #:nodoc:\n case options\n when Array\n %w(--force -f --skip -s).each { |i| options.delete(i) }\n options << \"--#{key}\"\n when Hash\n [:force, :skip, \"force\", \"skip\"].each { |i| options.delete(i) }\n options.merge!(key => true)\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":11,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n autoload :Actions, File.expand_path(\"actions\", __dir__)\n autoload :RakeCompat, File.expand_path(\"rake_compat\", __dir__)\n autoload :Group, File.expand_path(\"group\", __dir__)\n\n # Shortcuts for help and tree commands.\n HELP_MAPPINGS = %w(-h -? --help -D)\n TREE_MAPPINGS = %w(-t --tree)\n\n # Thor methods that should not be overwritten by the user.\n THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root\n action add_file create_file in_root inside run run_ruby_script)\n\n TEMPLATE_EXTNAME = \".tt\"\n\n class << self\n def deprecation_warning(message) #:nodoc:\n unless ENV[\"THOR_SILENCE_DEPRECATION\"]\n warn \"Deprecation warning: #{message}\\n\" +\n \"You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.\"\n end\n end\n end\n\n module Base\n attr_accessor :options, :parent_options, :args\n\n # It receives arguments in an Array and two hashes, one for options and\n # other for configuration.\n #\n # Notice that it does not check if all required arguments were supplied.\n # It should be done by the parser.\n #\n # ==="}
{"repo":"thor","file":"lib/thor/base.rb","line":27,"symbol":"deprecation_warning","kind":"method","lang":"ruby","code":"def deprecation_warning(message) #:nodoc:\n unless ENV[\"THOR_SILENCE_DEPRECATION\"]\n warn \"Deprecation warning: #{message}\\n\" +\n \"You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.\"\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":35,"symbol":"Base","kind":"module","lang":"ruby","code":"module Base\n attr_accessor :options, :parent_options, :args\n\n # It receives arguments in an Array and two hashes, one for options and\n # other for configuration.\n #\n # Notice that it does not check if all required arguments were supplied.\n # It should be done by the parser.\n #\n # ==== Parameters\n # args<Array[Object]>:: An array of objects. The objects are applied to their\n # respective accessors declared with <tt>argument</tt>.\n #\n # options<Hash>:: An options hash that will be available as self.options.\n # The hash given is converted to a hash with indifferent\n # access, magic predicates (options.skip?) and then frozen.\n #\n # config<Hash>:: Configuration for this Thor class.\n #\n def initialize(args = [], local_options = {}, config = {})\n parse_options = self.class.class_options\n\n # The start method splits inbound arguments at the first argument\n # that looks like an option (starts with - or --). It then calls\n # new, passing in the two halves of the arguments Array as the\n # first two parameters.\n\n command_options = config.delete(:command_optio"}
{"repo":"thor","file":"lib/thor/base.rb","line":54,"symbol":"initialize","kind":"method","lang":"ruby","doc":"options<Hash>:: An options hash that will be available as self.options. The hash given is converted to a hash with indifferent access, magic predicates (options.skip?) and then frozen. config<Hash>:: Configuration for this Thor class.","code":"def initialize(args = [], local_options = {}, config = {})\n parse_options = self.class.class_options\n\n # The start method splits inbound arguments at the first argument\n # that looks like an option (starts with - or --). It then calls\n # new, passing in the two halves of the arguments Array as the\n # first two parameters.\n\n command_options = config.delete(:command_options) # hook for start\n parse_options = parse_options.merge(command_options) if command_options\n\n if local_options.is_a?(Array)\n array_options = local_options\n hash_options = {}\n else\n # Handle the case where the class was explicitly instantiated\n # with pre-parsed options.\n array_options = []\n hash_options = local_options\n end\n\n # Let Thor::Options parse the options first, so it can remove\n # declared options from the array. This will leave us with\n # a list of arguments that weren't declared.\n current_command = config[:current_command]\n stop_on_unknown = self.class.stop_on_unknown_option? current_command\n\n # Give a relation of options.\n # After parsing, Thor::Options check whether right relat"}
{"repo":"thor","file":"lib/thor/base.rb","line":117,"symbol":"included","kind":"method","lang":"ruby","code":"def included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n base.send :include, Invocation\n base.send :include, Shell\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":129,"symbol":"subclasses","kind":"method","lang":"ruby","doc":"Returns the classes that inherits from Thor or Thor::Group. ==== Returns Array[Class]","code":"def subclasses\n @subclasses ||= []\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":138,"symbol":"subclass_files","kind":"method","lang":"ruby","doc":"Returns the files where the subclasses are kept. ==== Returns Hash[path<String> => Class]","code":"def subclass_files\n @subclass_files ||= Hash.new { |h, k| h[k] = [] }\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":145,"symbol":"register_klass_file","kind":"method","lang":"ruby","doc":"Whenever a class inherits from Thor or Thor::Group, we should track the class and the file on Thor::Base. This is the method responsible for it.","code":"def register_klass_file(klass) #:nodoc:\n file = caller[1].match(/(.*):\\d+/)[1]\n Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass)\n\n file_subclasses = Thor::Base.subclass_files[File.expand_path(file)]\n file_subclasses << klass unless file_subclasses.include?(klass)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":154,"symbol":"ClassMethods","kind":"module","lang":"ruby","code":"module ClassMethods\n def attr_reader(*) #:nodoc:\n no_commands { super }\n end\n\n def attr_writer(*) #:nodoc:\n no_commands { super }\n end\n\n def attr_accessor(*) #:nodoc:\n no_commands { super }\n end\n\n # If you want to raise an error for unknown options, call check_unknown_options!\n # This is disabled by default to allow dynamic invocations.\n def check_unknown_options!\n @check_unknown_options = true\n end\n\n def check_unknown_options #:nodoc:\n @check_unknown_options ||= from_superclass(:check_unknown_options, false)\n end\n\n def check_unknown_options?(config) #:nodoc:\n !!check_unknown_options\n end\n\n # If you want to raise an error when the default value of an option does not match\n # the type call check_default_type!\n # This will be the default; for compatibility a deprecation warning is issued if necessary.\n def check_default_type!\n @check_default_type = true\n end\n\n # If you want to use defaults that don't match the type of an option,\n # either specify `check_default_type: false` or call `allow_incompatible_default_type!`\n def allow_"}
{"repo":"thor","file":"lib/thor/base.rb","line":155,"symbol":"attr_reader","kind":"method","lang":"ruby","code":"def attr_reader(*) #:nodoc:\n no_commands { super }\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":159,"symbol":"attr_writer","kind":"method","lang":"ruby","code":"def attr_writer(*) #:nodoc:\n no_commands { super }\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":163,"symbol":"attr_accessor","kind":"method","lang":"ruby","code":"def attr_accessor(*) #:nodoc:\n no_commands { super }\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":169,"symbol":"check_unknown_options!","kind":"method","lang":"ruby","doc":"If you want to raise an error for unknown options, call check_unknown_options! This is disabled by default to allow dynamic invocations.","code":"def check_unknown_options!\n @check_unknown_options = true\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":173,"symbol":"check_unknown_options","kind":"method","lang":"ruby","code":"def check_unknown_options #:nodoc:\n @check_unknown_options ||= from_superclass(:check_unknown_options, false)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":177,"symbol":"check_unknown_options?","kind":"method","lang":"ruby","code":"def check_unknown_options?(config) #:nodoc:\n !!check_unknown_options\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":184,"symbol":"check_default_type!","kind":"method","lang":"ruby","doc":"If you want to raise an error when the default value of an option does not match the type call check_default_type! This will be the default; for compatibility a deprecation warning is issued if necessary.","code":"def check_default_type!\n @check_default_type = true\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":190,"symbol":"allow_incompatible_default_type!","kind":"method","lang":"ruby","doc":"If you want to use defaults that don't match the type of an option, either specify `check_default_type: false` or call `allow_incompatible_default_type!`","code":"def allow_incompatible_default_type!\n @check_default_type = false\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":194,"symbol":"check_default_type","kind":"method","lang":"ruby","code":"def check_default_type #:nodoc:\n @check_default_type = from_superclass(:check_default_type, nil) unless defined?(@check_default_type)\n @check_default_type\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":202,"symbol":"stop_on_unknown_option?","kind":"method","lang":"ruby","doc":"If true, option parsing is suspended as soon as an unknown option or a regular argument is encountered. All remaining arguments are passed to the command as regular arguments.","code":"def stop_on_unknown_option?(command_name) #:nodoc:\n false\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":208,"symbol":"disable_required_check?","kind":"method","lang":"ruby","doc":"If true, option set will not suspend the execution of the command when a required option is not provided.","code":"def disable_required_check?(command_name) #:nodoc:\n false\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":215,"symbol":"strict_args_position!","kind":"method","lang":"ruby","doc":"If you want only strict string args (useful when cascading thor classes), call strict_args_position! This is disabled by default to allow dynamic invocations.","code":"def strict_args_position!\n @strict_args_position = true\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":219,"symbol":"strict_args_position","kind":"method","lang":"ruby","code":"def strict_args_position #:nodoc:\n @strict_args_position ||= from_superclass(:strict_args_position, false)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":223,"symbol":"strict_args_position?","kind":"method","lang":"ruby","code":"def strict_args_position?(config) #:nodoc:\n !!strict_args_position\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":262,"symbol":"argument","kind":"method","lang":"ruby","doc":":default - Default value for this argument. It cannot be required and have default values. :banner - String to show on usage notes. ==== Errors ArgumentError:: Raised if you supply a required argument after a non required one.","code":"def argument(name, options = {})\n is_thor_reserved_word?(name, :argument)\n no_commands { attr_accessor name }\n\n required = if options.key?(:optional)\n !options[:optional]\n elsif options.key?(:required)\n options[:required]\n else\n options[:default].nil?\n end\n\n remove_argument name\n\n if required\n arguments.each do |argument|\n next if argument.required?\n raise ArgumentError, \"You cannot have #{name.to_s.inspect} as required argument after \" \\\n \"the non-required argument #{argument.human_name.inspect}.\"\n end\n end\n\n options[:required] = required\n\n arguments << Thor::Argument.new(name, options)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":294,"symbol":"arguments","kind":"method","lang":"ruby","doc":"Returns this class arguments, looking up in the ancestors chain. ==== Returns Array[Thor::Argument]","code":"def arguments\n @arguments ||= from_superclass(:arguments, [])\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":307,"symbol":"class_options","kind":"method","lang":"ruby","doc":"If you prefer more detailed declaration, check class_option. ==== Parameters Hash[Symbol => Object]","code":"def class_options(options = nil)\n @class_options ||= from_superclass(:class_options, {})\n build_options(options, @class_options) if options\n @class_options\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":329,"symbol":"class_option","kind":"method","lang":"ruby","doc":":group:: -- The group for this options. Use by class options to output options in different levels. :aliases:: -- Aliases for this option. <b>Note:</b> Thor follows a convention of one-dash-one-letter options. Thus aliases like \"-something\" wouldn't be parsed; use either \"\\--something\" or \"-s\" instead. :type:: -- The type of the argument, can be :string, :hash, :array, :numeric or :boolean. :banner:: -- String to show on usage notes. :hide:: -- If you want to hide this option from the help.","code":"def class_option(name, options = {})\n unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }\n raise ArgumentError, \"Expected a Symbol or String, got #{name.inspect}\"\n end\n build_option(name, options, class_options)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":358,"symbol":"class_exclusive","kind":"method","lang":"ruby","doc":"class_option :two class_exclusive :one, :two If you give \"--one\" and \"--two\" at the same time ExclusiveArgumentsError will be raised.","code":"def class_exclusive(*args, &block)\n register_options_relation_for(:class_options,\n :class_exclusive_option_names, *args, &block)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":393,"symbol":"class_at_least_one","kind":"method","lang":"ruby","doc":"class_option :two end end Then it is required either only one of \"--one\" or \"--two\".","code":"def class_at_least_one(*args, &block)\n register_options_relation_for(:class_options,\n :class_at_least_one_option_names, *args, &block)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":403,"symbol":"class_exclusive_option_names","kind":"method","lang":"ruby","doc":"Returns this class exclusive options array set, looking up in the ancestors chain. ==== Returns Array[Array[Thor::Option.name]]","code":"def class_exclusive_option_names\n @class_exclusive_option_names ||= from_superclass(:class_exclusive_option_names, [])\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":412,"symbol":"class_at_least_one_option_names","kind":"method","lang":"ruby","doc":"Returns this class at least one of required options array set, looking up in the ancestors chain. ==== Returns Array[Array[Thor::Option.name]]","code":"def class_at_least_one_option_names\n @class_at_least_one_option_names ||= from_superclass(:class_at_least_one_option_names, [])\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":427,"symbol":"remove_argument","kind":"method","lang":"ruby","doc":"==== Examples remove_argument :foo remove_argument :foo, :bar, :baz, :undefine => true","code":"def remove_argument(*names)\n options = names.last.is_a?(Hash) ? names.pop : {}\n\n names.each do |name|\n arguments.delete_if { |a| a.name == name.to_s }\n undef_method name, \"#{name}=\" if options[:undefine]\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":446,"symbol":"remove_class_option","kind":"method","lang":"ruby","doc":"==== Examples remove_class_option :foo remove_class_option :foo, :bar, :baz","code":"def remove_class_option(*names)\n names.each do |name|\n class_options.delete(name)\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":458,"symbol":"group","kind":"method","lang":"ruby","doc":"Defines the group. This is used when thor list is invoked so you can specify that only commands from a pre-defined group will be shown. Defaults to standard. ==== Parameters name<String|Symbol>","code":"def group(name = nil)\n if name\n @group = name.to_s\n else\n @group ||= from_superclass(:group, \"standard\")\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":472,"symbol":"commands","kind":"method","lang":"ruby","doc":"Returns the commands for this Thor class. ==== Returns Hash:: An ordered hash with commands names as keys and Thor::Command objects as values.","code":"def commands\n @commands ||= Hash.new\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":483,"symbol":"all_commands","kind":"method","lang":"ruby","doc":"Returns the commands for this Thor class and all subclasses. ==== Returns Hash:: An ordered hash with commands names as keys and Thor::Command objects as values.","code":"def all_commands\n @all_commands ||= from_superclass(:all_commands, Hash.new)\n @all_commands.merge!(commands)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":501,"symbol":"remove_command","kind":"method","lang":"ruby","doc":"==== Parameters name<Symbol|String>:: The name of the command to be removed options<Hash>:: You can give :undefine => true if you want commands the method to be undefined from the class as well.","code":"def remove_command(*names)\n options = names.last.is_a?(Hash) ? names.pop : {}\n\n names.each do |name|\n commands.delete(name.to_s)\n all_commands.delete(name.to_s)\n undef_method name if options[:undefine]\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":531,"symbol":"no_commands","kind":"method","lang":"ruby","doc":"class MyScript < Thor def this_is_not_a_command end remove_command :this_is_not_a_command end","code":"def no_commands(&block)\n no_commands_context.enter(&block)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":537,"symbol":"no_commands_context","kind":"method","lang":"ruby","code":"def no_commands_context\n @no_commands_context ||= NestedContext.new\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":541,"symbol":"no_commands?","kind":"method","lang":"ruby","code":"def no_commands?\n no_commands_context.entered?\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":567,"symbol":"namespace","kind":"method","lang":"ruby","doc":"namespace :default Your commands can be invoked with a shortcut. Instead of: thor :my_command","code":"def namespace(name = nil)\n if name\n @namespace = name.to_s\n else\n @namespace ||= Thor::Util.namespace_from_thor_class(self)\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":583,"symbol":"start","kind":"method","lang":"ruby","doc":"from an array. If you are inside Ruby and want to use a Thor class, you can simply initialize it: script = MyScript.new(args, options, config) script.invoke(:command, first_arg, second_arg, third_arg)","code":"def start(given_args = ARGV, config = {})\n config[:shell] ||= Thor::Base.shell.new\n dispatch(nil, given_args.dup, nil, config)\n rescue Thor::Error => e\n config[:debug] || ENV[\"THOR_DEBUG\"] == \"1\" ? (raise e) : config[:shell].error(e.message)\n exit(false) if exit_on_failure?\n rescue Errno::EPIPE\n # This happens if a thor command is piped to something like `head`,\n # which closes the pipe when it's done reading. This will also\n # mean that if the pipe is closed, further unnecessary\n # computation will not occur.\n exit(true)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":607,"symbol":"public_command","kind":"method","lang":"ruby","doc":"==== Examples public_command :foo public_command :foo, :bar, :baz","code":"def public_command(*names)\n names.each do |name|\n class_eval \"def #{name}(*); super end\", __FILE__, __LINE__\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":614,"symbol":"handle_no_command_error","kind":"method","lang":"ruby","code":"def handle_no_command_error(command, has_namespace = $thor_runner) #:nodoc:\n raise UndefinedCommandError.new(command, all_commands.keys, (namespace if has_namespace))\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":619,"symbol":"handle_argument_error","kind":"method","lang":"ruby","code":"def handle_argument_error(command, error, args, arity) #:nodoc:\n name = [command.ancestor_name, command.name].compact.join(\" \")\n msg = \"ERROR: \\\"#{basename} #{name}\\\" was called with \".dup\n msg << \"no arguments\" if args.empty?\n msg << \"arguments \" << args.inspect unless args.empty?\n msg << \"\\nUsage: \\\"#{banner(command).split(\"\\n\").join(\"\\\"\\n \\\"\")}\\\"\"\n raise InvocationError, msg\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":629,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","doc":"A flag that makes the process exit with status 1 if any error happens.","code":"def exit_on_failure?\n Thor.deprecation_warning \"Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `#{self.name}`\"\n false\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":639,"symbol":"class_options_help","kind":"method","lang":"ruby","doc":"Prints the class options per group. If an option does not belong to any group, it's printed as Class option.","code":"def class_options_help(shell, groups = {}) #:nodoc:\n # Group options by group\n class_options.each do |_, value|\n groups[value.group] ||= []\n groups[value.group] << value\n end\n\n # Deal with default group\n global_options = groups.delete(nil) || []\n print_options(shell, global_options)\n\n # Print all others\n groups.each do |group_name, options|\n print_options(shell, options, group_name)\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":657,"symbol":"print_options","kind":"method","lang":"ruby","doc":"Receives a set of options and print them.","code":"def print_options(shell, options, group_name = nil)\n return if options.empty?\n\n list = []\n padding = options.map { |o| o.aliases_for_usage.size }.max.to_i\n options.each do |option|\n next if option.hide\n item = [option.usage(padding)]\n item.push(option.description ? \"# #{option.description}\" : \"\")\n\n list << item\n list << [\"\", \"# Default: #{option.print_default}\"] if option.show_default?\n list << [\"\", \"# Possible values: #{option.enum_to_s}\"] if option.enum\n end\n\n shell.say(group_name ? \"#{group_name} options:\" : \"Options:\")\n shell.print_table(list, indent: 2)\n shell.say \"\"\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":678,"symbol":"is_thor_reserved_word?","kind":"method","lang":"ruby","doc":"Raises an error if the word given is a Thor reserved word.","code":"def is_thor_reserved_word?(word, type) #:nodoc:\n return false unless THOR_RESERVED_WORDS.include?(word.to_s)\n raise \"#{word.inspect} is a Thor reserved word and cannot be defined as #{type}\"\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":689,"symbol":"build_option","kind":"method","lang":"ruby","doc":"Build an option and adds it to the given scope. ==== Parameters name<Symbol>:: The name of the argument. options<Hash>:: Described in both class_option and method_option. scope<Hash>:: Options hash that is being built up","code":"def build_option(name, options, scope) #:nodoc:\n scope[name] = Thor::Option.new(name, {check_default_type: check_default_type}.merge!(options))\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":700,"symbol":"build_options","kind":"method","lang":"ruby","doc":"fast way to set a bunch of options: build_options :foo => true, :bar => :required, :baz => :string ==== Parameters Hash[Symbol => Object]","code":"def build_options(options, scope) #:nodoc:\n options.each do |key, value|\n scope[key] = Thor::Option.parse(key, value)\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":709,"symbol":"find_and_refresh_command","kind":"method","lang":"ruby","doc":"Finds a command with the given name. If the command belongs to the current class, just return it, otherwise dup it and add the fresh copy to the current command hash.","code":"def find_and_refresh_command(name) #:nodoc:\n if commands[name.to_s]\n commands[name.to_s]\n elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition\n commands[name.to_s] = command.clone\n else\n raise ArgumentError, \"You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found.\"\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":722,"symbol":"inherited","kind":"method","lang":"ruby","doc":"Every time someone inherits from a Thor class, register the klass and file into baseclass.","code":"def inherited(klass)\n super(klass)\n Thor::Base.register_klass_file(klass)\n klass.instance_variable_set(:@no_commands, 0)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":730,"symbol":"method_added","kind":"method","lang":"ruby","doc":"Fire this callback whenever a method is added. Added methods are tracked as commands by invoking the create_command method.","code":"def method_added(meth)\n super(meth)\n meth = meth.to_s\n\n if meth == \"initialize\"\n initialize_added\n return\n end\n\n # Return if it's not a public instance method\n return unless public_method_defined?(meth.to_sym)\n\n return if no_commands? || !create_command(meth)\n\n is_thor_reserved_word?(meth, :command)\n Thor::Base.register_klass_file(self)\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":750,"symbol":"from_superclass","kind":"method","lang":"ruby","doc":"Retrieves a value from superclass. If it reaches the baseclass, returns default.","code":"def from_superclass(method, default = nil)\n if self == baseclass || !superclass.respond_to?(method, true)\n default\n else\n value = superclass.send(method)\n\n # Ruby implements `dup` on Object, but raises a `TypeError`\n # if the method is called on immediates. As a result, we\n # don't have a good way to check whether dup will succeed\n # without calling it and rescuing the TypeError.\n begin\n value.dup\n rescue TypeError\n value\n end\n\n end\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":772,"symbol":"basename","kind":"method","lang":"ruby","doc":"The basename of the program invoking the thor class.","code":"def basename\n File.basename($PROGRAM_NAME).split(\" \").first\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":778,"symbol":"baseclass","kind":"method","lang":"ruby","doc":"SIGNATURE: Sets the baseclass. This is where the superclass lookup finishes.","code":"def baseclass #:nodoc:\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":783,"symbol":"create_command","kind":"method","lang":"ruby","doc":"SIGNATURE: Creates a new command if valid_command? is true. This method is called when a new method is added to the class.","code":"def create_command(meth) #:nodoc:\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":789,"symbol":"initialize_added","kind":"method","lang":"ruby","doc":"SIGNATURE: Defines behavior when the initialize method is added to the class.","code":"def initialize_added #:nodoc:\n end"}
{"repo":"thor","file":"lib/thor/base.rb","line":793,"symbol":"dispatch","kind":"method","lang":"ruby","doc":"SIGNATURE: The hook invoked by start.","code":"def dispatch(command, given_args, given_opts, config) #:nodoc:\n raise NotImplementedError\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class Command < Struct.new(:name, :description, :long_description, :wrap_long_description, :usage, :options, :options_relation, :ancestor_name)\n FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/\n\n def initialize(name, description, long_description, wrap_long_description, usage, options = nil, options_relation = nil)\n super(name.to_s, description, long_description, wrap_long_description, usage, options || {}, options_relation || {})\n end\n\n def initialize_copy(other) #:nodoc:\n super(other)\n self.options = other.options.dup if other.options\n self.options_relation = other.options_relation.dup if other.options_relation\n end\n\n def hidden?\n false\n end\n\n # By default, a command invokes a method in the thor class. You can change this\n # implementation to create custom commands.\n def run(instance, args = [])\n arity = nil\n\n if private_method?(instance)\n instance.class.handle_no_command_error(name)\n elsif public_method?(instance)\n arity = instance.method(name).arity\n instance.__send__(name, *args)\n elsif local_method?(instance, :method_missing)\n instance.__send__(:method_"}
{"repo":"thor","file":"lib/thor/command.rb","line":2,"symbol":"Command","kind":"class","lang":"ruby","code":"class Command < Struct.new(:name, :description, :long_description, :wrap_long_description, :usage, :options, :options_relation, :ancestor_name)\n FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/\n\n def initialize(name, description, long_description, wrap_long_description, usage, options = nil, options_relation = nil)\n super(name.to_s, description, long_description, wrap_long_description, usage, options || {}, options_relation || {})\n end\n\n def initialize_copy(other) #:nodoc:\n super(other)\n self.options = other.options.dup if other.options\n self.options_relation = other.options_relation.dup if other.options_relation\n end\n\n def hidden?\n false\n end\n\n # By default, a command invokes a method in the thor class. You can change this\n # implementation to create custom commands.\n def run(instance, args = [])\n arity = nil\n\n if private_method?(instance)\n instance.class.handle_no_command_error(name)\n elsif public_method?(instance)\n arity = instance.method(name).arity\n instance.__send__(name, *args)\n elsif local_method?(instance, :method_missing)\n instance.__send__(:method_missing, name"}
{"repo":"thor","file":"lib/thor/command.rb","line":5,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(name, description, long_description, wrap_long_description, usage, options = nil, options_relation = nil)\n super(name.to_s, description, long_description, wrap_long_description, usage, options || {}, options_relation || {})\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":9,"symbol":"initialize_copy","kind":"method","lang":"ruby","code":"def initialize_copy(other) #:nodoc:\n super(other)\n self.options = other.options.dup if other.options\n self.options_relation = other.options_relation.dup if other.options_relation\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":15,"symbol":"hidden?","kind":"method","lang":"ruby","code":"def hidden?\n false\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":21,"symbol":"run","kind":"method","lang":"ruby","doc":"By default, a command invokes a method in the thor class. You can change this implementation to create custom commands.","code":"def run(instance, args = [])\n arity = nil\n\n if private_method?(instance)\n instance.class.handle_no_command_error(name)\n elsif public_method?(instance)\n arity = instance.method(name).arity\n instance.__send__(name, *args)\n elsif local_method?(instance, :method_missing)\n instance.__send__(:method_missing, name.to_sym, *args)\n else\n instance.class.handle_no_command_error(name)\n end\n rescue ArgumentError => e\n handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)\n rescue NoMethodError => e\n handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (raise e)\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":42,"symbol":"formatted_usage","kind":"method","lang":"ruby","doc":"Returns the formatted usage by injecting given required arguments and required options into the given usage.","code":"def formatted_usage(klass, namespace = true, subcommand = false)\n if ancestor_name\n formatted = \"#{ancestor_name} \".dup # add space\n elsif namespace\n namespace = klass.namespace\n formatted = \"#{namespace.gsub(/^(default)/, '')}:\".dup\n end\n formatted ||= \"#{klass.namespace.split(':').last} \".dup if subcommand\n\n formatted ||= \"\".dup\n\n Array(usage).map do |specific_usage|\n formatted_specific_usage = formatted\n\n formatted_specific_usage += required_arguments_for(klass, specific_usage)\n\n # Add required options\n formatted_specific_usage += \" #{required_options}\"\n\n # Strip and go!\n formatted_specific_usage.strip\n end.join(\"\\n\")\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":66,"symbol":"method_exclusive_option_names","kind":"method","lang":"ruby","code":"def method_exclusive_option_names #:nodoc:\n self.options_relation[:exclusive_option_names] || []\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":70,"symbol":"method_at_least_one_option_names","kind":"method","lang":"ruby","code":"def method_at_least_one_option_names #:nodoc:\n self.options_relation[:at_least_one_option_names] || []\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":77,"symbol":"required_arguments_for","kind":"method","lang":"ruby","doc":"Add usage with required arguments","code":"def required_arguments_for(klass, usage)\n if klass && !klass.arguments.empty?\n usage.to_s.gsub(/^#{name}/) do |match|\n match << \" \" << klass.arguments.map(&:usage).compact.join(\" \")\n end\n else\n usage.to_s\n end\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":87,"symbol":"not_debugging?","kind":"method","lang":"ruby","code":"def not_debugging?(instance)\n !(instance.class.respond_to?(:debugging) && instance.class.debugging)\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":91,"symbol":"required_options","kind":"method","lang":"ruby","code":"def required_options\n @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(\" \")\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":96,"symbol":"public_method?","kind":"method","lang":"ruby","doc":"Given a target, checks if this class name is a public method.","code":"def public_method?(instance) #:nodoc:\n !(instance.public_methods & [name.to_s, name.to_sym]).empty?\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":100,"symbol":"private_method?","kind":"method","lang":"ruby","code":"def private_method?(instance)\n !(instance.private_methods & [name.to_s, name.to_sym]).empty?\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":104,"symbol":"local_method?","kind":"method","lang":"ruby","code":"def local_method?(instance, name)\n methods = instance.public_methods(false) + instance.private_methods(false) + instance.protected_methods(false)\n !(methods & [name.to_s, name.to_sym]).empty?\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":109,"symbol":"sans_backtrace","kind":"method","lang":"ruby","code":"def sans_backtrace(backtrace, caller) #:nodoc:\n saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~ %r{^kernel/} && RUBY_ENGINE =~ /rbx/) }\n saned - caller\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":114,"symbol":"handle_argument_error?","kind":"method","lang":"ruby","code":"def handle_argument_error?(instance, error, caller)\n not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \\d*, expected \\d*/) && begin\n saned = sans_backtrace(error.backtrace, caller)\n saned.empty? || saned.size == 1\n end\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":121,"symbol":"handle_no_method_error?","kind":"method","lang":"ruby","code":"def handle_no_method_error?(instance, error, caller)\n not_debugging?(instance) &&\n error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":129,"symbol":"HiddenCommand","kind":"class","lang":"ruby","doc":"A command that is hidden in help messages but still invocable.","code":"class HiddenCommand < Command\n def hidden?\n true\n end\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":130,"symbol":"hidden?","kind":"method","lang":"ruby","code":"def hidden?\n true\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":137,"symbol":"DynamicCommand","kind":"class","lang":"ruby","doc":"A dynamic command that handles method missing scenarios.","code":"class DynamicCommand < Command\n def initialize(name, options = nil)\n super(name.to_s, \"A dynamically-generated command\", name.to_s, nil, name.to_s, options)\n end\n\n def run(instance, args = [])\n if (instance.methods & [name.to_s, name.to_sym]).empty?\n super\n else\n instance.class.handle_no_command_error(name)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":138,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(name, options = nil)\n super(name.to_s, \"A dynamically-generated command\", name.to_s, nil, name.to_s, options)\n end"}
{"repo":"thor","file":"lib/thor/command.rb","line":142,"symbol":"run","kind":"method","lang":"ruby","code":"def run(instance, args = [])\n if (instance.methods & [name.to_s, name.to_sym]).empty?\n super\n else\n instance.class.handle_no_command_error(name)\n end\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module CoreExt #:nodoc:\n # A hash with indifferent access and magic predicates.\n #\n # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true\n #\n # hash[:foo] #=> 'bar'\n # hash['foo'] #=> 'bar'\n # hash.foo? #=> true\n #\n class HashWithIndifferentAccess < ::Hash #:nodoc:\n def initialize(hash = {})\n super()\n hash.each do |key, value|\n self[convert_key(key)] = value\n end\n end\n\n def [](key)\n super(convert_key(key))\n end\n\n def []=(key, value)\n super(convert_key(key), value)\n end\n\n def delete(key)\n super(convert_key(key))\n end\n\n def except(*keys)\n dup.tap do |hash|\n keys.each { |key| hash.delete(convert_key(key)) }\n end\n end\n\n def fetch(key, *args)\n super(convert_key(key), *args)\n end\n\n def slice(*keys)\n super(*keys.map{ |key| convert_key(key) })\n end\n\n def key?(key)\n super(convert_key(key))\n end\n\n def values_at(*indices)\n indices.map { |key| self[convert_key(key)] }\n end\n\n def merge(other)\n dup"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":2,"symbol":"CoreExt","kind":"module","lang":"ruby","code":"module CoreExt #:nodoc:\n # A hash with indifferent access and magic predicates.\n #\n # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true\n #\n # hash[:foo] #=> 'bar'\n # hash['foo'] #=> 'bar'\n # hash.foo? #=> true\n #\n class HashWithIndifferentAccess < ::Hash #:nodoc:\n def initialize(hash = {})\n super()\n hash.each do |key, value|\n self[convert_key(key)] = value\n end\n end\n\n def [](key)\n super(convert_key(key))\n end\n\n def []=(key, value)\n super(convert_key(key), value)\n end\n\n def delete(key)\n super(convert_key(key))\n end\n\n def except(*keys)\n dup.tap do |hash|\n keys.each { |key| hash.delete(convert_key(key)) }\n end\n end\n\n def fetch(key, *args)\n super(convert_key(key), *args)\n end\n\n def slice(*keys)\n super(*keys.map{ |key| convert_key(key) })\n end\n\n def key?(key)\n super(convert_key(key))\n end\n\n def values_at(*indices)\n indices.map { |key| self[convert_key(key)] }\n end\n\n def merge(other)\n dup.merge!(other"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":11,"symbol":"HashWithIndifferentAccess","kind":"class","lang":"ruby","doc":"hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true hash[:foo] #=> 'bar' hash['foo'] #=> 'bar' hash.foo? #=> true","code":"class HashWithIndifferentAccess < ::Hash #:nodoc:\n def initialize(hash = {})\n super()\n hash.each do |key, value|\n self[convert_key(key)] = value\n end\n end\n\n def [](key)\n super(convert_key(key))\n end\n\n def []=(key, value)\n super(convert_key(key), value)\n end\n\n def delete(key)\n super(convert_key(key))\n end\n\n def except(*keys)\n dup.tap do |hash|\n keys.each { |key| hash.delete(convert_key(key)) }\n end\n end\n\n def fetch(key, *args)\n super(convert_key(key), *args)\n end\n\n def slice(*keys)\n super(*keys.map{ |key| convert_key(key) })\n end\n\n def key?(key)\n super(convert_key(key))\n end\n\n def values_at(*indices)\n indices.map { |key| self[convert_key(key)] }\n end\n\n def merge(other)\n dup.merge!(other)\n end\n\n def merge!(other)\n other.each do |key, value|\n self[convert_key(key)] = value\n end\n self\n end\n\n def reverse_merge(other)\n self.class.new(other).merge(self)\n end\n\n def reverse_merge!(other_hash)\n replace(reverse_merge(ot"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":12,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(hash = {})\n super()\n hash.each do |key, value|\n self[convert_key(key)] = value\n end\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":27,"symbol":"delete","kind":"method","lang":"ruby","code":"def delete(key)\n super(convert_key(key))\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":31,"symbol":"except","kind":"method","lang":"ruby","code":"def except(*keys)\n dup.tap do |hash|\n keys.each { |key| hash.delete(convert_key(key)) }\n end\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":37,"symbol":"fetch","kind":"method","lang":"ruby","code":"def fetch(key, *args)\n super(convert_key(key), *args)\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":41,"symbol":"slice","kind":"method","lang":"ruby","code":"def slice(*keys)\n super(*keys.map{ |key| convert_key(key) })\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":45,"symbol":"key?","kind":"method","lang":"ruby","code":"def key?(key)\n super(convert_key(key))\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":49,"symbol":"values_at","kind":"method","lang":"ruby","code":"def values_at(*indices)\n indices.map { |key| self[convert_key(key)] }\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":53,"symbol":"merge","kind":"method","lang":"ruby","code":"def merge(other)\n dup.merge!(other)\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":57,"symbol":"merge!","kind":"method","lang":"ruby","code":"def merge!(other)\n other.each do |key, value|\n self[convert_key(key)] = value\n end\n self\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":64,"symbol":"reverse_merge","kind":"method","lang":"ruby","code":"def reverse_merge(other)\n self.class.new(other).merge(self)\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":68,"symbol":"reverse_merge!","kind":"method","lang":"ruby","code":"def reverse_merge!(other_hash)\n replace(reverse_merge(other_hash))\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":72,"symbol":"replace","kind":"method","lang":"ruby","code":"def replace(other_hash)\n super(other_hash)\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":77,"symbol":"to_hash","kind":"method","lang":"ruby","doc":"Convert to a Hash with String keys.","code":"def to_hash\n Hash.new(default).merge!(self)\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":83,"symbol":"convert_key","kind":"method","lang":"ruby","code":"def convert_key(key)\n key.is_a?(Symbol) ? key.to_s : key\n end"}
{"repo":"thor","file":"lib/thor/core_ext/hash_with_indifferent_access.rb","line":93,"symbol":"method_missing","kind":"method","lang":"ruby","doc":"Magic predicates. For instance: options.force? # => !!options['force'] options.shebang # => \"/usr/lib/local/ruby\" options.test_framework?(:rspec) # => options[:test_framework] == :rspec","code":"def method_missing(method, *args)\n method = method.to_s\n if method =~ /^(\\w+)\\?$/\n if args.empty?\n !!self[$1]\n else\n self[$1] == args.first\n end\n else\n self[method]\n end\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName\n Module.new do\n def to_s\n super + DidYouMean.formatter.message_for(corrections)\n end\n\n def corrections\n @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections\n end\n end\n end\n\n # Thor::Error is raised when it's caused by wrong usage of thor classes. Those\n # errors have their backtrace suppressed and are nicely shown to the user.\n #\n # Errors that are caused by the developer, like declaring a method which\n # overwrites a thor keyword, SHOULD NOT raise a Thor::Error. This way, we\n # ensure that developer errors are shown with full backtrace.\n class Error < StandardError\n end\n\n # Raised when a command was not found.\n class UndefinedCommandError < Error\n class SpellChecker\n attr_reader :error\n\n def initialize(error)\n @error = error\n end\n\n def corrections\n @corrections ||= spell_checker.correct(error.command).map(&:inspect)\n end\n\n def spell_checker\n DidYouMean::SpellChecker.new(dictionary: error.all_commands)\n end\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":4,"symbol":"to_s","kind":"method","lang":"ruby","code":"def to_s\n super + DidYouMean.formatter.message_for(corrections)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":8,"symbol":"corrections","kind":"method","lang":"ruby","code":"def corrections\n @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":20,"symbol":"Error","kind":"class","lang":"ruby","doc":"Thor::Error is raised when it's caused by wrong usage of thor classes. Those errors have their backtrace suppressed and are nicely shown to the user. Errors that are caused by the developer, like declaring a method which overwrites a thor keyword, SHOULD NOT raise a Thor::Error. This way, we ensure that developer errors are shown with full backtrace.","code":"class Error < StandardError\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":24,"symbol":"UndefinedCommandError","kind":"class","lang":"ruby","doc":"Raised when a command was not found.","code":"class UndefinedCommandError < Error\n class SpellChecker\n attr_reader :error\n\n def initialize(error)\n @error = error\n end\n\n def corrections\n @corrections ||= spell_checker.correct(error.command).map(&:inspect)\n end\n\n def spell_checker\n DidYouMean::SpellChecker.new(dictionary: error.all_commands)\n end\n end\n\n attr_reader :command, :all_commands\n\n def initialize(command, all_commands, namespace)\n @command = command\n @all_commands = all_commands\n\n message = \"Could not find command #{command.inspect}\"\n message = namespace ? \"#{message} in #{namespace.inspect} namespace.\" : \"#{message}.\"\n\n super(message)\n end\n\n prepend Correctable if Correctable\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":25,"symbol":"SpellChecker","kind":"class","lang":"ruby","code":"class SpellChecker\n attr_reader :error\n\n def initialize(error)\n @error = error\n end\n\n def corrections\n @corrections ||= spell_checker.correct(error.command).map(&:inspect)\n end\n\n def spell_checker\n DidYouMean::SpellChecker.new(dictionary: error.all_commands)\n end\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":28,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(error)\n @error = error\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":32,"symbol":"corrections","kind":"method","lang":"ruby","code":"def corrections\n @corrections ||= spell_checker.correct(error.command).map(&:inspect)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":36,"symbol":"spell_checker","kind":"method","lang":"ruby","code":"def spell_checker\n DidYouMean::SpellChecker.new(dictionary: error.all_commands)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":43,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(command, all_commands, namespace)\n @command = command\n @all_commands = all_commands\n\n message = \"Could not find command #{command.inspect}\"\n message = namespace ? \"#{message} in #{namespace.inspect} namespace.\" : \"#{message}.\"\n\n super(message)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":57,"symbol":"AmbiguousCommandError","kind":"class","lang":"ruby","code":"class AmbiguousCommandError < Error\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":62,"symbol":"InvocationError","kind":"class","lang":"ruby","doc":"Raised when a command was found, but not invoked properly.","code":"class InvocationError < Error\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":65,"symbol":"UnknownArgumentError","kind":"class","lang":"ruby","code":"class UnknownArgumentError < Error\n class SpellChecker\n attr_reader :error\n\n def initialize(error)\n @error = error\n end\n\n def corrections\n @corrections ||=\n error.unknown.flat_map { |unknown| spell_checker.correct(unknown) }.uniq.map(&:inspect)\n end\n\n def spell_checker\n @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)\n end\n end\n\n attr_reader :switches, :unknown\n\n def initialize(switches, unknown)\n @switches = switches\n @unknown = unknown\n\n super(\"Unknown switches #{unknown.map(&:inspect).join(', ')}\")\n end\n\n prepend Correctable if Correctable\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":66,"symbol":"SpellChecker","kind":"class","lang":"ruby","code":"class SpellChecker\n attr_reader :error\n\n def initialize(error)\n @error = error\n end\n\n def corrections\n @corrections ||=\n error.unknown.flat_map { |unknown| spell_checker.correct(unknown) }.uniq.map(&:inspect)\n end\n\n def spell_checker\n @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)\n end\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":69,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(error)\n @error = error\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":73,"symbol":"corrections","kind":"method","lang":"ruby","code":"def corrections\n @corrections ||=\n error.unknown.flat_map { |unknown| spell_checker.correct(unknown) }.uniq.map(&:inspect)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":78,"symbol":"spell_checker","kind":"method","lang":"ruby","code":"def spell_checker\n @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":85,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(switches, unknown)\n @switches = switches\n @unknown = unknown\n\n super(\"Unknown switches #{unknown.map(&:inspect).join(', ')}\")\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":95,"symbol":"RequiredArgumentMissingError","kind":"class","lang":"ruby","code":"class RequiredArgumentMissingError < InvocationError\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":98,"symbol":"MalformattedArgumentError","kind":"class","lang":"ruby","code":"class MalformattedArgumentError < InvocationError\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":101,"symbol":"ExclusiveArgumentError","kind":"class","lang":"ruby","code":"class ExclusiveArgumentError < InvocationError\n end"}
{"repo":"thor","file":"lib/thor/error.rb","line":104,"symbol":"AtLeastOneRequiredArgumentError","kind":"class","lang":"ruby","code":"class AtLeastOneRequiredArgumentError < InvocationError\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":16,"symbol":"desc","kind":"method","lang":"ruby","doc":"exists, tries to find the USAGE one folder above it, otherwise searches in the superclass. ==== Parameters description<String>:: The description for this Thor::Group.","code":"def desc(description = nil)\n if description\n @desc = description\n else\n @desc ||= from_superclass(:desc, nil)\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":29,"symbol":"help","kind":"method","lang":"ruby","doc":"Prints help information. ==== Options short:: When true, shows only usage.","code":"def help(shell)\n shell.say \"Usage:\"\n shell.say \" #{banner}\\n\"\n shell.say\n class_options_help(shell)\n shell.say desc if desc\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":39,"symbol":"invocations","kind":"method","lang":"ruby","doc":"Stores invocations for this class merging with superclass values.","code":"def invocations #:nodoc:\n @invocations ||= from_superclass(:invocations, {})\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":45,"symbol":"invocation_blocks","kind":"method","lang":"ruby","doc":"Stores invocation blocks used on invoke_from_option.","code":"def invocation_blocks #:nodoc:\n @invocation_blocks ||= from_superclass(:invocation_blocks, {})\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":56,"symbol":"invoke","kind":"method","lang":"ruby","doc":"method that will invoke the klass and command. You can give a block to configure how it will be invoked. The namespace/class given will have its options showed on the help usage. Check invoke_from_option for more information.","code":"def invoke(*names, &block)\n options = names.last.is_a?(Hash) ? names.pop : {}\n verbose = options.fetch(:verbose, true)\n\n names.each do |name|\n invocations[name] = false\n invocation_blocks[name] = block if block_given?\n\n class_eval <<-METHOD, __FILE__, __LINE__ + 1\n def _invoke_#{name.to_s.gsub(/\\W/, '_')}\n klass, command = self.class.prepare_for_invocation(nil, #{name.inspect})\n\n if klass\n say_status :invoke, #{name.inspect}, #{verbose.inspect}\n block = self.class.invocation_blocks[#{name.inspect}]\n _invoke_for_class_method klass, command, &block\n else\n say_status :error, %(#{name.inspect} [not found]), :red\n end\n end\n METHOD\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":110,"symbol":"invoke_from_option","kind":"method","lang":"ruby","doc":"==== Custom invocations You can also supply a block to customize how the option is going to be invoked. The block receives two parameters, an instance of the current class and the klass to be invoked.","code":"def invoke_from_option(*names, &block)\n options = names.last.is_a?(Hash) ? names.pop : {}\n verbose = options.fetch(:verbose, :white)\n\n names.each do |name|\n unless class_options.key?(name)\n raise ArgumentError, \"You have to define the option #{name.inspect} \" \\\n \"before setting invoke_from_option.\"\n end\n\n invocations[name] = true\n invocation_blocks[name] = block if block_given?\n\n class_eval <<-METHOD, __FILE__, __LINE__ + 1\n def _invoke_from_option_#{name.to_s.gsub(/\\W/, '_')}\n return unless options[#{name.inspect}]\n\n value = options[#{name.inspect}]\n value = #{name.inspect} if TrueClass === value\n klass, command = self.class.prepare_for_invocation(#{name.inspect}, value)\n\n if klass\n say_status :invoke, value, #{verbose.inspect}\n block = self.class.invocation_blocks[#{name.inspect}]\n _invoke_for_class_method klass, command, &block\n else\n say_status :error, %(\\#{value} [not found]), :red\n end\n end\n METHOD\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":149,"symbol":"remove_invocation","kind":"method","lang":"ruby","doc":"Remove a previously added invocation. ==== Examples remove_invocation :test_framework","code":"def remove_invocation(*names)\n names.each do |name|\n remove_command(name)\n remove_class_option(name)\n invocations.delete(name)\n invocation_blocks.delete(name)\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":161,"symbol":"class_options_help","kind":"method","lang":"ruby","doc":"Overwrite class options help to allow invoked generators options to be shown recursively when invoking a generator.","code":"def class_options_help(shell, groups = {}) #:nodoc:\n get_options_from_invocations(groups, class_options) do |klass|\n klass.send(:get_options_from_invocations, groups, class_options)\n end\n super(shell, groups)\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":172,"symbol":"get_options_from_invocations","kind":"method","lang":"ruby","doc":"Get invocations array and merge options from invocations. Those options are added to group_options hash. Options that already exists in base_options are not added twice.","code":"def get_options_from_invocations(group_options, base_options) #:nodoc:\n invocations.each do |name, from_option|\n value = if from_option\n option = class_options[name]\n option.type == :boolean ? name : option.default\n else\n name\n end\n next unless value\n\n klass, _ = prepare_for_invocation(name, value)\n next unless klass && klass.respond_to?(:class_options)\n\n value = value.to_s\n human_name = value.respond_to?(:classify) ? value.classify : value\n\n group_options[human_name] ||= []\n group_options[human_name] += klass.class_options.values.select do |class_option|\n base_options[class_option.name.to_sym].nil? && class_option.group.nil? &&\n !group_options.values.flatten.any? { |i| i.name == class_option.name }\n end\n\n yield klass if block_given?\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":199,"symbol":"printable_commands","kind":"method","lang":"ruby","doc":"Returns commands ready to be printed.","code":"def printable_commands(*)\n item = []\n item << banner\n item << (desc ? \"# #{desc.gsub(/\\s+/m, ' ')}\" : \"\")\n [item]\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":207,"symbol":"handle_argument_error","kind":"method","lang":"ruby","code":"def handle_argument_error(command, error, _args, arity) #:nodoc:\n msg = \"#{basename} #{command.name} takes #{arity} argument\".dup\n msg << \"s\" if arity > 1\n msg << \", but it should not.\"\n raise error, msg\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":221,"symbol":"command_exists?","kind":"method","lang":"ruby","doc":"==== Parameters command_name<String>:: The name of the command to check for existence. ==== Returns Boolean:: +true+ if the command exists, +false+ otherwise.","code":"def command_exists?(command_name) #:nodoc:\n commands.keys.include?(command_name)\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":228,"symbol":"dispatch","kind":"method","lang":"ruby","doc":"The method responsible for dispatching given the args.","code":"def dispatch(command, given_args, given_opts, config) #:nodoc:\n if Thor::HELP_MAPPINGS.include?(given_args.first)\n help(config[:shell])\n return\n end\n\n args, opts = Thor::Options.split(given_args)\n opts = given_opts || opts\n\n instance = new(args, opts, config)\n yield instance if block_given?\n\n if command\n instance.invoke_command(all_commands[command])\n else\n instance.invoke_all\n end\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":249,"symbol":"banner","kind":"method","lang":"ruby","doc":"The banner for this class. You can customize it if you are invoking the thor class by another ways which is not the Thor::Runner.","code":"def banner\n \"#{basename} #{self_command.formatted_usage(self, false)}\"\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":254,"symbol":"self_command","kind":"method","lang":"ruby","doc":"Represents the whole class as a command.","code":"def self_command #:nodoc:\n Thor::DynamicCommand.new(namespace, class_options)\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":259,"symbol":"baseclass","kind":"method","lang":"ruby","code":"def baseclass #:nodoc:\n Thor::Group\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":263,"symbol":"create_command","kind":"method","lang":"ruby","code":"def create_command(meth) #:nodoc:\n commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)\n true\n end"}
{"repo":"thor","file":"lib/thor/group.rb","line":276,"symbol":"_invoke_for_class_method","kind":"method","lang":"ruby","doc":"Shortcut to invoke with padding and block handling. Use internally by invoke and invoke_from_option class methods.","code":"def _invoke_for_class_method(klass, command = nil, *args, &block) #:nodoc:\n with_padding do\n if block\n case block.arity\n when 3\n yield(self, klass, command)\n when 2\n yield(self, klass)\n when 1\n instance_exec(klass, &block)\n end\n else\n invoke klass, command, *args\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Invocation\n def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end\n\n module ClassMethods\n # This method is responsible for receiving a name and find the proper\n # class and command for it. The key is an optional parameter which is\n # available only in class methods invocations (i.e. in Thor::Group).\n def prepare_for_invocation(key, name) #:nodoc:\n case name\n when Symbol, String\n Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)\n else\n name\n end\n end\n end\n\n # Make initializer aware of invocations and the initialization args.\n def initialize(args = [], options = {}, config = {}, &block) #:nodoc:\n @_invocations = config[:invocations] || Hash.new { |h, k| h[k] = [] }\n @_initializer = [args, options, config]\n super\n end\n\n # Make the current command chain accessible with in a Thor-(sub)command\n def current_command_chain\n @_invocations.values.flatten.map(&:to_sym)\n end\n\n # Receives a name and invokes it. The name can be a string (either \"command\" or\n # \"namespace:command\"), a Thor::Command, a Class "}
{"repo":"thor","file":"lib/thor/invocation.rb","line":2,"symbol":"Invocation","kind":"module","lang":"ruby","code":"module Invocation\n def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end\n\n module ClassMethods\n # This method is responsible for receiving a name and find the proper\n # class and command for it. The key is an optional parameter which is\n # available only in class methods invocations (i.e. in Thor::Group).\n def prepare_for_invocation(key, name) #:nodoc:\n case name\n when Symbol, String\n Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)\n else\n name\n end\n end\n end\n\n # Make initializer aware of invocations and the initialization args.\n def initialize(args = [], options = {}, config = {}, &block) #:nodoc:\n @_invocations = config[:invocations] || Hash.new { |h, k| h[k] = [] }\n @_initializer = [args, options, config]\n super\n end\n\n # Make the current command chain accessible with in a Thor-(sub)command\n def current_command_chain\n @_invocations.values.flatten.map(&:to_sym)\n end\n\n # Receives a name and invokes it. The name can be a string (either \"command\" or\n # \"namespace:command\"), a Thor::Command, a Class or a Thor ins"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":3,"symbol":"included","kind":"method","lang":"ruby","code":"def self.included(base) #:nodoc:\n super(base)\n base.extend ClassMethods\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":8,"symbol":"ClassMethods","kind":"module","lang":"ruby","code":"module ClassMethods\n # This method is responsible for receiving a name and find the proper\n # class and command for it. The key is an optional parameter which is\n # available only in class methods invocations (i.e. in Thor::Group).\n def prepare_for_invocation(key, name) #:nodoc:\n case name\n when Symbol, String\n Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)\n else\n name\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":12,"symbol":"prepare_for_invocation","kind":"method","lang":"ruby","doc":"This method is responsible for receiving a name and find the proper class and command for it. The key is an optional parameter which is available only in class methods invocations (i.e. in Thor::Group).","code":"def prepare_for_invocation(key, name) #:nodoc:\n case name\n when Symbol, String\n Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)\n else\n name\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":23,"symbol":"initialize","kind":"method","lang":"ruby","doc":"Make initializer aware of invocations and the initialization args.","code":"def initialize(args = [], options = {}, config = {}, &block) #:nodoc:\n @_invocations = config[:invocations] || Hash.new { |h, k| h[k] = [] }\n @_initializer = [args, options, config]\n super\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":30,"symbol":"current_command_chain","kind":"method","lang":"ruby","doc":"Make the current command chain accessible with in a Thor-(sub)command","code":"def current_command_chain\n @_invocations.values.flatten.map(&:to_sym)\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":102,"symbol":"invoke","kind":"method","lang":"ruby","doc":"invoke \"rspec:rr\", [], :style => :foo Besides giving an instance, you can also give a class to invoke: invoke Rspec::RR, [], :style => :foo","code":"def invoke(name = nil, *args)\n if name.nil?\n warn \"[Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\\n#{caller.join(\"\\n\")}\"\n return invoke_all\n end\n\n args.unshift(nil) if args.first.is_a?(Array) || args.first.nil?\n command, args, opts, config = args\n\n klass, command = _retrieve_class_and_command(name, command)\n raise \"Missing Thor class for invoke #{name}\" unless klass\n raise \"Expected Thor class, got #{klass}\" unless klass <= Thor::Base\n\n args, opts, config = _parse_initialization_options(args, opts, config)\n klass.send(:dispatch, command, args, opts, config) do |instance|\n instance.parent_options = options\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":122,"symbol":"invoke_command","kind":"method","lang":"ruby","doc":"Invoke the given command if the given args.","code":"def invoke_command(command, *args) #:nodoc:\n current = @_invocations[self.class]\n\n unless current.include?(command.name)\n current << command.name\n command.run(self, *args)\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":133,"symbol":"invoke_all","kind":"method","lang":"ruby","doc":"Invoke all commands for the current instance.","code":"def invoke_all #:nodoc:\n self.class.all_commands.map { |_, command| invoke_command(command) }\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":138,"symbol":"invoke_with_padding","kind":"method","lang":"ruby","doc":"Invokes using shell padding.","code":"def invoke_with_padding(*args)\n with_padding { invoke(*args) }\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":145,"symbol":"_shared_configuration","kind":"method","lang":"ruby","doc":"Configuration values that are shared between invocations.","code":"def _shared_configuration #:nodoc:\n {invocations: @_invocations}\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":153,"symbol":"_retrieve_class_and_command","kind":"method","lang":"ruby","doc":"This method simply retrieves the class and command to be invoked. If the name is nil or the given name is a command in the current class, use the given name and return self as class. Otherwise, call prepare_for_invocation in the current class.","code":"def _retrieve_class_and_command(name, sent_command = nil) #:nodoc:\n if name.nil?\n [self.class, nil]\n elsif self.class.all_commands[name.to_s]\n [self.class, name.to_s]\n else\n klass, command = self.class.prepare_for_invocation(nil, name)\n [klass, command || sent_command]\n end\n end"}
{"repo":"thor","file":"lib/thor/invocation.rb","line":166,"symbol":"_parse_initialization_options","kind":"method","lang":"ruby","doc":"Initialize klass using values stored in the @_initializer.","code":"def _parse_initialization_options(args, opts, config) #:nodoc:\n stored_args, stored_opts, stored_config = @_initializer\n\n args ||= stored_args.dup\n opts ||= stored_opts.dup\n\n config ||= {}\n config = stored_config.merge(_shared_configuration).merge!(config)\n\n [args, opts, config]\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module LineEditor\n class Basic\n attr_reader :prompt, :options\n\n def self.available?\n true\n end\n\n def initialize(prompt, options)\n @prompt = prompt\n @options = options\n end\n\n def readline\n $stdout.print(prompt)\n get_input\n end\n\n private\n\n def get_input\n if echo?\n $stdin.gets\n else\n # Lazy-load io/console since it is gem-ified as of 2.3\n require \"io/console\"\n $stdin.noecho(&:gets)\n end\n end\n\n def echo?\n options.fetch(:echo, true)\n end\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":2,"symbol":"LineEditor","kind":"module","lang":"ruby","code":"module LineEditor\n class Basic\n attr_reader :prompt, :options\n\n def self.available?\n true\n end\n\n def initialize(prompt, options)\n @prompt = prompt\n @options = options\n end\n\n def readline\n $stdout.print(prompt)\n get_input\n end\n\n private\n\n def get_input\n if echo?\n $stdin.gets\n else\n # Lazy-load io/console since it is gem-ified as of 2.3\n require \"io/console\"\n $stdin.noecho(&:gets)\n end\n end\n\n def echo?\n options.fetch(:echo, true)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":3,"symbol":"Basic","kind":"class","lang":"ruby","code":"class Basic\n attr_reader :prompt, :options\n\n def self.available?\n true\n end\n\n def initialize(prompt, options)\n @prompt = prompt\n @options = options\n end\n\n def readline\n $stdout.print(prompt)\n get_input\n end\n\n private\n\n def get_input\n if echo?\n $stdin.gets\n else\n # Lazy-load io/console since it is gem-ified as of 2.3\n require \"io/console\"\n $stdin.noecho(&:gets)\n end\n end\n\n def echo?\n options.fetch(:echo, true)\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":6,"symbol":"available?","kind":"method","lang":"ruby","code":"def self.available?\n true\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":10,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(prompt, options)\n @prompt = prompt\n @options = options\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":15,"symbol":"readline","kind":"method","lang":"ruby","code":"def readline\n $stdout.print(prompt)\n get_input\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":22,"symbol":"get_input","kind":"method","lang":"ruby","code":"def get_input\n if echo?\n $stdin.gets\n else\n # Lazy-load io/console since it is gem-ified as of 2.3\n require \"io/console\"\n $stdin.noecho(&:gets)\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/basic.rb","line":32,"symbol":"echo?","kind":"method","lang":"ruby","code":"def echo?\n options.fetch(:echo, true)\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module LineEditor\n class Readline < Basic\n def self.available?\n begin\n require \"readline\"\n rescue LoadError\n end\n\n Object.const_defined?(:Readline)\n end\n\n def readline\n if echo?\n ::Readline.completion_append_character = nil\n # rb-readline does not allow Readline.completion_proc= to receive nil.\n if complete = completion_proc\n ::Readline.completion_proc = complete\n end\n ::Readline.readline(prompt, add_to_history?)\n else\n super\n end\n end\n\n private\n\n def add_to_history?\n options.fetch(:add_to_history, true)\n end\n\n def completion_proc\n if use_path_completion?\n proc { |text| PathCompletion.new(text).matches }\n elsif completion_options.any?\n proc do |text|\n completion_options.select { |option| option.start_with?(text) }\n end\n end\n end\n\n def completion_options\n options.fetch(:limited_to, [])\n end\n\n def use_path_completion?\n options.fetch(:path, false)\n end\n\n class PathCompletion\n attr_reader :text\n "}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":2,"symbol":"LineEditor","kind":"module","lang":"ruby","code":"module LineEditor\n class Readline < Basic\n def self.available?\n begin\n require \"readline\"\n rescue LoadError\n end\n\n Object.const_defined?(:Readline)\n end\n\n def readline\n if echo?\n ::Readline.completion_append_character = nil\n # rb-readline does not allow Readline.completion_proc= to receive nil.\n if complete = completion_proc\n ::Readline.completion_proc = complete\n end\n ::Readline.readline(prompt, add_to_history?)\n else\n super\n end\n end\n\n private\n\n def add_to_history?\n options.fetch(:add_to_history, true)\n end\n\n def completion_proc\n if use_path_completion?\n proc { |text| PathCompletion.new(text).matches }\n elsif completion_options.any?\n proc do |text|\n completion_options.select { |option| option.start_with?(text) }\n end\n end\n end\n\n def completion_options\n options.fetch(:limited_to, [])\n end\n\n def use_path_completion?\n options.fetch(:path, false)\n end\n\n class PathCompletion\n attr_reader :text\n private"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":3,"symbol":"Readline","kind":"class","lang":"ruby","code":"class Readline < Basic\n def self.available?\n begin\n require \"readline\"\n rescue LoadError\n end\n\n Object.const_defined?(:Readline)\n end\n\n def readline\n if echo?\n ::Readline.completion_append_character = nil\n # rb-readline does not allow Readline.completion_proc= to receive nil.\n if complete = completion_proc\n ::Readline.completion_proc = complete\n end\n ::Readline.readline(prompt, add_to_history?)\n else\n super\n end\n end\n\n private\n\n def add_to_history?\n options.fetch(:add_to_history, true)\n end\n\n def completion_proc\n if use_path_completion?\n proc { |text| PathCompletion.new(text).matches }\n elsif completion_options.any?\n proc do |text|\n completion_options.select { |option| option.start_with?(text) }\n end\n end\n end\n\n def completion_options\n options.fetch(:limited_to, [])\n end\n\n def use_path_completion?\n options.fetch(:path, false)\n end\n\n class PathCompletion\n attr_reader :text\n private :text\n\n def in"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":4,"symbol":"available?","kind":"method","lang":"ruby","code":"def self.available?\n begin\n require \"readline\"\n rescue LoadError\n end\n\n Object.const_defined?(:Readline)\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":13,"symbol":"readline","kind":"method","lang":"ruby","code":"def readline\n if echo?\n ::Readline.completion_append_character = nil\n # rb-readline does not allow Readline.completion_proc= to receive nil.\n if complete = completion_proc\n ::Readline.completion_proc = complete\n end\n ::Readline.readline(prompt, add_to_history?)\n else\n super\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":28,"symbol":"add_to_history?","kind":"method","lang":"ruby","code":"def add_to_history?\n options.fetch(:add_to_history, true)\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":32,"symbol":"completion_proc","kind":"method","lang":"ruby","code":"def completion_proc\n if use_path_completion?\n proc { |text| PathCompletion.new(text).matches }\n elsif completion_options.any?\n proc do |text|\n completion_options.select { |option| option.start_with?(text) }\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":42,"symbol":"completion_options","kind":"method","lang":"ruby","code":"def completion_options\n options.fetch(:limited_to, [])\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":46,"symbol":"use_path_completion?","kind":"method","lang":"ruby","code":"def use_path_completion?\n options.fetch(:path, false)\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":50,"symbol":"PathCompletion","kind":"class","lang":"ruby","code":"class PathCompletion\n attr_reader :text\n private :text\n\n def initialize(text)\n @text = text\n end\n\n def matches\n relative_matches\n end\n\n private\n\n def relative_matches\n absolute_matches.map { |path| path.sub(base_path, \"\") }\n end\n\n def absolute_matches\n Dir[glob_pattern].map do |path|\n if File.directory?(path)\n \"#{path}/\"\n else\n path\n end\n end\n end\n\n def glob_pattern\n \"#{base_path}#{text}*\"\n end\n\n def base_path\n \"#{Dir.pwd}/\"\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":54,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(text)\n @text = text\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":58,"symbol":"matches","kind":"method","lang":"ruby","code":"def matches\n relative_matches\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":64,"symbol":"relative_matches","kind":"method","lang":"ruby","code":"def relative_matches\n absolute_matches.map { |path| path.sub(base_path, \"\") }\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":68,"symbol":"absolute_matches","kind":"method","lang":"ruby","code":"def absolute_matches\n Dir[glob_pattern].map do |path|\n if File.directory?(path)\n \"#{path}/\"\n else\n path\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":78,"symbol":"glob_pattern","kind":"method","lang":"ruby","code":"def glob_pattern\n \"#{base_path}#{text}*\"\n end"}
{"repo":"thor","file":"lib/thor/line_editor/readline.rb","line":82,"symbol":"base_path","kind":"method","lang":"ruby","code":"def base_path\n \"#{Dir.pwd}/\"\n end"}
{"repo":"thor","file":"lib/thor/line_editor.rb","line":4,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module LineEditor\n def self.readline(prompt, options = {})\n best_available.new(prompt, options).readline\n end\n\n def self.best_available\n [\n Thor::LineEditor::Readline,\n Thor::LineEditor::Basic\n ].detect(&:available?)\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/line_editor.rb","line":5,"symbol":"LineEditor","kind":"module","lang":"ruby","code":"module LineEditor\n def self.readline(prompt, options = {})\n best_available.new(prompt, options).readline\n end\n\n def self.best_available\n [\n Thor::LineEditor::Readline,\n Thor::LineEditor::Basic\n ].detect(&:available?)\n end\n end"}
{"repo":"thor","file":"lib/thor/line_editor.rb","line":6,"symbol":"readline","kind":"method","lang":"ruby","code":"def self.readline(prompt, options = {})\n best_available.new(prompt, options).readline\n end"}
{"repo":"thor","file":"lib/thor/line_editor.rb","line":10,"symbol":"best_available","kind":"method","lang":"ruby","code":"def self.best_available\n [\n Thor::LineEditor::Readline,\n Thor::LineEditor::Basic\n ].detect(&:available?)\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class NestedContext\n def initialize\n @depth = 0\n end\n\n def enter\n push\n\n yield\n ensure\n pop\n end\n\n def entered?\n @depth.positive?\n end\n\n private\n\n def push\n @depth += 1\n end\n\n def pop\n @depth -= 1\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":2,"symbol":"NestedContext","kind":"class","lang":"ruby","code":"class NestedContext\n def initialize\n @depth = 0\n end\n\n def enter\n push\n\n yield\n ensure\n pop\n end\n\n def entered?\n @depth.positive?\n end\n\n private\n\n def push\n @depth += 1\n end\n\n def pop\n @depth -= 1\n end\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":3,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize\n @depth = 0\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":7,"symbol":"enter","kind":"method","lang":"ruby","code":"def enter\n push\n\n yield\n ensure\n pop\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":15,"symbol":"entered?","kind":"method","lang":"ruby","code":"def entered?\n @depth.positive?\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":21,"symbol":"push","kind":"method","lang":"ruby","code":"def push\n @depth += 1\n end"}
{"repo":"thor","file":"lib/thor/nested_context.rb","line":25,"symbol":"pop","kind":"method","lang":"ruby","code":"def pop\n @depth -= 1\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class Argument #:nodoc:\n VALID_TYPES = [:numeric, :hash, :array, :string]\n\n attr_reader :name, :description, :enum, :required, :type, :default, :banner\n alias_method :human_name, :name\n\n def initialize(name, options = {})\n class_name = self.class.name.split(\"::\").last\n\n type = options[:type]\n\n raise ArgumentError, \"#{class_name} name can't be nil.\" if name.nil?\n raise ArgumentError, \"Type :#{type} is not valid for #{class_name.downcase}s.\" if type && !valid_type?(type)\n\n @name = name.to_s\n @description = options[:desc]\n @required = options.key?(:required) ? options[:required] : true\n @type = (type || :string).to_sym\n @default = options[:default]\n @banner = options[:banner] || default_banner\n @enum = options[:enum]\n\n validate! # Trigger specific validations\n end\n\n def print_default\n if @type == :array and @default.is_a?(Array)\n @default.map(&:dump).join(\" \")\n else\n @default\n end\n end\n\n def usage\n required? ? banner : \"[#{banner}]\"\n end\n\n def required?\n required\n end\n\n def show_def"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":2,"symbol":"Argument","kind":"class","lang":"ruby","code":"class Argument #:nodoc:\n VALID_TYPES = [:numeric, :hash, :array, :string]\n\n attr_reader :name, :description, :enum, :required, :type, :default, :banner\n alias_method :human_name, :name\n\n def initialize(name, options = {})\n class_name = self.class.name.split(\"::\").last\n\n type = options[:type]\n\n raise ArgumentError, \"#{class_name} name can't be nil.\" if name.nil?\n raise ArgumentError, \"Type :#{type} is not valid for #{class_name.downcase}s.\" if type && !valid_type?(type)\n\n @name = name.to_s\n @description = options[:desc]\n @required = options.key?(:required) ? options[:required] : true\n @type = (type || :string).to_sym\n @default = options[:default]\n @banner = options[:banner] || default_banner\n @enum = options[:enum]\n\n validate! # Trigger specific validations\n end\n\n def print_default\n if @type == :array and @default.is_a?(Array)\n @default.map(&:dump).join(\" \")\n else\n @default\n end\n end\n\n def usage\n required? ? banner : \"[#{banner}]\"\n end\n\n def required?\n required\n end\n\n def show_default?\n c"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":8,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(name, options = {})\n class_name = self.class.name.split(\"::\").last\n\n type = options[:type]\n\n raise ArgumentError, \"#{class_name} name can't be nil.\" if name.nil?\n raise ArgumentError, \"Type :#{type} is not valid for #{class_name.downcase}s.\" if type && !valid_type?(type)\n\n @name = name.to_s\n @description = options[:desc]\n @required = options.key?(:required) ? options[:required] : true\n @type = (type || :string).to_sym\n @default = options[:default]\n @banner = options[:banner] || default_banner\n @enum = options[:enum]\n\n validate! # Trigger specific validations\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":27,"symbol":"print_default","kind":"method","lang":"ruby","code":"def print_default\n if @type == :array and @default.is_a?(Array)\n @default.map(&:dump).join(\" \")\n else\n @default\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":35,"symbol":"usage","kind":"method","lang":"ruby","code":"def usage\n required? ? banner : \"[#{banner}]\"\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":39,"symbol":"required?","kind":"method","lang":"ruby","code":"def required?\n required\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":43,"symbol":"show_default?","kind":"method","lang":"ruby","code":"def show_default?\n case default\n when Array, String, Hash\n !default.empty?\n else\n default\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":52,"symbol":"enum_to_s","kind":"method","lang":"ruby","code":"def enum_to_s\n if enum.respond_to? :join\n enum.join(\", \")\n else\n \"#{enum.first}..#{enum.last}\"\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":62,"symbol":"validate!","kind":"method","lang":"ruby","code":"def validate!\n raise ArgumentError, \"An argument cannot be required and have default value.\" if required? && !default.nil?\n raise ArgumentError, \"An argument cannot have an enum other than an enumerable.\" if @enum && !@enum.is_a?(Enumerable)\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":67,"symbol":"valid_type?","kind":"method","lang":"ruby","code":"def valid_type?(type)\n self.class::VALID_TYPES.include?(type.to_sym)\n end"}
{"repo":"thor","file":"lib/thor/parser/argument.rb","line":71,"symbol":"default_banner","kind":"method","lang":"ruby","code":"def default_banner\n case type\n when :boolean\n nil\n when :string, :default\n human_name.upcase\n when :numeric\n \"N\"\n when :hash\n \"key:value\"\n when :array\n \"one two three\"\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class Arguments #:nodoc:\n NUMERIC = /[-+]?(\\d*\\.\\d+|\\d+)/\n\n # Receives an array of args and returns two arrays, one with arguments\n # and one with switches.\n #\n def self.split(args)\n arguments = []\n\n args.each do |item|\n break if item.is_a?(String) && item =~ /^-/\n arguments << item\n end\n\n [arguments, args[Range.new(arguments.size, -1)]]\n end\n\n def self.parse(*args)\n to_parse = args.pop\n new(*args).parse(to_parse)\n end\n\n # Takes an array of Thor::Argument objects.\n #\n def initialize(arguments = [])\n @assigns = {}\n @non_assigned_required = []\n @switches = arguments\n\n arguments.each do |argument|\n if !argument.default.nil?\n @assigns[argument.human_name] = argument.default.dup\n elsif argument.required?\n @non_assigned_required << argument\n end\n end\n end\n\n def parse(args)\n @pile = args.dup\n\n @switches.each do |argument|\n break unless peek\n @non_assigned_required.delete(argument)\n @assigns[argument.human_name] = send(:\"parse_#{argument.type}\", argument.human_name)\n end\n\n check_requirement!\n"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":2,"symbol":"Arguments","kind":"class","lang":"ruby","code":"class Arguments #:nodoc:\n NUMERIC = /[-+]?(\\d*\\.\\d+|\\d+)/\n\n # Receives an array of args and returns two arrays, one with arguments\n # and one with switches.\n #\n def self.split(args)\n arguments = []\n\n args.each do |item|\n break if item.is_a?(String) && item =~ /^-/\n arguments << item\n end\n\n [arguments, args[Range.new(arguments.size, -1)]]\n end\n\n def self.parse(*args)\n to_parse = args.pop\n new(*args).parse(to_parse)\n end\n\n # Takes an array of Thor::Argument objects.\n #\n def initialize(arguments = [])\n @assigns = {}\n @non_assigned_required = []\n @switches = arguments\n\n arguments.each do |argument|\n if !argument.default.nil?\n @assigns[argument.human_name] = argument.default.dup\n elsif argument.required?\n @non_assigned_required << argument\n end\n end\n end\n\n def parse(args)\n @pile = args.dup\n\n @switches.each do |argument|\n break unless peek\n @non_assigned_required.delete(argument)\n @assigns[argument.human_name] = send(:\"parse_#{argument.type}\", argument.human_name)\n end\n\n check_requirement!\n @assign"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":8,"symbol":"split","kind":"method","lang":"ruby","doc":"Receives an array of args and returns two arrays, one with arguments and one with switches.","code":"def self.split(args)\n arguments = []\n\n args.each do |item|\n break if item.is_a?(String) && item =~ /^-/\n arguments << item\n end\n\n [arguments, args[Range.new(arguments.size, -1)]]\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":19,"symbol":"parse","kind":"method","lang":"ruby","code":"def self.parse(*args)\n to_parse = args.pop\n new(*args).parse(to_parse)\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":26,"symbol":"initialize","kind":"method","lang":"ruby","doc":"Takes an array of Thor::Argument objects.","code":"def initialize(arguments = [])\n @assigns = {}\n @non_assigned_required = []\n @switches = arguments\n\n arguments.each do |argument|\n if !argument.default.nil?\n @assigns[argument.human_name] = argument.default.dup\n elsif argument.required?\n @non_assigned_required << argument\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":40,"symbol":"parse","kind":"method","lang":"ruby","code":"def parse(args)\n @pile = args.dup\n\n @switches.each do |argument|\n break unless peek\n @non_assigned_required.delete(argument)\n @assigns[argument.human_name] = send(:\"parse_#{argument.type}\", argument.human_name)\n end\n\n check_requirement!\n @assigns\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":53,"symbol":"remaining","kind":"method","lang":"ruby","code":"def remaining\n @pile\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":59,"symbol":"no_or_skip?","kind":"method","lang":"ruby","code":"def no_or_skip?(arg)\n arg =~ /^--(no|skip)-([-\\w]+)$/\n $2\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":64,"symbol":"last?","kind":"method","lang":"ruby","code":"def last?\n @pile.empty?\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":68,"symbol":"peek","kind":"method","lang":"ruby","code":"def peek\n @pile.first\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":72,"symbol":"shift","kind":"method","lang":"ruby","code":"def shift\n @pile.shift\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":76,"symbol":"unshift","kind":"method","lang":"ruby","code":"def unshift(arg)\n if arg.is_a?(Array)\n @pile = arg + @pile\n else\n @pile.unshift(arg)\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":84,"symbol":"current_is_value?","kind":"method","lang":"ruby","code":"def current_is_value?\n peek && peek.to_s !~ /^-{1,2}\\S+/\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":97,"symbol":"parse_hash","kind":"method","lang":"ruby","doc":"[ \"name:string\", \"age:integer\" ] Becomes: { \"name\" => \"string\", \"age\" => \"integer\" }","code":"def parse_hash(name)\n return shift if peek.is_a?(Hash)\n hash = {}\n\n while current_is_value? && peek.include?(\":\")\n key, value = shift.split(\":\", 2)\n raise MalformattedArgumentError, \"You can't specify '#{key}' more than once in option '#{name}'; got #{key}:#{hash[key]} and #{key}:#{value}\" if hash.include? key\n hash[key] = value\n end\n hash\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":118,"symbol":"parse_array","kind":"method","lang":"ruby","doc":"[\"a\", \"b\", \"c\"] And returns it as an array: [\"a\", \"b\", \"c\"]","code":"def parse_array(name)\n return shift if peek.is_a?(Array)\n\n array = []\n\n while current_is_value?\n value = shift\n\n if !value.empty?\n validate_enum_value!(name, value, \"Expected all values of '%s' to be one of %s; got %s\")\n end\n\n array << value\n end\n array\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":139,"symbol":"parse_numeric","kind":"method","lang":"ruby","doc":"Check if the peek is numeric format and return a Float or Integer. Check if the peek is included in enum if enum is provided. Otherwise raises an error.","code":"def parse_numeric(name)\n return shift if peek.is_a?(Numeric)\n\n unless peek =~ NUMERIC && $& == peek\n raise MalformattedArgumentError, \"Expected numeric value for '#{name}'; got #{peek.inspect}\"\n end\n\n value = $&.index(\".\") ? shift.to_f : shift.to_i\n\n validate_enum_value!(name, value, \"Expected '%s' to be one of %s; got %s\")\n\n value\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":158,"symbol":"parse_string","kind":"method","lang":"ruby","doc":"Parse string: for --string-arg, just return the current value in the pile for --no-string-arg, nil Check if the peek is included in enum if enum is provided. Otherwise raises an error.","code":"def parse_string(name)\n if no_or_skip?(name)\n nil\n else\n value = shift\n\n validate_enum_value!(name, value, \"Expected '%s' to be one of %s; got %s\")\n\n value\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":172,"symbol":"validate_enum_value!","kind":"method","lang":"ruby","doc":"Raises an error if the switch is an enum and the values aren't included on it.","code":"def validate_enum_value!(name, value, message)\n return unless @switches.is_a?(Hash)\n\n switch = @switches[name]\n\n return unless switch\n\n if switch.enum && !switch.enum.include?(value)\n raise MalformattedArgumentError, message % [name, switch.enum_to_s, value]\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/arguments.rb","line":186,"symbol":"check_requirement!","kind":"method","lang":"ruby","doc":"Raises an error if @non_assigned_required array is not empty.","code":"def check_requirement!\n return if @non_assigned_required.empty?\n names = @non_assigned_required.map do |o|\n o.respond_to?(:switch_name) ? o.switch_name : o.human_name\n end.join(\"', '\")\n class_name = self.class.name.split(\"::\").last.downcase\n raise RequiredArgumentMissingError, \"No value provided for required #{class_name} '#{names}'\"\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class Option < Argument #:nodoc:\n attr_reader :aliases, :group, :lazy_default, :hide, :repeatable\n\n VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]\n\n def initialize(name, options = {})\n @check_default_type = options[:check_default_type]\n options[:required] = false unless options.key?(:required)\n @repeatable = options.fetch(:repeatable, false)\n super\n @lazy_default = options[:lazy_default]\n @group = options[:group].to_s.capitalize if options[:group]\n @aliases = normalize_aliases(options[:aliases])\n @hide = options[:hide]\n end\n\n # This parse quick options given as method_options. It makes several\n # assumptions, but you can be more specific using the option method.\n #\n # parse :foo => \"bar\"\n # #=> Option foo with default value bar\n #\n # parse [:foo, :baz] => \"bar\"\n # #=> Option foo with default value bar and alias :baz\n #\n # parse :foo => :required\n # #=> Required option foo without default value\n #\n # parse :foo => 2\n # #=> Option foo with default value 2 and type numeric\n #\n # parse :foo => :numeric\n # #=>"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":2,"symbol":"Option","kind":"class","lang":"ruby","code":"class Option < Argument #:nodoc:\n attr_reader :aliases, :group, :lazy_default, :hide, :repeatable\n\n VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]\n\n def initialize(name, options = {})\n @check_default_type = options[:check_default_type]\n options[:required] = false unless options.key?(:required)\n @repeatable = options.fetch(:repeatable, false)\n super\n @lazy_default = options[:lazy_default]\n @group = options[:group].to_s.capitalize if options[:group]\n @aliases = normalize_aliases(options[:aliases])\n @hide = options[:hide]\n end\n\n # This parse quick options given as method_options. It makes several\n # assumptions, but you can be more specific using the option method.\n #\n # parse :foo => \"bar\"\n # #=> Option foo with default value bar\n #\n # parse [:foo, :baz] => \"bar\"\n # #=> Option foo with default value bar and alias :baz\n #\n # parse :foo => :required\n # #=> Required option foo without default value\n #\n # parse :foo => 2\n # #=> Option foo with default value 2 and type numeric\n #\n # parse :foo => :numeric\n # #=> Option foo w"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":7,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(name, options = {})\n @check_default_type = options[:check_default_type]\n options[:required] = false unless options.key?(:required)\n @repeatable = options.fetch(:repeatable, false)\n super\n @lazy_default = options[:lazy_default]\n @group = options[:group].to_s.capitalize if options[:group]\n @aliases = normalize_aliases(options[:aliases])\n @hide = options[:hide]\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":45,"symbol":"parse","kind":"method","lang":"ruby","doc":"The valid types are :boolean, :numeric, :hash, :array and :string. If none is given a default type is assumed. This default type accepts arguments as string (--foo=value) or booleans (just --foo). By default all options are optional, unless :required is given.","code":"def self.parse(key, value)\n if key.is_a?(Array)\n name, *aliases = key\n else\n name = key\n aliases = []\n end\n\n name = name.to_s\n default = value\n\n type = case value\n when Symbol\n default = nil\n if VALID_TYPES.include?(value)\n value\n elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition\n :string\n end\n when TrueClass, FalseClass\n :boolean\n when Numeric\n :numeric\n when Hash, Array, String\n value.class.name.downcase.to_sym\n end\n\n new(name.to_s, required: required, type: type, default: default, aliases: aliases)\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":75,"symbol":"switch_name","kind":"method","lang":"ruby","code":"def switch_name\n @switch_name ||= dasherized? ? name : dasherize(name)\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":79,"symbol":"human_name","kind":"method","lang":"ruby","code":"def human_name\n @human_name ||= dasherized? ? undasherize(name) : name\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":83,"symbol":"usage","kind":"method","lang":"ruby","code":"def usage(padding = 0)\n sample = if banner && !banner.to_s.empty?\n \"#{switch_name}=#{banner}\".dup\n else\n switch_name\n end\n\n sample = \"[#{sample}]\".dup unless required?\n\n if boolean? && name != \"force\" && !name.match(/\\A(no|skip)[\\-_]/)\n sample << \", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]\"\n end\n\n aliases_for_usage.ljust(padding) + sample\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":99,"symbol":"aliases_for_usage","kind":"method","lang":"ruby","code":"def aliases_for_usage\n if aliases.empty?\n \"\"\n else\n \"#{aliases.join(', ')}, \"\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":107,"symbol":"show_default?","kind":"method","lang":"ruby","code":"def show_default?\n case default\n when TrueClass, FalseClass\n true\n else\n super\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":126,"symbol":"validate!","kind":"method","lang":"ruby","code":"def validate!\n raise ArgumentError, \"An option cannot be boolean and required.\" if boolean? && required?\n validate_default_type!\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":131,"symbol":"validate_default_type!","kind":"method","lang":"ruby","code":"def validate_default_type!\n default_type = case @default\n when nil\n return\n when TrueClass, FalseClass\n required? ? :string : :boolean\n when Numeric\n :numeric\n when Symbol\n :string\n when Hash, Array, String\n @default.class.name.downcase.to_sym\n end\n\n expected_type = (@repeatable && @type != :hash) ? :array : @type\n\n if default_type != expected_type\n err = \"Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})\"\n\n if @check_default_type\n raise ArgumentError, err\n elsif @check_default_type == nil\n Thor.deprecation_warning \"#{err}.\\n\" +\n \"This will be rejected in the future unless you explicitly pass the options `check_default_type: false`\" +\n \" or call `allow_incompatible_default_type!` in your code\"\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":160,"symbol":"dasherized?","kind":"method","lang":"ruby","code":"def dasherized?\n name.index(\"-\") == 0\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":164,"symbol":"undasherize","kind":"method","lang":"ruby","code":"def undasherize(str)\n str.sub(/^-{1,2}/, \"\")\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":168,"symbol":"dasherize","kind":"method","lang":"ruby","code":"def dasherize(str)\n (str.length > 1 ? \"--\" : \"-\") + str.tr(\"_\", \"-\")\n end"}
{"repo":"thor","file":"lib/thor/parser/option.rb","line":174,"symbol":"normalize_aliases","kind":"method","lang":"ruby","code":"def normalize_aliases(aliases)\n Array(aliases).map { |short| short.to_s.sub(/^(?!\\-)/, \"-\") }\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n class Options < Arguments #:nodoc:\n LONG_RE = /^(--\\w+(?:-\\w+)*)$/\n SHORT_RE = /^(-[a-z])$/i\n EQ_RE = /^(--\\w+(?:-\\w+)*|-[a-z])=(.*)$/i\n SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args\n SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i\n OPTS_END = \"--\".freeze\n\n # Receives a hash and makes it switches.\n def self.to_switches(options)\n options.map do |key, value|\n case value\n when true\n \"--#{key}\"\n when Array\n \"--#{key} #{value.map(&:inspect).join(' ')}\"\n when Hash\n \"--#{key} #{value.map { |k, v| \"#{k}:#{v}\" }.join(' ')}\"\n when nil, false\n nil\n else\n \"--#{key} #{value.inspect}\"\n end\n end.compact.join(\" \")\n end\n\n # Takes a hash of Thor::Option and a hash with defaults.\n #\n # If +stop_on_unknown+ is true, #parse will stop as soon as it encounters\n # an unknown option or a regular argument.\n def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {})\n @stop_on_unknown = stop_on_unknown\n @exclusives = (relations[:exclus"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":2,"symbol":"Options","kind":"class","lang":"ruby","code":"class Options < Arguments #:nodoc:\n LONG_RE = /^(--\\w+(?:-\\w+)*)$/\n SHORT_RE = /^(-[a-z])$/i\n EQ_RE = /^(--\\w+(?:-\\w+)*|-[a-z])=(.*)$/i\n SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args\n SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i\n OPTS_END = \"--\".freeze\n\n # Receives a hash and makes it switches.\n def self.to_switches(options)\n options.map do |key, value|\n case value\n when true\n \"--#{key}\"\n when Array\n \"--#{key} #{value.map(&:inspect).join(' ')}\"\n when Hash\n \"--#{key} #{value.map { |k, v| \"#{k}:#{v}\" }.join(' ')}\"\n when nil, false\n nil\n else\n \"--#{key} #{value.inspect}\"\n end\n end.compact.join(\" \")\n end\n\n # Takes a hash of Thor::Option and a hash with defaults.\n #\n # If +stop_on_unknown+ is true, #parse will stop as soon as it encounters\n # an unknown option or a regular argument.\n def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {})\n @stop_on_unknown = stop_on_unknown\n @exclusives = (relations[:exclusive_option_na"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":11,"symbol":"to_switches","kind":"method","lang":"ruby","doc":"Receives a hash and makes it switches.","code":"def self.to_switches(options)\n options.map do |key, value|\n case value\n when true\n \"--#{key}\"\n when Array\n \"--#{key} #{value.map(&:inspect).join(' ')}\"\n when Hash\n \"--#{key} #{value.map { |k, v| \"#{k}:#{v}\" }.join(' ')}\"\n when nil, false\n nil\n else\n \"--#{key} #{value.inspect}\"\n end\n end.compact.join(\" \")\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":32,"symbol":"initialize","kind":"method","lang":"ruby","doc":"Takes a hash of Thor::Option and a hash with defaults. If +stop_on_unknown+ is true, #parse will stop as soon as it encounters an unknown option or a regular argument.","code":"def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {})\n @stop_on_unknown = stop_on_unknown\n @exclusives = (relations[:exclusive_option_names] || []).select{|array| !array.empty?}\n @at_least_ones = (relations[:at_least_one_option_names] || []).select{|array| !array.empty?}\n @disable_required_check = disable_required_check\n options = hash_options.values\n super(options)\n\n # Add defaults\n defaults.each do |key, value|\n @assigns[key.to_s] = value\n @non_assigned_required.delete(hash_options[key])\n end\n\n @shorts = {}\n @switches = {}\n @extra = []\n @stopped_parsing_after_extra_index = nil\n @is_treated_as_value = false\n\n options.each do |option|\n @switches[option.switch_name] = option\n\n option.aliases.each do |name|\n @shorts[name] ||= option.switch_name\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":61,"symbol":"remaining","kind":"method","lang":"ruby","code":"def remaining\n @extra\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":65,"symbol":"peek","kind":"method","lang":"ruby","code":"def peek\n return super unless @parsing_options\n\n result = super\n if result == OPTS_END\n shift\n @parsing_options = false\n @stopped_parsing_after_extra_index ||= @extra.size\n super\n else\n result\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":79,"symbol":"shift","kind":"method","lang":"ruby","code":"def shift\n @is_treated_as_value = false\n super\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":84,"symbol":"unshift","kind":"method","lang":"ruby","code":"def unshift(arg, is_value: false)\n @is_treated_as_value = is_value\n super(arg)\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":89,"symbol":"parse","kind":"method","lang":"ruby","code":"def parse(args) # rubocop:disable Metrics/MethodLength\n @pile = args.dup\n @is_treated_as_value = false\n @parsing_options = true\n\n while peek\n if parsing_options?\n match, is_switch = current_is_switch?\n shifted = shift\n\n if is_switch\n case shifted\n when SHORT_SQ_RE\n unshift($1.split(\"\").map { |f| \"-#{f}\" })\n next\n when EQ_RE\n unshift($2, is_value: true)\n switch = $1\n when SHORT_NUM\n unshift($2)\n switch = $1\n when LONG_RE, SHORT_RE\n switch = $1\n end\n\n switch = normalize_switch(switch)\n option = switch_option(switch)\n result = parse_peek(switch, option)\n assign_result!(option, result)\n elsif @stop_on_unknown\n @parsing_options = false\n @extra << shifted\n @stopped_parsing_after_extra_index ||= @extra.size\n @extra << shift while peek\n break\n elsif match\n @extra << shifted\n @extra << shift while peek && peek !~ /^-/\n else\n @e"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":144,"symbol":"check_exclusive!","kind":"method","lang":"ruby","code":"def check_exclusive!\n opts = @assigns.keys\n # When option A and B are exclusive, if A and B are given at the same time,\n # the difference of argument array size will decrease.\n found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }\n if found\n names = names_to_switch_names(found & opts).map{|n| \"'#{n}'\"}\n class_name = self.class.name.split(\"::\").last.downcase\n fail ExclusiveArgumentError, \"Found exclusive #{class_name} #{names.join(\", \")}\"\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":156,"symbol":"check_at_least_one!","kind":"method","lang":"ruby","code":"def check_at_least_one!\n opts = @assigns.keys\n # When at least one is required of the options A and B,\n # if the both options were not given, none? would be true.\n found = @at_least_ones.find{ |one_reqs| one_reqs.none?{ |o| opts.include? o} }\n if found\n names = names_to_switch_names(found).map{|n| \"'#{n}'\"}\n class_name = self.class.name.split(\"::\").last.downcase\n fail AtLeastOneRequiredArgumentError, \"Not found at least one of required #{class_name} #{names.join(\", \")}\"\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":168,"symbol":"check_unknown!","kind":"method","lang":"ruby","code":"def check_unknown!\n to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra\n\n # an unknown option starts with - or -- and has no more --'s afterward.\n unknown = to_check.select { |str| str =~ /^--?(?:(?!--).)*$/ }\n raise UnknownArgumentError.new(@switches.keys, unknown) unless unknown.empty?\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":179,"symbol":"names_to_switch_names","kind":"method","lang":"ruby","doc":"Option names changes to swith name or human name","code":"def names_to_switch_names(names = [])\n @switches.map do |_, o|\n if names.include? o.name\n o.respond_to?(:switch_name) ? o.switch_name : o.human_name\n else\n nil\n end\n end.compact\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":189,"symbol":"assign_result!","kind":"method","lang":"ruby","code":"def assign_result!(option, result)\n if option.repeatable && option.type == :hash\n (@assigns[option.human_name] ||= {}).merge!(result)\n elsif option.repeatable\n (@assigns[option.human_name] ||= []) << result\n else\n @assigns[option.human_name] = result\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":203,"symbol":"current_is_switch?","kind":"method","lang":"ruby","doc":"Check if the current value in peek is a registered switch. Two booleans are returned. The first is true if the current value starts with a hyphen; the second is true if it is a registered switch.","code":"def current_is_switch?\n return [false, false] if @is_treated_as_value\n case peek\n when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM\n [true, switch?($1)]\n when SHORT_SQ_RE\n [true, $1.split(\"\").any? { |f| switch?(\"-#{f}\") }]\n else\n [false, false]\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":215,"symbol":"current_is_switch_formatted?","kind":"method","lang":"ruby","code":"def current_is_switch_formatted?\n return false if @is_treated_as_value\n case peek\n when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE\n true\n else\n false\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":225,"symbol":"current_is_value?","kind":"method","lang":"ruby","code":"def current_is_value?\n return true if @is_treated_as_value\n peek && (!parsing_options? || super)\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":230,"symbol":"switch?","kind":"method","lang":"ruby","code":"def switch?(arg)\n !switch_option(normalize_switch(arg)).nil?\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":234,"symbol":"switch_option","kind":"method","lang":"ruby","code":"def switch_option(arg)\n if match = no_or_skip?(arg) # rubocop:disable Lint/AssignmentInCondition\n @switches[arg] || @switches[\"--#{match}\"]\n else\n @switches[arg]\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":244,"symbol":"normalize_switch","kind":"method","lang":"ruby","doc":"Check if the given argument is actually a shortcut.","code":"def normalize_switch(arg)\n (@shorts[arg] || arg).tr(\"_\", \"-\")\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":248,"symbol":"parsing_options?","kind":"method","lang":"ruby","code":"def parsing_options?\n peek\n @parsing_options\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":256,"symbol":"parse_boolean","kind":"method","lang":"ruby","doc":"Parse boolean values which can be given as --foo=true or --foo for true values, or --foo=false, --no-foo or --skip-foo for false values.","code":"def parse_boolean(switch)\n if current_is_value?\n if [\"true\", \"TRUE\", \"t\", \"T\", true].include?(peek)\n shift\n true\n elsif [\"false\", \"FALSE\", \"f\", \"F\", false].include?(peek)\n shift\n false\n else\n @switches.key?(switch) || !no_or_skip?(switch)\n end\n else\n @switches.key?(switch) || !no_or_skip?(switch)\n end\n end"}
{"repo":"thor","file":"lib/thor/parser/options.rb","line":274,"symbol":"parse_peek","kind":"method","lang":"ruby","doc":"Parse the value at the peek analyzing if it requires an input or not.","code":"def parse_peek(switch, option)\n if parsing_options? && (current_is_switch_formatted? || last?)\n if option.boolean?\n # No problem for boolean types\n elsif no_or_skip?(switch)\n return nil # User set value to nil\n elsif option.string? && !option.required?\n # Return the default if there is one, else the human name\n return option.lazy_default || option.default || option.human_name\n elsif option.lazy_default\n return option.lazy_default\n else\n raise MalformattedArgumentError, \"No value provided for option '#{switch}'\"\n end\n end\n\n @non_assigned_required.delete(option)\n send(:\"parse_#{option.type}\", switch)\n end"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":4,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n # Adds a compatibility layer to your Thor classes which allows you to use\n # rake package tasks. For example, to use rspec rake tasks, one can do:\n #\n # require 'thor/rake_compat'\n # require 'rspec/core/rake_task'\n #\n # class Default < Thor\n # include Thor::RakeCompat\n #\n # RSpec::Core::RakeTask.new(:spec) do |t|\n # t.spec_opts = ['--options', './.rspec']\n # t.spec_files = FileList['spec/**/*_spec.rb']\n # end\n # end\n #\n module RakeCompat\n include Rake::DSL if defined?(Rake::DSL)\n\n def self.rake_classes\n @rake_classes ||= []\n end\n\n def self.included(base)\n super(base)\n # Hack. Make rakefile point to invoker, so rdoc task is generated properly.\n rakefile = File.basename(caller[0].match(/(.*):\\d+/)[1])\n Rake.application.instance_variable_set(:@rakefile, rakefile)\n rake_classes << base\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":20,"symbol":"RakeCompat","kind":"module","lang":"ruby","doc":"RSpec::Core::RakeTask.new(:spec) do |t| t.spec_opts = ['--options', './.rspec'] t.spec_files = FileList['spec/**/*_spec.rb'] end end","code":"module RakeCompat\n include Rake::DSL if defined?(Rake::DSL)\n\n def self.rake_classes\n @rake_classes ||= []\n end\n\n def self.included(base)\n super(base)\n # Hack. Make rakefile point to invoker, so rdoc task is generated properly.\n rakefile = File.basename(caller[0].match(/(.*):\\d+/)[1])\n Rake.application.instance_variable_set(:@rakefile, rakefile)\n rake_classes << base\n end\n end"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":23,"symbol":"rake_classes","kind":"method","lang":"ruby","code":"def self.rake_classes\n @rake_classes ||= []\n end"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":27,"symbol":"included","kind":"method","lang":"ruby","code":"def self.included(base)\n super(base)\n # Hack. Make rakefile point to invoker, so rdoc task is generated properly.\n rakefile = File.basename(caller[0].match(/(.*):\\d+/)[1])\n Rake.application.instance_variable_set(:@rakefile, rakefile)\n rake_classes << base\n end"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":41,"symbol":"task","kind":"method","lang":"ruby","code":"def task(*)\n task = super\n\n if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition\n non_namespaced_name = task.name.split(\":\").last\n\n description = non_namespaced_name\n description << task.arg_names.map { |n| n.to_s.upcase }.join(\" \")\n description.strip!\n\n klass.desc description, Rake.application.last_description || non_namespaced_name\n Rake.application.last_description = nil\n klass.send :define_method, non_namespaced_name do |*args|\n Rake::Task[task.name.to_sym].invoke(*args)\n end\n end\n\n task\n end"}
{"repo":"thor","file":"lib/thor/rake_compat.rb","line":61,"symbol":"namespace","kind":"method","lang":"ruby","code":"def namespace(name)\n if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition\n const_name = Thor::Util.camel_case(name.to_s).to_sym\n klass.const_set(const_name, Class.new(Thor))\n new_klass = klass.const_get(const_name)\n Thor::RakeCompat.rake_classes << new_klass\n end\n\n super\n Thor::RakeCompat.rake_classes.pop\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":10,"symbol":"banner","kind":"method","lang":"ruby","code":"def self.banner(command, all = false, subcommand = false)\n \"thor \" + command.formatted_usage(self, all, subcommand)\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":14,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n true\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":20,"symbol":"help","kind":"method","lang":"ruby","doc":"Override Thor#help so it can give information about any class and any method.","code":"def help(meth = nil)\n if meth && !respond_to?(meth)\n initialize_thorfiles(meth)\n klass, command = Thor::Util.find_class_and_command_by_namespace(meth)\n self.class.handle_no_command_error(command, false) if klass.nil?\n klass.start([\"-h\", command].compact, shell: shell)\n else\n super\n end\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":34,"symbol":"method_missing","kind":"method","lang":"ruby","doc":"If a command is not found on Thor::Runner, method missing is invoked and Thor::Runner is then responsible for finding the command in all classes.","code":"def method_missing(meth, *args)\n meth = meth.to_s\n initialize_thorfiles(meth)\n klass, command = Thor::Util.find_class_and_command_by_namespace(meth)\n self.class.handle_no_command_error(command, false) if klass.nil?\n args.unshift(command) if command\n klass.start(args, shell: shell)\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":45,"symbol":"install","kind":"method","lang":"ruby","code":"def install(name) # rubocop:disable Metrics/MethodLength\n initialize_thorfiles\n\n is_uri = name =~ %r{^https?\\://}\n\n if is_uri\n base = name\n package = :file\n require \"open-uri\"\n begin\n contents = URI.open(name, &:read)\n rescue OpenURI::HTTPError\n raise Error, \"Error opening URI '#{name}'\"\n end\n else\n # If a directory name is provided as the argument, look for a 'main.thor'\n # command in said directory.\n begin\n if File.directory?(File.expand_path(name))\n base = File.join(name, \"main.thor\")\n package = :directory\n contents = File.open(base, &:read)\n else\n base = name\n package = :file\n require \"open-uri\"\n contents = URI.open(name, &:read)\n end\n rescue Errno::ENOENT\n raise Error, \"Error opening file '#{name}'\"\n end\n end\n\n say \"Your Thorfile contains:\"\n say contents\n\n unless options[\"force\"]\n return false if no?(\"Do you wish to continue [y/N]?\")\n end\n\n as = options[\"as\"] || begin\n first_line = contents.split(\"\\n\")[0]\n (match = first_line.match(/\\s*#\\s*module:\\s*([^\\n]*)/)) ? match[1].st"}
{"repo":"thor","file":"lib/thor/runner.rb","line":123,"symbol":"version","kind":"method","lang":"ruby","code":"def version\n require_relative \"version\"\n say \"Thor #{Thor::VERSION}\"\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":129,"symbol":"uninstall","kind":"method","lang":"ruby","code":"def uninstall(name)\n raise Error, \"Can't find module '#{name}'\" unless thor_yaml[name]\n say \"Uninstalling #{name}.\"\n require \"fileutils\"\n FileUtils.rm_rf(File.join(thor_root, (thor_yaml[name][:filename]).to_s))\n\n thor_yaml.delete(name)\n save_yaml(thor_yaml)\n\n puts \"Done.\"\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":142,"symbol":"update","kind":"method","lang":"ruby","code":"def update(name)\n raise Error, \"Can't find module '#{name}'\" if !thor_yaml[name] || !thor_yaml[name][:location]\n\n say \"Updating '#{name}' from #{thor_yaml[name][:location]}\"\n\n old_filename = thor_yaml[name][:filename]\n self.options = options.merge(\"as\" => name)\n\n if File.directory? File.expand_path(name)\n require \"fileutils\"\n FileUtils.rm_rf(File.join(thor_root, old_filename))\n\n thor_yaml.delete(old_filename)\n save_yaml(thor_yaml)\n\n filename = install(name)\n else\n filename = install(thor_yaml[name][:location])\n end\n\n File.delete(File.join(thor_root, old_filename)) unless filename == old_filename\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":167,"symbol":"installed","kind":"method","lang":"ruby","code":"def installed\n initialize_thorfiles(nil, true)\n display_klasses(true, options[\"internal\"])\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":174,"symbol":"list","kind":"method","lang":"ruby","code":"def list(search = \"\")\n initialize_thorfiles\n\n search = \".*#{search}\" if options[\"substring\"]\n search = /^#{search}.*/i\n group = options[:group] || \"standard\"\n\n klasses = Thor::Base.subclasses.select do |k|\n (options[:all] || k.group == group) && k.namespace =~ search\n end\n\n display_klasses(false, false, klasses)\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":190,"symbol":"thor_root","kind":"method","lang":"ruby","code":"def thor_root\n Thor::Util.thor_root\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":194,"symbol":"thor_yaml","kind":"method","lang":"ruby","code":"def thor_yaml\n @thor_yaml ||= begin\n yaml_file = File.join(thor_root, \"thor.yml\")\n require \"yaml\"\n yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)\n yaml || {}\n end\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":205,"symbol":"save_yaml","kind":"method","lang":"ruby","doc":"Save the yaml file. If none exists in thor root, creates one.","code":"def save_yaml(yaml)\n yaml_file = File.join(thor_root, \"thor.yml\")\n\n unless File.exist?(yaml_file)\n require \"fileutils\"\n FileUtils.mkdir_p(thor_root)\n yaml_file = File.join(thor_root, \"thor.yml\")\n FileUtils.touch(yaml_file)\n end\n\n File.open(yaml_file, \"w\") { |f| f.puts yaml.to_yaml }\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":225,"symbol":"initialize_thorfiles","kind":"method","lang":"ruby","doc":"in the thor_root instead of loading them all. By default, it also traverses the current path until find Thor files, as described in thorfiles. This look up can be skipped by supplying skip_lookup true.","code":"def initialize_thorfiles(relevant_to = nil, skip_lookup = false)\n thorfiles(relevant_to, skip_lookup).each do |f|\n Thor::Util.load_thorfile(f, nil, options[:debug]) unless Thor::Base.subclass_files.keys.include?(File.expand_path(f))\n end\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":253,"symbol":"thorfiles","kind":"method","lang":"ruby","doc":"1. c:\\Documents and Settings\\james\\dev\\thor 2. c:\\Documents and Settings\\james\\dev 3. c:\\Documents and Settings\\james 4. c:\\Documents and Settings 5. c:\\ <-- no Thorfiles found!","code":"def thorfiles(relevant_to = nil, skip_lookup = false)\n thorfiles = []\n\n unless skip_lookup\n Pathname.pwd.ascend do |path|\n thorfiles = Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten\n break unless thorfiles.empty?\n end\n end\n\n files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Thor::Util.thor_root_glob)\n files += thorfiles\n files -= [\"#{thor_root}/thor.yml\"]\n\n files.map! do |file|\n File.directory?(file) ? File.join(file, \"main.thor\") : file\n end\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":276,"symbol":"thorfiles_relevant_to","kind":"method","lang":"ruby","doc":"Load Thorfiles relevant to the given method. If you provide \"foo:bar\" it will load all thor files in the thor.yaml that has \"foo\" e \"foo:bar\" namespaces registered.","code":"def thorfiles_relevant_to(meth)\n lookup = [meth, meth.split(\":\")[0...-1].join(\":\")]\n\n files = thor_yaml.select do |_, v|\n v[:namespaces] && !(v[:namespaces] & lookup).empty?\n end\n\n files.map { |_, v| File.join(thor_root, (v[:filename]).to_s) }\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":289,"symbol":"display_klasses","kind":"method","lang":"ruby","doc":"Display information about the given klasses. If with_module is given, it shows a table with information extracted from the yaml file.","code":"def display_klasses(with_modules = false, show_internal = false, klasses = Thor::Base.subclasses)\n klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal\n\n raise Error, \"No Thor commands available\" if klasses.empty?\n show_modules if with_modules && !thor_yaml.empty?\n\n list = Hash.new { |h, k| h[k] = [] }\n groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }\n\n # Get classes which inherit from Thor\n (klasses - groups).each { |k| list[k.namespace.split(\":\").first] += k.printable_commands(false) }\n\n # Get classes which inherit from Thor::Base\n groups.map! { |k| k.printable_commands(false).first }\n list[\"root\"] = groups\n\n # Order namespaces with default coming first\n list = list.sort { |a, b| a[0].sub(/^default/, \"\") <=> b[0].sub(/^default/, \"\") }\n list.each { |n, commands| display_commands(n, commands) unless commands.empty? }\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":310,"symbol":"display_commands","kind":"method","lang":"ruby","code":"def display_commands(namespace, list) #:nodoc:\n list.sort! { |a, b| a[0] <=> b[0] }\n\n say shell.set_color(namespace, :blue, true)\n say \"-\" * namespace.size\n\n print_table(list, truncate: true)\n say\n end"}
{"repo":"thor","file":"lib/thor/runner.rb","line":321,"symbol":"show_modules","kind":"method","lang":"ruby","code":"def show_modules #:nodoc:\n info = []\n labels = %w(Modules Namespaces)\n\n info << labels\n info << [\"-\" * labels[0].size, \"-\" * labels[1].size]\n\n thor_yaml.each do |name, hash|\n info << [name, hash[:namespaces].join(\", \")]\n end\n\n print_table info\n say \"\"\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":5,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n class Basic\n attr_accessor :base\n attr_reader :padding\n\n # Initialize base, mute and padding to nil.\n #\n def initialize #:nodoc:\n @base = nil\n @mute = false\n @padding = 0\n @always_force = false\n end\n\n # Mute everything that's inside given block\n #\n def mute\n @mute = true\n yield\n ensure\n @mute = false\n end\n\n # Check if base is muted\n #\n def mute?\n @mute\n end\n\n # Sets the output padding, not allowing less than zero values.\n #\n def padding=(value)\n @padding = [0, value].max\n end\n\n # Sets the output padding while executing a block and resets it.\n #\n def indent(count = 1)\n orig_padding = padding\n self.padding = padding + count\n yield\n self.padding = orig_padding\n end\n\n # Asks something to the user and receives a response.\n #\n # If a default value is specified it will be presented to the user\n # and allows them to select that value with an empty response. This\n # option is ignored when limited answers are supplied.\n #\n "}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":6,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n class Basic\n attr_accessor :base\n attr_reader :padding\n\n # Initialize base, mute and padding to nil.\n #\n def initialize #:nodoc:\n @base = nil\n @mute = false\n @padding = 0\n @always_force = false\n end\n\n # Mute everything that's inside given block\n #\n def mute\n @mute = true\n yield\n ensure\n @mute = false\n end\n\n # Check if base is muted\n #\n def mute?\n @mute\n end\n\n # Sets the output padding, not allowing less than zero values.\n #\n def padding=(value)\n @padding = [0, value].max\n end\n\n # Sets the output padding while executing a block and resets it.\n #\n def indent(count = 1)\n orig_padding = padding\n self.padding = padding + count\n yield\n self.padding = orig_padding\n end\n\n # Asks something to the user and receives a response.\n #\n # If a default value is specified it will be presented to the user\n # and allows them to select that value with an empty response. This\n # option is ignored when limited answers are supplied.\n #\n # If asked to"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":7,"symbol":"Basic","kind":"class","lang":"ruby","code":"class Basic\n attr_accessor :base\n attr_reader :padding\n\n # Initialize base, mute and padding to nil.\n #\n def initialize #:nodoc:\n @base = nil\n @mute = false\n @padding = 0\n @always_force = false\n end\n\n # Mute everything that's inside given block\n #\n def mute\n @mute = true\n yield\n ensure\n @mute = false\n end\n\n # Check if base is muted\n #\n def mute?\n @mute\n end\n\n # Sets the output padding, not allowing less than zero values.\n #\n def padding=(value)\n @padding = [0, value].max\n end\n\n # Sets the output padding while executing a block and resets it.\n #\n def indent(count = 1)\n orig_padding = padding\n self.padding = padding + count\n yield\n self.padding = orig_padding\n end\n\n # Asks something to the user and receives a response.\n #\n # If a default value is specified it will be presented to the user\n # and allows them to select that value with an empty response. This\n # option is ignored when limited answers are supplied.\n #\n # If asked to limit the correc"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":13,"symbol":"initialize","kind":"method","lang":"ruby","doc":"Initialize base, mute and padding to nil.","code":"def initialize #:nodoc:\n @base = nil\n @mute = false\n @padding = 0\n @always_force = false\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":22,"symbol":"mute","kind":"method","lang":"ruby","doc":"Mute everything that's inside given block","code":"def mute\n @mute = true\n yield\n ensure\n @mute = false\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":31,"symbol":"mute?","kind":"method","lang":"ruby","doc":"Check if base is muted","code":"def mute?\n @mute\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":43,"symbol":"indent","kind":"method","lang":"ruby","doc":"Sets the output padding while executing a block and resets it.","code":"def indent(count = 1)\n orig_padding = padding\n self.padding = padding + count\n yield\n self.padding = orig_padding\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":80,"symbol":"ask","kind":"method","lang":"ruby","doc":"ask(\"What is your favorite Neopolitan flavor?\", :limited_to => [\"strawberry\", \"chocolate\", \"vanilla\"]) ask(\"What is your password?\", :echo => false) ask(\"Where should the file be saved?\", :path => true)","code":"def ask(statement, *args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n color = args.first\n\n if options[:limited_to]\n ask_filtered(statement, color, options)\n else\n ask_simply(statement, color, options)\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":98,"symbol":"say","kind":"method","lang":"ruby","doc":"or tab character, a new line is not appended (print + flush). Otherwise are passed straight to puts (behavior got from Highline). ==== Example say(\"I know you knew that.\")","code":"def say(message = \"\", color = nil, force_new_line = (message.to_s !~ /( |\\t)\\Z/))\n return if quiet?\n\n buffer = prepare_message(message, *color)\n buffer << \"\\n\" if force_new_line && !message.to_s.end_with?(\"\\n\")\n\n stdout.print(buffer)\n stdout.flush\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":115,"symbol":"say_error","kind":"method","lang":"ruby","doc":"or tab character, a new line is not appended (print + flush). Otherwise are passed straight to puts (behavior got from Highline). ==== Example say_error(\"error: something went wrong\")","code":"def say_error(message = \"\", color = nil, force_new_line = (message.to_s !~ /( |\\t)\\Z/))\n return if quiet?\n\n buffer = prepare_message(message, *color)\n buffer << \"\\n\" if force_new_line && !message.to_s.end_with?(\"\\n\")\n\n stderr.print(buffer)\n stderr.flush\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":130,"symbol":"say_status","kind":"method","lang":"ruby","doc":"Say a status with the given color and appends the message. Since this method is used frequently by actions, it allows nil or false to be given in log_status, avoiding the message from being shown. If a Symbol is given in log_status, it's used as the color.","code":"def say_status(status, message, log_status = true)\n return if quiet? || log_status == false\n spaces = \" \" * (padding + 1)\n status = status.to_s.rjust(12)\n margin = \" \" * status.length + spaces\n\n color = log_status.is_a?(Symbol) ? log_status : :green\n status = set_color status, color, true if color\n\n message = message.to_s.chomp.gsub(/(?<!\\A)^/, margin)\n buffer = \"#{status}#{spaces}#{message}\\n\"\n\n stdout.print(buffer)\n stdout.flush\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":149,"symbol":"yes?","kind":"method","lang":"ruby","doc":"Asks the user a question and returns true if the user replies \"y\" or \"yes\".","code":"def yes?(statement, color = nil)\n !!(ask(statement, color, add_to_history: false) =~ is?(:yes))\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":156,"symbol":"no?","kind":"method","lang":"ruby","doc":"Asks the user a question and returns true if the user replies \"n\" or \"no\".","code":"def no?(statement, color = nil)\n !!(ask(statement, color, add_to_history: false) =~ is?(:no))\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":165,"symbol":"print_in_columns","kind":"method","lang":"ruby","doc":"Prints values in columns ==== Parameters Array[String, String, ...]","code":"def print_in_columns(array)\n printer = ColumnPrinter.new(stdout)\n printer.print(array)\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":180,"symbol":"print_table","kind":"method","lang":"ruby","doc":"==== Options indent<Integer>:: Indent the first column by indent value. colwidth<Integer>:: Force the first column to colwidth spaces wide. borders<Boolean>:: Adds ascii borders.","code":"def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength\n printer = TablePrinter.new(stdout, options)\n printer.print(array)\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":194,"symbol":"print_wrapped","kind":"method","lang":"ruby","doc":"==== Parameters String ==== Options indent<Integer>:: Indent each line of the printed paragraph by indent value.","code":"def print_wrapped(message, options = {})\n printer = WrappedPrinter.new(stdout, options)\n printer.print(message)\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":207,"symbol":"file_collision","kind":"method","lang":"ruby","doc":"response as the content for the diff. ==== Parameters destination<String>:: the destination file to solve conflicts block<Proc>:: an optional block that returns the value to be used in diff and merge","code":"def file_collision(destination)\n return true if @always_force\n options = block_given? ? \"[Ynaqdhm]\" : \"[Ynaqh]\"\n\n loop do\n answer = ask(\n %[Overwrite #{destination}? (enter \"h\" for help) #{options}],\n add_to_history: false\n )\n\n case answer\n when nil\n say \"\"\n return true\n when is?(:yes), is?(:force), \"\"\n return true\n when is?(:no), is?(:skip)\n return false\n when is?(:always)\n return @always_force = true\n when is?(:quit)\n say \"Aborting...\"\n raise SystemExit\n when is?(:diff)\n show_diff(destination, yield) if block_given?\n say \"Retrying...\"\n when is?(:merge)\n if block_given? && !merge_tool.empty?\n merge(destination, yield)\n return nil\n end\n\n say \"Please specify merge tool to `THOR_MERGE` env.\"\n else\n say file_collision_help(block_given?)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":251,"symbol":"error","kind":"method","lang":"ruby","doc":"Called if something goes wrong during the execution. This is used by Thor internally and should not be used inside your scripts. If something went wrong, you can always raise an exception. If you raise a Thor::Error, it will be rescued and wrapped in the method below.","code":"def error(statement)\n stderr.puts statement\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":258,"symbol":"set_color","kind":"method","lang":"ruby","doc":"Apply color to the given string with optional bold. Disabled in the Thor::Shell::Basic class.","code":"def set_color(string, *) #:nodoc:\n string\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":264,"symbol":"prepare_message","kind":"method","lang":"ruby","code":"def prepare_message(message, *color)\n spaces = \" \" * padding\n spaces + set_color(message.to_s, *color)\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":269,"symbol":"can_display_colors?","kind":"method","lang":"ruby","code":"def can_display_colors?\n false\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":273,"symbol":"lookup_color","kind":"method","lang":"ruby","code":"def lookup_color(color)\n return color unless color.is_a?(Symbol)\n self.class.const_get(color.to_s.upcase)\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":278,"symbol":"stdout","kind":"method","lang":"ruby","code":"def stdout\n $stdout\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":282,"symbol":"stderr","kind":"method","lang":"ruby","code":"def stderr\n $stderr\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":286,"symbol":"is?","kind":"method","lang":"ruby","code":"def is?(value) #:nodoc:\n value = value.to_s\n\n if value.size == 1\n /\\A#{value}\\z/i\n else\n /\\A(#{value}|#{value[0, 1]})\\z/i\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":296,"symbol":"file_collision_help","kind":"method","lang":"ruby","code":"def file_collision_help(block_given) #:nodoc:\n help = <<-HELP\n Y - yes, overwrite\n n - no, do not overwrite\n a - all, overwrite this and all others\n q - quit, abort\n h - help, show this help\n HELP\n if block_given\n help << <<-HELP\n d - diff, show the differences between the old and the new\n m - merge, run merge tool\n HELP\n end\n help\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":313,"symbol":"show_diff","kind":"method","lang":"ruby","code":"def show_diff(destination, content) #:nodoc:\n require \"tempfile\"\n Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|\n temp.write content\n temp.rewind\n system(*diff_tool, destination, temp.path)\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":322,"symbol":"quiet?","kind":"method","lang":"ruby","code":"def quiet? #:nodoc:\n mute? || (base && base.options[:quiet])\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":326,"symbol":"unix?","kind":"method","lang":"ruby","code":"def unix?\n Terminal.unix?\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":330,"symbol":"ask_simply","kind":"method","lang":"ruby","code":"def ask_simply(statement, color, options)\n default = options[:default]\n message = [statement, (\"(#{default})\" if default), nil].uniq.join(\" \")\n message = prepare_message(message, *color)\n result = Thor::LineEditor.readline(message, options)\n\n return unless result\n\n result = result.strip\n\n if default && result == \"\"\n default\n else\n result\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":347,"symbol":"ask_filtered","kind":"method","lang":"ruby","code":"def ask_filtered(statement, color, options)\n answer_set = options[:limited_to]\n case_insensitive = options.fetch(:case_insensitive, false)\n correct_answer = nil\n until correct_answer\n answers = answer_set.join(\", \")\n answer = ask_simply(\"#{statement} [#{answers}]\", color, options)\n correct_answer = answer_match(answer_set, answer, case_insensitive)\n say(\"Your response must be one of: [#{answers}]. Please try again.\") unless correct_answer\n end\n correct_answer\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":360,"symbol":"answer_match","kind":"method","lang":"ruby","code":"def answer_match(possibilities, answer, case_insensitive)\n if case_insensitive\n possibilities.detect{ |possibility| possibility.downcase == answer.downcase }\n else\n possibilities.detect{ |possibility| possibility == answer }\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":368,"symbol":"merge","kind":"method","lang":"ruby","code":"def merge(destination, content) #:nodoc:\n require \"tempfile\"\n Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination), binmode: true) do |temp|\n temp.write content\n temp.rewind\n system(*merge_tool, temp.path, destination)\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":377,"symbol":"merge_tool","kind":"method","lang":"ruby","code":"def merge_tool #:nodoc:\n @merge_tool ||= begin\n require \"shellwords\"\n Shellwords.split(ENV[\"THOR_MERGE\"] || \"git difftool --no-index\")\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/basic.rb","line":384,"symbol":"diff_tool","kind":"method","lang":"ruby","code":"def diff_tool #:nodoc:\n @diff_cmd ||= begin\n require \"shellwords\"\n Shellwords.split(ENV[\"THOR_DIFF\"] || ENV[\"RAILS_DIFF\"] || \"diff -u\")\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":6,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n # Inherit from Thor::Shell::Basic and add set_color behavior. Check\n # Thor::Shell::Basic to see all available methods.\n #\n class Color < Basic\n include LCSDiff\n\n # Embed in a String to clear all previous ANSI sequences.\n CLEAR = \"\\e[0m\"\n # The start of an ANSI bold sequence.\n BOLD = \"\\e[1m\"\n\n # Set the terminal's foreground ANSI color to black.\n BLACK = \"\\e[30m\"\n # Set the terminal's foreground ANSI color to red.\n RED = \"\\e[31m\"\n # Set the terminal's foreground ANSI color to green.\n GREEN = \"\\e[32m\"\n # Set the terminal's foreground ANSI color to yellow.\n YELLOW = \"\\e[33m\"\n # Set the terminal's foreground ANSI color to blue.\n BLUE = \"\\e[34m\"\n # Set the terminal's foreground ANSI color to magenta.\n MAGENTA = \"\\e[35m\"\n # Set the terminal's foreground ANSI color to cyan.\n CYAN = \"\\e[36m\"\n # Set the terminal's foreground ANSI color to white.\n WHITE = \"\\e[37m\"\n\n # Set the terminal's background ANSI color to black.\n ON_BLACK = \"\\e[40m\"\n # Set the terminal's background ANSI color"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":7,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n # Inherit from Thor::Shell::Basic and add set_color behavior. Check\n # Thor::Shell::Basic to see all available methods.\n #\n class Color < Basic\n include LCSDiff\n\n # Embed in a String to clear all previous ANSI sequences.\n CLEAR = \"\\e[0m\"\n # The start of an ANSI bold sequence.\n BOLD = \"\\e[1m\"\n\n # Set the terminal's foreground ANSI color to black.\n BLACK = \"\\e[30m\"\n # Set the terminal's foreground ANSI color to red.\n RED = \"\\e[31m\"\n # Set the terminal's foreground ANSI color to green.\n GREEN = \"\\e[32m\"\n # Set the terminal's foreground ANSI color to yellow.\n YELLOW = \"\\e[33m\"\n # Set the terminal's foreground ANSI color to blue.\n BLUE = \"\\e[34m\"\n # Set the terminal's foreground ANSI color to magenta.\n MAGENTA = \"\\e[35m\"\n # Set the terminal's foreground ANSI color to cyan.\n CYAN = \"\\e[36m\"\n # Set the terminal's foreground ANSI color to white.\n WHITE = \"\\e[37m\"\n\n # Set the terminal's background ANSI color to black.\n ON_BLACK = \"\\e[40m\"\n # Set the terminal's background ANSI color to red.\n "}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":11,"symbol":"Color","kind":"class","lang":"ruby","doc":"Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods.","code":"class Color < Basic\n include LCSDiff\n\n # Embed in a String to clear all previous ANSI sequences.\n CLEAR = \"\\e[0m\"\n # The start of an ANSI bold sequence.\n BOLD = \"\\e[1m\"\n\n # Set the terminal's foreground ANSI color to black.\n BLACK = \"\\e[30m\"\n # Set the terminal's foreground ANSI color to red.\n RED = \"\\e[31m\"\n # Set the terminal's foreground ANSI color to green.\n GREEN = \"\\e[32m\"\n # Set the terminal's foreground ANSI color to yellow.\n YELLOW = \"\\e[33m\"\n # Set the terminal's foreground ANSI color to blue.\n BLUE = \"\\e[34m\"\n # Set the terminal's foreground ANSI color to magenta.\n MAGENTA = \"\\e[35m\"\n # Set the terminal's foreground ANSI color to cyan.\n CYAN = \"\\e[36m\"\n # Set the terminal's foreground ANSI color to white.\n WHITE = \"\\e[37m\"\n\n # Set the terminal's background ANSI color to black.\n ON_BLACK = \"\\e[40m\"\n # Set the terminal's background ANSI color to red.\n ON_RED = \"\\e[41m\"\n # Set the terminal's background ANSI color to green.\n ON_GREEN = \"\\e[42m\"\n # Set the terminal's background A"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":84,"symbol":"set_color","kind":"method","lang":"ruby","doc":":on_green :on_yellow :on_blue :on_magenta :on_cyan :on_white","code":"def set_color(string, *colors)\n if colors.compact.empty? || !can_display_colors?\n string\n elsif colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }\n ansi_colors = colors.map { |color| lookup_color(color) }\n \"#{ansi_colors.join}#{string}#{CLEAR}\"\n else\n # The old API was `set_color(color, bold=boolean)`. We\n # continue to support the old API because you should never\n # break old APIs unnecessarily :P\n foreground, bold = colors\n foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol)\n\n bold = bold ? BOLD : \"\"\n \"#{bold}#{foreground}#{string}#{CLEAR}\"\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":104,"symbol":"can_display_colors?","kind":"method","lang":"ruby","code":"def can_display_colors?\n are_colors_supported? && !are_colors_disabled?\n end"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":108,"symbol":"are_colors_supported?","kind":"method","lang":"ruby","code":"def are_colors_supported?\n stdout.tty? && ENV[\"TERM\"] != \"dumb\"\n end"}
{"repo":"thor","file":"lib/thor/shell/color.rb","line":112,"symbol":"are_colors_disabled?","kind":"method","lang":"ruby","code":"def are_colors_disabled?\n !ENV[\"NO_COLOR\"].nil? && !ENV[\"NO_COLOR\"].empty?\n end"}
{"repo":"thor","file":"lib/thor/shell/column_printer.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n class ColumnPrinter\n attr_reader :stdout, :options\n\n def initialize(stdout, options = {})\n @stdout = stdout\n @options = options\n @indent = options[:indent].to_i\n end\n\n def print(array)\n return if array.empty?\n colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2\n array.each_with_index do |value, index|\n # Don't output trailing spaces when printing the last column\n if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length\n stdout.puts value\n else\n stdout.printf(\"%-#{colwidth}s\", value)\n end\n end\n end\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/shell/column_printer.rb","line":4,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n class ColumnPrinter\n attr_reader :stdout, :options\n\n def initialize(stdout, options = {})\n @stdout = stdout\n @options = options\n @indent = options[:indent].to_i\n end\n\n def print(array)\n return if array.empty?\n colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2\n array.each_with_index do |value, index|\n # Don't output trailing spaces when printing the last column\n if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length\n stdout.puts value\n else\n stdout.printf(\"%-#{colwidth}s\", value)\n end\n end\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/column_printer.rb","line":5,"symbol":"ColumnPrinter","kind":"class","lang":"ruby","code":"class ColumnPrinter\n attr_reader :stdout, :options\n\n def initialize(stdout, options = {})\n @stdout = stdout\n @options = options\n @indent = options[:indent].to_i\n end\n\n def print(array)\n return if array.empty?\n colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2\n array.each_with_index do |value, index|\n # Don't output trailing spaces when printing the last column\n if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length\n stdout.puts value\n else\n stdout.printf(\"%-#{colwidth}s\", value)\n end\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/column_printer.rb","line":8,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(stdout, options = {})\n @stdout = stdout\n @options = options\n @indent = options[:indent].to_i\n end"}
{"repo":"thor","file":"lib/thor/shell/column_printer.rb","line":14,"symbol":"print","kind":"method","lang":"ruby","code":"def print(array)\n return if array.empty?\n colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2\n array.each_with_index do |value, index|\n # Don't output trailing spaces when printing the last column\n if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length\n stdout.puts value\n else\n stdout.printf(\"%-#{colwidth}s\", value)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":4,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n # Inherit from Thor::Shell::Basic and add set_color behavior. Check\n # Thor::Shell::Basic to see all available methods.\n #\n class HTML < Basic\n include LCSDiff\n\n # The start of an HTML bold sequence.\n BOLD = \"font-weight: bold\"\n\n # Set the terminal's foreground HTML color to black.\n BLACK = \"color: black\"\n # Set the terminal's foreground HTML color to red.\n RED = \"color: red\"\n # Set the terminal's foreground HTML color to green.\n GREEN = \"color: green\"\n # Set the terminal's foreground HTML color to yellow.\n YELLOW = \"color: yellow\"\n # Set the terminal's foreground HTML color to blue.\n BLUE = \"color: blue\"\n # Set the terminal's foreground HTML color to magenta.\n MAGENTA = \"color: magenta\"\n # Set the terminal's foreground HTML color to cyan.\n CYAN = \"color: cyan\"\n # Set the terminal's foreground HTML color to white.\n WHITE = \"color: white\"\n\n # Set the terminal's background HTML color to black.\n ON_BLACK = \"background-color: black\"\n # Set the terminal's background HTML color to red.\n O"}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":5,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n # Inherit from Thor::Shell::Basic and add set_color behavior. Check\n # Thor::Shell::Basic to see all available methods.\n #\n class HTML < Basic\n include LCSDiff\n\n # The start of an HTML bold sequence.\n BOLD = \"font-weight: bold\"\n\n # Set the terminal's foreground HTML color to black.\n BLACK = \"color: black\"\n # Set the terminal's foreground HTML color to red.\n RED = \"color: red\"\n # Set the terminal's foreground HTML color to green.\n GREEN = \"color: green\"\n # Set the terminal's foreground HTML color to yellow.\n YELLOW = \"color: yellow\"\n # Set the terminal's foreground HTML color to blue.\n BLUE = \"color: blue\"\n # Set the terminal's foreground HTML color to magenta.\n MAGENTA = \"color: magenta\"\n # Set the terminal's foreground HTML color to cyan.\n CYAN = \"color: cyan\"\n # Set the terminal's foreground HTML color to white.\n WHITE = \"color: white\"\n\n # Set the terminal's background HTML color to black.\n ON_BLACK = \"background-color: black\"\n # Set the terminal's background HTML color to red.\n ON_RED = \""}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":9,"symbol":"HTML","kind":"class","lang":"ruby","doc":"Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods.","code":"class HTML < Basic\n include LCSDiff\n\n # The start of an HTML bold sequence.\n BOLD = \"font-weight: bold\"\n\n # Set the terminal's foreground HTML color to black.\n BLACK = \"color: black\"\n # Set the terminal's foreground HTML color to red.\n RED = \"color: red\"\n # Set the terminal's foreground HTML color to green.\n GREEN = \"color: green\"\n # Set the terminal's foreground HTML color to yellow.\n YELLOW = \"color: yellow\"\n # Set the terminal's foreground HTML color to blue.\n BLUE = \"color: blue\"\n # Set the terminal's foreground HTML color to magenta.\n MAGENTA = \"color: magenta\"\n # Set the terminal's foreground HTML color to cyan.\n CYAN = \"color: cyan\"\n # Set the terminal's foreground HTML color to white.\n WHITE = \"color: white\"\n\n # Set the terminal's background HTML color to black.\n ON_BLACK = \"background-color: black\"\n # Set the terminal's background HTML color to red.\n ON_RED = \"background-color: red\"\n # Set the terminal's background HTML color to green.\n ON_GREEN = \"background-color: green\"\n # Set the termina"}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":54,"symbol":"set_color","kind":"method","lang":"ruby","doc":"Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.","code":"def set_color(string, *colors)\n if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }\n html_colors = colors.map { |color| lookup_color(color) }\n \"<span style=\\\"#{html_colors.join('; ')};\\\">#{Thor::Util.escape_html(string)}</span>\"\n else\n color, bold = colors\n html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)\n styles = [html_color]\n styles << BOLD if bold\n \"<span style=\\\"#{styles.join('; ')};\\\">#{Thor::Util.escape_html(string)}</span>\"\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":73,"symbol":"ask","kind":"method","lang":"ruby","doc":"Ask something to the user and receives a response. ==== Example ask(\"What is your name?\") TODO: Implement #ask for Thor::Shell::HTML","code":"def ask(statement, color = nil)\n raise NotImplementedError, \"Implement #ask for Thor::Shell::HTML\"\n end"}
{"repo":"thor","file":"lib/thor/shell/html.rb","line":79,"symbol":"can_display_colors?","kind":"method","lang":"ruby","code":"def can_display_colors?\n true\n end"}
{"repo":"thor","file":"lib/thor/shell/lcs_diff.rb","line":1,"symbol":"LCSDiff","kind":"module","lang":"ruby","code":"module LCSDiff\nprotected\n\n # Overwrite show_diff to show diff with colors if Diff::LCS is\n # available.\n def show_diff(destination, content) #:nodoc:\n if diff_lcs_loaded? && ENV[\"THOR_DIFF\"].nil? && ENV[\"RAILS_DIFF\"].nil?\n actual = File.binread(destination).to_s.split(\"\\n\")\n content = content.to_s.split(\"\\n\")\n\n Diff::LCS.sdiff(actual, content).each do |diff|\n output_diff_line(diff)\n end\n else\n super\n end\n end\n\nprivate\n\n def output_diff_line(diff) #:nodoc:\n case diff.action\n when \"-\"\n say \"- #{diff.old_element.chomp}\", :red, true\n when \"+\"\n say \"+ #{diff.new_element.chomp}\", :green, true\n when \"!\"\n say \"- #{diff.old_element.chomp}\", :red, true\n say \"+ #{diff.new_element.chomp}\", :green, true\n else\n say \" #{diff.old_element.chomp}\", nil, true\n end\n end\n\n # Check if Diff::LCS is loaded. If it is, use it to create pretty output\n # for diff.\n def diff_lcs_loaded? #:nodoc:\n return true if defined?(Diff::LCS)\n return @diff_lcs_loaded unless @diff_lcs_loaded.nil?\n\n @diff_lcs_loaded = begin\n require \"diff/lcs\"\n true\n rescue LoadError\n false\n end\n end\n\nend"}
{"repo":"thor","file":"lib/thor/shell/lcs_diff.rb","line":6,"symbol":"show_diff","kind":"method","lang":"ruby","doc":"Overwrite show_diff to show diff with colors if Diff::LCS is available.","code":"def show_diff(destination, content) #:nodoc:\n if diff_lcs_loaded? && ENV[\"THOR_DIFF\"].nil? && ENV[\"RAILS_DIFF\"].nil?\n actual = File.binread(destination).to_s.split(\"\\n\")\n content = content.to_s.split(\"\\n\")\n\n Diff::LCS.sdiff(actual, content).each do |diff|\n output_diff_line(diff)\n end\n else\n super\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/lcs_diff.rb","line":21,"symbol":"output_diff_line","kind":"method","lang":"ruby","code":"def output_diff_line(diff) #:nodoc:\n case diff.action\n when \"-\"\n say \"- #{diff.old_element.chomp}\", :red, true\n when \"+\"\n say \"+ #{diff.new_element.chomp}\", :green, true\n when \"!\"\n say \"- #{diff.old_element.chomp}\", :red, true\n say \"+ #{diff.new_element.chomp}\", :green, true\n else\n say \" #{diff.old_element.chomp}\", nil, true\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/lcs_diff.rb","line":37,"symbol":"diff_lcs_loaded?","kind":"method","lang":"ruby","doc":"Check if Diff::LCS is loaded. If it is, use it to create pretty output for diff.","code":"def diff_lcs_loaded? #:nodoc:\n return true if defined?(Diff::LCS)\n return @diff_lcs_loaded unless @diff_lcs_loaded.nil?\n\n @diff_lcs_loaded = begin\n require \"diff/lcs\"\n true\n rescue LoadError\n false\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":4,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n class TablePrinter < ColumnPrinter\n BORDER_SEPARATOR = :separator\n\n def initialize(stdout, options = {})\n super\n @formats = []\n @maximas = []\n @colwidth = options[:colwidth]\n @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]\n @padding = 1\n end\n\n def print(array)\n return if array.empty?\n\n prepare(array)\n\n print_border_separator if options[:borders]\n\n array.each do |row|\n if options[:borders] && row == BORDER_SEPARATOR\n print_border_separator\n next\n end\n\n sentence = \"\".dup\n\n row.each_with_index do |column, index|\n sentence << format_cell(column, row.size, index)\n end\n\n sentence = truncate(sentence)\n sentence << \"|\" if options[:borders]\n stdout.puts indentation + sentence\n\n end\n print_border_separator if options[:borders]\n end\n\n private\n\n def prepare(array)\n array = array.reject{|row| row == BORDER_SEPARATOR }\n\n @formats << \"%-#{@colwidth + 2}s\".dup if @colwidth\n start = @colwidth "}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":5,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n class TablePrinter < ColumnPrinter\n BORDER_SEPARATOR = :separator\n\n def initialize(stdout, options = {})\n super\n @formats = []\n @maximas = []\n @colwidth = options[:colwidth]\n @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]\n @padding = 1\n end\n\n def print(array)\n return if array.empty?\n\n prepare(array)\n\n print_border_separator if options[:borders]\n\n array.each do |row|\n if options[:borders] && row == BORDER_SEPARATOR\n print_border_separator\n next\n end\n\n sentence = \"\".dup\n\n row.each_with_index do |column, index|\n sentence << format_cell(column, row.size, index)\n end\n\n sentence = truncate(sentence)\n sentence << \"|\" if options[:borders]\n stdout.puts indentation + sentence\n\n end\n print_border_separator if options[:borders]\n end\n\n private\n\n def prepare(array)\n array = array.reject{|row| row == BORDER_SEPARATOR }\n\n @formats << \"%-#{@colwidth + 2}s\".dup if @colwidth\n start = @colwidth ? 1 : 0\n\n "}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":6,"symbol":"TablePrinter","kind":"class","lang":"ruby","code":"class TablePrinter < ColumnPrinter\n BORDER_SEPARATOR = :separator\n\n def initialize(stdout, options = {})\n super\n @formats = []\n @maximas = []\n @colwidth = options[:colwidth]\n @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]\n @padding = 1\n end\n\n def print(array)\n return if array.empty?\n\n prepare(array)\n\n print_border_separator if options[:borders]\n\n array.each do |row|\n if options[:borders] && row == BORDER_SEPARATOR\n print_border_separator\n next\n end\n\n sentence = \"\".dup\n\n row.each_with_index do |column, index|\n sentence << format_cell(column, row.size, index)\n end\n\n sentence = truncate(sentence)\n sentence << \"|\" if options[:borders]\n stdout.puts indentation + sentence\n\n end\n print_border_separator if options[:borders]\n end\n\n private\n\n def prepare(array)\n array = array.reject{|row| row == BORDER_SEPARATOR }\n\n @formats << \"%-#{@colwidth + 2}s\".dup if @colwidth\n start = @colwidth ? 1 : 0\n\n colcount = ar"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":9,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(stdout, options = {})\n super\n @formats = []\n @maximas = []\n @colwidth = options[:colwidth]\n @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]\n @padding = 1\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":18,"symbol":"print","kind":"method","lang":"ruby","code":"def print(array)\n return if array.empty?\n\n prepare(array)\n\n print_border_separator if options[:borders]\n\n array.each do |row|\n if options[:borders] && row == BORDER_SEPARATOR\n print_border_separator\n next\n end\n\n sentence = \"\".dup\n\n row.each_with_index do |column, index|\n sentence << format_cell(column, row.size, index)\n end\n\n sentence = truncate(sentence)\n sentence << \"|\" if options[:borders]\n stdout.puts indentation + sentence\n\n end\n print_border_separator if options[:borders]\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":47,"symbol":"prepare","kind":"method","lang":"ruby","code":"def prepare(array)\n array = array.reject{|row| row == BORDER_SEPARATOR }\n\n @formats << \"%-#{@colwidth + 2}s\".dup if @colwidth\n start = @colwidth ? 1 : 0\n\n colcount = array.max { |a, b| a.size <=> b.size }.size\n\n start.upto(colcount - 1) do |index|\n maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max\n\n @maximas << maxima\n @formats << if options[:borders]\n \"%-#{maxima}s\".dup\n elsif index == colcount - 1\n # Don't output 2 trailing spaces when printing the last column\n \"%-s\".dup\n else\n \"%-#{maxima + 2}s\".dup\n end\n end\n\n @formats << \"%s\"\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":72,"symbol":"format_cell","kind":"method","lang":"ruby","code":"def format_cell(column, row_size, index)\n maxima = @maximas[index]\n\n f = if column.is_a?(Numeric)\n if options[:borders]\n # With borders we handle padding separately\n \"%#{maxima}s\"\n elsif index == row_size - 1\n # Don't output 2 trailing spaces when printing the last column\n \"%#{maxima}s\"\n else\n \"%#{maxima}s \"\n end\n else\n @formats[index]\n end\n\n cell = \"\".dup\n cell << \"|\" + \" \" * @padding if options[:borders]\n cell << f % column.to_s\n cell << \" \" * @padding if options[:borders]\n cell\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":96,"symbol":"print_border_separator","kind":"method","lang":"ruby","code":"def print_border_separator\n separator = @maximas.map do |maxima|\n \"+\" + \"-\" * (maxima + 2 * @padding)\n end\n stdout.puts indentation + separator.join + \"+\"\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":103,"symbol":"truncate","kind":"method","lang":"ruby","code":"def truncate(string)\n return string unless @truncate\n chars = string.chars.to_a\n if chars.length <= @truncate\n chars.join\n else\n chars[0, @truncate - 3 - @indent].join + \"...\"\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/table_printer.rb","line":113,"symbol":"indentation","kind":"method","lang":"ruby","code":"def indentation\n \" \" * @indent\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n module Terminal\n DEFAULT_TERMINAL_WIDTH = 80\n\n class << self\n # This code was copied from Rake, available under MIT-LICENSE\n # Copyright (c) 2003, 2004 Jim Weirich\n def terminal_width\n result = if ENV[\"THOR_COLUMNS\"]\n ENV[\"THOR_COLUMNS\"].to_i\n else\n unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH\n end\n result < 10 ? DEFAULT_TERMINAL_WIDTH : result\n rescue\n DEFAULT_TERMINAL_WIDTH\n end\n\n def unix?\n RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i\n end\n\n private\n\n # Calculate the dynamic width of the terminal\n def dynamic_width\n @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)\n end\n\n def dynamic_width_stty\n `stty size 2>/dev/null`.split[1].to_i\n end\n\n def dynamic_width_tput\n `tput cols 2>/dev/null`.to_i\n end\n\n end\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":2,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n module Terminal\n DEFAULT_TERMINAL_WIDTH = 80\n\n class << self\n # This code was copied from Rake, available under MIT-LICENSE\n # Copyright (c) 2003, 2004 Jim Weirich\n def terminal_width\n result = if ENV[\"THOR_COLUMNS\"]\n ENV[\"THOR_COLUMNS\"].to_i\n else\n unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH\n end\n result < 10 ? DEFAULT_TERMINAL_WIDTH : result\n rescue\n DEFAULT_TERMINAL_WIDTH\n end\n\n def unix?\n RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i\n end\n\n private\n\n # Calculate the dynamic width of the terminal\n def dynamic_width\n @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)\n end\n\n def dynamic_width_stty\n `stty size 2>/dev/null`.split[1].to_i\n end\n\n def dynamic_width_tput\n `tput cols 2>/dev/null`.to_i\n end\n\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":3,"symbol":"Terminal","kind":"module","lang":"ruby","code":"module Terminal\n DEFAULT_TERMINAL_WIDTH = 80\n\n class << self\n # This code was copied from Rake, available under MIT-LICENSE\n # Copyright (c) 2003, 2004 Jim Weirich\n def terminal_width\n result = if ENV[\"THOR_COLUMNS\"]\n ENV[\"THOR_COLUMNS\"].to_i\n else\n unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH\n end\n result < 10 ? DEFAULT_TERMINAL_WIDTH : result\n rescue\n DEFAULT_TERMINAL_WIDTH\n end\n\n def unix?\n RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i\n end\n\n private\n\n # Calculate the dynamic width of the terminal\n def dynamic_width\n @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)\n end\n\n def dynamic_width_stty\n `stty size 2>/dev/null`.split[1].to_i\n end\n\n def dynamic_width_tput\n `tput cols 2>/dev/null`.to_i\n end\n\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":9,"symbol":"terminal_width","kind":"method","lang":"ruby","doc":"This code was copied from Rake, available under MIT-LICENSE Copyright (c) 2003, 2004 Jim Weirich","code":"def terminal_width\n result = if ENV[\"THOR_COLUMNS\"]\n ENV[\"THOR_COLUMNS\"].to_i\n else\n unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH\n end\n result < 10 ? DEFAULT_TERMINAL_WIDTH : result\n rescue\n DEFAULT_TERMINAL_WIDTH\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":20,"symbol":"unix?","kind":"method","lang":"ruby","code":"def unix?\n RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":27,"symbol":"dynamic_width","kind":"method","lang":"ruby","doc":"Calculate the dynamic width of the terminal","code":"def dynamic_width\n @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":31,"symbol":"dynamic_width_stty","kind":"method","lang":"ruby","code":"def dynamic_width_stty\n `stty size 2>/dev/null`.split[1].to_i\n end"}
{"repo":"thor","file":"lib/thor/shell/terminal.rb","line":35,"symbol":"dynamic_width_tput","kind":"method","lang":"ruby","code":"def dynamic_width_tput\n `tput cols 2>/dev/null`.to_i\n end"}
{"repo":"thor","file":"lib/thor/shell/wrapped_printer.rb","line":4,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Shell\n class WrappedPrinter < ColumnPrinter\n def print(message)\n width = Terminal.terminal_width - @indent\n paras = message.split(\"\\n\\n\")\n\n paras.map! do |unwrapped|\n words = unwrapped.split(\" \")\n counter = words.first.length\n words.inject do |memo, word|\n word = word.gsub(/\\n\\005/, \"\\n\").gsub(/\\005/, \"\\n\")\n counter = 0 if word.include? \"\\n\"\n if (counter + word.length + 1) < width\n memo = \"#{memo} #{word}\"\n counter += (word.length + 1)\n else\n memo = \"#{memo}\\n#{word}\"\n counter = word.length\n end\n memo\n end\n end.compact!\n\n paras.each do |para|\n para.split(\"\\n\").each do |line|\n stdout.puts line.insert(0, \" \" * @indent)\n end\n stdout.puts unless para == paras.last\n end\n end\n end\n end\nend"}
{"repo":"thor","file":"lib/thor/shell/wrapped_printer.rb","line":5,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n class WrappedPrinter < ColumnPrinter\n def print(message)\n width = Terminal.terminal_width - @indent\n paras = message.split(\"\\n\\n\")\n\n paras.map! do |unwrapped|\n words = unwrapped.split(\" \")\n counter = words.first.length\n words.inject do |memo, word|\n word = word.gsub(/\\n\\005/, \"\\n\").gsub(/\\005/, \"\\n\")\n counter = 0 if word.include? \"\\n\"\n if (counter + word.length + 1) < width\n memo = \"#{memo} #{word}\"\n counter += (word.length + 1)\n else\n memo = \"#{memo}\\n#{word}\"\n counter = word.length\n end\n memo\n end\n end.compact!\n\n paras.each do |para|\n para.split(\"\\n\").each do |line|\n stdout.puts line.insert(0, \" \" * @indent)\n end\n stdout.puts unless para == paras.last\n end\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/wrapped_printer.rb","line":6,"symbol":"WrappedPrinter","kind":"class","lang":"ruby","code":"class WrappedPrinter < ColumnPrinter\n def print(message)\n width = Terminal.terminal_width - @indent\n paras = message.split(\"\\n\\n\")\n\n paras.map! do |unwrapped|\n words = unwrapped.split(\" \")\n counter = words.first.length\n words.inject do |memo, word|\n word = word.gsub(/\\n\\005/, \"\\n\").gsub(/\\005/, \"\\n\")\n counter = 0 if word.include? \"\\n\"\n if (counter + word.length + 1) < width\n memo = \"#{memo} #{word}\"\n counter += (word.length + 1)\n else\n memo = \"#{memo}\\n#{word}\"\n counter = word.length\n end\n memo\n end\n end.compact!\n\n paras.each do |para|\n para.split(\"\\n\").each do |line|\n stdout.puts line.insert(0, \" \" * @indent)\n end\n stdout.puts unless para == paras.last\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell/wrapped_printer.rb","line":7,"symbol":"print","kind":"method","lang":"ruby","code":"def print(message)\n width = Terminal.terminal_width - @indent\n paras = message.split(\"\\n\\n\")\n\n paras.map! do |unwrapped|\n words = unwrapped.split(\" \")\n counter = words.first.length\n words.inject do |memo, word|\n word = word.gsub(/\\n\\005/, \"\\n\").gsub(/\\005/, \"\\n\")\n counter = 0 if word.include? \"\\n\"\n if (counter + word.length + 1) < width\n memo = \"#{memo} #{word}\"\n counter += (word.length + 1)\n else\n memo = \"#{memo}\\n#{word}\"\n counter = word.length\n end\n memo\n end\n end.compact!\n\n paras.each do |para|\n para.split(\"\\n\").each do |line|\n stdout.puts line.insert(0, \" \" * @indent)\n end\n stdout.puts unless para == paras.last\n end\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Base\n class << self\n attr_writer :shell\n\n # Returns the shell used in all Thor classes. If you are in a Unix platform\n # it will use a colored log, otherwise it will use a basic one without color.\n #\n def shell\n @shell ||= if ENV[\"THOR_SHELL\"] && !ENV[\"THOR_SHELL\"].empty?\n Thor::Shell.const_get(ENV[\"THOR_SHELL\"])\n elsif RbConfig::CONFIG[\"host_os\"] =~ /mswin|mingw/ && !ENV[\"ANSICON\"]\n Thor::Shell::Basic\n else\n Thor::Shell::Color\n end\n end\n end\n end\n\n module Shell\n SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]\n attr_writer :shell\n\n autoload :Basic, File.expand_path(\"shell/basic\", __dir__)\n autoload :Color, File.expand_path(\"shell/color\", __dir__)\n autoload :HTML, File.expand_path(\"shell/html\", __dir__)\n\n # Add shell to initialize config values.\n #\n # ==== Configuration\n # shell<Object>:: An instance of the shell to be used.\n #\n # ==== Examples\n #\n # class MyScript < Thor\n # argument :first, :t"}
{"repo":"thor","file":"lib/thor/shell.rb","line":4,"symbol":"Base","kind":"module","lang":"ruby","code":"module Base\n class << self\n attr_writer :shell\n\n # Returns the shell used in all Thor classes. If you are in a Unix platform\n # it will use a colored log, otherwise it will use a basic one without color.\n #\n def shell\n @shell ||= if ENV[\"THOR_SHELL\"] && !ENV[\"THOR_SHELL\"].empty?\n Thor::Shell.const_get(ENV[\"THOR_SHELL\"])\n elsif RbConfig::CONFIG[\"host_os\"] =~ /mswin|mingw/ && !ENV[\"ANSICON\"]\n Thor::Shell::Basic\n else\n Thor::Shell::Color\n end\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":11,"symbol":"shell","kind":"method","lang":"ruby","doc":"Returns the shell used in all Thor classes. If you are in a Unix platform it will use a colored log, otherwise it will use a basic one without color.","code":"def shell\n @shell ||= if ENV[\"THOR_SHELL\"] && !ENV[\"THOR_SHELL\"].empty?\n Thor::Shell.const_get(ENV[\"THOR_SHELL\"])\n elsif RbConfig::CONFIG[\"host_os\"] =~ /mswin|mingw/ && !ENV[\"ANSICON\"]\n Thor::Shell::Basic\n else\n Thor::Shell::Color\n end\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":23,"symbol":"Shell","kind":"module","lang":"ruby","code":"module Shell\n SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]\n attr_writer :shell\n\n autoload :Basic, File.expand_path(\"shell/basic\", __dir__)\n autoload :Color, File.expand_path(\"shell/color\", __dir__)\n autoload :HTML, File.expand_path(\"shell/html\", __dir__)\n\n # Add shell to initialize config values.\n #\n # ==== Configuration\n # shell<Object>:: An instance of the shell to be used.\n #\n # ==== Examples\n #\n # class MyScript < Thor\n # argument :first, :type => :numeric\n # end\n #\n # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new\n #\n def initialize(args = [], options = {}, config = {})\n super\n self.shell = config[:shell]\n shell.base ||= self if shell.respond_to?(:base)\n end\n\n # Holds the shell for the given Thor instance. If no shell is given,\n # it gets a default shell from Thor::Base.shell.\n def shell\n @shell ||= Thor::Base.shell.new\n end\n\n # Common methods that are delegated to the shell.\n SHELL_DELEGATED_METHODS.each do |meth"}
{"repo":"thor","file":"lib/thor/shell.rb","line":44,"symbol":"initialize","kind":"method","lang":"ruby","doc":"class MyScript < Thor argument :first, :type => :numeric end MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new","code":"def initialize(args = [], options = {}, config = {})\n super\n self.shell = config[:shell]\n shell.base ||= self if shell.respond_to?(:base)\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":52,"symbol":"shell","kind":"method","lang":"ruby","doc":"Holds the shell for the given Thor instance. If no shell is given, it gets a default shell from Thor::Base.shell.","code":"def shell\n @shell ||= Thor::Base.shell.new\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":66,"symbol":"with_padding","kind":"method","lang":"ruby","doc":"Yields the given block with padding.","code":"def with_padding\n shell.padding += 1\n yield\n ensure\n shell.padding -= 1\n end"}
{"repo":"thor","file":"lib/thor/shell.rb","line":77,"symbol":"_shared_configuration","kind":"method","lang":"ruby","doc":"Allow shell to be shared between invocations.","code":"def _shared_configuration #:nodoc:\n super.merge!(shell: shell)\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n module Sandbox #:nodoc:\n end\n\n # This module holds several utilities:\n #\n # 1) Methods to convert thor namespaces to constants and vice-versa.\n #\n # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> \"foo:bar:baz\"\n #\n # 2) Loading thor files and sandboxing:\n #\n # Thor::Util.load_thorfile(\"~/.thor/foo\")\n #\n module Util\n class << self\n # Receives a namespace and search for it in the Thor::Base subclasses.\n #\n # ==== Parameters\n # namespace<String>:: The namespace to search for.\n #\n def find_by_namespace(namespace)\n namespace = \"default#{namespace}\" if namespace.empty? || namespace =~ /^:/\n Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }\n end\n\n # Receives a constant and converts it to a Thor namespace. Since Thor\n # commands can be added to a sandbox, this method is also responsible for\n # removing the sandbox namespace.\n #\n # This method should not be used in general because it's used to deal with\n # older versions of Thor. On current versions, if you need to get the\n # namespace from a class, just call namespace on it.\n #\n # ==== Pa"}
{"repo":"thor","file":"lib/thor/util.rb","line":4,"symbol":"Sandbox","kind":"module","lang":"ruby","code":"module Sandbox #:nodoc:\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":17,"symbol":"Util","kind":"module","lang":"ruby","doc":"Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> \"foo:bar:baz\" 2) Loading thor files and sandboxing: Thor::Util.load_thorfile(\"~/.thor/foo\")","code":"module Util\n class << self\n # Receives a namespace and search for it in the Thor::Base subclasses.\n #\n # ==== Parameters\n # namespace<String>:: The namespace to search for.\n #\n def find_by_namespace(namespace)\n namespace = \"default#{namespace}\" if namespace.empty? || namespace =~ /^:/\n Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }\n end\n\n # Receives a constant and converts it to a Thor namespace. Since Thor\n # commands can be added to a sandbox, this method is also responsible for\n # removing the sandbox namespace.\n #\n # This method should not be used in general because it's used to deal with\n # older versions of Thor. On current versions, if you need to get the\n # namespace from a class, just call namespace on it.\n #\n # ==== Parameters\n # constant<Object>:: The constant to be converted to the thor path.\n #\n # ==== Returns\n # String:: If we receive Foo::Bar::Baz it returns \"foo:bar:baz\"\n #\n def namespace_from_thor_class(constant)\n constant = constant.to_s.gsub(/^Thor::Sandbox::/, \"\")\n constant = snake_case(constant).sque"}
{"repo":"thor","file":"lib/thor/util.rb","line":24,"symbol":"find_by_namespace","kind":"method","lang":"ruby","doc":"Receives a namespace and search for it in the Thor::Base subclasses. ==== Parameters namespace<String>:: The namespace to search for.","code":"def find_by_namespace(namespace)\n namespace = \"default#{namespace}\" if namespace.empty? || namespace =~ /^:/\n Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":43,"symbol":"namespace_from_thor_class","kind":"method","lang":"ruby","doc":"==== Parameters constant<Object>:: The constant to be converted to the thor path. ==== Returns String:: If we receive Foo::Bar::Baz it returns \"foo:bar:baz\"","code":"def namespace_from_thor_class(constant)\n constant = constant.to_s.gsub(/^Thor::Sandbox::/, \"\")\n constant = snake_case(constant).squeeze(\":\")\n constant\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":58,"symbol":"namespaces_in_content","kind":"method","lang":"ruby","doc":"==== Parameters contents<String> ==== Returns Array[Object]","code":"def namespaces_in_content(contents, file = __FILE__)\n old_constants = Thor::Base.subclasses.dup\n Thor::Base.subclasses.clear\n\n load_thorfile(file, contents)\n\n new_constants = Thor::Base.subclasses.dup\n Thor::Base.subclasses.replace(old_constants)\n\n new_constants.map!(&:namespace)\n new_constants.compact!\n new_constants\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":74,"symbol":"thor_classes_in","kind":"method","lang":"ruby","doc":"Returns the thor classes declared inside the given class.","code":"def thor_classes_in(klass)\n stringfied_constants = klass.constants.map(&:to_s)\n Thor::Base.subclasses.select do |subclass|\n next unless subclass.name\n stringfied_constants.include?(subclass.name.gsub(\"#{klass.name}::\", \"\"))\n end\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":90,"symbol":"snake_case","kind":"method","lang":"ruby","doc":"==== Parameters String ==== Returns String","code":"def snake_case(str)\n return str.downcase if str =~ /^[A-Z_]+$/\n str.gsub(/\\B[A-Z]/, '_\\&').squeeze(\"_\") =~ /_*(.*)/\n Regexp.last_match(-1).downcase\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":104,"symbol":"camel_case","kind":"method","lang":"ruby","doc":"==== Parameters String ==== Returns String","code":"def camel_case(str)\n return str if str !~ /_/ && str =~ /[A-Z]+.*/\n str.split(\"_\").map(&:capitalize).join\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":131,"symbol":"find_class_and_command_by_namespace","kind":"method","lang":"ruby","doc":"Thor::Util.namespace_to_thor_class(\"baz:foo\") #=> Baz::Foo, nil Thor::Util.namespace_to_thor_class(\"foo:bar:baz\") #=> Foo::Bar, \"baz\" ==== Parameters namespace<String>","code":"def find_class_and_command_by_namespace(namespace, fallback = true)\n if namespace.include?(\":\") # look for a namespaced command\n *pieces, command = namespace.split(\":\")\n namespace = pieces.join(\":\")\n namespace = \"default\" if namespace.empty?\n klass = Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.command_exists?(command) }\n end\n unless klass # look for a Thor::Group with the right name\n klass = Thor::Util.find_by_namespace(namespace)\n command = nil\n end\n if !klass && fallback # try a command in the default namespace\n command = namespace\n klass = Thor::Util.find_by_namespace(\"\")\n end\n [klass, command]\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":153,"symbol":"load_thorfile","kind":"method","lang":"ruby","doc":"Receives a path and load the thor file in the path. The file is evaluated inside the sandbox to avoid namespacing conflicts.","code":"def load_thorfile(path, content = nil, debug = false)\n content ||= File.read(path)\n\n begin\n Thor::Sandbox.class_eval(content, path)\n rescue StandardError => e\n $stderr.puts(\"WARNING: unable to load thorfile #{path.inspect}: #{e.message}\")\n if debug\n $stderr.puts(*e.backtrace)\n else\n $stderr.puts(e.backtrace.first)\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":168,"symbol":"user_home","kind":"method","lang":"ruby","code":"def user_home\n @@user_home ||= if ENV[\"HOME\"]\n ENV[\"HOME\"]\n elsif ENV[\"USERPROFILE\"]\n ENV[\"USERPROFILE\"]\n elsif ENV[\"HOMEDRIVE\"] && ENV[\"HOMEPATH\"]\n File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"])\n elsif ENV[\"APPDATA\"]\n ENV[\"APPDATA\"]\n else\n begin\n File.expand_path(\"~\")\n rescue\n if File::ALT_SEPARATOR\n \"C:/\"\n else\n \"/\"\n end\n end\n end\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":192,"symbol":"thor_root","kind":"method","lang":"ruby","doc":"Returns the root where thor files are located, depending on the OS.","code":"def thor_root\n File.join(user_home, \".thor\").tr(\"\\\\\", \"/\")\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":203,"symbol":"thor_root_glob","kind":"method","lang":"ruby","doc":"like this: C:\\Documents and Settings\\james\\.thor If we don't #gsub the \\ character, Dir.glob will fail.","code":"def thor_root_glob\n files = Dir[\"#{escape_globs(thor_root)}/*\"]\n\n files.map! do |file|\n File.directory?(file) ? File.join(file, \"main.thor\") : file\n end\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":213,"symbol":"globs_for","kind":"method","lang":"ruby","doc":"Where to look for Thor files.","code":"def globs_for(path)\n path = escape_globs(path)\n [\"#{path}/Thorfile\", \"#{path}/*.thor\", \"#{path}/tasks/*.thor\", \"#{path}/lib/tasks/**/*.thor\"]\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":221,"symbol":"ruby_command","kind":"method","lang":"ruby","doc":"Return the path to the ruby interpreter taking into account multiple installations and windows extensions.","code":"def ruby_command\n @ruby_command ||= begin\n ruby_name = RbConfig::CONFIG[\"ruby_install_name\"]\n ruby = File.join(RbConfig::CONFIG[\"bindir\"], ruby_name)\n ruby << RbConfig::CONFIG[\"EXEEXT\"]\n\n # avoid using different name than ruby (on platforms supporting links)\n if ruby_name != \"ruby\" && File.respond_to?(:readlink)\n begin\n alternate_ruby = File.join(RbConfig::CONFIG[\"bindir\"], \"ruby\")\n alternate_ruby << RbConfig::CONFIG[\"EXEEXT\"]\n\n # ruby is a symlink\n if File.symlink? alternate_ruby\n linked_ruby = File.readlink alternate_ruby\n\n # symlink points to 'ruby_install_name'\n ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby\n end\n rescue NotImplementedError # rubocop:disable Lint/HandleExceptions\n # just ignore on windows\n end\n end\n\n # escape string in case path to ruby executable contain spaces.\n ruby.sub!(/.*\\s.*/m, '\"\\&\"')\n ruby\n end\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":264,"symbol":"escape_globs","kind":"method","lang":"ruby","doc":"==== Parameters String ==== Returns String","code":"def escape_globs(path)\n path.to_s.gsub(/[*?{}\\[\\]]/, '\\\\\\\\\\\\&')\n end"}
{"repo":"thor","file":"lib/thor/util.rb","line":280,"symbol":"escape_html","kind":"method","lang":"ruby","doc":"==== Parameters String ==== Returns String","code":"def escape_html(string)\n CGI.escapeHTML(string)\n end"}
{"repo":"thor","file":"lib/thor/version.rb","line":1,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n VERSION = \"1.5.0\"\nend"}
{"repo":"thor","file":"lib/thor.rb","line":3,"symbol":"Thor","kind":"class","lang":"ruby","code":"class Thor\n $thor_runner ||= false\n class << self\n # Allows for custom \"Command\" package naming.\n #\n # === Parameters\n # name<String>\n # options<Hash>\n #\n def package_name(name, _ = {})\n @package_name = name.nil? || name == \"\" ? nil : name\n end\n\n # Sets the default command when thor is executed without an explicit command to be called.\n #\n # ==== Parameters\n # meth<Symbol>:: name of the default command\n #\n def default_command(meth = nil)\n if meth\n @default_command = meth == :none ? \"help\" : meth.to_s\n else\n @default_command ||= from_superclass(:default_command, \"help\")\n end\n end\n alias_method :default_task, :default_command\n\n # Registers another Thor subclass as a command.\n #\n # ==== Parameters\n # klass<Class>:: Thor subclass to register\n # command<String>:: Subcommand name to use\n # usage<String>:: Short usage for the subcommand\n # description<String>:: Description for the subcommand\n def register(klass, subcommand_name, usage, description, options = {})\n if klass <= Thor::Group\n desc usage, description, options\n define_method(subcommand_name) { |*args| in"}
{"repo":"thor","file":"lib/thor.rb","line":12,"symbol":"package_name","kind":"method","lang":"ruby","doc":"Allows for custom \"Command\" package naming. === Parameters name<String> options<Hash>","code":"def package_name(name, _ = {})\n @package_name = name.nil? || name == \"\" ? nil : name\n end"}
{"repo":"thor","file":"lib/thor.rb","line":21,"symbol":"default_command","kind":"method","lang":"ruby","doc":"Sets the default command when thor is executed without an explicit command to be called. ==== Parameters meth<Symbol>:: name of the default command","code":"def default_command(meth = nil)\n if meth\n @default_command = meth == :none ? \"help\" : meth.to_s\n else\n @default_command ||= from_superclass(:default_command, \"help\")\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":37,"symbol":"register","kind":"method","lang":"ruby","doc":"==== Parameters klass<Class>:: Thor subclass to register command<String>:: Subcommand name to use usage<String>:: Short usage for the subcommand description<String>:: Description for the subcommand","code":"def register(klass, subcommand_name, usage, description, options = {})\n if klass <= Thor::Group\n desc usage, description, options\n define_method(subcommand_name) { |*args| invoke(klass, args) }\n else\n desc usage, description, options\n subcommand subcommand_name, klass\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":54,"symbol":"desc","kind":"method","lang":"ruby","doc":"==== Parameters usage<String> description<String> options<String>","code":"def desc(usage, description, options = {})\n if options[:for]\n command = find_and_refresh_command(options[:for])\n command.usage = usage if usage\n command.description = description if description\n else\n @usage = usage\n @desc = description\n @hide = options[:hide] || false\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":78,"symbol":"long_desc","kind":"method","lang":"ruby","doc":"long_desc 'your very long description', wrap: false ==== Parameters long description<String> options<Hash>","code":"def long_desc(long_description, options = {})\n if options[:for]\n command = find_and_refresh_command(options[:for])\n command.long_description = long_description if long_description\n else\n @long_desc = long_description\n @long_desc_wrap = options[:wrap] != false\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":101,"symbol":"map","kind":"method","lang":"ruby","doc":"Will invoke the list command. ==== Parameters Hash[String|Array => Symbol]:: Maps the string or the strings in the array to the given command.","code":"def map(mappings = nil, **kw)\n @map ||= from_superclass(:map, {})\n\n if mappings && !kw.empty?\n mappings = kw.merge!(mappings)\n else\n mappings ||= kw\n end\n if mappings\n mappings.each do |key, value|\n if key.respond_to?(:each)\n key.each { |subkey| @map[subkey] = value }\n else\n @map[key] = value\n end\n end\n end\n\n @map\n end"}
{"repo":"thor","file":"lib/thor.rb","line":129,"symbol":"method_options","kind":"method","lang":"ruby","doc":"==== Parameters Hash[Symbol => Object]:: The hash key is the name of the option and the value is the type of the option. Can be :string, :array, :hash, :boolean, :numeric or :required (string). If you give a value, the type of the value is used.","code":"def method_options(options = nil)\n @method_options ||= {}\n build_options(options, @method_options) if options\n @method_options\n end"}
{"repo":"thor","file":"lib/thor.rb","line":163,"symbol":"method_option","kind":"method","lang":"ruby","doc":":default - Default value for this argument. It cannot be required and have default values. :aliases - Aliases for this option. :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean. :banner - String to show on usage notes. :hide - If you want to hide this option from the help.","code":"def method_option(name, options = {})\n unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }\n raise ArgumentError, \"Expected a Symbol or String, got #{name.inspect}\"\n end\n scope = if options[:for]\n find_and_refresh_command(options[:for]).options\n else\n method_options\n end\n\n build_option(name, options, scope)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":203,"symbol":"method_exclusive","kind":"method","lang":"ruby","doc":"option :two exclusive :one, :two If you give \"--one\" and \"--two\" at the same time ExclusiveArgumentsError will be raised.","code":"def method_exclusive(*args, &block)\n register_options_relation_for(:method_options,\n :method_exclusive_option_names, *args, &block)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":246,"symbol":"method_at_least_one","kind":"method","lang":"ruby","doc":"option :two end end Then it is required either only one of \"--one\" or \"--two\".","code":"def method_at_least_one(*args, &block)\n register_options_relation_for(:method_options,\n :method_at_least_one_option_names, *args, &block)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":258,"symbol":"command_help","kind":"method","lang":"ruby","doc":"Prints help information for the given command. ==== Parameters shell<Thor::Shell> command_name<String>","code":"def command_help(shell, command_name)\n meth = normalize_command_name(command_name)\n command = all_commands[meth]\n handle_no_command_error(meth) unless command\n\n shell.say \"Usage:\"\n shell.say \" #{banner(command).split(\"\\n\").join(\"\\n \")}\"\n shell.say\n class_options_help(shell, nil => command.options.values)\n print_exclusive_options(shell, command)\n print_at_least_one_required_options(shell, command)\n\n if command.long_description\n shell.say \"Description:\"\n if command.wrap_long_description\n shell.print_wrapped(command.long_description, indent: 2)\n else\n shell.say command.long_description\n end\n else\n shell.say command.description\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":288,"symbol":"help","kind":"method","lang":"ruby","doc":"Prints help information for this class. ==== Parameters shell<Thor::Shell>","code":"def help(shell, subcommand = false)\n list = printable_commands(true, subcommand)\n Thor::Util.thor_classes_in(self).each do |klass|\n list += klass.printable_commands(false)\n end\n sort_commands!(list)\n\n if defined?(@package_name) && @package_name\n shell.say \"#{@package_name} commands:\"\n else\n shell.say \"Commands:\"\n end\n\n shell.print_table(list, indent: 2, truncate: true)\n shell.say\n class_options_help(shell)\n print_exclusive_options(shell)\n print_at_least_one_required_options(shell)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":309,"symbol":"printable_commands","kind":"method","lang":"ruby","doc":"Returns commands ready to be printed.","code":"def printable_commands(all = true, subcommand = false)\n (all ? all_commands : commands).map do |_, command|\n next if command.hidden?\n item = []\n item << banner(command, false, subcommand)\n item << (command.description ? \"# #{command.description.gsub(/\\s+/m, ' ')}\" : \"\")\n item\n end.compact\n end"}
{"repo":"thor","file":"lib/thor.rb","line":320,"symbol":"subcommands","kind":"method","lang":"ruby","code":"def subcommands\n @subcommands ||= from_superclass(:subcommands, [])\n end"}
{"repo":"thor","file":"lib/thor.rb","line":325,"symbol":"subcommand_classes","kind":"method","lang":"ruby","code":"def subcommand_classes\n @subcommand_classes ||= {}\n end"}
{"repo":"thor","file":"lib/thor.rb","line":329,"symbol":"subcommand","kind":"method","lang":"ruby","code":"def subcommand(subcommand, subcommand_class)\n subcommands << subcommand.to_s\n subcommand_class.subcommand_help subcommand\n subcommand_classes[subcommand.to_s] = subcommand_class\n\n define_method(subcommand) do |*args|\n args, opts = Thor::Arguments.split(args)\n invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]\n invoke_args.unshift \"help\" if opts.delete(\"--help\") || opts.delete(\"-h\")\n invoke subcommand_class, *invoke_args\n end\n subcommand_class.commands.each do |_meth, command|\n command.ancestor_name = subcommand\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":350,"symbol":"check_unknown_options!","kind":"method","lang":"ruby","doc":"Extend check unknown options to accept a hash of conditions. === Parameters options<Hash>: A hash containing :only and/or :except keys","code":"def check_unknown_options!(options = {})\n @check_unknown_options ||= {}\n options.each do |key, value|\n if value\n @check_unknown_options[key] = Array(value)\n else\n @check_unknown_options.delete(key)\n end\n end\n @check_unknown_options\n end"}
{"repo":"thor","file":"lib/thor.rb","line":363,"symbol":"check_unknown_options?","kind":"method","lang":"ruby","doc":"Overwrite check_unknown_options? to take subcommands and options into account.","code":"def check_unknown_options?(config) #:nodoc:\n options = check_unknown_options\n return false unless options\n\n command = config[:current_command]\n return true unless command\n\n name = command.name\n\n if subcommands.include?(name)\n false\n elsif options[:except]\n !options[:except].include?(name.to_sym)\n elsif options[:only]\n options[:only].include?(name.to_sym)\n else\n true\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":420,"symbol":"stop_on_unknown_option!","kind":"method","lang":"ruby","doc":"$ thor exec echo --verbose foo --verbose foo ==== Parameters Symbol ...:: A list of commands that should be affected.","code":"def stop_on_unknown_option!(*command_names)\n @stop_on_unknown_option = stop_on_unknown_option | command_names\n end"}
{"repo":"thor","file":"lib/thor.rb","line":424,"symbol":"stop_on_unknown_option?","kind":"method","lang":"ruby","code":"def stop_on_unknown_option?(command) #:nodoc:\n command && stop_on_unknown_option.include?(command.name.to_sym)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":434,"symbol":"disable_required_check!","kind":"method","lang":"ruby","doc":"Disable the check for required options for the given commands. This is useful if you have a command that does not need the required options to work, like help. ==== Parameters Symbol ...:: A list of commands that should be affected.","code":"def disable_required_check!(*command_names)\n @disable_required_check = disable_required_check | command_names\n end"}
{"repo":"thor","file":"lib/thor.rb","line":438,"symbol":"disable_required_check?","kind":"method","lang":"ruby","code":"def disable_required_check?(command) #:nodoc:\n command && disable_required_check.include?(command.name.to_sym)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":449,"symbol":"command_exists?","kind":"method","lang":"ruby","doc":"==== Parameters command_name<String>:: The name of the command to check for existence. ==== Returns Boolean:: +true+ if the command exists, +false+ otherwise.","code":"def command_exists?(command_name) #:nodoc:\n commands.keys.include?(normalize_command_name(command_name))\n end"}
{"repo":"thor","file":"lib/thor.rb","line":460,"symbol":"method_exclusive_option_names","kind":"method","lang":"ruby","doc":"Returns this class exclusive options array set. ==== Returns Array[Array[Thor::Option.name]]","code":"def method_exclusive_option_names #:nodoc:\n @method_exclusive_option_names ||= []\n end"}
{"repo":"thor","file":"lib/thor.rb","line":469,"symbol":"method_at_least_one_option_names","kind":"method","lang":"ruby","doc":"Returns this class at least one of required options array set. ==== Returns Array[Array[Thor::Option.name]]","code":"def method_at_least_one_option_names #:nodoc:\n @method_at_least_one_option_names ||= []\n end"}
{"repo":"thor","file":"lib/thor.rb","line":473,"symbol":"stop_on_unknown_option","kind":"method","lang":"ruby","code":"def stop_on_unknown_option #:nodoc:\n @stop_on_unknown_option ||= []\n end"}
{"repo":"thor","file":"lib/thor.rb","line":478,"symbol":"disable_required_check","kind":"method","lang":"ruby","doc":"help command has the required check disabled by default.","code":"def disable_required_check #:nodoc:\n @disable_required_check ||= [:help]\n end"}
{"repo":"thor","file":"lib/thor.rb","line":482,"symbol":"print_exclusive_options","kind":"method","lang":"ruby","code":"def print_exclusive_options(shell, command = nil) # :nodoc:\n opts = []\n opts = command.method_exclusive_option_names unless command.nil?\n opts += class_exclusive_option_names\n unless opts.empty?\n shell.say \"Exclusive Options:\"\n shell.print_table(opts.map{ |ex| ex.map{ |e| \"--#{e}\"}}, indent: 2 )\n shell.say\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":493,"symbol":"print_at_least_one_required_options","kind":"method","lang":"ruby","code":"def print_at_least_one_required_options(shell, command = nil) # :nodoc:\n opts = []\n opts = command.method_at_least_one_option_names unless command.nil?\n opts += class_at_least_one_option_names\n unless opts.empty?\n shell.say \"Required At Least One:\"\n shell.print_table(opts.map{ |ex| ex.map{ |e| \"--#{e}\"}}, indent: 2 )\n shell.say\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":505,"symbol":"dispatch","kind":"method","lang":"ruby","doc":"The method responsible for dispatching given the args.","code":"def dispatch(meth, given_args, given_opts, config) #:nodoc:\n meth ||= retrieve_command_name(given_args)\n command = all_commands[normalize_command_name(meth)]\n\n if !command && config[:invoked_via_subcommand]\n # We're a subcommand and our first argument didn't match any of our\n # commands. So we put it back and call our default command.\n given_args.unshift(meth)\n command = all_commands[normalize_command_name(default_command)]\n end\n\n if command\n args, opts = Thor::Options.split(given_args)\n if stop_on_unknown_option?(command) && !args.empty?\n # given_args starts with a non-option, so we treat everything as\n # ordinary arguments\n args.concat opts\n opts.clear\n end\n else\n args = given_args\n opts = nil\n command = dynamic_command_class.new(meth)\n end\n\n opts = given_opts || opts || []\n config[:current_command] = command\n config[:command_options] = command.options\n\n instance = new(args, opts, config)\n yield instance if block_given?\n args = instance.args\n trailing = args[Range.new(arguments.size, -1)]\n instance.inv"}
{"repo":"thor","file":"lib/thor.rb","line":546,"symbol":"banner","kind":"method","lang":"ruby","doc":"The banner for this class. You can customize it if you are invoking the thor class by another ways which is not the Thor::Runner. It receives the command that is going to be invoked and a boolean which indicates if the namespace should be displayed as arguments.","code":"def banner(command, namespace = nil, subcommand = false)\n command.formatted_usage(self, $thor_runner, subcommand).split(\"\\n\").map do |formatted_usage|\n \"#{basename} #{formatted_usage}\"\n end.join(\"\\n\")\n end"}
{"repo":"thor","file":"lib/thor.rb","line":552,"symbol":"baseclass","kind":"method","lang":"ruby","code":"def baseclass #:nodoc:\n Thor\n end"}
{"repo":"thor","file":"lib/thor.rb","line":556,"symbol":"dynamic_command_class","kind":"method","lang":"ruby","code":"def dynamic_command_class #:nodoc:\n Thor::DynamicCommand\n end"}
{"repo":"thor","file":"lib/thor.rb","line":560,"symbol":"create_command","kind":"method","lang":"ruby","code":"def create_command(meth) #:nodoc:\n @usage ||= nil\n @desc ||= nil\n @long_desc ||= nil\n @long_desc_wrap ||= nil\n @hide ||= nil\n\n if @usage && @desc\n base_class = @hide ? Thor::HiddenCommand : Thor::Command\n relations = {exclusive_option_names: method_exclusive_option_names,\n at_least_one_option_names: method_at_least_one_option_names}\n commands[meth] = base_class.new(meth, @desc, @long_desc, @long_desc_wrap, @usage, method_options, relations)\n @usage, @desc, @long_desc, @long_desc_wrap, @method_options, @hide = nil\n @method_exclusive_option_names, @method_at_least_one_option_names = nil\n true\n elsif all_commands[meth] || meth == \"method_missing\"\n true\n else\n caller_line = caller[1]\n unless defined_in_gem?(caller_line)\n puts \"[WARNING] Attempted to create command #{meth.inspect} without usage or description. \" \\\n \"Call desc if you want this method to be available as command or declare it inside a \" \\\n \"no_commands{} block. Invoked from #{caller_line.inspect}.\"\n end\n false\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":589,"symbol":"defined_in_gem?","kind":"method","lang":"ruby","code":"def defined_in_gem?(caller_line) #:nodoc:\n return false unless caller_line\n Gem.path.any? { |path| caller_line.include?(path) }\n end"}
{"repo":"thor","file":"lib/thor.rb","line":594,"symbol":"initialize_added","kind":"method","lang":"ruby","code":"def initialize_added #:nodoc:\n class_options.merge!(method_options)\n @method_options = nil\n end"}
{"repo":"thor","file":"lib/thor.rb","line":600,"symbol":"retrieve_command_name","kind":"method","lang":"ruby","doc":"Retrieve the command name from given args.","code":"def retrieve_command_name(args) #:nodoc:\n meth = args.first.to_s unless args.empty?\n args.shift if meth && (map[meth] || meth !~ /^\\-/)\n end"}
{"repo":"thor","file":"lib/thor.rb","line":613,"symbol":"normalize_command_name","kind":"method","lang":"ruby","doc":"the commands hash. In addition to normalizing aliases, this logic will determine if a shortened command is an unambiguous substring of a command or alias. +normalize_command_name+ also converts names like +animal-prison+ into +animal_prison+.","code":"def normalize_command_name(meth) #:nodoc:\n return default_command.to_s.tr(\"-\", \"_\") unless meth\n\n possibilities = find_command_possibilities(meth)\n raise AmbiguousTaskError, \"Ambiguous command #{meth} matches [#{possibilities.join(', ')}]\" if possibilities.size > 1\n\n if possibilities.empty?\n meth ||= default_command\n elsif map[meth]\n meth = map[meth]\n else\n meth = possibilities.first\n end\n\n meth.to_s.tr(\"-\", \"_\") # treat foo-bar as foo_bar\n end"}
{"repo":"thor","file":"lib/thor.rb","line":634,"symbol":"find_command_possibilities","kind":"method","lang":"ruby","doc":"this is the logic that takes the command name passed in by the user and determines whether it is an unambiguous substrings of a command or alias name.","code":"def find_command_possibilities(meth)\n len = meth.to_s.length\n possibilities = all_commands.reject {|k, v| v.is_a?(HiddenCommand) }.merge(map).keys.select { |n| meth == n[0, len] }.sort\n unique_possibilities = possibilities.map { |k| map[k] || k }.uniq\n\n if possibilities.include?(meth)\n [meth]\n elsif unique_possibilities.size == 1\n unique_possibilities\n else\n possibilities\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":649,"symbol":"subcommand_help","kind":"method","lang":"ruby","code":"def subcommand_help(cmd)\n desc \"help [COMMAND]\", \"Describe subcommands or one specific subcommand\"\n class_eval \"\n def help(command = nil, subcommand = true); super; end\n\"\n end"}
{"repo":"thor","file":"lib/thor.rb","line":661,"symbol":"sort_commands!","kind":"method","lang":"ruby","doc":"Sort the commands, lexicographically by default. Can be overridden in the subclass to change the display order of the commands.","code":"def sort_commands!(list)\n list.sort! { |a, b| a[0] <=> b[0] }\n end"}
{"repo":"thor","file":"lib/thor.rb","line":671,"symbol":"help","kind":"method","lang":"ruby","code":"def help(command = nil, subcommand = false)\n if command\n if self.class.subcommands.include? command\n self.class.subcommand_classes[command].help(shell, true)\n else\n self.class.command_help(shell, command)\n end\n else\n self.class.help(shell, subcommand)\n end\n end"}
{"repo":"thor","file":"lib/thor.rb","line":686,"symbol":"tree","kind":"method","lang":"ruby","code":"def tree\n build_command_tree(self.class, \"\")\n end"}
{"repo":"thor","file":"lib/thor.rb","line":692,"symbol":"build_command_tree","kind":"method","lang":"ruby","code":"def build_command_tree(klass, indent)\n # Print current class name if it's not the root Thor class\n unless klass == Thor\n say \"#{indent}#{klass.namespace || 'default'}\", :blue\n indent = \"#{indent} \"\n end\n\n # Print all commands for this class\n visible_commands = klass.commands.reject { |_, cmd| cmd.hidden? || cmd.name == \"help\" }\n commands_count = visible_commands.count\n visible_commands.sort.each_with_index do |(command_name, command), i|\n description = command.description.split(\"\\n\").first || \"\"\n icon = i == (commands_count - 1) ? \"└─\" : \"├─\"\n say \"#{indent}#{icon} \", nil, false\n say command_name, :green, false\n say \" (#{description})\" unless description.empty?\n end\n\n # Print all subcommands (from registered Thor subclasses)\n klass.subcommand_classes.each do |_, subclass|\n build_command_tree(subclass, indent)\n end\n end"}
{"repo":"thor","file":"spec/actions/create_file_spec.rb","line":10,"symbol":"create_file","kind":"method","lang":"ruby","code":"def create_file(destination = nil, config = {}, options = {}, contents = \"CONFIGURATION\")\n @base = MyCounter.new([1, 2], options, destination_root: destination_root)\n allow(@base).to receive(:file_name).and_return(\"rdoc\")\n\n @action = Thor::Actions::CreateFile.new(@base, destination, contents, {verbose: !@silence}.merge(config))\n end"}
{"repo":"thor","file":"spec/actions/create_file_spec.rb","line":17,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n capture(:stdout) { @action.invoke! }\n end"}
{"repo":"thor","file":"spec/actions/create_file_spec.rb","line":21,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n capture(:stdout) { @action.revoke! }\n end"}
{"repo":"thor","file":"spec/actions/create_file_spec.rb","line":25,"symbol":"silence!","kind":"method","lang":"ruby","code":"def silence!\n @silence = true\n end"}
{"repo":"thor","file":"spec/actions/create_link_spec.rb","line":31,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n capture(:stdout) { action.invoke! }\n end"}
{"repo":"thor","file":"spec/actions/create_link_spec.rb","line":35,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n capture(:stdout) { action.revoke! }\n end"}
{"repo":"thor","file":"spec/actions/directory_spec.rb","line":11,"symbol":"invoker","kind":"method","lang":"ruby","code":"def invoker\n @invoker ||= WhinyGenerator.new([1, 2], {}, destination_root: destination_root)\n end"}
{"repo":"thor","file":"spec/actions/directory_spec.rb","line":15,"symbol":"revoker","kind":"method","lang":"ruby","code":"def revoker\n @revoker ||= WhinyGenerator.new([1, 2], {}, destination_root: destination_root, behavior: :revoke)\n end"}
{"repo":"thor","file":"spec/actions/directory_spec.rb","line":19,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!(*args, &block)\n capture(:stdout) { invoker.directory(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/directory_spec.rb","line":23,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!(*args, &block)\n capture(:stdout) { revoker.directory(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/directory_spec.rb","line":27,"symbol":"exists_and_identical?","kind":"method","lang":"ruby","code":"def exists_and_identical?(source_path, destination_path)\n %w(config.rb README).each do |file|\n source = File.join(source_root, source_path, file)\n destination = File.join(destination_root, destination_path, file)\n\n expect(File.exist?(destination)).to be true\n expect(FileUtils.identical?(source, destination)).to be true\n end\n end"}
{"repo":"thor","file":"spec/actions/empty_directory_spec.rb","line":9,"symbol":"empty_directory","kind":"method","lang":"ruby","code":"def empty_directory(destination, options = {})\n @action = Thor::Actions::EmptyDirectory.new(base, destination)\n end"}
{"repo":"thor","file":"spec/actions/empty_directory_spec.rb","line":13,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!\n capture(:stdout) { @action.invoke! }\n end"}
{"repo":"thor","file":"spec/actions/empty_directory_spec.rb","line":17,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!\n capture(:stdout) { @action.revoke! }\n end"}
{"repo":"thor","file":"spec/actions/empty_directory_spec.rb","line":21,"symbol":"base","kind":"method","lang":"ruby","code":"def base\n @base ||= MyCounter.new([1, 2], {}, destination_root: destination_root)\n end"}
{"repo":"thor","file":"spec/actions/empty_directory_spec.rb","line":112,"symbol":"private_file_name","kind":"method","lang":"ruby","code":"def private_file_name\n \"expected\"\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":4,"symbol":"runner","kind":"method","lang":"ruby","code":"def runner(options = {}, behavior = :invoke)\n @runner ||= MyCounter.new([1], options, destination_root: destination_root, behavior: behavior)\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":8,"symbol":"action","kind":"method","lang":"ruby","code":"def action(*args, &block)\n capture(:stdout) { runner.send(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":12,"symbol":"exists_and_identical?","kind":"method","lang":"ruby","code":"def exists_and_identical?(source, destination)\n destination = File.join(destination_root, destination)\n expect(File.exist?(destination)).to be true\n\n source = File.join(source_root, source)\n expect(FileUtils).to be_identical(source, destination)\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":20,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"foo\")\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":304,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"doc\", \"README\")\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":567,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"application.rb\")\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":592,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"application_helper.rb\")\n end"}
{"repo":"thor","file":"spec/actions/file_manipulation_spec.rb","line":622,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"doc\", \"COMMENTER\")\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":11,"symbol":"invoker","kind":"method","lang":"ruby","code":"def invoker(options = {})\n @invoker ||= MyCounter.new([1, 2], options, destination_root: destination_root)\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":15,"symbol":"revoker","kind":"method","lang":"ruby","code":"def revoker\n @revoker ||= MyCounter.new([1, 2], {}, destination_root: destination_root, behavior: :revoke)\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":19,"symbol":"invoke!","kind":"method","lang":"ruby","code":"def invoke!(*args, &block)\n capture(:stdout) { invoker.insert_into_file(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":23,"symbol":"invoke_with_a_bang!","kind":"method","lang":"ruby","code":"def invoke_with_a_bang!(*args, &block)\n capture(:stdout) { invoker.insert_into_file!(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":27,"symbol":"revoke!","kind":"method","lang":"ruby","code":"def revoke!(*args, &block)\n capture(:stdout) { revoker.insert_into_file(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions/inject_into_file_spec.rb","line":31,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"doc/README\")\n end"}
{"repo":"thor","file":"spec/actions_spec.rb","line":4,"symbol":"runner","kind":"method","lang":"ruby","code":"def runner(options = {})\n @runner ||= MyCounter.new([1], options, destination_root: destination_root)\n end"}
{"repo":"thor","file":"spec/actions_spec.rb","line":8,"symbol":"action","kind":"method","lang":"ruby","code":"def action(*args, &block)\n capture(:stdout) { runner.send(*args, &block) }\n end"}
{"repo":"thor","file":"spec/actions_spec.rb","line":12,"symbol":"file","kind":"method","lang":"ruby","code":"def file\n File.join(destination_root, \"foo\")\n end"}
{"repo":"thor","file":"spec/base_spec.rb","line":4,"symbol":"Amazing","kind":"class","lang":"ruby","code":"class Amazing\n desc \"hello\", \"say hello\"\n def hello\n puts \"Hello\"\n end\nend"}
{"repo":"thor","file":"spec/base_spec.rb","line":6,"symbol":"hello","kind":"method","lang":"ruby","code":"def hello\n puts \"Hello\"\n end"}
{"repo":"thor","file":"spec/command_spec.rb","line":4,"symbol":"command","kind":"method","lang":"ruby","code":"def command(options = {}, usage = \"can_has\")\n options.each do |key, value|\n options[key] = Thor::Option.parse(key, value)\n end\n\n @command ||= Thor::Command.new(:can_has, \"I can has cheezburger\", \"I can has cheezburger\\nLots and lots of it\", nil, usage, options)\n end"}
{"repo":"thor","file":"spec/command_spec.rb","line":72,"symbol":"handle_no_command_error","kind":"method","lang":"ruby","code":"def self.handle_no_command_error(name)\n name\n end"}
{"repo":"thor","file":"spec/command_spec.rb","line":76,"symbol":"can_has","kind":"method","lang":"ruby","code":"def can_has\n \"fail\"\n end"}
{"repo":"thor","file":"spec/encoding_spec.rb","line":6,"symbol":"load_thorfile","kind":"method","lang":"ruby","code":"def load_thorfile(filename)\n Thor::Util.load_thorfile(File.expand_path(\"./fixtures/#{filename}\", __dir__))\n end"}
{"repo":"thor","file":"spec/fixtures/application.rb","line":1,"symbol":"Application","kind":"class","lang":"ruby","code":"class Application < Base\nend"}
{"repo":"thor","file":"spec/fixtures/application_helper.rb","line":1,"symbol":"ApplicationHelper","kind":"module","lang":"ruby","code":"module ApplicationHelper\nend"}
{"repo":"thor","file":"spec/fixtures/command.thor","line":3,"symbol":"Amazing","kind":"class","lang":"ruby","code":"class Amazing < Thor\n def self.exit_on_failure?\n false\n end\n\n desc \"describe NAME\", \"say that someone is amazing\"\n method_options :forcefully => :boolean\n def describe(name, opts)\n ret = \"#{name} is amazing\"\n puts opts[\"forcefully\"] ? ret.upcase : ret\n end\nend"}
{"repo":"thor","file":"spec/fixtures/command.thor","line":4,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/command.thor","line":10,"symbol":"describe","kind":"method","lang":"ruby","code":"def describe(name, opts)\n ret = \"#{name} is amazing\"\n puts opts[\"forcefully\"] ? ret.upcase : ret\n end"}
{"repo":"thor","file":"spec/fixtures/encoding_implicit.thor","line":3,"symbol":"EncodingImplicit","kind":"class","lang":"ruby","code":"class EncodingImplicit < Thor\n SOME_STRING = \"Some λέξεις 一些词 🎉\"\n\n desc \"encoding\", \"tests that encoding is correct\"\n\n def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"UTF-8\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal UTF-8\"\n end\n end\nend"}
{"repo":"thor","file":"spec/fixtures/encoding_implicit.thor","line":8,"symbol":"encoding","kind":"method","lang":"ruby","code":"def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"UTF-8\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal UTF-8\"\n end\n end"}
{"repo":"thor","file":"spec/fixtures/encoding_other.thor","line":4,"symbol":"EncodingOther","kind":"class","lang":"ruby","code":"class EncodingOther < Thor\n SOME_STRING = \"Some ������\"\n\n desc \"encoding\", \"tests that encoding is correct\"\n\n def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"ISO-8859-7\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal ISO-8859-7\"\n end\n end\nend"}
{"repo":"thor","file":"spec/fixtures/encoding_other.thor","line":9,"symbol":"encoding","kind":"method","lang":"ruby","code":"def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"ISO-8859-7\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal ISO-8859-7\"\n end\n end"}
{"repo":"thor","file":"spec/fixtures/encoding_with_utf8.thor","line":4,"symbol":"EncodingWithUtf8","kind":"class","lang":"ruby","code":"class EncodingWithUtf8 < Thor\n SOME_STRING = \"Some λέξεις 一些词 🎉\"\n\n desc \"encoding\", \"tests that encoding is correct\"\n\n def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"UTF-8\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal UTF-8\"\n end\n end\nend"}
{"repo":"thor","file":"spec/fixtures/encoding_with_utf8.thor","line":9,"symbol":"encoding","kind":"method","lang":"ruby","code":"def encoding\n puts \"#{SOME_STRING.inspect}: #{SOME_STRING.encoding}:\"\n if SOME_STRING.encoding.name == \"UTF-8\"\n puts \"ok\"\n else\n puts \"expected #{SOME_STRING.encoding.name} to equal UTF-8\"\n end\n end"}
{"repo":"thor","file":"spec/fixtures/enum.thor","line":1,"symbol":"Enum","kind":"class","lang":"ruby","code":"class Enum < Thor::Group\n include Thor::Actions\n\n desc \"snack\"\n class_option \"fruit\", :aliases => \"-f\", :type => :string, :enum => %w(apple banana)\n def snack\n puts options['fruit']\n end\n\nend"}
{"repo":"thor","file":"spec/fixtures/enum.thor","line":6,"symbol":"snack","kind":"method","lang":"ruby","code":"def snack\n puts options['fruit']\n end"}
{"repo":"thor","file":"spec/fixtures/exit_status.thor","line":3,"symbol":"ExitStatus","kind":"class","lang":"ruby","code":"class ExitStatus < Thor\n def self.exit_on_failure?\n true\n end\n\n desc \"error\", \"exit with a planned error\"\n def error\n raise Thor::Error.new(\"planned error\")\n end\n\n desc \"ok\", \"exit with no error\"\n def ok\n end\nend"}
{"repo":"thor","file":"spec/fixtures/exit_status.thor","line":4,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n true\n end"}
{"repo":"thor","file":"spec/fixtures/exit_status.thor","line":9,"symbol":"error","kind":"method","lang":"ruby","code":"def error\n raise Thor::Error.new(\"planned error\")\n end"}
{"repo":"thor","file":"spec/fixtures/exit_status.thor","line":14,"symbol":"ok","kind":"method","lang":"ruby","code":"def ok\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":1,"symbol":"MyCounter","kind":"class","lang":"ruby","code":"class MyCounter < Thor::Group\n include Thor::Actions\n add_runtime_options!\n\n def self.exit_on_failure?\n false\n end\n\n def self.get_from_super\n from_superclass(:get_from_super, 13)\n end\n\n source_root File.expand_path(File.dirname(__FILE__))\n source_paths << File.expand_path(\"broken\", File.dirname(__FILE__))\n\n argument :first, :type => :numeric\n argument :second, :type => :numeric, :default => 2\n\n class_option :third, :type => :numeric, :desc => \"The third argument\", :default => 3,\n :banner => \"THREE\", :aliases => \"-t\"\n class_option :fourth, :type => :numeric, :desc => \"The fourth argument\"\n class_option :simple, :type => :numeric, :aliases => 'z'\n class_option :symbolic, :type => :numeric, :aliases => [:y, :r]\n class_option :array, :type => :array, :default => ['foo','bar']\n\n desc <<-FOO\nDescription:\n This generator runs three commands: one, two and three.\nFOO\n\n def one\n first\n end\n\n def two\n second\n end\n\n def three\n options[:third]\n end\n\n def four\n options[:fourth]\n end\n\n def five\n options[:simple]\n end\n\n def six\n options[:symbolic]\n end\n\n def self.inherited(base)\n super\n base.s"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":5,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":9,"symbol":"get_from_super","kind":"method","lang":"ruby","code":"def self.get_from_super\n from_superclass(:get_from_super, 13)\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":31,"symbol":"one","kind":"method","lang":"ruby","code":"def one\n first\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":35,"symbol":"two","kind":"method","lang":"ruby","code":"def two\n second\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":39,"symbol":"three","kind":"method","lang":"ruby","code":"def three\n options[:third]\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":43,"symbol":"four","kind":"method","lang":"ruby","code":"def four\n options[:fourth]\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":47,"symbol":"five","kind":"method","lang":"ruby","code":"def five\n options[:simple]\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":51,"symbol":"six","kind":"method","lang":"ruby","code":"def six\n options[:symbolic]\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":55,"symbol":"inherited","kind":"method","lang":"ruby","code":"def self.inherited(base)\n super\n base.source_paths.unshift(File.expand_path(File.join(File.dirname(__FILE__), \"doc\")))\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":61,"symbol":"world","kind":"method","lang":"ruby","code":"def world(&block)\n result = capture(&block)\n concat(result.strip + \" world!\")\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":68,"symbol":"ClearCounter","kind":"class","lang":"ruby","code":"class ClearCounter < MyCounter\n remove_argument :first, :second, :undefine => true\n remove_class_option :third\n\n def self.source_root\n File.expand_path(File.join(File.dirname(__FILE__), \"bundle\"))\n end\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":72,"symbol":"source_root","kind":"method","lang":"ruby","code":"def self.source_root\n File.expand_path(File.join(File.dirname(__FILE__), \"bundle\"))\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":77,"symbol":"BrokenCounter","kind":"class","lang":"ruby","code":"class BrokenCounter < MyCounter\n namespace \"app:broken:counter\"\n class_option :fail, :type => :boolean, :default => false\n\n class << self\n undef_method :source_root\n end\n\n def one\n options[:first]\n end\n\n def four\n respond_to?(:fail)\n end\n\n def five\n options[:fail] ? this_method_does_not_exist : 5\n end\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":85,"symbol":"one","kind":"method","lang":"ruby","code":"def one\n options[:first]\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":89,"symbol":"four","kind":"method","lang":"ruby","code":"def four\n respond_to?(:fail)\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":93,"symbol":"five","kind":"method","lang":"ruby","code":"def five\n options[:fail] ? this_method_does_not_exist : 5\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":98,"symbol":"WhinyGenerator","kind":"class","lang":"ruby","code":"class WhinyGenerator < Thor::Group\n include Thor::Actions\n\n def self.source_root\n File.expand_path(File.dirname(__FILE__))\n end\n\n def wrong_arity(required)\n end\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":101,"symbol":"source_root","kind":"method","lang":"ruby","code":"def self.source_root\n File.expand_path(File.dirname(__FILE__))\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":105,"symbol":"wrong_arity","kind":"method","lang":"ruby","code":"def wrong_arity(required)\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":109,"symbol":"CommandConflict","kind":"class","lang":"ruby","code":"class CommandConflict < Thor::Group\n desc \"A group with the same name as a default command\"\n def group\n puts \"group\"\n end\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":111,"symbol":"group","kind":"method","lang":"ruby","code":"def group\n puts \"group\"\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":116,"symbol":"ParentGroup","kind":"class","lang":"ruby","code":"class ParentGroup < Thor::Group\nprivate\n def foo\n \"foo\"\n end\n\n def baz(name = 'baz')\n name\n end\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":118,"symbol":"foo","kind":"method","lang":"ruby","code":"def foo\n \"foo\"\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":122,"symbol":"baz","kind":"method","lang":"ruby","code":"def baz(name = 'baz')\n name\n end"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":127,"symbol":"ChildGroup","kind":"class","lang":"ruby","code":"class ChildGroup < ParentGroup\n def bar\n \"bar\"\n end\n\n public_command :foo, :baz\nend"}
{"repo":"thor","file":"spec/fixtures/group.thor","line":128,"symbol":"bar","kind":"method","lang":"ruby","code":"def bar\n \"bar\"\n end"}
{"repo":"thor","file":"spec/fixtures/help.thor","line":3,"symbol":"Help","kind":"class","lang":"ruby","code":"class Help < Thor\n\n desc :bugs, \"ALL THE BUGZ!\"\n option \"--not_help\", :type => :boolean\n def bugs\n puts \"Invoked!\"\n end\n\nend"}
{"repo":"thor","file":"spec/fixtures/help.thor","line":7,"symbol":"bugs","kind":"method","lang":"ruby","code":"def bugs\n puts \"Invoked!\"\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":1,"symbol":"A","kind":"class","lang":"ruby","code":"class A < Thor\n include Thor::Actions\n\n desc \"one\", \"invoke one\"\n def one\n p 1\n invoke :two\n invoke :three\n end\n\n desc \"two\", \"invoke two\"\n def two\n p 2\n invoke :three\n end\n\n desc \"three\", \"invoke three\"\n def three\n p 3\n end\n\n desc \"four\", \"invoke four\"\n def four\n p 4\n invoke \"defined:five\"\n end\n\n desc \"five N\", \"check if number is equal 5\"\n def five(number)\n number == 5\n end\n\n desc \"invoker\", \"invoke a b command\"\n def invoker(*args)\n invoke :b, :one, [\"Jose\"]\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":5,"symbol":"one","kind":"method","lang":"ruby","code":"def one\n p 1\n invoke :two\n invoke :three\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":12,"symbol":"two","kind":"method","lang":"ruby","code":"def two\n p 2\n invoke :three\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":18,"symbol":"three","kind":"method","lang":"ruby","code":"def three\n p 3\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":23,"symbol":"four","kind":"method","lang":"ruby","code":"def four\n p 4\n invoke \"defined:five\"\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":29,"symbol":"five","kind":"method","lang":"ruby","code":"def five(number)\n number == 5\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":34,"symbol":"invoker","kind":"method","lang":"ruby","code":"def invoker(*args)\n invoke :b, :one, [\"Jose\"]\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":39,"symbol":"B","kind":"class","lang":"ruby","code":"class B < Thor\n class_option :last_name, :type => :string\n\n desc \"one FIRST_NAME\", \"invoke one\"\n def one(first_name)\n \"#{options.last_name}, #{first_name}\"\n end\n\n desc \"two\", \"invoke two\"\n def two\n options\n end\n\n desc \"three\", \"invoke three\"\n def three\n self\n end\n\n desc \"four\", \"invoke four\"\n option :defaulted_value, :type => :string, :default => 'default'\n def four\n options.defaulted_value\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":43,"symbol":"one","kind":"method","lang":"ruby","code":"def one(first_name)\n \"#{options.last_name}, #{first_name}\"\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":48,"symbol":"two","kind":"method","lang":"ruby","code":"def two\n options\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":53,"symbol":"three","kind":"method","lang":"ruby","code":"def three\n self\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":59,"symbol":"four","kind":"method","lang":"ruby","code":"def four\n options.defaulted_value\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":64,"symbol":"C","kind":"class","lang":"ruby","code":"class C < Thor::Group\n include Thor::Actions\n\n def one\n p 1\n end\n\n def two\n p 2\n end\n\n def three\n p 3\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":67,"symbol":"one","kind":"method","lang":"ruby","code":"def one\n p 1\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":71,"symbol":"two","kind":"method","lang":"ruby","code":"def two\n p 2\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":75,"symbol":"three","kind":"method","lang":"ruby","code":"def three\n p 3\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":80,"symbol":"Defined","kind":"class","lang":"ruby","code":"class Defined < Thor::Group\n class_option :unused, :type => :boolean, :desc => \"This option has no use\"\n\n def one\n p 1\n invoke \"a:two\"\n invoke \"a:three\"\n invoke \"a:four\"\n invoke \"defined:five\"\n end\n\n def five\n p 5\n end\n\n def print_status\n say_status :finished, :counting\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":83,"symbol":"one","kind":"method","lang":"ruby","code":"def one\n p 1\n invoke \"a:two\"\n invoke \"a:three\"\n invoke \"a:four\"\n invoke \"defined:five\"\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":91,"symbol":"five","kind":"method","lang":"ruby","code":"def five\n p 5\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":95,"symbol":"print_status","kind":"method","lang":"ruby","code":"def print_status\n say_status :finished, :counting\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":100,"symbol":"E","kind":"class","lang":"ruby","code":"class E < Thor::Group\n invoke Defined\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":104,"symbol":"F","kind":"class","lang":"ruby","code":"class F < Thor::Group\n invoke \"b:one\" do |instance, klass, command|\n instance.invoke klass, command, [ \"Jose\" ], :last_name => \"Valim\"\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":110,"symbol":"G","kind":"class","lang":"ruby","code":"class G < Thor::Group\n class_option :invoked, :type => :string, :default => \"defined\"\n invoke_from_option :invoked\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":115,"symbol":"H","kind":"class","lang":"ruby","code":"class H < Thor::Group\n class_option :defined, :type => :boolean, :default => true\n invoke_from_option :defined\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":120,"symbol":"I","kind":"class","lang":"ruby","code":"class I < Thor\n desc \"two\", \"Two\"\n def two\n current_command_chain\n end\nend"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":122,"symbol":"two","kind":"method","lang":"ruby","code":"def two\n current_command_chain\n end"}
{"repo":"thor","file":"spec/fixtures/invoke.thor","line":127,"symbol":"J","kind":"class","lang":"ruby","code":"class J < Thor\n desc \"i\", \"I\"\n subcommand :one, I\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":1,"symbol":"MyScript","kind":"class","lang":"ruby","code":"class MyScript < Thor\n check_unknown_options! :except => :with_optional\n\n def self.exit_on_failure?\n false\n end\n\n attr_accessor :some_attribute\n attr_writer :another_attribute\n attr_reader :another_attribute\n\n private\n attr_reader :private_attribute\n\n public\n group :script\n default_command :example_default_command\n\n map \"-T\" => :animal, [\"-f\", \"--foo\"] => :foo\n\n map \"animal_prison\" => \"zoo\"\n\n desc \"zoo\", \"zoo around\"\n def zoo\n true\n end\n\n desc \"animal TYPE\", \"horse around\"\n\n no_commands do\n no_commands do\n def this_is_not_a_command\n end\n end\n\n def neither_is_this\n end\n end\n\n def animal(type)\n [type]\n end\n\n map \"hid\" => \"hidden\"\n\n desc \"hidden TYPE\", \"this is hidden\", :hide => true\n def hidden(type)\n [type]\n end\n\n map \"fu\" => \"zoo\"\n\n desc \"foo BAR\", <<END\ndo some fooing\n This is more info!\n Everyone likes more info!\nEND\n method_option :force, :type => :boolean, :desc => \"Force to do some fooing\"\n def foo(bar)\n [bar, options]\n end\n\n method_option :all, :desc => \"Do bazing for all the things\"\n desc [\"baz THING\", \"baz --all\"], \"super cool\"\n def baz(thing = nil)\n raise if thing.nil? && !options.include?(:all)\n e"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":4,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":24,"symbol":"zoo","kind":"method","lang":"ruby","code":"def zoo\n true\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":32,"symbol":"this_is_not_a_command","kind":"method","lang":"ruby","code":"def this_is_not_a_command\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":36,"symbol":"neither_is_this","kind":"method","lang":"ruby","code":"def neither_is_this\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":40,"symbol":"animal","kind":"method","lang":"ruby","code":"def animal(type)\n [type]\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":47,"symbol":"hidden","kind":"method","lang":"ruby","code":"def hidden(type)\n [type]\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":59,"symbol":"foo","kind":"method","lang":"ruby","code":"def foo(bar)\n [bar, options]\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":65,"symbol":"baz","kind":"method","lang":"ruby","code":"def baz(thing = nil)\n raise if thing.nil? && !options.include?(:all)\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":71,"symbol":"example_default_command","kind":"method","lang":"ruby","code":"def example_default_command\n options.empty? ? \"default command\" : options\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":76,"symbol":"call_myself_with_wrong_arity","kind":"method","lang":"ruby","code":"def call_myself_with_wrong_arity\n call_myself_with_wrong_arity(4)\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":81,"symbol":"call_unexistent_method","kind":"method","lang":"ruby","code":"def call_unexistent_method\n boom!\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":92,"symbol":"long_description","kind":"method","lang":"ruby","code":"def long_description\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":96,"symbol":"name_with_dashes","kind":"method","lang":"ruby","code":"def name_with_dashes\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":108,"symbol":"long_description_unwrapped","kind":"method","lang":"ruby","code":"def long_description_unwrapped\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":117,"symbol":"with_optional","kind":"method","lang":"ruby","code":"def with_optional(name=nil, *args)\n [name, options, args]\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":121,"symbol":"AnotherScript","kind":"class","lang":"ruby","code":"class AnotherScript < Thor\n desc \"baz\", \"do some bazing\"\n def baz\n end\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":123,"symbol":"baz","kind":"method","lang":"ruby","code":"def baz\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":128,"symbol":"send","kind":"method","lang":"ruby","code":"def send\n true\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":133,"symbol":"potentially_ambiguous","kind":"method","lang":"ruby","code":"def potentially_ambiguous\n true\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":138,"symbol":"potentially_ambiguous_but_hidden","kind":"method","lang":"ruby","code":"def potentially_ambiguous_but_hidden\n false\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":144,"symbol":"method_missing","kind":"method","lang":"ruby","code":"def method_missing(meth, *args)\n if meth == :boom!\n super\n else\n [meth, args]\n end\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":153,"symbol":"what","kind":"method","lang":"ruby","code":"def what\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":157,"symbol":"MyChildScript","kind":"class","lang":"ruby","code":"class MyChildScript < MyScript\n remove_command :name_with_dashes\n\n method_options :force => :boolean, :param => :numeric\n def initialize(*args)\n super\n end\n\n desc \"zoo\", \"zoo around\"\n method_options :param => :required\n def zoo\n options\n end\n\n desc \"animal TYPE\", \"horse around\"\n def animal(type)\n [type, options]\n end\n method_option :other, :type => :string, :default => \"method default\", :for => :animal\n desc \"animal KIND\", \"fish around\", :for => :animal\n\n desc \"boom\", \"explodes everything\"\n def boom\n end\n\n remove_command :boom, :undefine => true\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":161,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize(*args)\n super\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":167,"symbol":"zoo","kind":"method","lang":"ruby","code":"def zoo\n options\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":172,"symbol":"animal","kind":"method","lang":"ruby","code":"def animal(type)\n [type, options]\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":179,"symbol":"boom","kind":"method","lang":"ruby","code":"def boom\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":185,"symbol":"Barn","kind":"class","lang":"ruby","code":"class Barn < Thor\n def self.exit_on_failure?\n false\n end\n\n desc \"open [ITEM]\", \"open the barn door\"\n def open(item = nil)\n if item == \"shotgun\"\n puts \"That's going to leave a mark.\"\n else\n puts \"Open sesame!\"\n end\n end\n\n desc \"paint [COLOR]\", \"paint the barn\"\n method_option :coats, :type => :numeric, :default => 2, :desc => 'how many coats of paint'\n def paint(color='red')\n puts \"#{options[:coats]} coats of #{color} paint\"\n end\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":186,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":191,"symbol":"open","kind":"method","lang":"ruby","code":"def open(item = nil)\n if item == \"shotgun\"\n puts \"That's going to leave a mark.\"\n else\n puts \"Open sesame!\"\n end\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":201,"symbol":"paint","kind":"method","lang":"ruby","code":"def paint(color='red')\n puts \"#{options[:coats]} coats of #{color} paint\"\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":206,"symbol":"PackageNameScript","kind":"class","lang":"ruby","code":"class PackageNameScript < Thor\n package_name \"Baboon\"\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":210,"symbol":"Scripts","kind":"module","lang":"ruby","code":"module Scripts\n class MyScript < MyChildScript\n argument :accessor, :type => :string\n class_options :force => :boolean\n method_option :new_option, :type => :string, :for => :example_default_command\n\n def zoo\n self.accessor\n end\n end\n\n class MyDefaults < Thor\n check_unknown_options!\n\n def self.exit_on_failure?\n false\n end\n\n namespace :default\n desc \"cow\", \"prints 'moo'\"\n def cow\n puts \"moo\"\n end\n\n desc \"command_conflict\", \"only gets called when prepended with a colon\"\n def command_conflict\n puts \"command\"\n end\n\n desc \"barn\", \"commands to manage the barn\"\n subcommand \"barn\", Barn\n end\n\n class ChildDefault < Thor\n namespace \"default:child\"\n end\n\n class Arities < Thor\n def self.exit_on_failure?\n false\n end\n\n desc \"zero_args\", \"takes zero args\"\n def zero_args\n end\n\n desc \"one_arg ARG\", \"takes one arg\"\n def one_arg(arg)\n end\n\n desc \"two_args ARG1 ARG2\", \"takes two args\"\n def two_args(arg1, arg2)\n end\n\n desc \"optional_arg [ARG]\", \"takes an optional arg\"\n def optional_arg(arg='default')\n end\n\n desc [\"multiple_usages ARG --foo\", \"multiple_usages ARG --bar\"], \"ta"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":211,"symbol":"MyScript","kind":"class","lang":"ruby","code":"class MyScript < MyChildScript\n argument :accessor, :type => :string\n class_options :force => :boolean\n method_option :new_option, :type => :string, :for => :example_default_command\n\n def zoo\n self.accessor\n end\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":216,"symbol":"zoo","kind":"method","lang":"ruby","code":"def zoo\n self.accessor\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":221,"symbol":"MyDefaults","kind":"class","lang":"ruby","code":"class MyDefaults < Thor\n check_unknown_options!\n\n def self.exit_on_failure?\n false\n end\n\n namespace :default\n desc \"cow\", \"prints 'moo'\"\n def cow\n puts \"moo\"\n end\n\n desc \"command_conflict\", \"only gets called when prepended with a colon\"\n def command_conflict\n puts \"command\"\n end\n\n desc \"barn\", \"commands to manage the barn\"\n subcommand \"barn\", Barn\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":224,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":230,"symbol":"cow","kind":"method","lang":"ruby","code":"def cow\n puts \"moo\"\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":235,"symbol":"command_conflict","kind":"method","lang":"ruby","code":"def command_conflict\n puts \"command\"\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":243,"symbol":"ChildDefault","kind":"class","lang":"ruby","code":"class ChildDefault < Thor\n namespace \"default:child\"\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":247,"symbol":"Arities","kind":"class","lang":"ruby","code":"class Arities < Thor\n def self.exit_on_failure?\n false\n end\n\n desc \"zero_args\", \"takes zero args\"\n def zero_args\n end\n\n desc \"one_arg ARG\", \"takes one arg\"\n def one_arg(arg)\n end\n\n desc \"two_args ARG1 ARG2\", \"takes two args\"\n def two_args(arg1, arg2)\n end\n\n desc \"optional_arg [ARG]\", \"takes an optional arg\"\n def optional_arg(arg='default')\n end\n\n desc [\"multiple_usages ARG --foo\", \"multiple_usages ARG --bar\"], \"takes mutually exclusive combinations of args and flags\"\n def multiple_usages(arg)\n end\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":248,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":253,"symbol":"zero_args","kind":"method","lang":"ruby","code":"def zero_args\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":257,"symbol":"one_arg","kind":"method","lang":"ruby","code":"def one_arg(arg)\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":261,"symbol":"two_args","kind":"method","lang":"ruby","code":"def two_args(arg1, arg2)\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":265,"symbol":"optional_arg","kind":"method","lang":"ruby","code":"def optional_arg(arg='default')\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":269,"symbol":"multiple_usages","kind":"method","lang":"ruby","code":"def multiple_usages(arg)\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":274,"symbol":"Apple","kind":"class","lang":"ruby","code":"class Apple < Thor\n namespace :fruits\n desc 'apple', 'apple'; def apple; end\n desc 'rotten-apple', 'rotten apple'; def rotten_apple; end\n map \"ra\" => :rotten_apple\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":276,"symbol":"apple","kind":"method","lang":"ruby","code":"def apple; end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":277,"symbol":"rotten_apple","kind":"method","lang":"ruby","code":"def rotten_apple; end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":281,"symbol":"Pear","kind":"class","lang":"ruby","code":"class Pear < Thor\n namespace :fruits\n desc 'pear', 'pear'; def pear; end\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":283,"symbol":"pear","kind":"method","lang":"ruby","code":"def pear; end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":286,"symbol":"MyClassOptionScript","kind":"class","lang":"ruby","code":"class MyClassOptionScript < Thor\n class_option :free\n\n class_exclusive do\n class_option :one\n class_option :two\n end\n\n class_at_least_one do\n class_option :three\n class_option :four\n end\n\n desc \"mix\", \"\"\n exclusive do\n at_least_one do\n option :five\n option :six\n option :seven\n end\n end\n def mix\n end\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":307,"symbol":"mix","kind":"method","lang":"ruby","code":"def mix\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":311,"symbol":"MyOptionScript","kind":"class","lang":"ruby","code":"class MyOptionScript < Thor\n desc \"exclusive\", \"\"\n exclusive do\n method_option :one\n method_option :two\n method_option :three\n end\n method_option :after1\n method_option :after2\n def exclusive\n end\n\n exclusive :after1, :after2, {:for => :exclusive}\n\n desc \"at_least_one\", \"\"\n at_least_one do\n method_option :one\n method_option :two\n method_option :three\n end\n method_option :after1\n method_option :after2\n def at_least_one\n end\n at_least_one :after1, :after2, :for => :at_least_one\n\n desc \"only_one\", \"\"\n exclusive do\n at_least_one do\n option :one\n option :two\n option :three\n end\n end\n def only_one\n end\n\n desc \"no_relastions\", \"\"\n option :no_rel1\n option :no_rel2\n def no_relations\n end\nend"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":320,"symbol":"exclusive","kind":"method","lang":"ruby","code":"def exclusive\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":333,"symbol":"at_least_one","kind":"method","lang":"ruby","code":"def at_least_one\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":345,"symbol":"only_one","kind":"method","lang":"ruby","code":"def only_one\n end"}
{"repo":"thor","file":"spec/fixtures/script.thor","line":351,"symbol":"no_relations","kind":"method","lang":"ruby","code":"def no_relations\n end"}
{"repo":"thor","file":"spec/fixtures/subcommand.thor","line":1,"symbol":"TestSubcommands","kind":"module","lang":"ruby","code":"module TestSubcommands\n\n class Subcommand < Thor\n desc \"print_opt\", \"My method\"\n def print_opt\n print options[\"opt\"]\n end\n end\n\n class Parent < Thor\n class_option \"opt\"\n\n desc \"sub\", \"My subcommand\"\n subcommand \"sub\", Subcommand\n end\n\nend"}
{"repo":"thor","file":"spec/fixtures/subcommand.thor","line":3,"symbol":"Subcommand","kind":"class","lang":"ruby","code":"class Subcommand < Thor\n desc \"print_opt\", \"My method\"\n def print_opt\n print options[\"opt\"]\n end\n end"}
{"repo":"thor","file":"spec/fixtures/subcommand.thor","line":5,"symbol":"print_opt","kind":"method","lang":"ruby","code":"def print_opt\n print options[\"opt\"]\n end"}
{"repo":"thor","file":"spec/fixtures/subcommand.thor","line":10,"symbol":"Parent","kind":"class","lang":"ruby","code":"class Parent < Thor\n class_option \"opt\"\n\n desc \"sub\", \"My subcommand\"\n subcommand \"sub\", Subcommand\n end"}
{"repo":"thor","file":"spec/fixtures/verbose.thor","line":7,"symbol":"Test","kind":"class","lang":"ruby","code":"class Test < Thor\n def self.exit_on_failure?\n true\n end\nend"}
{"repo":"thor","file":"spec/fixtures/verbose.thor","line":8,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n true\n end"}
{"repo":"thor","file":"spec/group_spec.rb","line":206,"symbol":"hi","kind":"method","lang":"ruby","code":"def hi\n self.name = name.upcase if options[:loud]\n \"Hi #{name}\"\n end"}
{"repo":"thor","file":"spec/group_spec.rb","line":223,"symbol":"hi","kind":"method","lang":"ruby","code":"def hi\n self.name = name.upcase if options[:loud]\n out = \"Hi #{name}\"\n out << \": \" << args.join(\", \") unless args.empty?\n out\n end"}
{"repo":"thor","file":"spec/helper.rb","line":49,"symbol":"capture","kind":"method","lang":"ruby","code":"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\n end"}
{"repo":"thor","file":"spec/helper.rb","line":62,"symbol":"source_root","kind":"method","lang":"ruby","code":"def source_root\n File.join(File.dirname(__FILE__), \"fixtures\")\n end"}
{"repo":"thor","file":"spec/helper.rb","line":66,"symbol":"destination_root","kind":"method","lang":"ruby","code":"def destination_root\n File.join(File.dirname(__FILE__), \"sandbox\")\n end"}
{"repo":"thor","file":"spec/helper.rb","line":72,"symbol":"silence_warnings","kind":"method","lang":"ruby","doc":"This code was adapted from Ruby on Rails, available under MIT-LICENSE Copyright (c) 2004-2013 David Heinemeier Hansson","code":"def silence_warnings\n old_verbose = $VERBOSE\n $VERBOSE = nil\n yield\n ensure\n $VERBOSE = old_verbose\n end"}
{"repo":"thor","file":"spec/helper.rb","line":83,"symbol":"windows?","kind":"method","lang":"ruby","doc":"true if running on windows, used for conditional spec skips @return [TrueClass/FalseClass]","code":"def windows?\n Gem.win_platform?\n end"}
{"repo":"thor","file":"spec/parser/argument_spec.rb","line":5,"symbol":"argument","kind":"method","lang":"ruby","code":"def argument(name, options = {})\n @argument ||= Thor::Argument.new(name, options)\n end"}
{"repo":"thor","file":"spec/parser/arguments_spec.rb","line":5,"symbol":"create","kind":"method","lang":"ruby","code":"def create(opts = {})\n arguments = opts.map do |type, default|\n options = {required: default.nil?, type: type, default: default}\n Thor::Argument.new(type.to_s, options)\n end\n\n arguments.sort! { |a, b| b.name <=> a.name }\n @opt = Thor::Arguments.new(arguments)\n end"}
{"repo":"thor","file":"spec/parser/arguments_spec.rb","line":15,"symbol":"parse","kind":"method","lang":"ruby","code":"def parse(*args)\n @opt.parse(args)\n end"}
{"repo":"thor","file":"spec/parser/option_spec.rb","line":5,"symbol":"parse","kind":"method","lang":"ruby","code":"def parse(key, value)\n Thor::Option.parse(key, value)\n end"}
{"repo":"thor","file":"spec/parser/option_spec.rb","line":9,"symbol":"option","kind":"method","lang":"ruby","code":"def option(name, options = {})\n @option ||= Thor::Option.new(name, options)\n end"}
{"repo":"thor","file":"spec/parser/options_spec.rb","line":5,"symbol":"create","kind":"method","lang":"ruby","code":"def create(opts, defaults = {}, stop_on_unknown = false, exclusives = [], at_least_ones = [])\n relation = {\n exclusive_option_names: exclusives,\n at_least_one_option_names: at_least_ones\n }\n opts.each do |key, value|\n opts[key] = Thor::Option.parse(key, value) unless value.is_a?(Thor::Option)\n end\n @opt = Thor::Options.new(opts, defaults, stop_on_unknown, false, relation)\n end"}
{"repo":"thor","file":"spec/parser/options_spec.rb","line":16,"symbol":"parse","kind":"method","lang":"ruby","code":"def parse(*args)\n @opt.parse(args.flatten)\n end"}
{"repo":"thor","file":"spec/parser/options_spec.rb","line":20,"symbol":"check_unknown!","kind":"method","lang":"ruby","code":"def check_unknown!\n @opt.check_unknown!\n end"}
{"repo":"thor","file":"spec/parser/options_spec.rb","line":24,"symbol":"remaining","kind":"method","lang":"ruby","code":"def remaining\n @opt.remaining\n end"}
{"repo":"thor","file":"spec/quality_spec.rb","line":2,"symbol":"check_for_spec_defs_with_single_quotes","kind":"method","lang":"ruby","code":"def check_for_spec_defs_with_single_quotes(filename)\n failing_lines = []\n\n File.readlines(filename).each_with_index do |line, number|\n failing_lines << number + 1 if line =~ /^ *(describe|it|context) {1}'{1}/\n end\n\n \"#{filename} uses inconsistent single quotes on lines #{failing_lines.join(', ')}\" unless failing_lines.empty?\n end"}
{"repo":"thor","file":"spec/quality_spec.rb","line":12,"symbol":"check_for_tab_characters","kind":"method","lang":"ruby","code":"def check_for_tab_characters(filename)\n failing_lines = []\n File.readlines(filename).each_with_index do |line, number|\n failing_lines << number + 1 if line =~ /\\t/\n end\n\n \"#{filename} has tab characters on lines #{failing_lines.join(', ')}\" unless failing_lines.empty?\n end"}
{"repo":"thor","file":"spec/quality_spec.rb","line":21,"symbol":"check_for_extra_spaces","kind":"method","lang":"ruby","code":"def check_for_extra_spaces(filename)\n failing_lines = []\n File.readlines(filename).each_with_index do |line, number|\n next if line =~ /^\\s+#.*\\s+\\n$/\n failing_lines << number + 1 if line =~ /\\s+\\n$/\n end\n\n \"#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}\" unless failing_lines.empty?\n end"}
{"repo":"thor","file":"spec/rake_compat_spec.rb","line":7,"symbol":"RakeTask","kind":"class","lang":"ruby","code":"class RakeTask < Rake::TaskLib\n def initialize\n define\n end\n\n def define\n $main.instance_eval do\n desc \"Say it's cool\"\n task :cool do\n puts \"COOL\"\n end\n\n namespace :hiper_mega do\n task :super do\n puts \"HIPER MEGA SUPER\"\n end\n end\n end\n end\nend"}
{"repo":"thor","file":"spec/rake_compat_spec.rb","line":8,"symbol":"initialize","kind":"method","lang":"ruby","code":"def initialize\n define\n end"}
{"repo":"thor","file":"spec/rake_compat_spec.rb","line":12,"symbol":"define","kind":"method","lang":"ruby","code":"def define\n $main.instance_eval do\n desc \"Say it's cool\"\n task :cool do\n puts \"COOL\"\n end\n\n namespace :hiper_mega do\n task :super do\n puts \"HIPER MEGA SUPER\"\n end\n end\n end\n end"}
{"repo":"thor","file":"spec/rake_compat_spec.rb","line":28,"symbol":"ThorTask","kind":"class","lang":"ruby","code":"class ThorTask < Thor\n include Thor::RakeCompat\n RakeTask.new\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":3,"symbol":"BoringVendorProvidedCLI","kind":"class","lang":"ruby","code":"class BoringVendorProvidedCLI < Thor\n desc \"boring\", \"do boring stuff\"\n def boring\n puts \"bored. <yawn>\"\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":5,"symbol":"boring","kind":"method","lang":"ruby","code":"def boring\n puts \"bored. <yawn>\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":10,"symbol":"ExcitingPluginCLI","kind":"class","lang":"ruby","code":"class ExcitingPluginCLI < Thor\n desc \"hooray\", \"say hooray!\"\n def hooray\n puts \"hooray!\"\n end\n\n desc \"fireworks\", \"exciting fireworks!\"\n def fireworks\n puts \"kaboom!\"\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":12,"symbol":"hooray","kind":"method","lang":"ruby","code":"def hooray\n puts \"hooray!\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":17,"symbol":"fireworks","kind":"method","lang":"ruby","code":"def fireworks\n puts \"kaboom!\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":22,"symbol":"SuperSecretPlugin","kind":"class","lang":"ruby","code":"class SuperSecretPlugin < Thor\n default_command :squirrel\n\n desc \"squirrel\", \"All of secret squirrel's secrets\"\n def squirrel\n puts \"I love nuts\"\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":26,"symbol":"squirrel","kind":"method","lang":"ruby","code":"def squirrel\n puts \"I love nuts\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":31,"symbol":"GroupPlugin","kind":"class","lang":"ruby","code":"class GroupPlugin < Thor::Group\n desc \"part one\"\n def part_one\n puts \"part one\"\n end\n\n desc \"part two\"\n def part_two\n puts \"part two\"\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":33,"symbol":"part_one","kind":"method","lang":"ruby","code":"def part_one\n puts \"part one\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":38,"symbol":"part_two","kind":"method","lang":"ruby","code":"def part_two\n puts \"part two\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":43,"symbol":"ClassOptionGroupPlugin","kind":"class","lang":"ruby","code":"class ClassOptionGroupPlugin < Thor::Group\n class_option :who,\n type: :string,\n aliases: \"-w\",\n default: \"zebra\"\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":50,"symbol":"PluginInheritingFromClassOptionsGroup","kind":"class","lang":"ruby","code":"class PluginInheritingFromClassOptionsGroup < ClassOptionGroupPlugin\n desc \"animal\"\n def animal\n p options[:who]\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":52,"symbol":"animal","kind":"method","lang":"ruby","code":"def animal\n p options[:who]\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":57,"symbol":"PluginWithDefault","kind":"class","lang":"ruby","code":"class PluginWithDefault < Thor\n desc \"say MSG\", \"print MSG\"\n def say(msg)\n puts msg\n end\n\n default_command :say\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":59,"symbol":"say","kind":"method","lang":"ruby","code":"def say(msg)\n puts msg\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":66,"symbol":"PluginWithDefaultMultipleArguments","kind":"class","lang":"ruby","code":"class PluginWithDefaultMultipleArguments < Thor\n desc \"say MSG [MSG]\", \"print multiple messages\"\n def say(*args)\n puts args\n end\n\n default_command :say\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":68,"symbol":"say","kind":"method","lang":"ruby","code":"def say(*args)\n puts args\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":75,"symbol":"PluginWithDefaultcommandAndDeclaredArgument","kind":"class","lang":"ruby","code":"class PluginWithDefaultcommandAndDeclaredArgument < Thor\n desc \"say MSG [MSG]\", \"print multiple messages\"\n argument :msg\n def say\n puts msg\n end\n\n default_command :say\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":78,"symbol":"say","kind":"method","lang":"ruby","code":"def say\n puts msg\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":85,"symbol":"SubcommandWithDefault","kind":"class","lang":"ruby","code":"class SubcommandWithDefault < Thor\n default_command :default\n\n desc \"default\", \"default subcommand\"\n def default\n puts \"default\"\n end\n\n desc \"with_args\", \"subcommand with arguments\"\n def with_args(*args)\n puts \"received arguments: \" + args.join(\",\")\n end\nend"}
{"repo":"thor","file":"spec/register_spec.rb","line":89,"symbol":"default","kind":"method","lang":"ruby","code":"def default\n puts \"default\"\n end"}
{"repo":"thor","file":"spec/register_spec.rb","line":94,"symbol":"with_args","kind":"method","lang":"ruby","code":"def with_args(*args)\n puts \"received arguments: \" + args.join(\",\")\n end"}
{"repo":"thor","file":"spec/runner_spec.rb","line":5,"symbol":"when_no_thorfiles_exist","kind":"method","lang":"ruby","code":"def when_no_thorfiles_exist\n old_dir = Dir.pwd\n Dir.chdir \"..\"\n delete = Thor::Base.subclasses.select { |e| e.namespace == \"default\" }\n delete.each { |e| Thor::Base.subclasses.delete e }\n yield\n Thor::Base.subclasses.concat delete\n Dir.chdir old_dir\n end"}
{"repo":"thor","file":"spec/script_exit_status_spec.rb","line":2,"symbol":"thor_command","kind":"method","lang":"ruby","code":"def thor_command(command)\n gem_dir= File.expand_path(\"#{File.dirname(__FILE__)}/..\")\n lib_path= \"#{gem_dir}/lib\"\n script_path= \"#{gem_dir}/spec/fixtures/exit_status.thor\"\n ruby_lib= ENV[\"RUBYLIB\"].nil? ? lib_path : \"#{lib_path}:#{ENV['RUBYLIB']}\"\n\n full_command= \"ruby #{script_path} #{command}\"\n r,w= IO.pipe\n pid= spawn({\"RUBYLIB\" => ruby_lib},\n full_command,\n {out: w, err: [:child, :out]})\n w.close\n\n _, exit_status= Process.wait2(pid)\n r.read\n r.close\n\n exit_status.exitstatus\n end"}
{"repo":"thor","file":"spec/shell/basic_spec.rb","line":5,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Shell::Basic.new\n end"}
{"repo":"thor","file":"spec/shell/color_spec.rb","line":4,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Shell::Color.new\n end"}
{"repo":"thor","file":"spec/shell/html_spec.rb","line":4,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Shell::HTML.new\n end"}
{"repo":"thor","file":"spec/shell_spec.rb","line":4,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Base.shell.new\n end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":4,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Base.shell.new\n end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":11,"symbol":"a","kind":"method","lang":"ruby","code":"def a; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":14,"symbol":"z","kind":"method","lang":"ruby","code":"def z; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":30,"symbol":"a","kind":"method","lang":"ruby","code":"def a; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":33,"symbol":"z","kind":"method","lang":"ruby","code":"def z; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":35,"symbol":"sort_commands!","kind":"method","lang":"ruby","code":"def self.sort_commands!(list)\n list.sort!\n list.reverse!\n end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":55,"symbol":"a","kind":"method","lang":"ruby","code":"def a; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":58,"symbol":"z","kind":"method","lang":"ruby","code":"def z; end"}
{"repo":"thor","file":"spec/sort_spec.rb","line":60,"symbol":"sort_commands!","kind":"method","lang":"ruby","code":"def self.sort_commands!(list)\n list.sort_by! do |a,b|\n a[0] == :help ? -1 : a[0] <=> b[0]\n end\n end"}
{"repo":"thor","file":"spec/subcommand_spec.rb","line":47,"symbol":"SubcommandTest1","kind":"module","lang":"ruby","code":"module SubcommandTest1\n class Child1 < Thor\n desc \"foo NAME\", \"Fooo\"\n def foo(name)\n puts \"#{name} was given\"\n end\n end\n\n class Parent < Thor\n desc \"child1\", \"child1 description\"\n subcommand \"child1\", Child1\n\n def self.exit_on_failure?\n false\n end\n end\n end"}
{"repo":"thor","file":"spec/subcommand_spec.rb","line":48,"symbol":"Child1","kind":"class","lang":"ruby","code":"class Child1 < Thor\n desc \"foo NAME\", \"Fooo\"\n def foo(name)\n puts \"#{name} was given\"\n end\n end"}
{"repo":"thor","file":"spec/subcommand_spec.rb","line":50,"symbol":"foo","kind":"method","lang":"ruby","code":"def foo(name)\n puts \"#{name} was given\"\n end"}
{"repo":"thor","file":"spec/subcommand_spec.rb","line":55,"symbol":"Parent","kind":"class","lang":"ruby","code":"class Parent < Thor\n desc \"child1\", \"child1 description\"\n subcommand \"child1\", Child1\n\n def self.exit_on_failure?\n false\n end\n end"}
{"repo":"thor","file":"spec/subcommand_spec.rb","line":59,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":100,"symbol":"exec","kind":"method","lang":"ruby","code":"def exec(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":105,"symbol":"boring","kind":"method","lang":"ruby","code":"def boring(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":173,"symbol":"exec","kind":"method","lang":"ruby","code":"def exec(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":177,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":227,"symbol":"checked","kind":"method","lang":"ruby","code":"def checked(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":231,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":288,"symbol":"exec","kind":"method","lang":"ruby","code":"def exec(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":293,"symbol":"boring","kind":"method","lang":"ruby","code":"def boring(*args)\n [options, args]\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":297,"symbol":"exit_on_failure?","kind":"method","lang":"ruby","code":"def self.exit_on_failure?\n false\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":547,"symbol":"shell","kind":"method","lang":"ruby","code":"def shell\n @shell ||= Thor::Base.shell.new\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":714,"symbol":"bar","kind":"method","lang":"ruby","code":"def bar; end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":767,"symbol":"hi","kind":"method","lang":"ruby","code":"def hi(name)\n name = name.upcase if options[:loud]\n \"Hi #{name}\"\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":797,"symbol":"unknown","kind":"method","lang":"ruby","code":"def unknown(*args)\n args\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":811,"symbol":"unknown","kind":"method","lang":"ruby","code":"def unknown(*args)\n args\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":827,"symbol":"unknown","kind":"method","lang":"ruby","code":"def unknown(*args)\n args\n end"}
{"repo":"thor","file":"spec/thor_spec.rb","line":880,"symbol":"no_arg","kind":"method","lang":"ruby","code":"def no_arg\n end"}
{"repo":"thor","file":"spec/tree_spec.rb","line":4,"symbol":"TreeApp","kind":"class","lang":"ruby","code":"class TreeApp < Thor\n desc \"command1\", \"A top level command\"\n\n def command1\n end\n\n desc \"command2\", \"Another top level command\"\n\n def command2\n end\n\n class SubApp < Thor\n desc \"subcommand1\", \"A subcommand\"\n\n def subcommand1\n end\n end\n\n desc \"sub\", \"Subcommands\"\n subcommand \"sub\", SubApp\nend"}
{"repo":"thor","file":"spec/tree_spec.rb","line":7,"symbol":"command1","kind":"method","lang":"ruby","code":"def command1\n end"}
{"repo":"thor","file":"spec/tree_spec.rb","line":12,"symbol":"command2","kind":"method","lang":"ruby","code":"def command2\n end"}
{"repo":"thor","file":"spec/tree_spec.rb","line":15,"symbol":"SubApp","kind":"class","lang":"ruby","code":"class SubApp < Thor\n desc \"subcommand1\", \"A subcommand\"\n\n def subcommand1\n end\n end"}
{"repo":"thor","file":"spec/tree_spec.rb","line":18,"symbol":"subcommand1","kind":"method","lang":"ruby","code":"def subcommand1\n end"}
{"repo":"thor","file":"spec/util_spec.rb","line":4,"symbol":"clear_user_home!","kind":"method","lang":"ruby","code":"def self.clear_user_home!\n @@user_home = nil\n end"}