boson-more 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +97 -0
- data/Rakefile +35 -0
- data/deps.rip +1 -0
- data/lib/boson/alias.rb +75 -0
- data/lib/boson/argument_inspector.rb +90 -0
- data/lib/boson/commands/core.rb +67 -0
- data/lib/boson/commands/view_core.rb +19 -0
- data/lib/boson/commands/web_core.rb +153 -0
- data/lib/boson/comment_inspector.rb +100 -0
- data/lib/boson/console.rb +40 -0
- data/lib/boson/console_runner.rb +60 -0
- data/lib/boson/index.rb +48 -0
- data/lib/boson/libraries/file_library.rb +144 -0
- data/lib/boson/libraries/gem_library.rb +30 -0
- data/lib/boson/libraries/local_file_library.rb +30 -0
- data/lib/boson/libraries/module_library.rb +37 -0
- data/lib/boson/libraries/require_library.rb +23 -0
- data/lib/boson/libraries.rb +183 -0
- data/lib/boson/more/version.rb +5 -0
- data/lib/boson/more.rb +18 -0
- data/lib/boson/more_commands.rb +14 -0
- data/lib/boson/more_inspector.rb +42 -0
- data/lib/boson/more_manager.rb +34 -0
- data/lib/boson/more_method_inspector.rb +74 -0
- data/lib/boson/more_option_parser.rb +28 -0
- data/lib/boson/more_scientist.rb +68 -0
- data/lib/boson/more_util.rb +30 -0
- data/lib/boson/namespace.rb +31 -0
- data/lib/boson/namespacer.rb +117 -0
- data/lib/boson/pipe.rb +156 -0
- data/lib/boson/pipe_runner.rb +44 -0
- data/lib/boson/pipes.rb +75 -0
- data/lib/boson/repo.rb +96 -0
- data/lib/boson/repo_index.rb +135 -0
- data/lib/boson/runner_options.rb +88 -0
- data/lib/boson/save.rb +198 -0
- data/lib/boson/science.rb +273 -0
- data/lib/boson/view.rb +98 -0
- data/lib/boson/viewable.rb +48 -0
- data/test/alias_test.rb +55 -0
- data/test/argument_inspector_test.rb +40 -0
- data/test/command_test.rb +22 -0
- data/test/commands_test.rb +53 -0
- data/test/comment_inspector_test.rb +126 -0
- data/test/console_runner_test.rb +58 -0
- data/test/deps.rip +4 -0
- data/test/file_library_test.rb +41 -0
- data/test/gem_library_test.rb +40 -0
- data/test/libraries_test.rb +55 -0
- data/test/loader_test.rb +38 -0
- data/test/module_library_test.rb +30 -0
- data/test/more_manager_test.rb +29 -0
- data/test/more_method_inspector_test.rb +42 -0
- data/test/more_scientist_test.rb +10 -0
- data/test/namespacer_test.rb +61 -0
- data/test/pipes_test.rb +65 -0
- data/test/repo_index_test.rb +123 -0
- data/test/repo_test.rb +23 -0
- data/test/runner_options_test.rb +29 -0
- data/test/save_test.rb +86 -0
- data/test/science_test.rb +58 -0
- data/test/scientist_test.rb +195 -0
- data/test/test_helper.rb +165 -0
- data/test/web_test.rb +22 -0
- metadata +169 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'bacon'
|
2
|
+
require 'bacon/bits'
|
3
|
+
require 'mocha'
|
4
|
+
require 'mocha-on-bacon'
|
5
|
+
require 'boson'
|
6
|
+
require 'fileutils'
|
7
|
+
Object.send :remove_const, :OptionParser
|
8
|
+
Boson.constants.each {|e| Object.const_set(e, Boson.const_get(e)) unless Object.const_defined?(e) }
|
9
|
+
ENV['BOSONRC'] = File.dirname(__FILE__) + '/.bosonrc'
|
10
|
+
ENV['BOSON_HOME'] = File.dirname(__FILE__)
|
11
|
+
|
12
|
+
# make local so it doesn't pick up my real boson dir
|
13
|
+
Boson.repo.dir = File.dirname(__FILE__)
|
14
|
+
Boson.instance_variable_set "@repos", [Boson.repo]
|
15
|
+
|
16
|
+
module TestHelpers
|
17
|
+
def assert_error(error, message=nil)
|
18
|
+
yield
|
19
|
+
rescue error=>e
|
20
|
+
e.class.should == error
|
21
|
+
e.message.should =~ Regexp.new(message) if message
|
22
|
+
else
|
23
|
+
nil.should == error
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset
|
27
|
+
reset_main_object
|
28
|
+
reset_boson
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_constant(name, mod=Object)
|
32
|
+
mod.send(:remove_const, name) if mod.const_defined?(name, false)
|
33
|
+
end
|
34
|
+
|
35
|
+
def reset_main_object
|
36
|
+
Boson.send :remove_const, "Universe"
|
37
|
+
eval "module ::Boson::Universe; end"
|
38
|
+
remove_constant "Blah", Boson::Commands
|
39
|
+
Boson.main_object = Object.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def reset_boson
|
43
|
+
reset_libraries
|
44
|
+
Boson.instance_eval("@commands = nil")
|
45
|
+
end
|
46
|
+
|
47
|
+
def reset_libraries
|
48
|
+
Boson.instance_eval("@libraries = nil")
|
49
|
+
end
|
50
|
+
|
51
|
+
def command_exists?(name, bool=true)
|
52
|
+
(!!Command.find(name)).should == bool
|
53
|
+
end
|
54
|
+
|
55
|
+
def library_loaded?(name, bool=true)
|
56
|
+
Manager.loaded?(name).should == bool
|
57
|
+
end
|
58
|
+
|
59
|
+
def library(name)
|
60
|
+
Boson.library(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def library_has_module(lib, lib_module)
|
64
|
+
Manager.loaded?(lib).should == true
|
65
|
+
test_lib = library(lib)
|
66
|
+
(test_lib.module.is_a?(Module) && (test_lib.module.to_s == lib_module)).should == true
|
67
|
+
end
|
68
|
+
|
69
|
+
def library_has_command(lib, command, bool=true)
|
70
|
+
(lib = library(lib)) && lib.commands.include?(command).should == bool
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_runner(*methods, &block)
|
74
|
+
options = methods[-1].is_a?(Hash) ? methods.pop : {}
|
75
|
+
library = options[:library] || :Blarg
|
76
|
+
remove_constant library
|
77
|
+
|
78
|
+
Object.const_set(library, Class.new(Boson::Runner)).tap do |klass|
|
79
|
+
if block
|
80
|
+
klass.module_eval(&block)
|
81
|
+
else
|
82
|
+
methods.each do |meth|
|
83
|
+
klass.send(:define_method, meth) { }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def capture_stdout(&block)
|
90
|
+
original_stdout = $stdout
|
91
|
+
$stdout = fake = StringIO.new
|
92
|
+
begin
|
93
|
+
yield
|
94
|
+
ensure
|
95
|
+
$stdout = original_stdout
|
96
|
+
end
|
97
|
+
fake.string
|
98
|
+
end
|
99
|
+
|
100
|
+
def with_config(options)
|
101
|
+
old_config = Boson.config
|
102
|
+
Boson.config = Boson.config.merge(options)
|
103
|
+
yield
|
104
|
+
Boson.config = old_config
|
105
|
+
end
|
106
|
+
|
107
|
+
def capture_stderr(&block)
|
108
|
+
original_stderr = $stderr
|
109
|
+
$stderr = fake = StringIO.new
|
110
|
+
begin
|
111
|
+
yield
|
112
|
+
ensure
|
113
|
+
$stderr = original_stderr
|
114
|
+
end
|
115
|
+
fake.string
|
116
|
+
end
|
117
|
+
|
118
|
+
def create_library(libraries, attributes={})
|
119
|
+
libraries = [libraries] unless libraries.is_a?(Array)
|
120
|
+
libraries.map {|e|
|
121
|
+
lib = Library.new({:name=>e}.update(attributes))
|
122
|
+
Manager.add_library(lib); lib
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
def manager_load(lib, options={})
|
127
|
+
@stderr = capture_stderr { Manager.load(lib, options) }
|
128
|
+
end
|
129
|
+
|
130
|
+
attr_reader :stderr
|
131
|
+
|
132
|
+
if ENV['RSPEC']
|
133
|
+
def should_not_raise(&block)
|
134
|
+
block.should_not raise_error
|
135
|
+
end
|
136
|
+
else
|
137
|
+
# Since rspec doesn't allow should != or should.not
|
138
|
+
Object.send(:define_method, :should_not) {|*args, &block|
|
139
|
+
should.not(*args, &block)
|
140
|
+
}
|
141
|
+
def should_not_raise(&block)
|
142
|
+
should.not.raise &block
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
if ENV['RSPEC']
|
148
|
+
module RspecBits
|
149
|
+
def before_all(&block)
|
150
|
+
before(:all, &block)
|
151
|
+
end
|
152
|
+
|
153
|
+
def after_all(&block)
|
154
|
+
after(:all, &block)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
RSpec.configure {|c|
|
159
|
+
c.mock_with :mocha
|
160
|
+
c.extend RspecBits
|
161
|
+
c.include TestHelpers
|
162
|
+
}
|
163
|
+
else
|
164
|
+
Bacon::Context.send :include, TestHelpers
|
165
|
+
end
|
data/test/web_test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
describe "WebCore" do
|
4
|
+
it "#get with no options" do
|
5
|
+
request = mock { expects(:request).with({}) }
|
6
|
+
Commands::WebCore::Get.expects(:new).with('blah.com').returns(request)
|
7
|
+
Commands::WebCore.get 'blah.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "#post with no options" do
|
11
|
+
Net::HTTP.expects(:post_form).with(anything, {}).returns(nil)
|
12
|
+
Commands::WebCore.post 'blah.com'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "#build_url with string params" do
|
16
|
+
Commands::WebCore.build_url('ababd.com', :q=>'search').should == 'ababd.com?q=search'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#build_url with array params" do
|
20
|
+
Commands::WebCore.build_url('ababd.com', :q=>%w{multi word search}).should == 'ababd.com?q=multi+word+search'
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boson-more
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gabriel Horner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: boson
|
16
|
+
requirement: &70309802568200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70309802568200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mocha
|
27
|
+
requirement: &70309802567760 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70309802567760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bacon
|
38
|
+
requirement: &70309802567100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.1.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70309802567100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha-on-bacon
|
49
|
+
requirement: &70309802566580 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70309802566580
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bacon-bits
|
60
|
+
requirement: &70309802566060 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70309802566060
|
69
|
+
description: A collection of boson plugins that can be mixed and matched
|
70
|
+
email: gabriel.horner@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files:
|
74
|
+
- README.md
|
75
|
+
- LICENSE.txt
|
76
|
+
files:
|
77
|
+
- lib/boson/alias.rb
|
78
|
+
- lib/boson/argument_inspector.rb
|
79
|
+
- lib/boson/commands/core.rb
|
80
|
+
- lib/boson/commands/view_core.rb
|
81
|
+
- lib/boson/commands/web_core.rb
|
82
|
+
- lib/boson/comment_inspector.rb
|
83
|
+
- lib/boson/console.rb
|
84
|
+
- lib/boson/console_runner.rb
|
85
|
+
- lib/boson/index.rb
|
86
|
+
- lib/boson/libraries/file_library.rb
|
87
|
+
- lib/boson/libraries/gem_library.rb
|
88
|
+
- lib/boson/libraries/local_file_library.rb
|
89
|
+
- lib/boson/libraries/module_library.rb
|
90
|
+
- lib/boson/libraries/require_library.rb
|
91
|
+
- lib/boson/libraries.rb
|
92
|
+
- lib/boson/more/version.rb
|
93
|
+
- lib/boson/more.rb
|
94
|
+
- lib/boson/more_commands.rb
|
95
|
+
- lib/boson/more_inspector.rb
|
96
|
+
- lib/boson/more_manager.rb
|
97
|
+
- lib/boson/more_method_inspector.rb
|
98
|
+
- lib/boson/more_option_parser.rb
|
99
|
+
- lib/boson/more_scientist.rb
|
100
|
+
- lib/boson/more_util.rb
|
101
|
+
- lib/boson/namespace.rb
|
102
|
+
- lib/boson/namespacer.rb
|
103
|
+
- lib/boson/pipe.rb
|
104
|
+
- lib/boson/pipe_runner.rb
|
105
|
+
- lib/boson/pipes.rb
|
106
|
+
- lib/boson/repo.rb
|
107
|
+
- lib/boson/repo_index.rb
|
108
|
+
- lib/boson/runner_options.rb
|
109
|
+
- lib/boson/save.rb
|
110
|
+
- lib/boson/science.rb
|
111
|
+
- lib/boson/view.rb
|
112
|
+
- lib/boson/viewable.rb
|
113
|
+
- test/alias_test.rb
|
114
|
+
- test/argument_inspector_test.rb
|
115
|
+
- test/command_test.rb
|
116
|
+
- test/commands_test.rb
|
117
|
+
- test/comment_inspector_test.rb
|
118
|
+
- test/console_runner_test.rb
|
119
|
+
- test/file_library_test.rb
|
120
|
+
- test/gem_library_test.rb
|
121
|
+
- test/libraries_test.rb
|
122
|
+
- test/loader_test.rb
|
123
|
+
- test/module_library_test.rb
|
124
|
+
- test/more_manager_test.rb
|
125
|
+
- test/more_method_inspector_test.rb
|
126
|
+
- test/more_scientist_test.rb
|
127
|
+
- test/namespacer_test.rb
|
128
|
+
- test/pipes_test.rb
|
129
|
+
- test/repo_index_test.rb
|
130
|
+
- test/repo_test.rb
|
131
|
+
- test/runner_options_test.rb
|
132
|
+
- test/save_test.rb
|
133
|
+
- test/science_test.rb
|
134
|
+
- test/scientist_test.rb
|
135
|
+
- test/test_helper.rb
|
136
|
+
- test/web_test.rb
|
137
|
+
- LICENSE.txt
|
138
|
+
- deps.rip
|
139
|
+
- test/deps.rip
|
140
|
+
- Rakefile
|
141
|
+
- .gemspec
|
142
|
+
- README.md
|
143
|
+
homepage: http://github.com/cldwalker/boson-more
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ! '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 1.3.6
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.8.15
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: boson2 plugins
|
168
|
+
test_files: []
|
169
|
+
has_rdoc:
|