ul-wukong 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +60 -0
  3. data/.gitmodules +6 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +19 -0
  6. data/.yardopts +6 -0
  7. data/CHANGELOG.md +7 -0
  8. data/Gemfile +17 -0
  9. data/Guardfile +12 -0
  10. data/LICENSE.md +95 -0
  11. data/NOTES-travis.md +31 -0
  12. data/README-old.md +422 -0
  13. data/README.md +1308 -0
  14. data/Rakefile +28 -0
  15. data/TODO.md +99 -0
  16. data/bin/cutc +30 -0
  17. data/bin/cuttab +5 -0
  18. data/bin/greptrue +6 -0
  19. data/bin/md5sort +20 -0
  20. data/bin/setcat +11 -0
  21. data/bin/tabchar +5 -0
  22. data/bin/uniq-ord +59 -0
  23. data/bin/uniqc +3 -0
  24. data/bin/wu +34 -0
  25. data/bin/wu-clean-encoding +31 -0
  26. data/bin/wu-date +13 -0
  27. data/bin/wu-datetime +13 -0
  28. data/bin/wu-hist +3 -0
  29. data/bin/wu-lign +186 -0
  30. data/bin/wu-local +4 -0
  31. data/bin/wu-plus +9 -0
  32. data/bin/wu-source +5 -0
  33. data/bin/wu-sum +31 -0
  34. data/diagrams/wu_local.dot +39 -0
  35. data/diagrams/wu_local.dot.png +0 -0
  36. data/examples/Gemfile +38 -0
  37. data/examples/README.md +9 -0
  38. data/examples/basic/string_reverser.rb +23 -0
  39. data/examples/basic/tiny_count.rb +8 -0
  40. data/examples/basic/word_count/accumulator.rb +26 -0
  41. data/examples/basic/word_count/tokenizer.rb +13 -0
  42. data/examples/basic/word_count/word_count.rb +6 -0
  43. data/examples/dataflow/scraper_macro_flow.rb +28 -0
  44. data/examples/deploy_pack/Gemfile +6 -0
  45. data/examples/deploy_pack/README.md +6 -0
  46. data/examples/deploy_pack/a/b/c/.gitkeep +0 -0
  47. data/examples/deploy_pack/app/processors/string_reverser.rb +5 -0
  48. data/examples/deploy_pack/config/environment.rb +1 -0
  49. data/examples/dsl/dataflow/fibonacci_series.rb +101 -0
  50. data/examples/dsl/dataflow/scraper_macro_flow.rb +28 -0
  51. data/examples/dsl/dataflow/simple.rb +12 -0
  52. data/examples/dsl/dataflow/telegram.rb +45 -0
  53. data/examples/dsl/workflow/cherry_pie.dot +97 -0
  54. data/examples/dsl/workflow/cherry_pie.md +104 -0
  55. data/examples/dsl/workflow/cherry_pie.png +0 -0
  56. data/examples/dsl/workflow/cherry_pie.rb +101 -0
  57. data/examples/empty/.gitkeep +0 -0
  58. data/examples/examples_helper.rb +9 -0
  59. data/examples/geo.rb +4 -0
  60. data/examples/geo/geo_grids.numbers +0 -0
  61. data/examples/geo/geolocated.rb +331 -0
  62. data/examples/geo/quadtile.rb +69 -0
  63. data/examples/geo/spec/geolocated_spec.rb +247 -0
  64. data/examples/geo/tile_fetcher.rb +77 -0
  65. data/examples/graph/implied_geolocation/README.md +63 -0
  66. data/examples/graph/minimum_spanning_tree/airfares_graphviz.rb +73 -0
  67. data/examples/improver/tweet_summary.rb +73 -0
  68. data/examples/loadable.rb +2 -0
  69. data/examples/munging/airline_flights/airline_flights.rake +83 -0
  70. data/examples/munging/airline_flights/airplane.rb +0 -0
  71. data/examples/munging/airline_flights/airport_id_unification.rb +129 -0
  72. data/examples/munging/airline_flights/airport_ok_chars.rb +4 -0
  73. data/examples/munging/airline_flights/indexable.rb +75 -0
  74. data/examples/munging/airline_flights/indexable_spec.rb +90 -0
  75. data/examples/munging/airline_flights/reconcile_airports.rb +142 -0
  76. data/examples/munging/airline_flights/tasks.rake +83 -0
  77. data/examples/munging/airline_flights/topcities.rb +167 -0
  78. data/examples/munging/geo/geo_json.rb +54 -0
  79. data/examples/munging/geo/geo_models.rb +69 -0
  80. data/examples/munging/geo/geonames_models.rb +107 -0
  81. data/examples/munging/geo/iso_codes.rb +172 -0
  82. data/examples/munging/geo/reconcile_countries.rb +124 -0
  83. data/examples/munging/geo/tasks.rake +71 -0
  84. data/examples/munging/wikipedia/articles/extract_articles-parsed.rb +79 -0
  85. data/examples/munging/wikipedia/articles/extract_articles-templated.rb +136 -0
  86. data/examples/munging/wikipedia/articles/textualize_articles.rb +54 -0
  87. data/examples/munging/wikipedia/articles/verify_structure.rb +43 -0
  88. data/examples/munging/wikipedia/articles/wp2txt-LICENSE.txt +22 -0
  89. data/examples/munging/wikipedia/articles/wp2txt_article.rb +259 -0
  90. data/examples/munging/wikipedia/articles/wp2txt_utils.rb +452 -0
  91. data/examples/munging/wikipedia/dbpedia/dbpedia_common.rb +5 -0
  92. data/examples/munging/wikipedia/dbpedia/dbpedia_extract_geocoordinates.rb +78 -0
  93. data/examples/munging/wikipedia/dbpedia/extract_links-cruft.rb +66 -0
  94. data/examples/munging/wikipedia/dbpedia/extract_links.rb +260 -0
  95. data/examples/munging/wikipedia/dbpedia/sameas_extractor.rb +20 -0
  96. data/examples/rake_helper.rb +97 -0
  97. data/examples/ruby_project/Gemfile +6 -0
  98. data/examples/ruby_project/README.md +6 -0
  99. data/examples/ruby_project/a/b/c/.gitkeep +0 -0
  100. data/examples/server_logs/geo_ip_mapping/munge_geolite.rb +82 -0
  101. data/examples/server_logs/logline.rb +95 -0
  102. data/examples/server_logs/models.rb +66 -0
  103. data/examples/server_logs/page_counts.pig +48 -0
  104. data/examples/server_logs/server_logs-01-parse-script.rb +13 -0
  105. data/examples/server_logs/server_logs-02-histograms-full.rb +33 -0
  106. data/examples/server_logs/server_logs-02-histograms-mapper.rb +14 -0
  107. data/examples/server_logs/server_logs-03-breadcrumbs-full.rb +71 -0
  108. data/examples/server_logs/server_logs-04-page_page_edges-full.rb +40 -0
  109. data/examples/serverlogs/geo_ip_mapping/munge_geolite.rb +82 -0
  110. data/examples/serverlogs/models/logline.rb +102 -0
  111. data/examples/serverlogs/parser/apache_parser_widget.rb +46 -0
  112. data/examples/serverlogs/visit_paths/common.rb +4 -0
  113. data/examples/serverlogs/visit_paths/page_counts.pig +48 -0
  114. data/examples/serverlogs/visit_paths/serverlogs-01-parse-script.rb +11 -0
  115. data/examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb +31 -0
  116. data/examples/serverlogs/visit_paths/serverlogs-02-histograms-mapper.rb +12 -0
  117. data/examples/serverlogs/visit_paths/serverlogs-03-breadcrumbs-full.rb +67 -0
  118. data/examples/serverlogs/visit_paths/serverlogs-04-page_page_edges-full.rb +38 -0
  119. data/examples/splitter.rb +94 -0
  120. data/examples/string_reverser.rb +7 -0
  121. data/examples/text/pig_latin/pig_latinizer.rb +35 -0
  122. data/examples/text/pig_latin/pig_latinizer_widget.rb +16 -0
  123. data/examples/text/regional_flavor/README.md +14 -0
  124. data/examples/text/regional_flavor/article_wordbags.pig +39 -0
  125. data/examples/text/regional_flavor/j01-article_wordbags.rb +4 -0
  126. data/examples/text/regional_flavor/simple_pig_script.pig +27 -0
  127. data/examples/twitter.rb +5 -0
  128. data/lib/hanuman.rb +36 -0
  129. data/lib/hanuman/graph.rb +97 -0
  130. data/lib/hanuman/graphvizzer.rb +206 -0
  131. data/lib/hanuman/graphvizzer/gv_models.rb +161 -0
  132. data/lib/hanuman/graphvizzer/gv_presenter.rb +97 -0
  133. data/lib/hanuman/link.rb +35 -0
  134. data/lib/hanuman/registry.rb +46 -0
  135. data/lib/hanuman/stage.rb +128 -0
  136. data/lib/hanuman/tree.rb +67 -0
  137. data/lib/wu/geo.rb +4 -0
  138. data/lib/wu/geo/geo_grids.numbers +0 -0
  139. data/lib/wu/geo/geolocated.rb +331 -0
  140. data/lib/wu/geo/quadtile.rb +69 -0
  141. data/lib/wu/graph/union_find.rb +62 -0
  142. data/lib/wu/model/reconcilable.rb +63 -0
  143. data/lib/wu/munging.rb +71 -0
  144. data/lib/wu/social/models/twitter.rb +31 -0
  145. data/lib/wu/wikipedia/models.rb +20 -0
  146. data/lib/wukong.rb +54 -0
  147. data/lib/wukong/dataflow.rb +43 -0
  148. data/lib/wukong/doc_helpers.rb +14 -0
  149. data/lib/wukong/doc_helpers/dataflow_handler.rb +29 -0
  150. data/lib/wukong/doc_helpers/field_handler.rb +91 -0
  151. data/lib/wukong/doc_helpers/processor_handler.rb +29 -0
  152. data/lib/wukong/driver.rb +214 -0
  153. data/lib/wukong/driver/event_machine_driver.rb +15 -0
  154. data/lib/wukong/driver/wiring.rb +68 -0
  155. data/lib/wukong/local.rb +42 -0
  156. data/lib/wukong/local/runner.rb +96 -0
  157. data/lib/wukong/local/stdio_driver.rb +104 -0
  158. data/lib/wukong/logger.rb +102 -0
  159. data/lib/wukong/model/faker.rb +136 -0
  160. data/lib/wukong/model/flatpack_parser/flat.rb +60 -0
  161. data/lib/wukong/model/flatpack_parser/flatpack.rb +4 -0
  162. data/lib/wukong/model/flatpack_parser/lang.rb +46 -0
  163. data/lib/wukong/model/flatpack_parser/parser.rb +55 -0
  164. data/lib/wukong/model/flatpack_parser/tokens.rb +130 -0
  165. data/lib/wukong/plugin.rb +48 -0
  166. data/lib/wukong/processor.rb +110 -0
  167. data/lib/wukong/rake_helper.rb +6 -0
  168. data/lib/wukong/runner.rb +169 -0
  169. data/lib/wukong/runner/boot_sequence.rb +123 -0
  170. data/lib/wukong/runner/code_loader.rb +52 -0
  171. data/lib/wukong/runner/command_runner.rb +44 -0
  172. data/lib/wukong/runner/deploy_pack_loader.rb +75 -0
  173. data/lib/wukong/runner/help_message.rb +42 -0
  174. data/lib/wukong/source.rb +33 -0
  175. data/lib/wukong/source/source_driver.rb +74 -0
  176. data/lib/wukong/source/source_runner.rb +38 -0
  177. data/lib/wukong/spec_helpers.rb +74 -0
  178. data/lib/wukong/spec_helpers/integration_tests.rb +150 -0
  179. data/lib/wukong/spec_helpers/integration_tests/integration_test_matchers.rb +207 -0
  180. data/lib/wukong/spec_helpers/integration_tests/integration_test_runner.rb +97 -0
  181. data/lib/wukong/spec_helpers/shared_examples.rb +22 -0
  182. data/lib/wukong/spec_helpers/unit_tests.rb +135 -0
  183. data/lib/wukong/spec_helpers/unit_tests/unit_test_driver.rb +132 -0
  184. data/lib/wukong/spec_helpers/unit_tests/unit_test_matchers.rb +169 -0
  185. data/lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb +60 -0
  186. data/lib/wukong/version.rb +3 -0
  187. data/lib/wukong/widget/echo.rb +55 -0
  188. data/lib/wukong/widget/extract.rb +122 -0
  189. data/lib/wukong/widget/filters.rb +452 -0
  190. data/lib/wukong/widget/logger.rb +56 -0
  191. data/lib/wukong/widget/operators.rb +82 -0
  192. data/lib/wukong/widget/reducers.rb +10 -0
  193. data/lib/wukong/widget/reducers/accumulator.rb +73 -0
  194. data/lib/wukong/widget/reducers/bin.rb +368 -0
  195. data/lib/wukong/widget/reducers/count.rb +73 -0
  196. data/lib/wukong/widget/reducers/group.rb +128 -0
  197. data/lib/wukong/widget/reducers/group_concat.rb +98 -0
  198. data/lib/wukong/widget/reducers/improver.rb +71 -0
  199. data/lib/wukong/widget/reducers/join_xml.rb +37 -0
  200. data/lib/wukong/widget/reducers/moments.rb +72 -0
  201. data/lib/wukong/widget/reducers/sort.rb +180 -0
  202. data/lib/wukong/widget/reducers/uniq.rb +91 -0
  203. data/lib/wukong/widget/serializers.rb +317 -0
  204. data/lib/wukong/widget/utils.rb +46 -0
  205. data/lib/wukong/widgets.rb +7 -0
  206. data/spec/examples/dataflow/fibonacci_series_spec.rb +18 -0
  207. data/spec/examples/dataflow/parse_apache_logs_spec.rb +8 -0
  208. data/spec/examples/dataflow/parsing_spec.rb +14 -0
  209. data/spec/examples/dataflow/simple_spec.rb +34 -0
  210. data/spec/examples/dataflow/telegram_spec.rb +43 -0
  211. data/spec/examples/graph/minimum_spanning_tree_spec.rb +34 -0
  212. data/spec/examples/munging/airline_flights/identifiers_spec.rb +16 -0
  213. data/spec/examples/munging/airline_flights_spec.rb +202 -0
  214. data/spec/examples/text/pig_latin_spec.rb +18 -0
  215. data/spec/examples/workflow/cherry_pie_spec.rb +36 -0
  216. data/spec/hanuman/graph_spec.rb +119 -0
  217. data/spec/hanuman/hanuman_spec.rb +10 -0
  218. data/spec/hanuman/registry_spec.rb +123 -0
  219. data/spec/hanuman/stage_spec.rb +81 -0
  220. data/spec/hanuman/tree_spec.rb +119 -0
  221. data/spec/spec.opts +1 -0
  222. data/spec/spec_helper.rb +43 -0
  223. data/spec/support/example_test_helpers.rb +95 -0
  224. data/spec/support/hanuman_test_helpers.rb +92 -0
  225. data/spec/support/integration_helper.rb +38 -0
  226. data/spec/support/model_test_helpers.rb +115 -0
  227. data/spec/support/shared_context_for_graphs.rb +57 -0
  228. data/spec/support/shared_context_for_reducers.rb +37 -0
  229. data/spec/support/shared_examples_for_builders.rb +94 -0
  230. data/spec/support/shared_examples_for_shortcuts.rb +57 -0
  231. data/spec/wu/model/reconcilable_spec.rb +152 -0
  232. data/spec/wukong/dataflow_spec.rb +87 -0
  233. data/spec/wukong/driver_spec.rb +154 -0
  234. data/spec/wukong/local/runner_spec.rb +29 -0
  235. data/spec/wukong/local/stdio_driver_spec.rb +73 -0
  236. data/spec/wukong/local_spec.rb +6 -0
  237. data/spec/wukong/logger_spec.rb +49 -0
  238. data/spec/wukong/model/faker_spec.rb +132 -0
  239. data/spec/wukong/processor_spec.rb +21 -0
  240. data/spec/wukong/runner_spec.rb +132 -0
  241. data/spec/wukong/source_spec.rb +6 -0
  242. data/spec/wukong/widget/extract_spec.rb +101 -0
  243. data/spec/wukong/widget/filters_spec.rb +79 -0
  244. data/spec/wukong/widget/logger_spec.rb +23 -0
  245. data/spec/wukong/widget/operators_spec.rb +25 -0
  246. data/spec/wukong/widget/reducers/bin_spec.rb +92 -0
  247. data/spec/wukong/widget/reducers/count_spec.rb +11 -0
  248. data/spec/wukong/widget/reducers/group_spec.rb +21 -0
  249. data/spec/wukong/widget/reducers/join_xml_spec.rb +25 -0
  250. data/spec/wukong/widget/reducers/moments_spec.rb +36 -0
  251. data/spec/wukong/widget/reducers/sort_spec.rb +26 -0
  252. data/spec/wukong/widget/reducers/uniq_spec.rb +14 -0
  253. data/spec/wukong/widget/serializers_spec.rb +114 -0
  254. data/spec/wukong/widget/sink_spec.rb +19 -0
  255. data/spec/wukong/widget/source_spec.rb +65 -0
  256. data/spec/wukong/wu-local_spec.rb +109 -0
  257. data/spec/wukong/wu-source_spec.rb +32 -0
  258. data/spec/wukong/wu_spec.rb +14 -0
  259. data/spec/wukong/wukong_spec.rb +10 -0
  260. data/wukong.gemspec +35 -0
  261. metadata +465 -0
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Local::LocalRunner do
4
+ before { EM.stub(:run) }
5
+
6
+ describe "choosing a processor name" do
7
+
8
+ it "raises an error without any arguments" do
9
+ expect { local_runner() }.to raise_error(Wukong::Error, /must provide.*processor.*run.*argument/i)
10
+ end
11
+
12
+ it "raises an error when passed the name of a processor that isn't registered" do
13
+ expect { local_runner('some_proc_that_dont_exit') }.to raise_error(Wukong::Error, /no such processor.*some_proc.*/i)
14
+ end
15
+
16
+ it "accepts an explicit --run argument" do
17
+ local_runner('--run=identity').processor.should == 'identity'
18
+ end
19
+
20
+ it "accepts a registered processor name from the first argument" do
21
+ local_runner('identity').processor.should == 'identity'
22
+ end
23
+
24
+ it "accepts a registerd processor name from the the basename of the first file argument" do
25
+ local_runner(examples_dir('string_reverser.rb')).processor.should == 'string_reverser'
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Local::StdioDriver do
4
+ before { EM.stub(:stop) }
5
+
6
+ let(:driver) { Wukong::Local::StdioDriver.new(:bogus_event_machine_inserted_arg, :identity, {}) }
7
+
8
+ it "attaches itself as an EventMachine handler for $stdin, providing the given label and settings" do
9
+ EM.should_receive(:attach).with($stdin, Wukong::Local::StdioDriver, :foo, {})
10
+ Wukong::Local::StdioDriver.start(:foo, {})
11
+ end
12
+
13
+ describe "setting up a dataflow" do
14
+ context "#post_init hook from EventMachine" do
15
+ after { driver.post_init }
16
+
17
+ it "sets signal traps for INT and TERM" do
18
+ Signal.should_receive(:trap).with('INT').at_least(:once)
19
+ Signal.should_receive(:trap).with('TERM').at_least(:once)
20
+ end
21
+
22
+ it "calls the #setup_dataflow method" do
23
+ driver.should_receive(:setup_dataflow).at_least(:once)
24
+ end
25
+
26
+ it "syncs $stdout" do
27
+ $stdout.should_receive(:sync).at_least(:once)
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ describe "driving a dataflow" do
34
+ context "#receive_line hook from EventMachine" do
35
+ let(:line) { "hello" }
36
+
37
+ after { driver.receive_line(line) }
38
+ it "passes the line to the #send_through_dataflow method" do
39
+ driver.should_receive(:send_through_dataflow).with(line)
40
+ end
41
+
42
+ context "upon an error within the dataflow" do
43
+ let(:message) { "whoops" }
44
+
45
+ before do
46
+ driver.should_receive(:send_through_dataflow).with(line) do
47
+ raise Wukong::Error.new(message)
48
+ end
49
+ driver.log.stub(:error)
50
+ end
51
+
52
+ it "logs an error message" do
53
+ driver.log.should_receive(:error).with(kind_of(String))
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "shutting down a dataflow" do
60
+ context "#unbind hook from EventMachine" do
61
+ after { driver.unbind }
62
+
63
+ it "calls the #finalize_and_stop_dataflow method" do
64
+ driver.should_receive(:finalize_and_stop_dataflow)
65
+ end
66
+
67
+ it "stops the EventMachine reactor" do
68
+ EM.should_receive(:stop)
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Local do
4
+ it_behaves_like 'a plugin'
5
+ end
6
+
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Logging do
4
+
5
+ let(:loggable) { Class.new.class_eval { include Wukong::Logging } }
6
+ let(:model) { Class.new.class_eval { include Gorillib::Model } }
7
+
8
+ describe "a class including Wukong::Logging" do
9
+ subject { loggable }
10
+
11
+ it { should respond_to(:log) }
12
+
13
+ describe "has instances that" do
14
+ let(:loggable_instance) { loggable.new }
15
+ subject { loggable_instance }
16
+
17
+ it { should respond_to(:log) }
18
+ describe "have an instance method #log that" do
19
+ let(:log) { loggable_instance.log }
20
+ subject { log }
21
+
22
+ it { should respond_to(:debug) }
23
+ it { should respond_to(:info) }
24
+ it { should respond_to(:warn) }
25
+ end
26
+ end
27
+
28
+ describe "has subclasses" do
29
+ let(:child) { Class.new(loggable) }
30
+
31
+ describe "with instances that" do
32
+ subject { child.new }
33
+
34
+ it { should respond_to(:log) }
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "a class including Gorillib::Model and then Wukong::Logging" do
40
+ let(:loggable_model) { model.class_eval { include Wukong::Logging } }
41
+ subject { loggable_model }
42
+
43
+ describe "has fields that" do
44
+ subject { loggable_model.fields }
45
+ it { should include(:log) }
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,132 @@
1
+ # require 'spec_helper'
2
+
3
+ # describe 'Wukong::Faker', :helpers => true do
4
+
5
+ # context 'specifies fakers' do
6
+ # subject{ Class.new{ include Gorillib::Model; include Wukong::Faker } }
7
+
8
+ # it 'using type if no faker given' do
9
+ # subject.field :last_name, String
10
+ # # subject.fields[:last_name].type.should_receive(:fake_value)
11
+ # Gorillib::Factory(String).should_receive(:fake_value)
12
+ # subject.fake_value
13
+ # end
14
+
15
+ # it 'with proc' do
16
+ # my_proc = ->{ %w[John Paul George Ringo] }
17
+ # subject.field :first_name, String, :faker => my_proc
18
+ # my_proc.should_receive(:call)
19
+ # subject.fake_value
20
+ # end
21
+
22
+ # it 'with helper name' do
23
+ # subject.field :longitude, String, :faker => :fake_longitude
24
+ # Wukong::Faker::Helpers.should_receive(:fake_longitude)
25
+ # subject.fake_value
26
+ # end
27
+
28
+ # it 'with explicit faker factory' do
29
+ # subject.field :longitude, String, :faker => Gorillib::Factory(Integer)
30
+ # Gorillib::Factory(Integer).should_receive(:fake_value)
31
+ # subject.fake_value
32
+ # end
33
+
34
+ # it 'with explicit method' do
35
+ # subject.define_singleton_method(:fake_orgasm){ 'OHHH YEAHHH' }
36
+ # subject.field :orgasm, String
37
+ # subject.should_receive(:fake_orgasm)
38
+ # subject.fake_value
39
+ # end
40
+ # end
41
+
42
+ # be_ish_matcher :guid, /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
43
+
44
+ # be_ish_matcher :fileext, %r{^[\w\.\-]+$}
45
+ # be_ish_matcher :basename, %r{^\w+\.\w+$}
46
+ # be_ish_matcher :dirname, %r{^/(\w+/){1,}\w+$}
47
+ # be_ish_matcher :filename, %r{^/(\w+/){1,}\w+\.\w+$}
48
+
49
+ # be_ish_matcher :identifier, /\A[a-z]\w*\z/
50
+
51
+ # be_ish_matcher :hostname, /^(\w+\.)+\w+$/
52
+ # be_ish_matcher :ip_address, /^(\d+\.){3}\d+$/
53
+
54
+ # context 'extensions to Gorillib::Factory' do
55
+ # context Gorillib::Factory(String) do
56
+ # its(:fake_value){ should =~ /^\w+$/ }
57
+ # end
58
+ # context(Gorillib::Factory(Guid)) do
59
+ # its(:fake_value){ should be_guid_ish }
60
+ # end
61
+ # context(Gorillib::Factory(IpAddress)) do
62
+ # its(:fake_value){ should be_ip_address_ish }
63
+ # end
64
+ # context(Gorillib::Factory(Hostname)) do
65
+ # its(:fake_value){ should be_hostname_ish }
66
+ # end
67
+
68
+ # context(Gorillib::Factory(Symbol)) do
69
+ # its(:fake_value){ should be_a Symbol }
70
+ # its(:fake_value){ should be_identifier_ish }
71
+ # end
72
+
73
+ # context(Gorillib::Factory(Integer)) do
74
+ # its(:fake_value){ should be_a Integer }
75
+ # its(:fake_value){ should be < 100 }
76
+ # end
77
+
78
+ # context(Gorillib::Factory(Time)) do
79
+ # its(:fake_value){ should be_a Time }
80
+ # its(:fake_value){ should be_within(5).of(Time.now) }
81
+ # end
82
+
83
+ # context(Gorillib::Factory(NilClass) ){ its(:fake_value){ should equal(nil) } }
84
+ # context(Gorillib::Factory(TrueClass) ){ its(:fake_value){ should equal(true) } }
85
+ # context(Gorillib::Factory(FalseClass) ){ its(:fake_value){ should equal(false) } }
86
+ # context(Gorillib::Factory(:boolean) ){ its(:fake_value){ should be_in([true, false]) } }
87
+
88
+ # end
89
+
90
+ # context Wukong::Faker::Helpers do
91
+ # subject{ Wukong::Faker::Helpers }
92
+
93
+ # its(:fake_integer){ should be_a(Integer) }
94
+ # its(:fake_integer){ should be < 100 }
95
+ # it{ subject.fake_integer(:min => 90, :max => 90).should == 90 }
96
+ # it{ subject.fake_integer(:min => 91, :max => 99).should be_in(91..99) }
97
+
98
+ # its(:fake_float){ should be_a(Float) }
99
+ # its(:fake_float){ should be < 1.0 }
100
+ # it{ subject.fake_float(:min => 90, :max => 90).should == 90 }
101
+ # it{ subject.fake_float(:min => 91, :max => 99).should be_in(91..99) }
102
+
103
+ # its(:fake_latitude){ should be_a(Float) }
104
+ # its(:fake_latitude){ should be_in(32 .. 45) }
105
+ # its(:fake_longitude){ should be_a(Float) }
106
+ # its(:fake_longitude){ should be_in(-117 .. -68) }
107
+
108
+ # its(:fake_country_id){ should be_a(String) }
109
+
110
+ # its(:fake_area_code){ should be_a(Integer) }
111
+ # its(:fake_area_code){ should be_in( 201 .. 987) }
112
+
113
+ # its(:fake_identifier){ should be_identifier_ish }
114
+ # its(:fake_sentence){ should =~ /(\S+\s+){1,5}\S+\./ }
115
+ # its(:fake_sentence){ should =~ /(\S+\.)/ }
116
+
117
+ # its(:fake_fileext ){ should be_a(String) }
118
+ # its(:fake_basename){ should be_a(String) }
119
+ # its(:fake_dirname ){ should be_a(String) }
120
+ # its(:fake_filename){ should be_a(String) }
121
+ # its(:fake_fileext ){ should be_fileext_ish }
122
+ # its(:fake_basename){ should be_basename_ish }
123
+ # its(:fake_dirname ){ should be_dirname_ish }
124
+ # its(:fake_filename){ should be_filename_ish }
125
+
126
+ # its(:fake_hostname){ should be_hostname_ish }
127
+ # its(:fake_ip_addresss){ should be_ip_address_ish }
128
+ # its(:fake_version_number){ should be_a(String) }
129
+ # its(:fake_version_number){ should =~ /^\d+\.\d+$/ }
130
+ # end
131
+
132
+ # end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Processor do
4
+
5
+ subject { Wukong::Processor.new }
6
+
7
+ describe "has an interface" do
8
+ it{ should respond_to(:setup) }
9
+ it{ should respond_to(:process) }
10
+ it{ should respond_to(:finalize) }
11
+ it{ should respond_to(:stop) }
12
+ end
13
+
14
+ describe "default process method" do
15
+ it "yields the original input record by default on process" do
16
+ expect { |b| subject.process(1, &b) }.to yield_with_args(1)
17
+ end
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wukong::Runner do
4
+
5
+ context "can boot itself by" do
6
+
7
+ describe "loading" do
8
+ it "files passed on the command-line" do
9
+ loadable = examples_dir('loadable.rb')
10
+ generic_runner(loadable) do
11
+ should_receive(:load_ruby_file).with(loadable)
12
+ end
13
+ end
14
+ it "files when its in a deploy pack" do
15
+ generic_runner { should_receive(:load_deploy_pack) }
16
+ end
17
+ end
18
+
19
+ describe "configuring" do
20
+ subject do
21
+ Class.new(Wukong::Runner).tap do |configured|
22
+ configured.class_eval do
23
+ usage 'a nice usage message'
24
+ description 'a lovely description'
25
+ end
26
+ end
27
+ end
28
+
29
+ it "a usage message" do
30
+ runner(subject, 'wu-generic').settings.usage.should =~ /^usage: .* a nice usage message$/
31
+ end
32
+
33
+ it "a description" do
34
+ runner(subject, 'wu-generic').settings.description.should == 'a lovely description'
35
+ end
36
+
37
+ it "plugins" do
38
+ generic_runner { Wukong.should_receive(:configure_plugins) }
39
+ end
40
+ end
41
+
42
+ describe "resolving" do
43
+ it "doesn't move on if resolve causes an error" do
44
+ generic_runner do
45
+ settings.should_receive(:resolve!).and_raise(RuntimeError)
46
+ should_not_receive(:setup)
47
+ should_not_receive(:validate)
48
+ should_not_receive(:run)
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "setting up" do
54
+ it "asks plugins to boot" do
55
+ generic_runner do
56
+ Wukong.should_receive(:boot_plugins)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "validating" do
62
+ it "should run if validatation passes" do
63
+ generic_runner do
64
+ should_receive(:validate).and_return(true)
65
+ should_receive(:run)
66
+ end
67
+ end
68
+ it "dies if validate fails" do
69
+ generic_runner do
70
+ should_receive(:validate).and_return(false)
71
+ should_not_receive(:run)
72
+ should_receive(:die)
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ context "situating itself within a deploy pack" do
79
+ context "in an arbitrary directory" do
80
+ let(:dir) { examples_dir('empty') }
81
+ before { FileUtils.cd(dir) }
82
+ subject { generic_runner }
83
+ its(:deploy_pack_dir) { should == '/' }
84
+ its(:environment_file) { should == '/config/environment.rb' }
85
+ its(:in_deploy_pack?) { should be_false }
86
+ end
87
+
88
+ context "when BUNDLE_GEMFILE points at a regular Ruby project" do
89
+ let(:dir) { examples_dir('empty') }
90
+ let(:deploy_pack_dir) { examples_dir('ruby_project') }
91
+ before do
92
+ FileUtils.cd(dir)
93
+ ENV.stub(:[]).with("BUNDLE_GEMFILE").and_return(File.join(deploy_pack_dir, 'Gemfile'))
94
+ end
95
+ subject { generic_runner }
96
+ its(:deploy_pack_dir) { should == '/' }
97
+ its(:environment_file) { should == '/config/environment.rb' }
98
+ its(:in_deploy_pack?) { should be_false }
99
+ end
100
+
101
+ context "when BUNDLE_GEMFILE points at a deploy pack" do
102
+ let(:dir) { examples_dir('empty') }
103
+ let(:deploy_pack_dir) { examples_dir('deploy_pack') }
104
+ before do
105
+ FileUtils.cd(dir)
106
+ ENV.stub(:[]).with("BUNDLE_GEMFILE").and_return(File.join(deploy_pack_dir, 'Gemfile'))
107
+ end
108
+ subject { generic_runner }
109
+ its(:deploy_pack_dir) { should == deploy_pack_dir.to_s }
110
+ its(:environment_file) { should == File.join(deploy_pack_dir, 'config/environment.rb')}
111
+ its(:in_deploy_pack?) { should be_true }
112
+ end
113
+
114
+ context "in an arbitrary Ruby project with a Gemfile" do
115
+ let(:dir) { examples_dir('ruby_project') }
116
+ before { FileUtils.cd(dir) }
117
+ subject { generic_runner }
118
+ its(:deploy_pack_dir) { should == '/' }
119
+ its(:environment_file) { should == '/config/environment.rb' }
120
+ its(:in_deploy_pack?) { should be_false }
121
+ end
122
+
123
+ context "in a deploy pack with a Gemfile and a config/environment.rb" do
124
+ let(:dir) { examples_dir('deploy_pack') }
125
+ before { FileUtils.cd(dir) }
126
+ subject { generic_runner }
127
+ its(:deploy_pack_dir) { should == dir }
128
+ its(:environment_file) { should == File.join(dir, 'config/environment.rb')}
129
+ its(:in_deploy_pack?) { should be_true }
130
+ end
131
+ end
132
+ end