spec/fixtures/script.thor in thor-0.17.0 vs spec/fixtures/script.thor in thor-0.18.0
- old
+ new
@@ -3,12 +3,16 @@
attr_accessor :some_attribute
attr_writer :another_attribute
attr_reader :another_attribute
+ private
+ attr_reader :private_attribute
+
+ public
group :script
- default_task :example_default_task
+ default_command :example_default_command
map "-T" => :animal, ["-f", "--foo"] => :foo
map "animal_prison" => "zoo"
@@ -17,12 +21,12 @@
true
end
desc "animal TYPE", "horse around"
- no_tasks do
- def this_is_not_a_task
+ no_commands do
+ def this_is_not_a_command
end
end
def animal(type)
[type]
@@ -45,22 +49,22 @@
method_option :force, :type => :boolean, :desc => "Force to do some fooing"
def foo(bar)
[bar, options]
end
- desc "example_default_task", "example!"
+ desc "example_default_command", "example!"
method_options :with => :string
- def example_default_task
- options.empty? ? "default task" : options
+ def example_default_command
+ options.empty? ? "default command" : options
end
desc "call_myself_with_wrong_arity", "get the right error"
def call_myself_with_wrong_arity
call_myself_with_wrong_arity(4)
end
- desc "call_unexistent_method", "Call unexistent method inside a task"
+ desc "call_unexistent_method", "Call unexistent method inside a command"
def call_unexistent_method
boom!
end
desc "long_description", "a" * 80
@@ -71,11 +75,11 @@
It even has two paragraphs.
D
def long_description
end
- desc "name-with-dashes", "Ensure normalization of task names"
+ desc "name-with-dashes", "Ensure normalization of command names"
def name_with_dashes
end
method_options :all => :boolean
method_option :lazy, :lazy_default => "yes"
@@ -91,11 +95,11 @@
desc "baz", "do some bazing"
def baz
end
end
- desc "send", "send as a task name"
+ desc "send", "send as a command name"
def send
true
end
private
@@ -112,11 +116,11 @@
def what
end
end
class MyChildScript < MyScript
- remove_task :bar
+ remove_command :bar
method_options :force => :boolean, :param => :numeric
def initialize(*args)
super
end
@@ -136,11 +140,11 @@
desc "boom", "explodes everything"
def boom
end
- remove_task :boom, :undefine => true
+ remove_command :boom, :undefine => true
end
class Barn < Thor
desc "open [ITEM]", "open the barn door"
def open(item = nil)
@@ -154,18 +158,21 @@
desc "paint [COLOR]", "paint the barn"
method_option :coats, :type => :numeric, :default => 2, :desc => 'how many coats of paint'
def paint(color='red')
puts "#{options[:coats]} coats of #{color} paint"
end
+end
+class PackageNameScript < Thor
+ package_name "Baboon"
end
module Scripts
class MyScript < MyChildScript
argument :accessor, :type => :string
class_options :force => :boolean
- method_option :new_option, :type => :string, :for => :example_default_task
+ method_option :new_option, :type => :string, :for => :example_default_command
def zoo
self.accessor
end
end
@@ -177,19 +184,37 @@
desc "cow", "prints 'moo'"
def cow
puts "moo"
end
- desc "task_conflict", "only gets called when prepended with a colon"
- def task_conflict
- puts "task"
+ desc "command_conflict", "only gets called when prepended with a colon"
+ def command_conflict
+ puts "command"
end
desc "barn", "commands to manage the barn"
subcommand "barn", Barn
end
class ChildDefault < Thor
namespace "default:child"
+ end
+
+ class Arities < Thor
+ desc "zero_args", "takes zero args"
+ def zero_args
+ end
+
+ desc "one_arg ARG", "takes one arg"
+ def one_arg(arg)
+ end
+
+ desc "two_args ARG1 ARG2", "takes two args"
+ def two_args(arg1, arg2)
+ end
+
+ desc "optional_arg [ARG]", "takes an optional arg"
+ def optional_arg(arg='default')
+ end
end
end