auser-poolparty 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/cloud +37 -48
  3. data/bin/cloud-bootstrap +33 -23
  4. data/bin/cloud-configure +33 -34
  5. data/bin/cloud-console +31 -9
  6. data/bin/cloud-contract +27 -11
  7. data/bin/cloud-expand +32 -19
  8. data/bin/cloud-list +31 -15
  9. data/bin/cloud-osxcopy +22 -12
  10. data/bin/cloud-provision +35 -24
  11. data/bin/cloud-setup-dev +31 -20
  12. data/bin/cloud-show +40 -21
  13. data/bin/cloud-ssh +24 -15
  14. data/bin/cloud-start +33 -19
  15. data/bin/cloud-terminate +33 -20
  16. data/bin/cloud-verify +38 -29
  17. data/bin/install-poolparty +4 -198
  18. data/bin/server-cloud-elections +1 -1
  19. data/examples/basic.rb +9 -9
  20. data/examples/fairchild.rb +1 -1
  21. data/examples/metavirt_cloud.rb +21 -0
  22. data/lib/poolparty/aska.rb +3 -0
  23. data/lib/poolparty/base_packages/haproxy.rb +19 -18
  24. data/lib/poolparty/base_packages/poolparty.rb +1 -1
  25. data/lib/poolparty/core/hash.rb +46 -0
  26. data/lib/poolparty/core/object.rb +21 -15
  27. data/lib/poolparty/core/string.rb +16 -0
  28. data/lib/poolparty/dependency_resolver/chef_resolver.rb +23 -6
  29. data/lib/poolparty/dependency_resolver/dependency_resolver.rb +1 -1
  30. data/lib/poolparty/dependency_resolver/dependency_resolver_cloud_extensions.rb +2 -2
  31. data/lib/poolparty/dependency_resolver/puppet_resolver.rb +10 -32
  32. data/lib/poolparty/helpers/optioner.rb +19 -14
  33. data/lib/poolparty/installers/base_installer.rb +113 -0
  34. data/lib/poolparty/installers/ec2.rb +141 -0
  35. data/lib/poolparty/installers/vmrun.rb +144 -0
  36. data/lib/poolparty/modules/callbacks.rb +6 -2
  37. data/lib/poolparty/modules/cloud_dsl.rb +2 -2
  38. data/lib/poolparty/modules/cloud_resourcer.rb +10 -50
  39. data/lib/poolparty/modules/file_writer.rb +2 -2
  40. data/lib/poolparty/modules/pinger.rb +4 -1
  41. data/lib/poolparty/modules/resourcing_dsl.rb +1 -29
  42. data/lib/poolparty/modules/searchable_paths.rb +3 -3
  43. data/lib/poolparty/monitors/monitor_rack.rb +1 -1
  44. data/lib/poolparty/net/remote_bases.rb +2 -0
  45. data/lib/poolparty/net/remote_instance.rb +6 -4
  46. data/lib/poolparty/net/remoter/interactive.rb +2 -3
  47. data/lib/poolparty/net/remoter_base.rb +54 -31
  48. data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +49 -26
  49. data/lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb +6 -19
  50. data/lib/poolparty/net/remoter_bases/ec2/ec2_response_object.rb +4 -3
  51. data/lib/poolparty/net/remoter_bases/metavirt/metavirt.rb +99 -0
  52. data/lib/poolparty/net/remoter_bases/metavirt/metavirt_instance.rb +52 -0
  53. data/lib/poolparty/net/remoter_bases/vmrun/utilities/vm_disk.rb +1 -1
  54. data/lib/poolparty/net/remoter_bases/vmrun/utilities/vmx.rb +1 -1
  55. data/lib/poolparty/net/remoter_bases/vmrun/utilities/vmx_file.rb +117 -117
  56. data/lib/poolparty/net/remoter_bases/vmrun/vmrun.rb +36 -31
  57. data/lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb +9 -5
  58. data/lib/poolparty/plugins/apache2/apache.rb +118 -73
  59. data/lib/poolparty/plugins/chef.rb +15 -17
  60. data/lib/poolparty/plugins/chef_deploy.rb +18 -4
  61. data/lib/poolparty/plugins/deploy_directory.rb +25 -16
  62. data/lib/poolparty/plugins/gem_package.rb +15 -5
  63. data/lib/poolparty/plugins/git.rb +44 -30
  64. data/lib/poolparty/plugins/line_in_file.rb +5 -1
  65. data/lib/poolparty/plugins/rails_deploy.rb +79 -26
  66. data/lib/poolparty/plugins/svn.rb +2 -2
  67. data/lib/poolparty/poolparty/cloud.rb +101 -47
  68. data/lib/poolparty/poolparty/default.rb +25 -23
  69. data/lib/poolparty/poolparty/key.rb +18 -27
  70. data/lib/poolparty/poolparty/neighborhoods.rb +1 -1
  71. data/lib/poolparty/poolparty/plugin.rb +17 -7
  72. data/lib/poolparty/poolparty/pool.rb +3 -3
  73. data/lib/poolparty/poolparty/poolparty_base_class.rb +41 -35
  74. data/lib/poolparty/poolparty/resource.rb +18 -44
  75. data/lib/poolparty/poolparty/service.rb +1 -5
  76. data/lib/poolparty/provision/boot_strapper.rb +24 -19
  77. data/lib/poolparty/provision/configurations/chef.rb +4 -4
  78. data/lib/poolparty/provision/dr_configure.rb +11 -10
  79. data/lib/poolparty/resources/cron.rb +7 -3
  80. data/lib/poolparty/resources/directory.rb +7 -0
  81. data/lib/poolparty/resources/exec.rb +2 -1
  82. data/lib/poolparty/resources/file.rb +23 -9
  83. data/lib/poolparty/resources/group.rb +21 -0
  84. data/lib/poolparty/resources/host.rb +2 -1
  85. data/lib/poolparty/resources/mount.rb +0 -4
  86. data/lib/poolparty/resources/remote_file.rb +1 -1
  87. data/lib/poolparty/resources/service.rb +2 -1
  88. data/lib/poolparty/resources/sshkey.rb +10 -12
  89. data/lib/poolparty/resources/symlink.rb +3 -5
  90. data/lib/poolparty/resources/user.rb +5 -0
  91. data/lib/poolparty/resources/variable.rb +1 -1
  92. data/lib/poolparty/templates/haproxy.conf +1 -1
  93. data/lib/poolparty/verification/verify.rb +4 -0
  94. data/lib/poolparty.rb +9 -4
  95. data/lib/poolpartycl.rb +1 -52
  96. data/spec/bin/bin_spec_helper.rb +1 -0
  97. data/spec/bin/server-list-active_spec.rb +3 -3
  98. data/spec/poolparty/core/object_spec.rb +9 -46
  99. data/spec/poolparty/dependency_resolver/dependency_resolver_cloud_extensions_spec.rb +18 -12
  100. data/spec/poolparty/fixtures/clouds.json +1 -1
  101. data/spec/poolparty/helpers/optioner_spec.rb +4 -11
  102. data/spec/poolparty/modules/cloud_resourcer_spec.rb +1 -1
  103. data/spec/poolparty/net/remote_instance_spec.rb +0 -1
  104. data/spec/poolparty/net/remoter_base_spec.rb +7 -11
  105. data/spec/poolparty/net/remoter_bases/ec2_mocks_and_stubs.rb +9 -11
  106. data/spec/poolparty/net/remoter_bases/ec2_remote_instance_spec.rb +6 -44
  107. data/spec/poolparty/net/remoter_bases/ec2_spec.rb +2 -3
  108. data/spec/poolparty/net/remoter_spec.rb +2 -3
  109. data/spec/poolparty/plugins/git_spec.rb +5 -8
  110. data/spec/poolparty/poolparty/cloud_spec.rb +17 -24
  111. data/spec/poolparty/poolparty/configurers/files/ruby_basic.rb +1 -3
  112. data/spec/poolparty/poolparty/configurers/ruby_spec.rb +1 -6
  113. data/spec/poolparty/poolparty/default_spec.rb +23 -22
  114. data/spec/poolparty/poolparty/example_spec.rb +6 -5
  115. data/spec/poolparty/poolparty/plugin_model_spec.rb +7 -4
  116. data/spec/poolparty/poolparty/pool_spec.rb +2 -9
  117. data/spec/poolparty/poolparty/resource_spec.rb +10 -24
  118. data/spec/poolparty/poolparty/script_spec.rb +1 -4
  119. data/spec/poolparty/poolparty/test_plugins/webserver.rb +0 -2
  120. data/spec/poolparty/resources/file_spec.rb +4 -4
  121. data/spec/poolparty/resources/service_spec.rb +1 -1
  122. data/spec/poolparty/spec_helper.rb +9 -38
  123. data/tasks/spec.rake +6 -2
  124. data/test/fixtures/test_key +1 -0
  125. data/test/poolparty/core/object_test.rb +29 -0
  126. data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +1 -1
  127. data/test/poolparty/modules/cloud_dsl_test.rb +4 -4
  128. data/test/poolparty/net/remoter_bases/metavirt/metavirt_test.rb +55 -0
  129. data/test/poolparty/net/remoter_bases/vmrun/vmrun_test.rb +41 -14
  130. data/test/poolparty/plugins/chef_deploy_test.rb +37 -0
  131. data/test/poolparty/plugins/rails_deploy_test.rb +50 -0
  132. data/test/poolparty/poolparty/plugin_test.rb +18 -0
  133. data/test/poolparty/poolparty/poolparty_base_class_test.rb +41 -3
  134. data/test/test_helper.rb +5 -1
  135. data/vendor/gems/dslify/LICENSE +20 -0
  136. data/vendor/gems/dslify/README.rdoc +33 -0
  137. data/vendor/gems/dslify/Rakefile +56 -56
  138. data/vendor/gems/dslify/lib/dslify.rb +76 -5
  139. data/vendor/gems/dslify/test/dslify_test.rb +197 -0
  140. data/vendor/gems/dslify/test/test_helper.rb +7 -0
  141. data/vendor/gems/git-style-binaries/README.markdown +274 -0
  142. data/vendor/gems/{butterfly → git-style-binaries}/Rakefile +64 -62
  143. data/vendor/gems/git-style-binaries/VERSION.yml +4 -0
  144. data/vendor/gems/git-style-binaries/doc/EXAMPLES +1 -0
  145. data/vendor/gems/git-style-binaries/doc/poolparty-binaries.screenplay +45 -0
  146. data/vendor/gems/git-style-binaries/git-style-binaries.gemspec +69 -0
  147. data/vendor/gems/git-style-binaries/lib/ext/colorize.rb +198 -0
  148. data/vendor/gems/git-style-binaries/lib/ext/core.rb +16 -0
  149. data/vendor/gems/git-style-binaries/lib/git-style-binary/autorunner.rb +21 -0
  150. data/vendor/gems/git-style-binaries/lib/git-style-binary/command.rb +204 -0
  151. data/vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb +32 -0
  152. data/vendor/gems/git-style-binaries/lib/git-style-binary/helpers/name_resolver.rb +78 -0
  153. data/vendor/gems/git-style-binaries/lib/git-style-binary/helpers/pager.rb +37 -0
  154. data/vendor/gems/git-style-binaries/lib/git-style-binary/parser.rb +223 -0
  155. data/vendor/gems/git-style-binaries/lib/git-style-binary.rb +74 -0
  156. data/vendor/gems/git-style-binaries/test/fixtures/flickr +4 -0
  157. data/vendor/gems/git-style-binaries/test/fixtures/flickr-download +17 -0
  158. data/vendor/gems/git-style-binaries/test/fixtures/wordpress +42 -0
  159. data/vendor/gems/git-style-binaries/test/fixtures/wordpress-categories +18 -0
  160. data/vendor/gems/git-style-binaries/test/fixtures/wordpress-list +18 -0
  161. data/vendor/gems/git-style-binaries/test/fixtures/wordpress-post +26 -0
  162. data/vendor/gems/git-style-binaries/test/git-style-binary/command_test.rb +17 -0
  163. data/vendor/gems/git-style-binaries/test/git_style_binary_test.rb +21 -0
  164. data/vendor/gems/git-style-binaries/test/running_binaries_test.rb +224 -0
  165. data/vendor/gems/git-style-binaries/test/shoulda_macros/matching_stdio.rb +13 -0
  166. data/vendor/gems/git-style-binaries/test/test_helper.rb +28 -0
  167. data/vendor/gems/parenting/lib/parenting/parenting.rb +13 -4
  168. data/vendor/gems/rest-client/README.rdoc +151 -0
  169. data/vendor/gems/rest-client/Rakefile +85 -0
  170. data/vendor/gems/rest-client/bin/restclient +87 -0
  171. data/vendor/gems/rest-client/lib/rest_client.rb +2 -0
  172. data/vendor/gems/rest-client/lib/restclient/exceptions.rb +84 -0
  173. data/vendor/gems/rest-client/lib/restclient/mixin/response.rb +43 -0
  174. data/vendor/gems/rest-client/lib/restclient/raw_response.rb +30 -0
  175. data/vendor/gems/rest-client/lib/restclient/request.rb +232 -0
  176. data/vendor/gems/rest-client/lib/restclient/resource.rb +146 -0
  177. data/vendor/gems/rest-client/lib/restclient/response.rb +20 -0
  178. data/vendor/gems/rest-client/lib/restclient.rb +93 -0
  179. data/vendor/gems/rest-client/rest-client.gemspec +21 -0
  180. data/vendor/gems/rest-client/spec/base.rb +4 -0
  181. data/vendor/gems/rest-client/spec/exceptions_spec.rb +54 -0
  182. data/vendor/gems/rest-client/spec/mixin/response_spec.rb +46 -0
  183. data/vendor/gems/rest-client/spec/raw_response_spec.rb +17 -0
  184. data/vendor/gems/rest-client/spec/request_spec.rb +442 -0
  185. data/vendor/gems/rest-client/spec/resource_spec.rb +75 -0
  186. data/vendor/gems/rest-client/spec/response_spec.rb +16 -0
  187. data/vendor/gems/rest-client/spec/restclient_spec.rb +53 -0
  188. data/vendor/gems/trollop/FAQ.txt +35 -0
  189. data/vendor/gems/trollop/History.txt +97 -0
  190. data/vendor/gems/trollop/Manifest.txt +7 -0
  191. data/vendor/gems/trollop/README.txt +40 -0
  192. data/vendor/gems/trollop/Rakefile +36 -0
  193. data/vendor/gems/trollop/lib/trollop.rb +735 -0
  194. data/vendor/gems/trollop/release-script.txt +13 -0
  195. data/vendor/gems/trollop/test/test_trollop.rb +1042 -0
  196. data/vendor/gems/trollop/www/index.html +167 -0
  197. metadata +100 -70
  198. data/bin/cloud-describe +0 -28
  199. data/bin/cloud-handle-load +0 -27
  200. data/bin/cloud-rsync +0 -28
  201. data/bin/cloud-spec +0 -40
  202. data/lib/poolparty/plugins/nanite.rb +0 -41
  203. data/lib/poolparty/plugins/runit.rb +0 -96
  204. data/vendor/gems/butterfly/History.txt +0 -4
  205. data/vendor/gems/butterfly/PostInstall.txt +0 -2
  206. data/vendor/gems/butterfly/README.rdoc +0 -48
  207. data/vendor/gems/butterfly/VERSION.yml +0 -4
  208. data/vendor/gems/butterfly/bin/flutter +0 -4
  209. data/vendor/gems/butterfly/butterfly.gemspec +0 -37
  210. data/vendor/gems/butterfly/examples/config.ru +0 -15
  211. data/vendor/gems/butterfly/examples/my_app.rb +0 -12
  212. data/vendor/gems/butterfly/lib/butterfly.rb +0 -14
  213. data/vendor/gems/butterfly/lib/handler.rb +0 -48
  214. data/vendor/gems/butterfly/lib/request.rb +0 -29
  215. data/vendor/gems/butterfly/lib/response.rb +0 -49
  216. data/vendor/gems/butterfly/script/console +0 -10
  217. data/vendor/gems/butterfly/script/destroy +0 -14
  218. data/vendor/gems/butterfly/script/generate +0 -14
  219. data/vendor/gems/butterfly/test/test_adapter_base.rb +0 -23
  220. data/vendor/gems/butterfly/test/test_butterfly_request.rb +0 -46
  221. data/vendor/gems/butterfly/test/test_butterfly_response.rb +0 -43
  222. data/vendor/gems/butterfly/test/test_butterfly_server.rb +0 -16
  223. data/vendor/gems/butterfly/test/test_default.rb +0 -12
  224. data/vendor/gems/butterfly/test/test_helper.rb +0 -6
  225. data/vendor/gems/dslify/History.txt +0 -4
  226. data/vendor/gems/dslify/Manifest.txt +0 -25
  227. data/vendor/gems/dslify/PostInstall.txt +0 -5
  228. data/vendor/gems/dslify/README.txt +0 -60
  229. data/vendor/gems/dslify/config/hoe.rb +0 -73
  230. data/vendor/gems/dslify/config/requirements.rb +0 -15
  231. data/vendor/gems/dslify/dslify.gemspec +0 -40
  232. data/vendor/gems/dslify/lib/dslify/dslify.rb +0 -76
  233. data/vendor/gems/dslify/lib/dslify/version.rb +0 -10
  234. data/vendor/gems/dslify/script/console +0 -10
  235. data/vendor/gems/dslify/script/destroy +0 -14
  236. data/vendor/gems/dslify/script/generate +0 -14
  237. data/vendor/gems/dslify/script/txt2html +0 -82
  238. data/vendor/gems/dslify/setup.rb +0 -1585
  239. data/vendor/gems/dslify/tasks/deployment.rake +0 -34
  240. data/vendor/gems/dslify/tasks/environment.rake +0 -7
  241. data/vendor/gems/dslify/tasks/website.rake +0 -17
  242. data/vendor/gems/dslify/test/test_dslify.rb +0 -138
  243. data/vendor/gems/dslify/website/index.html +0 -86
  244. data/vendor/gems/dslify/website/index.txt +0 -83
  245. data/vendor/gems/dslify/website/javascripts/rounded_corners_lite.inc.js +0 -285
  246. data/vendor/gems/dslify/website/stylesheets/screen.css +0 -138
  247. data/vendor/gems/dslify/website/template.html.erb +0 -48
@@ -0,0 +1,197 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class Quickie
4
+ include Dslify
5
+ def initialize(&block)
6
+ instance_eval &block if block
7
+ end
8
+ end
9
+
10
+ class QuickieTest < Test::Unit::TestCase
11
+ context "setting" do
12
+ before do
13
+ Quickie.class_eval do
14
+ dsl_methods :bank, :snobs, :author, :gilligans_island
15
+ end
16
+ @q = Quickie.new
17
+ end
18
+ it "should be able to set methods on self" do
19
+ assert_nothing_raised do
20
+ @q.bank "bobs"
21
+ end
22
+ end
23
+ it "should set and then retrieve the same value back" do
24
+ @q.snobs "are mean"
25
+ assert_equal @q.snobs, "are mean"
26
+ end
27
+ it "should set and retrieve values back with an = sign" do
28
+ @q.author = ["Ari Lerner"]
29
+ assert_equal @q.author, ["Ari Lerner"]
30
+ end
31
+ it "should set these values in the h Hash on the object" do
32
+ assert_raise NoMethodError do
33
+ @q.movies "can be fun"
34
+ end
35
+ end
36
+ it "should set multiple keys with set_vars_from_options" do
37
+ @q.set_vars_from_options({:a => "a", :b => "b"})
38
+ assert_equal @q.a, "a"
39
+ assert_equal @q.b, "b"
40
+ end
41
+ it "should set methods even when they are called with a block" do
42
+ @q.author Quickie.new do
43
+ end
44
+ assert_equal @q.author.class, Quickie
45
+ end
46
+ it "should not blow up when called with a ? at the end of the method" do
47
+ @q.set_vars_from_options({:pete => "and pete"})
48
+ assert_nothing_raised do
49
+ @q.pete?
50
+ end
51
+ end
52
+ it "should return false if the method exists" do
53
+ assert_equal @q.bobs?, false
54
+ end
55
+ it "should return true if the option is set" do
56
+ @q.gilligans_island "is a tv show"
57
+ assert @q.gilligans_island?
58
+ end
59
+ end
60
+
61
+ context "calling methods on an instance" do
62
+ setup do
63
+ class Detective
64
+ include Dslify
65
+ attr_reader :snooped
66
+ def snoop(*n)
67
+ @snooped = "done!"
68
+ end
69
+ end
70
+ @d= Detective.new
71
+ end
72
+ should "Call the method snoop with set_vars_from_options" do
73
+ @d.set_vars_from_options(:snoop => true)
74
+ assert @d.snooped
75
+ end
76
+ end
77
+
78
+ context "default options" do
79
+ setup do
80
+ class Bang
81
+ include Dslify
82
+ default_options(
83
+ :says => 'vmrun'
84
+ )
85
+ def initialize(opts={}, &block)
86
+ instance_eval &block if block
87
+ end
88
+ end
89
+ @bang = Bang.new
90
+ end
91
+
92
+ should "overwrite the default dsl option in instance_eval" do
93
+ assert_equal @bang.says, "vmrun"
94
+ @bang = Bang.new do
95
+ says "snake"
96
+ end
97
+ assert_equal @bang.says, "snake"
98
+ end
99
+ end
100
+
101
+
102
+ context "with inheritance and classes" do
103
+ before do
104
+ class Pop
105
+ include Dslify
106
+ default_options :name => "pop", :flavor=>'cherry'
107
+ def initialize(o={})
108
+ set_vars_from_options(o)
109
+ end
110
+
111
+ def real_method
112
+ "the real deal, no magic"
113
+ end
114
+ end
115
+
116
+ class Foo < Pop
117
+ default_options :name=>'fooey'
118
+ end
119
+
120
+ class Bar < Pop
121
+ default_options :name=>'pangy', :taste => "spicy"
122
+ end
123
+
124
+ class Dad < Pop
125
+ end
126
+
127
+ class Grandad < Dad
128
+ end
129
+
130
+ class Defaults < Pop
131
+ default_options(
132
+ :global_default => "red_rum"
133
+ )
134
+ end
135
+
136
+ @pop = Pop.new
137
+ @foo = Foo.new
138
+ @bar = Bar.new
139
+ end
140
+ it "should take the default options set on the class" do
141
+ assert_equal @pop.dsl_options[:name], "pop"
142
+ assert_equal @pop.name, "pop"
143
+ end
144
+ it "should allow us to add defaults on the instance by calling dsl_options" do
145
+ # QuickieTest::Pop.name == "Cinnamon"
146
+ @poptart = Pop.new :name => "Cinnamon"
147
+ assert_equal @poptart.name, "Cinnamon"
148
+ end
149
+ it "should take the default options on a second class that inherits from the base" do
150
+ assert_equal @foo.name, "fooey"
151
+ end
152
+ it "should take the default options on a third inheriting class" do
153
+ assert_equal @bar.name, "pangy"
154
+ end
155
+ it "should not add a method not in the default_options" do
156
+ assert_equal @bar.respond_to?(:boat), false
157
+ end
158
+ it "should return the original default options test" do
159
+ assert_equal @bar.dsl_options[:taste], "spicy"
160
+ assert_equal @bar.dsl_options[:name], "pangy"
161
+ end
162
+ it "should set the default options of the child to the superclass's if it doesn't exist" do
163
+ # QuickieTest::Dad => QuickieTest::Pop
164
+ d = Dad.new
165
+ assert Pop.new.name == 'pop'
166
+ assert_equal "pop", d.name
167
+ d.name "Frankenstein"
168
+ assert_equal d.name, "Frankenstein"
169
+ end
170
+ it "should raise if the method isn't found on itself, the parent or in the rest of the method missing chain" do
171
+ assert_raise NoMethodError do
172
+ Class.new.sanitorium
173
+ end
174
+ end
175
+ it "should be able to reach the grandparent through the chain of dsify-ed classes" do
176
+ # QuickieTest::Grandad => QuickieTest::Dad => QuickieTest::Pop
177
+ assert Dad.method_defined?(:name)
178
+ assert Dad.new.flavor == 'cherry'
179
+ assert Grandad.new.name, "pop"
180
+ end
181
+ # it "should be able to take a method that responds to an object" do
182
+ # class Tanks
183
+ # include Dslify
184
+ # forwards_to :parent
185
+ # def initialize(obj)
186
+ # @parent = obj
187
+ # end
188
+ # def parent
189
+ # @parent
190
+ # end
191
+ # end
192
+ # t = Tanks.new(@bar)
193
+ # # QuickieTest::Tanks => Object => #<QuickieTest::Bar>
194
+ # assert_equal t.taste, @bar.taste
195
+ # end
196
+ end
197
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require "context"
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ require 'dslify'
@@ -0,0 +1,274 @@
1
+ git-style-binaries
2
+ ==================
3
+
4
+ Ridiculously easy git-style binaries.
5
+
6
+ This gem uses [`trollop`](http://trollop.rubyforge.org/) for option parsing
7
+
8
+ ## Installation
9
+
10
+ gem install jashmenn-git-style-binaries --source=http://gems.github.com
11
+
12
+ ## Try it out
13
+
14
+ cd `gem env gemdir`/gems/jashmenn-git-style-binaries-0.1.4/test/fixtures
15
+ ./wordpress -h
16
+ ./wordpress help post
17
+
18
+ ## Goal
19
+
20
+ Lets use the imaginary `wordpress` gem. Let's say we have three different
21
+ actions we want to specify:
22
+
23
+ * categories
24
+ * list
25
+ * post
26
+
27
+ Each command has its own binary in a directory structure like this:
28
+
29
+ bin/
30
+ |-- wordpress
31
+ |-- wordpress-categories
32
+ |-- wordpress-list
33
+ `-- wordpress-post
34
+
35
+ The goal is to be able to call commands in this manner:
36
+
37
+ wordpress -h # gives help summary of all commands
38
+ wordpress-list -h # gives long help of wordpress-list
39
+ wordpress list -h # ditto
40
+ echo "about me" | wordpress-post --title="new post" # posts a new post with that title
41
+
42
+ ## Example code
43
+ Our `bin/wordpress` binary is called the *primary* . Our primary only needs to contain the following line:
44
+
45
+ #!/usr/bin/env ruby
46
+ require 'git-style-binary/command'
47
+
48
+ `git-style-binary` will automatically make this command the primary.
49
+
50
+ The `bin/wordpress-post` binary could contain the following:
51
+
52
+ #!/usr/bin/env ruby
53
+ require 'git-style-binary/command'
54
+
55
+ GitStyleBinary.command do
56
+ short_desc "create a blog post"
57
+ banner <<-EOS
58
+ Usage: #{command.full_name} #{all_options_string} {content|STDIN}
59
+
60
+ Posts content to a wordpress blog
61
+
62
+ EOS
63
+ opt :blog, "short name of the blog to use", :default => 'default'
64
+ opt :category, "tag/category. specify multiple times for multiple categories", :type => String, :multi => true
65
+ opt :title, "title for the post", :required => true, :type => String
66
+ opt :type, "type of the content [html|xhtml|text]", :default => 'html', :type => String
67
+
68
+ run do |command|
69
+ command.die :type, "type must be one of [html|xhtml|text]" unless command.opts[:type] =~ /^(x?html|text)$/i
70
+
71
+ puts "Subcommand name: #{command.name.inspect}"
72
+ puts "Options: #{command.opts.inspect}"
73
+ puts "Remaining arguments: #{command.argv.inspect}"
74
+ end
75
+ end
76
+
77
+ And so on with the other binaries.
78
+
79
+ ## Running the binaries
80
+
81
+ Now if we run `wordpress -h` we get the following output:
82
+
83
+ NAME
84
+ wordpress
85
+
86
+ VERSION
87
+ 0.0.1 (c) 2009 Nate Murray - local
88
+
89
+ SYNOPSIS
90
+ wordpress [--version] [--test-primary] [--help] [--verbose] COMMAND [ARGS]
91
+
92
+ SUBCOMMANDS
93
+ wordpress-categories
94
+ do something with categories
95
+
96
+ wordpress-help
97
+ get help for a specific command
98
+
99
+ wordpress-list
100
+ list blog postings
101
+
102
+ wordpress-post
103
+ create a blog post
104
+
105
+
106
+ See 'wordpress help COMMAND' for more information on a specific command.
107
+
108
+ OPTIONS
109
+ -v, --verbose
110
+ verbose
111
+
112
+
113
+ -t, --test-primary=<s>
114
+ test an option on the primary
115
+
116
+
117
+ -e, --version
118
+ Print version and exit
119
+
120
+
121
+ -h, --help
122
+ Show this message
123
+
124
+
125
+
126
+ Default **options**, **version string**, and **usage banner** are automatically selected for you.
127
+ The subcommands and their short descriptions are loaded automatically!
128
+
129
+ You can pass the `-h` flag to any one of the subcommands (with or without the
130
+ connecting `-`) or use the built-in `help` subcommand for the same effect. For instance:
131
+
132
+ $ wordpress help post
133
+
134
+ NAME
135
+ wordpress-post - create a blog post
136
+
137
+ VERSION
138
+ 0.0.1 (c) 2009 Nate Murray - local
139
+
140
+ SYNOPSIS
141
+ wordpress-post [--type] [--version] [--test-primary] [--blog] [--help] [--verbose] [--category]
142
+ [--title] COMMAND [ARGS] {content|STDIN}
143
+
144
+ OPTIONS
145
+ -v, --verbose
146
+ verbose
147
+
148
+
149
+ -t, --test-primary=<s>
150
+ test an option on the primary
151
+
152
+
153
+ -b, --blog=<s>
154
+ short name of the blog to use (default: default)
155
+
156
+
157
+ -c, --category=<s>
158
+ tag/category. specify multiple times for multiple
159
+ categories
160
+
161
+
162
+ -i, --title=<s>
163
+ title for the post
164
+
165
+
166
+ -y, --type=<s>
167
+ type of the content [html|xhtml|text] (default: html)
168
+
169
+
170
+ -e, --version
171
+ Print version and exit
172
+
173
+
174
+ -h, --help
175
+ Show this message
176
+
177
+
178
+ For more examples, see the binaries in `test/fixtures/`.
179
+
180
+ ## Primary options
181
+
182
+ Often you may *want* the primary to have its own set of options. Simply call `GitStyleBinary.primary` with a block like so:
183
+
184
+ #!/usr/bin/env ruby
185
+ require 'git-style-binary/command'
186
+ GitStyleBinary.primary do
187
+ version "#{command.full_name} 0.0.1 (c) 2009 Nate Murray - local"
188
+ opt :test_primary, "a primary string option", :type => String
189
+
190
+ run do |command|
191
+ puts "Primary Options: #{command.opts.inspect}"
192
+ end
193
+ end
194
+
195
+ Primary options are **inherited** by all subcommands. That means in this case
196
+ all subcommands will now get the `--test-primary` option available to them as
197
+ well as this new `version` string.
198
+
199
+ ## Option parsing
200
+
201
+ Option parsing is done by [trollop](http://trollop.rubyforge.org/).
202
+ `git-style-binary` uses this more-or-less exactly. See the [trollop
203
+ documentation](http://trollop.rubyforge.org/) for information on how to setup
204
+ the options and flags.
205
+
206
+ ## Callbacks
207
+
208
+ Callbacks are available on the primary and subcommands. Available callbacks currently
209
+ are before/after_run. These execute before the run block of the command parser and take
210
+ take one argument, which is the command itself
211
+
212
+ ## The `run` block
213
+
214
+ To get the 'introspection' on the individual binaries every binary is `load`ed
215
+ on `primary help`. We need a way to get that information while not running
216
+ every command when calling `primary help`. To achieve that you need to put what
217
+ will be run in the `run` block.
218
+
219
+ `run` `yields` a `Command` object which contains a number of useful options
220
+ such as `name`, `full_name`, `opts`, and `argv`.
221
+
222
+ * `command.opts` is a hash of the options parsed
223
+ * `command.argv` is an array of the remaining arguments
224
+
225
+ ## Features
226
+ * automatic colorization
227
+ * automatic paging
228
+
229
+ ## To Learn more
230
+
231
+ Play with the examples in the `test/fixtures` directory.
232
+
233
+ ## Credits
234
+ * `git-style-binary` was written by Nate Murray `<nate@natemurray.com>`
235
+ * `trollop` was written by [William Morgan](http://trollop.rubyforge.org/)
236
+ * Inspiration comes from Ari Lerner's [git-style-binaries](http://blog.xnot.org/2008/12/16/git-style-binaries/) for [PoolParty.rb](http://poolpartyrb.com)
237
+ * [`colorize.rb`](http://colorize.rubyforge.org) by Michal Kalbarczyk
238
+ * Automatic less paging by [Nathan Weizenbaum](http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby)
239
+ * Color inspiration from [Brian Henderson](http://xcombinator.com) teaching me how to get `man git` colors using `less` on MacOSX
240
+
241
+ ## TODO
242
+ * automagic tab completion - Automatic for subcommands and options for any library that uses this
243
+
244
+ ## Known Bugs/Problems
245
+ * Young
246
+ * A few places of really ugly code
247
+ * A feeling that this could be done in 1/2 lines of code
248
+
249
+ ## Authors
250
+ By Nate Murray and Ari Lerner
251
+
252
+ ## Copyright
253
+
254
+ The MIT License
255
+
256
+ Copyright (c) 2009 Nate Murray. See LICENSE for details.
257
+
258
+ Permission is hereby granted, free of charge, to any person obtaining a copy
259
+ of this software and associated documentation files (the "Software"), to deal
260
+ in the Software without restriction, including without limitation the rights
261
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
262
+ copies of the Software, and to permit persons to whom the Software is
263
+ furnished to do so, subject to the following conditions:
264
+
265
+ The above copyright notice and this permission notice shall be included in
266
+ all copies or substantial portions of the Software.
267
+
268
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
269
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
270
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
271
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
272
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
273
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
274
+ THE SOFTWARE.
@@ -1,62 +1,64 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- # %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
5
- # require File.dirname(__FILE__) + '/lib/butterfly'
6
-
7
-
8
- begin
9
- require 'jeweler'
10
- Jeweler::Tasks.new do |gem|
11
- gem.name = "butterfly"
12
- gem.summary = %Q{An HTTP mini server to query against modular adaptors}
13
- gem.email = "arilerner@mac.com"
14
- gem.homepage = "http://github.com/auser/butterfly"
15
- gem.files = FileList["[A-Z]*", "{bin,examples,lib,test}/**/*", '.gitignore']
16
- gem.post_install_message = 'PostInstall.txt'
17
- gem.add_dependency 'rack', '>=0.9'
18
- gem.add_dependency 'json', '>=1.1.3'
19
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
- end
21
- rescue LoadError
22
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
23
- end
24
-
25
- require 'rake/testtask'
26
- Rake::TestTask.new(:test) do |test|
27
- test.libs << 'lib' << 'test'
28
- test.pattern = 'test/test*.rb'
29
- test.verbose = false
30
- end
31
-
32
- begin
33
- require 'rcov/rcovtask'
34
- Rcov::RcovTask.new do |test|
35
- test.libs << 'test'
36
- test.pattern = 'test/*_test.rb'
37
- test.verbose = true
38
- end
39
- rescue LoadError
40
- task :rcov do
41
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
- end
43
- end
44
-
45
-
46
- task :default => :test
47
-
48
- require 'rake/rdoctask'
49
- Rake::RDocTask.new do |rdoc|
50
- if File.exist?('VERSION.yml')
51
- config = YAML.load(File.read('VERSION.yml'))
52
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
53
- else
54
- version = ""
55
- end
56
-
57
- rdoc.rdoc_dir = 'rdoc'
58
- rdoc.title = "butterfly #{version}"
59
- rdoc.rdoc_files.include('README*')
60
- rdoc.rdoc_files.include('lib/**/*.rb')
61
- end
62
-
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "git-style-binaries"
8
+ gem.description = %Q{Ridiculously easy git-style binaries}
9
+ gem.summary =<<-EOF
10
+ Add git-style binaries to your project easily.
11
+ EOF
12
+ gem.email = "nate@natemurray.com"
13
+ gem.homepage = "http://github.com/jashmenn/git-style-binaries"
14
+ gem.authors = ["Nate Murray"]
15
+ gem.add_dependency 'trollop'
16
+ gem.add_dependency 'thoughtbot-shoulda' # for running the tests
17
+
18
+ excludes = /(README\.html)/
19
+ gem.files = (FileList["[A-Z]*.*", "{bin,examples,generators,lib,rails,spec,test}/**/*", 'Rakefile', 'LICENSE*']).delete_if{|f| f =~ excludes}
20
+ gem.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"].delete_if{|f| f =~ excludes}
21
+ end
22
+ rescue LoadError
23
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
24
+ end
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'lib' << 'test'
29
+ test.pattern = 'test/**/*_test.rb'
30
+ test.verbose = true
31
+ end
32
+
33
+ begin
34
+ require 'rcov/rcovtask'
35
+ Rcov::RcovTask.new do |test|
36
+ test.libs << 'test'
37
+ test.pattern = 'test/**/*_test.rb'
38
+ test.verbose = true
39
+ end
40
+ rescue LoadError
41
+ task :rcov do
42
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
43
+ end
44
+ end
45
+
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION.yml')
52
+ config = YAML.load(File.read('VERSION.yml'))
53
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
54
+ else
55
+ version = ""
56
+ end
57
+
58
+ rdoc.rdoc_dir = 'rdoc'
59
+ rdoc.title = "git-style-binaries #{version}"
60
+ rdoc.rdoc_files.include('README*')
61
+ rdoc.rdoc_files.include('lib/**/*.rb')
62
+ end
63
+
64
+ task :bump => ['version:bump:patch', 'gemspec', 'build']
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 6
@@ -0,0 +1 @@
1
+ see test/fixtures
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env castanaut
2
+ # Castanaut screencast file. sudo gem install castanaut
3
+
4
+ # see if there is a terminal module
5
+ # download the 'ttyrecord' binary
6
+ # get castanaut src
7
+ # get applescript docs
8
+ plugin "terminal"
9
+ plugin "keystack"
10
+
11
+ launch "Terminal", at(10, 10, 800, 600)
12
+
13
+ # say <<-eos
14
+ # Hey, welcome to the git-style-binaries screencast.
15
+ # First, lets talk a little about what a git-style-binary even is.
16
+ # eos
17
+
18
+ pause 1
19
+ while_saying "as you can see here, git has over one hundred binaries that all perform various functions." do
20
+ type "git-"
21
+ pause 1
22
+ keystroke_literal('tab')
23
+ keystroke_literal('tab')
24
+ type "y"
25
+ pause 2
26
+ type " "
27
+ keystroke_using('u', :control)
28
+ end
29
+
30
+ while_saying "so, for instance, we have. git-add. for adding files. git-status for getting the status of our repo and so on" do
31
+ cli "git-add"
32
+ pause 2
33
+ cli "git-status"
34
+ end
35
+
36
+ while_saying "we want to emulate that effect with poolparty." do
37
+ cli "cd #{ENV['POOLPARTY_SRC']}"
38
+ end
39
+
40
+ pause 2
41
+
42
+ while_saying "just in case you're not familiar with poolparty, its a cloud management system. "
43
+ # open safari poolpartyrb.com
44
+
45
+ # vim: ft=ruby