angry_mob 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.md +123 -0
- data/bin/mob +139 -0
- data/lib/angry_mob.rb +28 -0
- data/lib/angry_mob/act.rb +111 -0
- data/lib/angry_mob/act/scheduler.rb +143 -0
- data/lib/angry_mob/action.rb +11 -0
- data/lib/angry_mob/builder.rb +115 -0
- data/lib/angry_mob/extend.rb +10 -0
- data/lib/angry_mob/extend/array.rb +30 -0
- data/lib/angry_mob/extend/blank.rb +108 -0
- data/lib/angry_mob/extend/blankslate.rb +109 -0
- data/lib/angry_mob/extend/dictionary.rb +140 -0
- data/lib/angry_mob/extend/hash.rb +67 -0
- data/lib/angry_mob/extend/object.rb +21 -0
- data/lib/angry_mob/extend/pathname.rb +23 -0
- data/lib/angry_mob/extend/string.rb +8 -0
- data/lib/angry_mob/log.rb +28 -0
- data/lib/angry_mob/mob.rb +77 -0
- data/lib/angry_mob/mob_loader.rb +115 -0
- data/lib/angry_mob/node.rb +44 -0
- data/lib/angry_mob/notifier.rb +76 -0
- data/lib/angry_mob/target.rb +257 -0
- data/lib/angry_mob/target/arguments.rb +71 -0
- data/lib/angry_mob/target/call.rb +57 -0
- data/lib/angry_mob/target/default_resource_locator.rb +11 -0
- data/lib/angry_mob/target/defaults.rb +23 -0
- data/lib/angry_mob/target/mother.rb +66 -0
- data/lib/angry_mob/target/notify.rb +57 -0
- data/lib/angry_mob/target/tracking.rb +96 -0
- data/lib/angry_mob/ui.rb +247 -0
- data/lib/angry_mob/util.rb +11 -0
- data/lib/angry_mob/vendored.rb +8 -0
- data/lib/angry_mob/version.rb +3 -0
- data/vendor/angry_hash/Rakefile +17 -0
- data/vendor/angry_hash/VERSION +1 -0
- data/vendor/angry_hash/angry_hash.gemspec +47 -0
- data/vendor/angry_hash/examples/accessors_eg.rb +46 -0
- data/vendor/angry_hash/examples/creation_eg.rb +43 -0
- data/vendor/angry_hash/examples/dsl.eg.rb +18 -0
- data/vendor/angry_hash/examples/dup_eg.rb +86 -0
- data/vendor/angry_hash/examples/eg_helper.rb +24 -0
- data/vendor/angry_hash/examples/merge_eg.rb +135 -0
- data/vendor/angry_hash/lib/angry_hash.rb +215 -0
- data/vendor/angry_hash/lib/angry_hash/dsl.rb +44 -0
- data/vendor/angry_hash/lib/angry_hash/extension_tracking.rb +12 -0
- data/vendor/angry_hash/lib/angry_hash/merge_string.rb +58 -0
- data/vendor/json/COPYING +58 -0
- data/vendor/json/GPL +340 -0
- data/vendor/json/README +360 -0
- data/vendor/json/lib/json/common.rb +371 -0
- data/vendor/json/lib/json/pure.rb +77 -0
- data/vendor/json/lib/json/pure/generator.rb +443 -0
- data/vendor/json/lib/json/pure/parser.rb +303 -0
- data/vendor/json/lib/json/version.rb +8 -0
- data/vendor/thor/CHANGELOG.rdoc +89 -0
- data/vendor/thor/LICENSE +20 -0
- data/vendor/thor/README.rdoc +297 -0
- data/vendor/thor/Thorfile +69 -0
- data/vendor/thor/bin/rake2thor +86 -0
- data/vendor/thor/bin/thor +6 -0
- data/vendor/thor/lib/thor.rb +244 -0
- data/vendor/thor/lib/thor/actions.rb +275 -0
- data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor/lib/thor/actions/directory.rb +91 -0
- data/vendor/thor/lib/thor/actions/empty_directory.rb +134 -0
- data/vendor/thor/lib/thor/actions/file_manipulation.rb +223 -0
- data/vendor/thor/lib/thor/actions/inject_into_file.rb +104 -0
- data/vendor/thor/lib/thor/base.rb +540 -0
- data/vendor/thor/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/vendor/thor/lib/thor/error.rb +30 -0
- data/vendor/thor/lib/thor/group.rb +271 -0
- data/vendor/thor/lib/thor/invocation.rb +180 -0
- data/vendor/thor/lib/thor/parser.rb +4 -0
- data/vendor/thor/lib/thor/parser/argument.rb +67 -0
- data/vendor/thor/lib/thor/parser/arguments.rb +150 -0
- data/vendor/thor/lib/thor/parser/option.rb +128 -0
- data/vendor/thor/lib/thor/parser/options.rb +169 -0
- data/vendor/thor/lib/thor/rake_compat.rb +66 -0
- data/vendor/thor/lib/thor/runner.rb +314 -0
- data/vendor/thor/lib/thor/shell.rb +83 -0
- data/vendor/thor/lib/thor/shell/basic.rb +239 -0
- data/vendor/thor/lib/thor/shell/color.rb +108 -0
- data/vendor/thor/lib/thor/task.rb +102 -0
- data/vendor/thor/lib/thor/util.rb +224 -0
- data/vendor/thor/lib/thor/version.rb +3 -0
- data/vendor/thor/spec/actions/create_file_spec.rb +170 -0
- data/vendor/thor/spec/actions/directory_spec.rb +131 -0
- data/vendor/thor/spec/actions/empty_directory_spec.rb +91 -0
- data/vendor/thor/spec/actions/file_manipulation_spec.rb +271 -0
- data/vendor/thor/spec/actions/inject_into_file_spec.rb +135 -0
- data/vendor/thor/spec/actions_spec.rb +292 -0
- data/vendor/thor/spec/base_spec.rb +263 -0
- data/vendor/thor/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
- data/vendor/thor/spec/core_ext/ordered_hash_spec.rb +115 -0
- data/vendor/thor/spec/fixtures/application.rb +2 -0
- data/vendor/thor/spec/fixtures/bundle/execute.rb +6 -0
- data/vendor/thor/spec/fixtures/bundle/main.thor +1 -0
- data/vendor/thor/spec/fixtures/doc/%file_name%.rb.tt +1 -0
- data/vendor/thor/spec/fixtures/doc/README +3 -0
- data/vendor/thor/spec/fixtures/doc/config.rb +1 -0
- data/vendor/thor/spec/fixtures/group.thor +90 -0
- data/vendor/thor/spec/fixtures/invoke.thor +112 -0
- data/vendor/thor/spec/fixtures/script.thor +145 -0
- data/vendor/thor/spec/fixtures/task.thor +10 -0
- data/vendor/thor/spec/group_spec.rb +171 -0
- data/vendor/thor/spec/invocation_spec.rb +107 -0
- data/vendor/thor/spec/parser/argument_spec.rb +47 -0
- data/vendor/thor/spec/parser/arguments_spec.rb +64 -0
- data/vendor/thor/spec/parser/option_spec.rb +202 -0
- data/vendor/thor/spec/parser/options_spec.rb +292 -0
- data/vendor/thor/spec/rake_compat_spec.rb +68 -0
- data/vendor/thor/spec/runner_spec.rb +210 -0
- data/vendor/thor/spec/shell/basic_spec.rb +205 -0
- data/vendor/thor/spec/shell/color_spec.rb +41 -0
- data/vendor/thor/spec/shell_spec.rb +34 -0
- data/vendor/thor/spec/spec.opts +1 -0
- data/vendor/thor/spec/spec_helper.rb +54 -0
- data/vendor/thor/spec/task_spec.rb +69 -0
- data/vendor/thor/spec/thor_spec.rb +237 -0
- data/vendor/thor/spec/util_spec.rb +163 -0
- data/vendor/thor/thor.gemspec +120 -0
- metadata +199 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'thor/core_ext/hash_with_indifferent_access'
|
3
|
+
|
4
|
+
describe Thor::CoreExt::HashWithIndifferentAccess do
|
5
|
+
before(:each) do
|
6
|
+
@hash = Thor::CoreExt::HashWithIndifferentAccess.new :foo => 'bar', 'baz' => 'bee', :force => true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "has values accessible by either strings or symbols" do
|
10
|
+
@hash['foo'].must == 'bar'
|
11
|
+
@hash[:foo].must == 'bar'
|
12
|
+
|
13
|
+
@hash.values_at(:foo, :baz).must == ['bar', 'bee']
|
14
|
+
@hash.delete(:foo).must == 'bar'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "handles magic boolean predicates" do
|
18
|
+
@hash.force?.must be_true
|
19
|
+
@hash.foo?.must be_true
|
20
|
+
@hash.nothing?.must be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles magic comparisions" do
|
24
|
+
@hash.foo?('bar').must be_true
|
25
|
+
@hash.foo?('bee').must be_false
|
26
|
+
end
|
27
|
+
|
28
|
+
it "maps methods to keys" do
|
29
|
+
@hash.foo.must == @hash['foo']
|
30
|
+
end
|
31
|
+
|
32
|
+
it "merges keys independent if they are symbols or strings" do
|
33
|
+
@hash.merge!('force' => false, :baz => "boom")
|
34
|
+
@hash[:force].must == false
|
35
|
+
@hash[:baz].must == "boom"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "creates a new hash by merging keys independent if they are symbols or strings" do
|
39
|
+
other = @hash.merge('force' => false, :baz => "boom")
|
40
|
+
other[:force].must == false
|
41
|
+
other[:baz].must == "boom"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'thor/core_ext/ordered_hash'
|
3
|
+
|
4
|
+
describe Thor::CoreExt::OrderedHash do
|
5
|
+
before :each do
|
6
|
+
@hash = Thor::CoreExt::OrderedHash.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "without any items" do
|
10
|
+
it "returns nil for an undefined key" do
|
11
|
+
@hash["foo"].must be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "doesn't iterate through any items" do
|
15
|
+
@hash.each { fail }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has an empty key and values list" do
|
19
|
+
@hash.keys.must be_empty
|
20
|
+
@hash.values.must be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must be empty" do
|
24
|
+
@hash.must be_empty
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "with several items" do
|
29
|
+
before :each do
|
30
|
+
@hash[:foo] = "Foo!"
|
31
|
+
@hash[:bar] = "Bar!"
|
32
|
+
@hash[:baz] = "Baz!"
|
33
|
+
@hash[:bop] = "Bop!"
|
34
|
+
@hash[:bat] = "Bat!"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil for an undefined key" do
|
38
|
+
@hash[:boom].must be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the value for each key" do
|
42
|
+
@hash[:foo].must == "Foo!"
|
43
|
+
@hash[:bar].must == "Bar!"
|
44
|
+
@hash[:baz].must == "Baz!"
|
45
|
+
@hash[:bop].must == "Bop!"
|
46
|
+
@hash[:bat].must == "Bat!"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "iterates through the keys and values in order of assignment" do
|
50
|
+
arr = []
|
51
|
+
@hash.each do |key, value|
|
52
|
+
arr << [key, value]
|
53
|
+
end
|
54
|
+
arr.must == [[:foo, "Foo!"], [:bar, "Bar!"], [:baz, "Baz!"],
|
55
|
+
[:bop, "Bop!"], [:bat, "Bat!"]]
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns the keys in order of insertion" do
|
59
|
+
@hash.keys.must == [:foo, :bar, :baz, :bop, :bat]
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns the values in order of insertion" do
|
63
|
+
@hash.values.must == ["Foo!", "Bar!", "Baz!", "Bop!", "Bat!"]
|
64
|
+
end
|
65
|
+
|
66
|
+
it "does not move an overwritten node to the end of the ordering" do
|
67
|
+
@hash[:baz] = "Bip!"
|
68
|
+
@hash.values.must == ["Foo!", "Bar!", "Bip!", "Bop!", "Bat!"]
|
69
|
+
|
70
|
+
@hash[:foo] = "Bip!"
|
71
|
+
@hash.values.must == ["Bip!", "Bar!", "Bip!", "Bop!", "Bat!"]
|
72
|
+
|
73
|
+
@hash[:bat] = "Bip!"
|
74
|
+
@hash.values.must == ["Bip!", "Bar!", "Bip!", "Bop!", "Bip!"]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "appends another ordered hash while preserving ordering" do
|
78
|
+
other_hash = Thor::CoreExt::OrderedHash.new
|
79
|
+
other_hash[1] = "one"
|
80
|
+
other_hash[2] = "two"
|
81
|
+
other_hash[3] = "three"
|
82
|
+
@hash.merge(other_hash).values.must == ["Foo!", "Bar!", "Baz!", "Bop!", "Bat!", "one", "two", "three"]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "overwrites hash keys with matching appended keys" do
|
86
|
+
other_hash = Thor::CoreExt::OrderedHash.new
|
87
|
+
other_hash[:bar] = "bar"
|
88
|
+
@hash.merge(other_hash)[:bar].must == "bar"
|
89
|
+
@hash[:bar].must == "Bar!"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "converts to an array" do
|
93
|
+
@hash.to_a.must == [[:foo, "Foo!"], [:bar, "Bar!"], [:baz, "Baz!"], [:bop, "Bop!"], [:bat, "Bat!"]]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "must not be empty" do
|
97
|
+
@hash.must_not be_empty
|
98
|
+
end
|
99
|
+
|
100
|
+
it "deletes values from hash" do
|
101
|
+
@hash.delete(:baz).must == "Baz!"
|
102
|
+
@hash.values.must == ["Foo!", "Bar!", "Bop!", "Bat!"]
|
103
|
+
|
104
|
+
@hash.delete(:foo).must == "Foo!"
|
105
|
+
@hash.values.must == ["Bar!", "Bop!", "Bat!"]
|
106
|
+
|
107
|
+
@hash.delete(:bat).must == "Bat!"
|
108
|
+
@hash.values.must == ["Bar!", "Bop!"]
|
109
|
+
end
|
110
|
+
|
111
|
+
it "returns nil if the value to be deleted can't be found" do
|
112
|
+
@hash.delete(:nothing).must be_nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'execute')
|
@@ -0,0 +1 @@
|
|
1
|
+
FOO = <%= "FOO" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
class <%= @klass %>; end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
class MyCounter < Thor::Group
|
2
|
+
include Thor::Actions
|
3
|
+
add_runtime_options!
|
4
|
+
|
5
|
+
def self.get_from_super
|
6
|
+
from_superclass(:get_from_super, 13)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
File.expand_path(File.dirname(__FILE__))
|
11
|
+
end
|
12
|
+
source_paths << File.expand_path("broken", File.dirname(__FILE__))
|
13
|
+
|
14
|
+
argument :first, :type => :numeric
|
15
|
+
argument :second, :type => :numeric, :default => 2
|
16
|
+
|
17
|
+
class_option :third, :type => :numeric, :desc => "The third argument", :default => 3,
|
18
|
+
:banner => "THREE", :aliases => "-t"
|
19
|
+
class_option :fourth, :type => :numeric, :desc => "The fourth argument"
|
20
|
+
|
21
|
+
desc <<-FOO
|
22
|
+
Description:
|
23
|
+
This generator runs three tasks: one, two and three.
|
24
|
+
FOO
|
25
|
+
|
26
|
+
def one
|
27
|
+
first
|
28
|
+
end
|
29
|
+
|
30
|
+
def two
|
31
|
+
second
|
32
|
+
end
|
33
|
+
|
34
|
+
def three
|
35
|
+
options[:third]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.inherited(base)
|
39
|
+
super
|
40
|
+
base.source_paths.unshift(File.expand_path(File.join(File.dirname(__FILE__), "doc")))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class ClearCounter < MyCounter
|
45
|
+
remove_argument :first, :second, :undefine => true
|
46
|
+
remove_class_option :third
|
47
|
+
|
48
|
+
def self.source_root
|
49
|
+
File.expand_path(File.join(File.dirname(__FILE__), "bundle"))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class BrokenCounter < MyCounter
|
54
|
+
namespace "app:broken:counter"
|
55
|
+
class_option :fail, :type => :boolean, :default => false
|
56
|
+
|
57
|
+
class << self
|
58
|
+
undef_method :source_root
|
59
|
+
end
|
60
|
+
|
61
|
+
def one
|
62
|
+
options[:first]
|
63
|
+
end
|
64
|
+
|
65
|
+
def four
|
66
|
+
respond_to?(:fail)
|
67
|
+
end
|
68
|
+
|
69
|
+
def five
|
70
|
+
options[:fail] ? this_method_does_not_exist : 5
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class WhinyGenerator < Thor::Group
|
75
|
+
include Thor::Actions
|
76
|
+
|
77
|
+
def self.source_root
|
78
|
+
File.expand_path(File.dirname(__FILE__))
|
79
|
+
end
|
80
|
+
|
81
|
+
def wrong_arity(required)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class TaskConflict < Thor::Group
|
86
|
+
desc "A group with the same name as a default task"
|
87
|
+
def group
|
88
|
+
puts "group"
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
class A < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
desc "one", "invoke one"
|
5
|
+
def one
|
6
|
+
p 1
|
7
|
+
invoke :two
|
8
|
+
invoke :three
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "two", "invoke two"
|
12
|
+
def two
|
13
|
+
p 2
|
14
|
+
invoke :three
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "three", "invoke three"
|
18
|
+
def three
|
19
|
+
p 3
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "four", "invoke four"
|
23
|
+
def four
|
24
|
+
p 4
|
25
|
+
invoke "defined:five"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "five N", "check if number is equal 5"
|
29
|
+
def five(number)
|
30
|
+
number == 5
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "invoker", "invoke a b task"
|
34
|
+
def invoker(*args)
|
35
|
+
invoke :b, :one, ["Jose"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class B < Thor
|
40
|
+
class_option :last_name, :type => :string
|
41
|
+
|
42
|
+
desc "one FIRST_NAME", "invoke one"
|
43
|
+
def one(first_name)
|
44
|
+
"#{options.last_name}, #{first_name}"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "two", "invoke two"
|
48
|
+
def two
|
49
|
+
options
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "three", "invoke three"
|
53
|
+
def three
|
54
|
+
self
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class C < Thor::Group
|
59
|
+
include Thor::Actions
|
60
|
+
|
61
|
+
def one
|
62
|
+
p 1
|
63
|
+
end
|
64
|
+
|
65
|
+
def two
|
66
|
+
p 2
|
67
|
+
end
|
68
|
+
|
69
|
+
def three
|
70
|
+
p 3
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Defined < Thor::Group
|
75
|
+
class_option :unused, :type => :boolean, :desc => "This option has no use"
|
76
|
+
|
77
|
+
def one
|
78
|
+
p 1
|
79
|
+
invoke "a:two"
|
80
|
+
invoke "a:three"
|
81
|
+
invoke "a:four"
|
82
|
+
invoke "defined:five"
|
83
|
+
end
|
84
|
+
|
85
|
+
def five
|
86
|
+
p 5
|
87
|
+
end
|
88
|
+
|
89
|
+
def print_status
|
90
|
+
say_status :finished, :counting
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class E < Thor::Group
|
95
|
+
invoke Defined
|
96
|
+
end
|
97
|
+
|
98
|
+
class F < Thor::Group
|
99
|
+
invoke "b:one" do |instance, klass, task|
|
100
|
+
instance.invoke klass, task, [ "Jose" ], :last_name => "Valim"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class G < Thor::Group
|
105
|
+
class_option :invoked, :type => :string, :default => "defined"
|
106
|
+
invoke_from_option :invoked
|
107
|
+
end
|
108
|
+
|
109
|
+
class H < Thor::Group
|
110
|
+
class_option :defined, :type => :boolean, :default => true
|
111
|
+
invoke_from_option :defined
|
112
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
class MyScript < Thor
|
2
|
+
check_unknown_options!
|
3
|
+
|
4
|
+
attr_accessor :some_attribute
|
5
|
+
attr_writer :another_attribute
|
6
|
+
attr_reader :another_attribute
|
7
|
+
|
8
|
+
group :script
|
9
|
+
default_task :example_default_task
|
10
|
+
|
11
|
+
map "-T" => :animal, ["-f", "--foo"] => :foo
|
12
|
+
|
13
|
+
desc "zoo", "zoo around"
|
14
|
+
def zoo
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "animal TYPE", "horse around"
|
19
|
+
|
20
|
+
no_tasks do
|
21
|
+
def this_is_not_a_task
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def animal(type)
|
26
|
+
[type]
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "foo BAR", <<END
|
30
|
+
do some fooing
|
31
|
+
This is more info!
|
32
|
+
Everyone likes more info!
|
33
|
+
END
|
34
|
+
method_option :force, :type => :boolean, :desc => "Force to do some fooing"
|
35
|
+
def foo(bar)
|
36
|
+
[bar, options]
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "example_default_task", "example!"
|
40
|
+
def example_default_task
|
41
|
+
options.empty? ? "default task" : options
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "call_myself_with_wrong_arity", "get the right error"
|
45
|
+
def call_myself_with_wrong_arity
|
46
|
+
call_myself_with_wrong_arity(4)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "call_unexistent_method", "Call unexistent method inside a task"
|
50
|
+
def call_unexistent_method
|
51
|
+
boom!
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "long_description", "a" * 80
|
55
|
+
def long_description
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "name-with-dashes", "Ensure normalization of task names"
|
59
|
+
def name_with_dashes
|
60
|
+
end
|
61
|
+
|
62
|
+
method_options :all => :boolean
|
63
|
+
desc "with_optional NAME", "invoke with optional name"
|
64
|
+
def with_optional(name=nil)
|
65
|
+
[ name, options ]
|
66
|
+
end
|
67
|
+
|
68
|
+
class AnotherScript < Thor
|
69
|
+
desc "baz", "do some bazing"
|
70
|
+
def baz
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def method_missing(meth, *args)
|
77
|
+
if meth == :boom!
|
78
|
+
super
|
79
|
+
else
|
80
|
+
[meth, args]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "what", "what"
|
85
|
+
def what
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class MyChildScript < MyScript
|
90
|
+
remove_task :bar
|
91
|
+
|
92
|
+
method_options :force => :boolean, :param => :numeric
|
93
|
+
def initialize(*args)
|
94
|
+
super
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "zoo", "zoo around"
|
98
|
+
method_options :param => :required
|
99
|
+
def zoo
|
100
|
+
options
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "animal TYPE", "horse around"
|
104
|
+
def animal(type)
|
105
|
+
[type, options]
|
106
|
+
end
|
107
|
+
method_option :other, :type => :string, :default => "method default", :for => :animal
|
108
|
+
desc "animal KIND", "fish around", :for => :animal
|
109
|
+
|
110
|
+
desc "boom", "explodes everything"
|
111
|
+
def boom
|
112
|
+
end
|
113
|
+
|
114
|
+
remove_task :boom, :undefine => true
|
115
|
+
end
|
116
|
+
|
117
|
+
module Scripts
|
118
|
+
class MyScript < MyChildScript
|
119
|
+
argument :accessor, :type => :string
|
120
|
+
class_options :force => :boolean
|
121
|
+
method_option :new_option, :type => :string, :for => :example_default_task
|
122
|
+
|
123
|
+
def zoo
|
124
|
+
self.accessor
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class MyDefaults < Thor
|
129
|
+
namespace :default
|
130
|
+
desc "cow", "prints 'moo'"
|
131
|
+
def cow
|
132
|
+
puts "moo"
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "task_conflict", "only gets called when prepended with a colon"
|
136
|
+
def task_conflict
|
137
|
+
puts "task"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class ChildDefault < Thor
|
142
|
+
namespace "default:child"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|