class Object

Public Class Methods

handle_no_command_error(name) click to toggle source
# File lib/vendor/thor/spec/command_spec.rb, line 67
def self.handle_no_command_error(name)
  name
end

Public Instance Methods

action(*args, &block) click to toggle source
# File lib/vendor/thor/spec/actions/file_manipulation_spec.rb, line 10
def action(*args, &block)
  capture(:stdout) { runner.send(*args, &block) }
end
argument(name, options={}) click to toggle source
# File lib/vendor/thor/spec/parser/argument_spec.rb, line 6
def argument(name, options={})
  @argument ||= Thor::Argument.new(name, options)
end
base() click to toggle source
# File lib/vendor/thor/spec/actions/empty_directory_spec.rb, line 21
def base
  @base ||= MyCounter.new([1,2], {}, { :destination_root => destination_root })
end
boring(*args) click to toggle source
# File lib/vendor/thor/spec/thor_spec.rb, line 105
def boring(*args)
  return options, args
end
can_has() click to toggle source
# File lib/vendor/thor/spec/command_spec.rb, line 72
def can_has
  "fail"
end
capture(stream) { || ... } click to toggle source
# File lib/vendor/thor/spec/helper.rb, line 45
def capture(stream)
  begin
    stream = stream.to_s
    eval "$#{stream} = StringIO.new"
    yield
    result = eval("$#{stream}").string
  ensure
    eval("$#{stream} = #{stream.upcase}")
  end

  result
end
Also aliased as: silence
check_unknown!() click to toggle source
# File lib/vendor/thor/spec/parser/options_spec.rb, line 17
def check_unknown!
  @opt.check_unknown!
end
command(options={}) click to toggle source
# File lib/vendor/thor/spec/command_spec.rb, line 4
def command(options={})
  options.each do |key, value|
    options[key] = Thor::Option.parse(key, value)
  end

  @command ||= Thor::Command.new(:can_has, "I can has cheezburger", "I can has cheezburger\nLots and lots of it", "can_has", options)
end
create(opts={}) click to toggle source
# File lib/vendor/thor/spec/parser/arguments_spec.rb, line 5
def create(opts={})
  arguments = opts.map do |type, default|
    options = {:required => default.nil?, :type => type, :default => default}
    Thor::Argument.new(type.to_s, options)
  end

  arguments.sort!{ |a,b| b.name <=> a.name }
  @opt = Thor::Arguments.new(arguments)
end
create_file(destination=nil, config={}, options={}) click to toggle source
# File lib/vendor/thor/spec/actions/create_file_spec.rb, line 9
def create_file(destination=nil, config={}, options={})
  @base = MyCounter.new([1, 2], options, { :destination_root => destination_root })
  allow(@base).to receive(:file_name).and_return('rdoc')

  @action = Thor::Actions::CreateFile.new(@base, destination, "CONFIGURATION",
                                          { :verbose => !@silence }.merge(config))
end
destination_root() click to toggle source
# File lib/vendor/thor/spec/helper.rb, line 62
def destination_root
  File.join(File.dirname(__FILE__), 'sandbox')
end
empty_directory(destination, options={}) click to toggle source
# File lib/vendor/thor/spec/actions/empty_directory_spec.rb, line 9
def empty_directory(destination, options={})
  @action = Thor::Actions::EmptyDirectory.new(base, destination)
end
exec(*args) click to toggle source
# File lib/vendor/thor/spec/thor_spec.rb, line 100
def exec(*args)
  return options, args
end
exists_and_identical?(source_path, destination_path) click to toggle source
# File lib/vendor/thor/spec/actions/directory_spec.rb, line 26
def exists_and_identical?(source_path, destination_path)
  %w(config.rb README).each do |file|
    source      = File.join(source_root, source_path, file)
    destination = File.join(destination_root, destination_path, file)

    expect(File.exists?(destination)).to be_true
    expect(FileUtils.identical?(source, destination)).to be_true
  end
end
file() click to toggle source
# File lib/vendor/thor/spec/actions/file_manipulation_spec.rb, line 22
def file
  File.join(destination_root, "foo")
end
hi() click to toggle source
# File lib/vendor/thor/spec/group_spec.rb, line 192
def hi
  name.upcase! if options[:loud]
  "Hi #{name}"
end
invoke!() click to toggle source
# File lib/vendor/thor/spec/actions/create_file_spec.rb, line 17
def invoke!
  capture(:stdout) { @action.invoke! }
end
invoker() click to toggle source
# File lib/vendor/thor/spec/actions/directory_spec.rb, line 10
def invoker
  @invoker ||= WhinyGenerator.new([1,2], {}, { :destination_root => destination_root })
end
namespace(name) click to toggle source
Calls superclass method
# File lib/vendor/thor/lib/thor/rake_compat.rb, line 60
def namespace(name)
  if klass = Thor::RakeCompat.rake_classes.last
    const_name = Thor::Util.camel_case(name.to_s).to_sym
    klass.const_set(const_name, Class.new(Thor))
    new_klass = klass.const_get(const_name)
    Thor::RakeCompat.rake_classes << new_klass
  end

  super
  Thor::RakeCompat.rake_classes.pop
end
Also aliased as: rake_namespace
option(name, options={}) click to toggle source
# File lib/vendor/thor/spec/parser/option_spec.rb, line 9
def option(name, options={})
  @option ||= Thor::Option.new(name, options)
end
parse(*args) click to toggle source
# File lib/vendor/thor/spec/parser/arguments_spec.rb, line 15
def parse(*args)
  @opt.parse(args)
end
rake_namespace(name)
Alias for: namespace
remaining() click to toggle source
# File lib/vendor/thor/spec/parser/options_spec.rb, line 21
def remaining
  @opt.remaining
end
revoke!() click to toggle source
# File lib/vendor/thor/spec/actions/create_file_spec.rb, line 21
def revoke!
  capture(:stdout) { @action.revoke! }
end
revoker() click to toggle source
# File lib/vendor/thor/spec/actions/directory_spec.rb, line 14
def revoker
  @revoker ||= WhinyGenerator.new([1,2], {}, { :destination_root => destination_root, :behavior => :revoke })
end
runner(options={}) click to toggle source
# File lib/vendor/thor/spec/actions/file_manipulation_spec.rb, line 6
def runner(options={})
  @runner ||= MyCounter.new([1], options, { :destination_root => destination_root })
end
shell() click to toggle source
# File lib/vendor/thor/spec/shell/basic_spec.rb, line 5
def shell
  @shell ||= Thor::Shell::Basic.new
end
silence(stream)
Alias for: capture
silence!() click to toggle source
# File lib/vendor/thor/spec/actions/create_file_spec.rb, line 25
def silence!
  @silence = true
end
source_root() click to toggle source
# File lib/vendor/thor/spec/helper.rb, line 58
def source_root
  File.join(File.dirname(__FILE__), 'fixtures')
end
task(*) click to toggle source
Calls superclass method
# File lib/vendor/thor/lib/thor/rake_compat.rb, line 40
def task(*)
  task = super

  if klass = Thor::RakeCompat.rake_classes.last
    non_namespaced_name = task.name.split(':').last

    description = non_namespaced_name
    description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
    description.strip!

    klass.desc description, Rake.application.last_description || non_namespaced_name
    Rake.application.last_description = nil
    klass.send :define_method, non_namespaced_name do |*args|
      Rake::Task[task.name.to_sym].invoke(*args)
    end
  end

  task
end
unknown(*args) click to toggle source
# File lib/vendor/thor/spec/thor_spec.rb, line 456
def unknown(*args)
  args
end
when_no_thorfiles_exist() { || ... } click to toggle source
# File lib/vendor/thor/spec/runner_spec.rb, line 5
def when_no_thorfiles_exist
  old_dir = Dir.pwd
  Dir.chdir '..'
  delete = Thor::Base.subclasses.select {|e| e.namespace == 'default' }
  delete.each {|e| Thor::Base.subclasses.delete e }
  yield
  Thor::Base.subclasses.concat delete
  Dir.chdir old_dir
end