bosonson 0.304.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG.rdoc +108 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.rdoc +181 -0
  4. data/bin/bss +6 -0
  5. data/bosonson.gemspec +24 -0
  6. data/deps.rip +2 -0
  7. data/lib/boson.rb +96 -0
  8. data/lib/boson/command.rb +196 -0
  9. data/lib/boson/commands.rb +7 -0
  10. data/lib/boson/commands/core.rb +77 -0
  11. data/lib/boson/commands/web_core.rb +153 -0
  12. data/lib/boson/index.rb +48 -0
  13. data/lib/boson/inspector.rb +120 -0
  14. data/lib/boson/inspectors/argument_inspector.rb +97 -0
  15. data/lib/boson/inspectors/comment_inspector.rb +100 -0
  16. data/lib/boson/inspectors/method_inspector.rb +98 -0
  17. data/lib/boson/libraries/file_library.rb +144 -0
  18. data/lib/boson/libraries/gem_library.rb +30 -0
  19. data/lib/boson/libraries/local_file_library.rb +30 -0
  20. data/lib/boson/libraries/module_library.rb +37 -0
  21. data/lib/boson/libraries/require_library.rb +23 -0
  22. data/lib/boson/library.rb +179 -0
  23. data/lib/boson/loader.rb +118 -0
  24. data/lib/boson/manager.rb +169 -0
  25. data/lib/boson/namespace.rb +31 -0
  26. data/lib/boson/option_command.rb +222 -0
  27. data/lib/boson/option_parser.rb +475 -0
  28. data/lib/boson/options.rb +146 -0
  29. data/lib/boson/pipe.rb +147 -0
  30. data/lib/boson/pipes.rb +75 -0
  31. data/lib/boson/repo.rb +107 -0
  32. data/lib/boson/repo_index.rb +124 -0
  33. data/lib/boson/runner.rb +81 -0
  34. data/lib/boson/runners/bin_runner.rb +208 -0
  35. data/lib/boson/runners/console_runner.rb +58 -0
  36. data/lib/boson/scientist.rb +182 -0
  37. data/lib/boson/util.rb +129 -0
  38. data/lib/boson/version.rb +3 -0
  39. data/lib/boson/view.rb +95 -0
  40. data/test/argument_inspector_test.rb +62 -0
  41. data/test/bin_runner_test.rb +223 -0
  42. data/test/command_test.rb +22 -0
  43. data/test/commands_test.rb +22 -0
  44. data/test/comment_inspector_test.rb +126 -0
  45. data/test/deps.rip +4 -0
  46. data/test/file_library_test.rb +42 -0
  47. data/test/loader_test.rb +235 -0
  48. data/test/manager_test.rb +114 -0
  49. data/test/method_inspector_test.rb +90 -0
  50. data/test/option_parser_test.rb +367 -0
  51. data/test/options_test.rb +189 -0
  52. data/test/pipes_test.rb +65 -0
  53. data/test/repo_index_test.rb +122 -0
  54. data/test/repo_test.rb +23 -0
  55. data/test/runner_test.rb +40 -0
  56. data/test/scientist_test.rb +341 -0
  57. data/test/test_helper.rb +130 -0
  58. data/test/util_test.rb +56 -0
  59. data/vendor/bundle/gems/bacon-bits-0.1.0/deps.rip +1 -0
  60. data/vendor/bundle/gems/hirb-0.6.0/test/deps.rip +4 -0
  61. metadata +217 -0
@@ -0,0 +1,130 @@
1
+ require 'bacon'
2
+ require 'bacon/bits'
3
+ require 'mocha'
4
+ require 'mocha-on-bacon'
5
+ require 'boson'
6
+ Object.send :remove_const, :OptionParser
7
+ Boson.constants.each {|e| Object.const_set(e, Boson.const_get(e)) unless Object.const_defined?(e) }
8
+
9
+ module TestHelpers
10
+ # make local so it doesn't pick up my real boson dir
11
+ Boson.repo.dir = File.dirname(__FILE__)
12
+ # prevent extra File.exists? calls which interfere with stubs for it
13
+ Boson.repo.config = {:libraries=>{}, :command_aliases=>{}, :console_defaults=>[]}
14
+ Boson.instance_variable_set "@repos", [Boson.repo]
15
+
16
+ def assert_error(error, message=nil)
17
+ yield
18
+ rescue error=>e
19
+ e.class.should == error
20
+ e.message.should =~ Regexp.new(message) if message
21
+ else
22
+ nil.should == error
23
+ end
24
+
25
+ def reset
26
+ reset_main_object
27
+ reset_boson
28
+ end
29
+
30
+ def reset_main_object
31
+ Boson.send :remove_const, "Universe"
32
+ eval "module ::Boson::Universe; include ::Boson::Commands::Namespace; end"
33
+ Boson::Commands.send :remove_const, "Blah" rescue nil
34
+ Boson.main_object = Object.new
35
+ end
36
+
37
+ def reset_boson
38
+ reset_libraries
39
+ Boson.instance_eval("@commands = nil")
40
+ end
41
+
42
+ def reset_libraries
43
+ Boson.instance_eval("@libraries = nil")
44
+ end
45
+
46
+ def command_exists?(name, bool=true)
47
+ (!!Command.find(name)).should == bool
48
+ end
49
+
50
+ def library_loaded?(name, bool=true)
51
+ Manager.loaded?(name).should == bool
52
+ end
53
+
54
+ def library(name)
55
+ Boson.library(name)
56
+ end
57
+
58
+ def library_has_module(lib, lib_module)
59
+ Manager.loaded?(lib).should == true
60
+ test_lib = library(lib)
61
+ (test_lib.module.is_a?(Module) && (test_lib.module.to_s == lib_module)).should == true
62
+ end
63
+
64
+ def library_has_command(lib, command, bool=true)
65
+ (lib = library(lib)) && lib.commands.include?(command).should == bool
66
+ end
67
+
68
+ # mocks as a file library
69
+ def mock_library(lib, options={})
70
+ options = {:file_string=>'', :exists=>true}.merge!(options)
71
+ File.expects(:exists?).with(FileLibrary.library_file(lib.to_s, Boson.repo.dir)).
72
+ at_least(1).returns(options.delete(:exists))
73
+ File.expects(:read).returns(options.delete(:file_string))
74
+ end
75
+
76
+ def load(lib, options={})
77
+ # prevent conflicts with existing File.read stubs
78
+ MethodInspector.stubs(:inspector_in_file?).returns(false)
79
+ mock_library(lib, options) unless options.delete(:no_mock)
80
+ result = Manager.load([lib], options)
81
+ FileLibrary.reset_file_cache
82
+ result
83
+ end
84
+
85
+ def capture_stdout(&block)
86
+ original_stdout = $stdout
87
+ $stdout = fake = StringIO.new
88
+ begin
89
+ yield
90
+ ensure
91
+ $stdout = original_stdout
92
+ end
93
+ fake.string
94
+ end
95
+
96
+ def with_config(options)
97
+ old_config = Boson.repo.config
98
+ Boson.repo.config = Boson.repo.config.merge(options)
99
+ yield
100
+ Boson.repo.config = old_config
101
+ end
102
+
103
+ def capture_stderr(&block)
104
+ original_stderr = $stderr
105
+ $stderr = fake = StringIO.new
106
+ begin
107
+ yield
108
+ ensure
109
+ $stderr = original_stderr
110
+ end
111
+ fake.string
112
+ end
113
+
114
+ def create_library(libraries, attributes={})
115
+ libraries = [libraries] unless libraries.is_a?(Array)
116
+ libraries.map {|e|
117
+ lib = Library.new({:name=>e}.update(attributes))
118
+ Manager.add_library(lib); lib
119
+ }
120
+ end
121
+
122
+ def aborts_with(regex)
123
+ BinRunner.expects(:abort).with {|e| e[regex] }
124
+ yield
125
+ end
126
+ end
127
+
128
+ class Bacon::Context
129
+ include TestHelpers
130
+ end
@@ -0,0 +1,56 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ describe "Util" do
4
+ it "underscore converts camelcase to underscore" do
5
+ Util.underscore('Boson::MethodInspector').should == 'boson/method_inspector'
6
+ end
7
+
8
+ it "constantize converts string to class" do
9
+ Util.constantize("Boson").should == ::Boson
10
+ end
11
+
12
+ describe "underscore_search" do
13
+ def search(query, list)
14
+ Util.underscore_search(query, list).sort {|a,b| a.to_s <=> b.to_s }
15
+ end
16
+
17
+ def first_search(query, list)
18
+ Util.underscore_search(query, list, true)
19
+ end
20
+
21
+ it "matches non underscore strings" do
22
+ search('som', %w{some words match sometimes}).should == %w{some sometimes}
23
+ end
24
+
25
+ it "matches first non underscore string" do
26
+ first_search('wo', %w{some work wobbles}).should == 'work'
27
+ end
28
+
29
+ it "matches non underscore symbols" do
30
+ search(:som, [:some, :words, :match, :sometimes]).should == [:some, :sometimes]
31
+ search('som', [:some, :words, :match, :sometimes]).should == [:some, :sometimes]
32
+ end
33
+
34
+ it "matches underscore strings" do
35
+ search('s_l', %w{some_long some_short some_lame}).should == %w{some_lame some_long}
36
+ end
37
+
38
+ it "matches first underscore string" do
39
+ first_search('s_l', %w{some_long some_short some_lame}).should == 'some_long'
40
+ end
41
+
42
+ it "matches underscore symbols" do
43
+ search(:s_l, [:some_long, :some_short, :some_lame]).should == [:some_lame, :some_long]
44
+ search('s_l', [:some_long, :some_short, :some_lame]).should == [:some_lame, :some_long]
45
+ end
46
+
47
+ it "matches full underscore string" do
48
+ search('some_long_name', %w{some_long_name some_short some_lame}).should == %w{some_long_name}
49
+ end
50
+
51
+ it "only matches exact match if multiple matches that start with exact match" do
52
+ search('bl', %w{bl blang bling}).should == ['bl']
53
+ first_search('bl', %w{bl blang bling}).should == 'bl'
54
+ end
55
+ end
56
+ end
@@ -0,0 +1 @@
1
+ bacon >=1.1.0
@@ -0,0 +1,4 @@
1
+ bacon >=1.1.0
2
+ mocha >=0.9.8
3
+ mocha-on-bacon >=0.1.1
4
+ bacon-bits >=0
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bosonson
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1245
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 304
9
+ - 1
10
+ version: 0.304.1
11
+ platform: ruby
12
+ authors:
13
+ - Tom Bombadil
14
+ - Gabriel Horner
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-12-20 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hirb
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 0
32
+ - 5
33
+ - 0
34
+ version: 0.5.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: alias
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 0
48
+ - 2
49
+ - 2
50
+ version: 0.2.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: mocha
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: bacon
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 19
76
+ segments:
77
+ - 1
78
+ - 1
79
+ - 0
80
+ version: 1.1.0
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha-on-bacon
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: bacon-bits
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ type: :development
110
+ version_requirements: *id006
111
+ description: bosonson is a command/task framework with the power to turn any ruby method into a full-fledged executable with options. Some unique features that differentiate it from rake and thor include being usable from irb and the commandline, optional automated views generated by hirb and allowing libraries to be written as plain ruby. For my libraries that use this, see irbfiles. Works with all major ruby versions. Forked from boson
112
+ email: amanibhavam@destructuring.org
113
+ executables:
114
+ - bss
115
+ extensions: []
116
+
117
+ extra_rdoc_files:
118
+ - README.rdoc
119
+ - LICENSE.txt
120
+ files:
121
+ - lib/boson/command.rb
122
+ - lib/boson/commands/core.rb
123
+ - lib/boson/commands/web_core.rb
124
+ - lib/boson/commands.rb
125
+ - lib/boson/index.rb
126
+ - lib/boson/inspector.rb
127
+ - lib/boson/inspectors/argument_inspector.rb
128
+ - lib/boson/inspectors/comment_inspector.rb
129
+ - lib/boson/inspectors/method_inspector.rb
130
+ - lib/boson/libraries/file_library.rb
131
+ - lib/boson/libraries/gem_library.rb
132
+ - lib/boson/libraries/local_file_library.rb
133
+ - lib/boson/libraries/module_library.rb
134
+ - lib/boson/libraries/require_library.rb
135
+ - lib/boson/library.rb
136
+ - lib/boson/loader.rb
137
+ - lib/boson/manager.rb
138
+ - lib/boson/namespace.rb
139
+ - lib/boson/option_command.rb
140
+ - lib/boson/option_parser.rb
141
+ - lib/boson/options.rb
142
+ - lib/boson/pipe.rb
143
+ - lib/boson/pipes.rb
144
+ - lib/boson/repo.rb
145
+ - lib/boson/repo_index.rb
146
+ - lib/boson/runner.rb
147
+ - lib/boson/runners/bin_runner.rb
148
+ - lib/boson/runners/console_runner.rb
149
+ - lib/boson/scientist.rb
150
+ - lib/boson/util.rb
151
+ - lib/boson/version.rb
152
+ - lib/boson/view.rb
153
+ - lib/boson.rb
154
+ - test/argument_inspector_test.rb
155
+ - test/bin_runner_test.rb
156
+ - test/command_test.rb
157
+ - test/commands_test.rb
158
+ - test/comment_inspector_test.rb
159
+ - test/file_library_test.rb
160
+ - test/loader_test.rb
161
+ - test/manager_test.rb
162
+ - test/method_inspector_test.rb
163
+ - test/option_parser_test.rb
164
+ - test/options_test.rb
165
+ - test/pipes_test.rb
166
+ - test/repo_index_test.rb
167
+ - test/repo_test.rb
168
+ - test/runner_test.rb
169
+ - test/scientist_test.rb
170
+ - test/test_helper.rb
171
+ - test/util_test.rb
172
+ - bin/bss
173
+ - LICENSE.txt
174
+ - CHANGELOG.rdoc
175
+ - README.rdoc
176
+ - deps.rip
177
+ - test/deps.rip
178
+ - vendor/bundle/gems/bacon-bits-0.1.0/deps.rip
179
+ - vendor/bundle/gems/hirb-0.6.0/test/deps.rip
180
+ - bosonson.gemspec
181
+ homepage: https://HeSYINUvSBZfxqA.github.com/bosonson
182
+ licenses:
183
+ - MIT
184
+ post_install_message:
185
+ rdoc_options: []
186
+
187
+ require_paths:
188
+ - lib
189
+ required_ruby_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ hash: 3
195
+ segments:
196
+ - 0
197
+ version: "0"
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ none: false
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ hash: 23
204
+ segments:
205
+ - 1
206
+ - 3
207
+ - 6
208
+ version: 1.3.6
209
+ requirements: []
210
+
211
+ rubyforge_project:
212
+ rubygems_version: 1.8.10
213
+ signing_key:
214
+ specification_version: 3
215
+ summary: A command/task framework similar to rake and thor that opens your ruby universe to the commandline and irb, forked from boson
216
+ test_files: []
217
+