boson 0.2.2 → 0.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.
- data/LICENSE.txt +1 -1
- data/README.rdoc +2 -2
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/lib/boson.rb +1 -1
- data/lib/boson/command.rb +12 -2
- data/lib/boson/commands/core.rb +16 -11
- data/lib/boson/commands/web_core.rb +107 -27
- data/lib/boson/inspector.rb +3 -9
- data/lib/boson/inspectors/method_inspector.rb +2 -2
- data/lib/boson/libraries/file_library.rb +6 -6
- data/lib/boson/manager.rb +1 -1
- data/lib/boson/option_command.rb +4 -1
- data/lib/boson/option_parser.rb +49 -21
- data/lib/boson/options.rb +18 -9
- data/lib/boson/pipe.rb +79 -89
- data/lib/boson/pipes.rb +67 -0
- data/lib/boson/repo.rb +13 -1
- data/lib/boson/runners/bin_runner.rb +6 -5
- data/lib/boson/scientist.rb +15 -12
- data/lib/boson/util.rb +19 -16
- data/lib/boson/view.rb +4 -1
- data/test/argument_inspector_test.rb +1 -1
- data/test/method_inspector_test.rb +2 -2
- data/test/option_parser_test.rb +2 -190
- data/test/options_test.rb +189 -0
- data/test/{pipe_test.rb → pipes_test.rb} +10 -14
- data/test/scientist_test.rb +4 -0
- data/test/test_helper.rb +11 -0
- data/test/util_test.rb +58 -0
- metadata +10 -5
@@ -7,51 +7,47 @@ module Boson
|
|
7
7
|
Ab = Struct.new(:a, :b) unless PipeTest.const_defined?(:Ab)
|
8
8
|
@objects = [Ab.new('some', 'thing'), Ab.new(:more, :yep)]
|
9
9
|
}
|
10
|
-
context "
|
10
|
+
context "query_pipe" do
|
11
11
|
|
12
12
|
test "searches one query" do
|
13
13
|
[@hashes, @objects].each {|e|
|
14
|
-
|
14
|
+
Pipes.query_pipe(e, :a=>'some').should == e[0,1]
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
18
|
test "searches non-string values" do
|
19
19
|
[@hashes, @objects].each {|e|
|
20
|
-
|
20
|
+
Pipes.query_pipe(e, :a=>'more').should == e[1,1]
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
24
24
|
test "searches multiple search terms" do
|
25
25
|
[@hashes, @objects].each {|e|
|
26
|
-
|
26
|
+
Pipes.query_pipe(e, :a=>'some', :b=>'yep').size.should == 2
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
30
|
test "prints error for invalid search field" do
|
31
|
-
capture_stderr {
|
31
|
+
capture_stderr { Pipes.query_pipe(@objects, :blah=>'blah') }.should =~ /failed.*'blah'/
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
context "
|
35
|
+
context "sort_pipe" do
|
36
36
|
test "sorts objects with values of different types" do
|
37
|
-
|
37
|
+
Pipes.sort_pipe(@objects, :a).should == @objects.reverse
|
38
38
|
end
|
39
39
|
|
40
40
|
test "sorts hashes with values of different types" do
|
41
|
-
|
41
|
+
Pipes.sort_pipe(@hashes, :a).should == @hashes.reverse
|
42
42
|
end
|
43
43
|
|
44
44
|
test "sorts numeric values" do
|
45
45
|
hashes = [{:a=>10, :b=>4}, {:a=>5, :b=>3}]
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
test "sorts and reverses sort" do
|
50
|
-
Pipe.sort_object(@hashes, :a, true).should == @hashes
|
46
|
+
Pipes.sort_pipe(hashes, :a).should == hashes.reverse
|
51
47
|
end
|
52
48
|
|
53
49
|
test "prints error for invalid sort field" do
|
54
|
-
capture_stderr {
|
50
|
+
capture_stderr { Pipes.sort_pipe(@objects, :blah)}.should =~ /failed.*'blah'/
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
data/test/scientist_test.rb
CHANGED
@@ -322,6 +322,10 @@ module Boson
|
|
322
322
|
local_and_global("doh -r -f - --dude").should == [{:foo=>true}, {:dude=>true, :render=>true}]
|
323
323
|
end
|
324
324
|
|
325
|
+
test "conflicting global option after -" do
|
326
|
+
local_and_global('doh - -f=1,2').should == [{}, {:fields=>["1", "2"]}]
|
327
|
+
end
|
328
|
+
|
325
329
|
test "no options parsed after --" do
|
326
330
|
local_and_global('doh -f -- -r').should == [{:foo=>true}, {}]
|
327
331
|
local_and_global('doh -- -r -f').should == [{}, {}]
|
data/test/test_helper.rb
CHANGED
@@ -130,4 +130,15 @@ class Test::Unit::TestCase
|
|
130
130
|
Boson::Manager.add_library(lib); lib
|
131
131
|
}
|
132
132
|
end
|
133
|
+
|
134
|
+
module OptionTestHelper
|
135
|
+
def create(opts)
|
136
|
+
@opt = Boson::OptionParser.new(opts)
|
137
|
+
end
|
138
|
+
|
139
|
+
def parse(*args)
|
140
|
+
@non_opts = []
|
141
|
+
@opt.parse(args.flatten)
|
142
|
+
end
|
143
|
+
end
|
133
144
|
end
|
data/test/util_test.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
module Boson
|
4
|
+
class UtilTest < Test::Unit::TestCase
|
5
|
+
test "underscore converts camelcase to underscore" do
|
6
|
+
Util.underscore('Boson::MethodInspector').should == 'boson/method_inspector'
|
7
|
+
end
|
8
|
+
|
9
|
+
test "constantize converts string to class" do
|
10
|
+
Util.constantize("Boson").should == ::Boson
|
11
|
+
end
|
12
|
+
|
13
|
+
context "underscore_search" do
|
14
|
+
def search(query, list)
|
15
|
+
Util.underscore_search(query, list).sort {|a,b| a.to_s <=> b.to_s }
|
16
|
+
end
|
17
|
+
|
18
|
+
def first_search(query, list)
|
19
|
+
Util.underscore_search(query, list, true)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "matches non underscore strings" do
|
23
|
+
search('som', %w{some words match sometimes}).should == %w{some sometimes}
|
24
|
+
end
|
25
|
+
|
26
|
+
test "matches first non underscore string" do
|
27
|
+
first_search('wo', %w{some work wobbles}).should == 'work'
|
28
|
+
end
|
29
|
+
|
30
|
+
test "matches non underscore symbols" do
|
31
|
+
search(:som, [:some, :words, :match, :sometimes]).should == [:some, :sometimes]
|
32
|
+
search('som', [:some, :words, :match, :sometimes]).should == [:some, :sometimes]
|
33
|
+
end
|
34
|
+
|
35
|
+
test "matches underscore strings" do
|
36
|
+
search('s_l', %w{some_long some_short some_lame}).should == %w{some_lame some_long}
|
37
|
+
end
|
38
|
+
|
39
|
+
test "matches first underscore string" do
|
40
|
+
first_search('s_l', %w{some_long some_short some_lame}).should == 'some_long'
|
41
|
+
end
|
42
|
+
|
43
|
+
test "matches underscore symbols" do
|
44
|
+
search(:s_l, [:some_long, :some_short, :some_lame]).should == [:some_lame, :some_long]
|
45
|
+
search('s_l', [:some_long, :some_short, :some_lame]).should == [:some_lame, :some_long]
|
46
|
+
end
|
47
|
+
|
48
|
+
test "matches full underscore string" do
|
49
|
+
search('some_long_name', %w{some_long_name some_short some_lame}).should == %w{some_long_name}
|
50
|
+
end
|
51
|
+
|
52
|
+
test "only matches exact match if multiple matches that start with exact match" do
|
53
|
+
search('bl', %w{bl blang bling}).should == ['bl']
|
54
|
+
first_search('bl', %w{bl blang bling}).should == 'bl'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Horner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-16 00:00:00 -05:00
|
13
13
|
default_executable: boson
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.2.
|
23
|
+
version: 0.2.10
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: alias
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/boson/option_parser.rb
|
71
71
|
- lib/boson/options.rb
|
72
72
|
- lib/boson/pipe.rb
|
73
|
+
- lib/boson/pipes.rb
|
73
74
|
- lib/boson/repo.rb
|
74
75
|
- lib/boson/repo_index.rb
|
75
76
|
- lib/boson/runner.rb
|
@@ -86,12 +87,14 @@ files:
|
|
86
87
|
- test/manager_test.rb
|
87
88
|
- test/method_inspector_test.rb
|
88
89
|
- test/option_parser_test.rb
|
89
|
-
- test/
|
90
|
+
- test/options_test.rb
|
91
|
+
- test/pipes_test.rb
|
90
92
|
- test/repo_index_test.rb
|
91
93
|
- test/repo_test.rb
|
92
94
|
- test/runner_test.rb
|
93
95
|
- test/scientist_test.rb
|
94
96
|
- test/test_helper.rb
|
97
|
+
- test/util_test.rb
|
95
98
|
has_rdoc: true
|
96
99
|
homepage: http://tagaholic.me/boson/
|
97
100
|
licenses: []
|
@@ -129,9 +132,11 @@ test_files:
|
|
129
132
|
- test/manager_test.rb
|
130
133
|
- test/method_inspector_test.rb
|
131
134
|
- test/option_parser_test.rb
|
132
|
-
- test/
|
135
|
+
- test/options_test.rb
|
136
|
+
- test/pipes_test.rb
|
133
137
|
- test/repo_index_test.rb
|
134
138
|
- test/repo_test.rb
|
135
139
|
- test/runner_test.rb
|
136
140
|
- test/scientist_test.rb
|
137
141
|
- test/test_helper.rb
|
142
|
+
- test/util_test.rb
|