puppet-module 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/CHANGES.markdown +91 -0
  2. data/LICENSE +17 -0
  3. data/README.markdown +221 -0
  4. data/Rakefile +87 -0
  5. data/VERSION +1 -0
  6. data/bin/puppet-module +7 -0
  7. data/lib/puppet/module/tool.rb +124 -0
  8. data/lib/puppet/module/tool/applications.rb +18 -0
  9. data/lib/puppet/module/tool/applications/application.rb +83 -0
  10. data/lib/puppet/module/tool/applications/builder.rb +88 -0
  11. data/lib/puppet/module/tool/applications/checksummer.rb +38 -0
  12. data/lib/puppet/module/tool/applications/cleaner.rb +14 -0
  13. data/lib/puppet/module/tool/applications/freezer.rb +20 -0
  14. data/lib/puppet/module/tool/applications/generator.rb +117 -0
  15. data/lib/puppet/module/tool/applications/installer.rb +83 -0
  16. data/lib/puppet/module/tool/applications/registrar.rb +34 -0
  17. data/lib/puppet/module/tool/applications/releaser.rb +48 -0
  18. data/lib/puppet/module/tool/applications/searcher.rb +34 -0
  19. data/lib/puppet/module/tool/applications/unpacker.rb +69 -0
  20. data/lib/puppet/module/tool/applications/unreleaser.rb +42 -0
  21. data/lib/puppet/module/tool/cache.rb +56 -0
  22. data/lib/puppet/module/tool/checksums.rb +52 -0
  23. data/lib/puppet/module/tool/cli.rb +127 -0
  24. data/lib/puppet/module/tool/contents_description.rb +84 -0
  25. data/lib/puppet/module/tool/dependency.rb +26 -0
  26. data/lib/puppet/module/tool/metadata.rb +80 -0
  27. data/lib/puppet/module/tool/modulefile.rb +47 -0
  28. data/lib/puppet/module/tool/repository.rb +74 -0
  29. data/lib/puppet/module/tool/skeleton.rb +39 -0
  30. data/lib/puppet/module/tool/utils.rb +9 -0
  31. data/lib/puppet/module/tool/utils/interrogation.rb +39 -0
  32. data/lib/puppet/module/tool/utils/settings.rb +36 -0
  33. data/lib/puppet/module/tool/utils/uri.rb +16 -0
  34. data/spec/fixtures/releases/jamtur01-apache/Modulefile +2 -0
  35. data/spec/fixtures/releases/jamtur01-apache/files/httpd +24 -0
  36. data/spec/fixtures/releases/jamtur01-apache/files/test.vhost +18 -0
  37. data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +21 -0
  38. data/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb +12 -0
  39. data/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp +5 -0
  40. data/spec/fixtures/releases/jamtur01-apache/manifests/init.pp +34 -0
  41. data/spec/fixtures/releases/jamtur01-apache/manifests/params.pp +17 -0
  42. data/spec/fixtures/releases/jamtur01-apache/manifests/php.pp +5 -0
  43. data/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp +15 -0
  44. data/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp +15 -0
  45. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -0
  46. data/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb +20 -0
  47. data/spec/fixtures/releases/jamtur01-apache/tests/apache.pp +1 -0
  48. data/spec/fixtures/releases/jamtur01-apache/tests/dev.pp +1 -0
  49. data/spec/fixtures/releases/jamtur01-apache/tests/init.pp +1 -0
  50. data/spec/fixtures/releases/jamtur01-apache/tests/php.pp +1 -0
  51. data/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp +1 -0
  52. data/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp +2 -0
  53. data/spec/integration/cli_spec.rb +373 -0
  54. data/spec/spec.opts +1 -0
  55. data/spec/spec_helper.rb +15 -0
  56. data/spec/support/output_support.rb +19 -0
  57. data/spec/support/stub_http_support.rb +14 -0
  58. data/spec/support/testdir_support.rb +26 -0
  59. data/spec/unit/application_spec.rb +25 -0
  60. data/spec/unit/repository_spec.rb +51 -0
  61. data/templates/generator/Modulefile.erb +5 -0
  62. data/templates/generator/README.erb +3 -0
  63. data/templates/generator/files/README.markdown +22 -0
  64. data/templates/generator/lib/puppet/facter/README.markdown +22 -0
  65. data/templates/generator/lib/puppet/parser/functions/README.markdown +17 -0
  66. data/templates/generator/lib/puppet/provider/README.markdown +14 -0
  67. data/templates/generator/lib/puppet/type/README.markdown +14 -0
  68. data/templates/generator/manifests/README.markdown +28 -0
  69. data/templates/generator/manifests/init.pp.erb +17 -0
  70. data/templates/generator/metadata.json +12 -0
  71. data/templates/generator/spec/README.markdown +7 -0
  72. data/templates/generator/spec/spec.opts +6 -0
  73. data/templates/generator/spec/spec_helper.rb +18 -0
  74. data/templates/generator/spec/unit/puppet/provider/README.markdown +4 -0
  75. data/templates/generator/spec/unit/puppet/type/README.markdown +4 -0
  76. data/templates/generator/templates/README.markdown +23 -0
  77. data/templates/generator/tests/init.pp.erb +1 -0
  78. data/vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb +23 -0
  79. data/vendor/facets-2.8.2-partial/lib/facets/kernel/tap.rb +39 -0
  80. data/vendor/multipart-post-1.0/Manifest.txt +9 -0
  81. data/vendor/multipart-post-1.0/README.txt +61 -0
  82. data/vendor/multipart-post-1.0/Rakefile +21 -0
  83. data/vendor/multipart-post-1.0/lib/composite_io.rb +89 -0
  84. data/vendor/multipart-post-1.0/lib/multipartable.rb +13 -0
  85. data/vendor/multipart-post-1.0/lib/net/http/post/multipart.rb +27 -0
  86. data/vendor/multipart-post-1.0/lib/parts.rb +66 -0
  87. data/vendor/multipart-post-1.0/test/net/http/post/test_multipart.rb +55 -0
  88. data/vendor/multipart-post-1.0/test/test_composite_io.rb +50 -0
  89. data/vendor/thor-852190ae/CHANGELOG.rdoc +89 -0
  90. data/vendor/thor-852190ae/LICENSE +20 -0
  91. data/vendor/thor-852190ae/README.rdoc +297 -0
  92. data/vendor/thor-852190ae/REVISION +1 -0
  93. data/vendor/thor-852190ae/Thorfile +69 -0
  94. data/vendor/thor-852190ae/bin/rake2thor +86 -0
  95. data/vendor/thor-852190ae/bin/thor +6 -0
  96. data/vendor/thor-852190ae/lib/thor.rb +244 -0
  97. data/vendor/thor-852190ae/lib/thor/actions.rb +275 -0
  98. data/vendor/thor-852190ae/lib/thor/actions/create_file.rb +103 -0
  99. data/vendor/thor-852190ae/lib/thor/actions/directory.rb +91 -0
  100. data/vendor/thor-852190ae/lib/thor/actions/empty_directory.rb +134 -0
  101. data/vendor/thor-852190ae/lib/thor/actions/file_manipulation.rb +223 -0
  102. data/vendor/thor-852190ae/lib/thor/actions/inject_into_file.rb +104 -0
  103. data/vendor/thor-852190ae/lib/thor/base.rb +540 -0
  104. data/vendor/thor-852190ae/lib/thor/core_ext/file_binary_read.rb +9 -0
  105. data/vendor/thor-852190ae/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  106. data/vendor/thor-852190ae/lib/thor/core_ext/ordered_hash.rb +100 -0
  107. data/vendor/thor-852190ae/lib/thor/error.rb +30 -0
  108. data/vendor/thor-852190ae/lib/thor/group.rb +271 -0
  109. data/vendor/thor-852190ae/lib/thor/invocation.rb +180 -0
  110. data/vendor/thor-852190ae/lib/thor/parser.rb +4 -0
  111. data/vendor/thor-852190ae/lib/thor/parser/argument.rb +67 -0
  112. data/vendor/thor-852190ae/lib/thor/parser/arguments.rb +150 -0
  113. data/vendor/thor-852190ae/lib/thor/parser/option.rb +128 -0
  114. data/vendor/thor-852190ae/lib/thor/parser/options.rb +169 -0
  115. data/vendor/thor-852190ae/lib/thor/rake_compat.rb +66 -0
  116. data/vendor/thor-852190ae/lib/thor/runner.rb +314 -0
  117. data/vendor/thor-852190ae/lib/thor/shell.rb +83 -0
  118. data/vendor/thor-852190ae/lib/thor/shell/basic.rb +239 -0
  119. data/vendor/thor-852190ae/lib/thor/shell/color.rb +108 -0
  120. data/vendor/thor-852190ae/lib/thor/task.rb +102 -0
  121. data/vendor/thor-852190ae/lib/thor/util.rb +230 -0
  122. data/vendor/thor-852190ae/lib/thor/version.rb +3 -0
  123. data/vendor/thor-852190ae/spec/actions/create_file_spec.rb +170 -0
  124. data/vendor/thor-852190ae/spec/actions/directory_spec.rb +131 -0
  125. data/vendor/thor-852190ae/spec/actions/empty_directory_spec.rb +91 -0
  126. data/vendor/thor-852190ae/spec/actions/file_manipulation_spec.rb +271 -0
  127. data/vendor/thor-852190ae/spec/actions/inject_into_file_spec.rb +135 -0
  128. data/vendor/thor-852190ae/spec/actions_spec.rb +292 -0
  129. data/vendor/thor-852190ae/spec/base_spec.rb +263 -0
  130. data/vendor/thor-852190ae/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
  131. data/vendor/thor-852190ae/spec/core_ext/ordered_hash_spec.rb +115 -0
  132. data/vendor/thor-852190ae/spec/fixtures/application.rb +2 -0
  133. data/vendor/thor-852190ae/spec/fixtures/bundle/execute.rb +6 -0
  134. data/vendor/thor-852190ae/spec/fixtures/bundle/main.thor +1 -0
  135. data/vendor/thor-852190ae/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  136. data/vendor/thor-852190ae/spec/fixtures/doc/README +3 -0
  137. data/vendor/thor-852190ae/spec/fixtures/doc/config.rb +1 -0
  138. data/vendor/thor-852190ae/spec/fixtures/group.thor +83 -0
  139. data/vendor/thor-852190ae/spec/fixtures/invoke.thor +112 -0
  140. data/vendor/thor-852190ae/spec/fixtures/script.thor +140 -0
  141. data/vendor/thor-852190ae/spec/fixtures/task.thor +10 -0
  142. data/vendor/thor-852190ae/spec/group_spec.rb +171 -0
  143. data/vendor/thor-852190ae/spec/invocation_spec.rb +107 -0
  144. data/vendor/thor-852190ae/spec/parser/argument_spec.rb +47 -0
  145. data/vendor/thor-852190ae/spec/parser/arguments_spec.rb +64 -0
  146. data/vendor/thor-852190ae/spec/parser/option_spec.rb +202 -0
  147. data/vendor/thor-852190ae/spec/parser/options_spec.rb +292 -0
  148. data/vendor/thor-852190ae/spec/rake_compat_spec.rb +68 -0
  149. data/vendor/thor-852190ae/spec/runner_spec.rb +202 -0
  150. data/vendor/thor-852190ae/spec/shell/basic_spec.rb +205 -0
  151. data/vendor/thor-852190ae/spec/shell/color_spec.rb +41 -0
  152. data/vendor/thor-852190ae/spec/shell_spec.rb +34 -0
  153. data/vendor/thor-852190ae/spec/spec.opts +1 -0
  154. data/vendor/thor-852190ae/spec/spec_helper.rb +54 -0
  155. data/vendor/thor-852190ae/spec/task_spec.rb +69 -0
  156. data/vendor/thor-852190ae/spec/thor_spec.rb +237 -0
  157. data/vendor/thor-852190ae/spec/util_spec.rb +167 -0
  158. data/vendor/thor-852190ae/thor.gemspec +120 -0
  159. metadata +229 -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,2 @@
1
+ class Application < Base
2
+ end
@@ -0,0 +1,6 @@
1
+ class Execute < Thor
2
+ desc "ls", "Execute ls"
3
+ def ls
4
+ system "ls"
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), 'execute')
@@ -0,0 +1,3 @@
1
+ __start__
2
+ README
3
+ __end__
@@ -0,0 +1 @@
1
+ class <%= @klass %>; end
@@ -0,0 +1,83 @@
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 run 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
@@ -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,140 @@
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 "test", "prints 'test'"
131
+ def test
132
+ puts "test"
133
+ end
134
+ end
135
+
136
+ class ChildDefault < Thor
137
+ namespace "default:child"
138
+ end
139
+ end
140
+