loops 2.0.5 → 2.0.6
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/lib/loops/cli/options.rb +8 -2
- data/lib/loops/version.rb +1 -1
- data/spec/loops/cli_spec.rb +20 -10
- data/spec/rails/config/init.rb +1 -0
- metadata +8 -6
data/lib/loops/cli/options.rb
CHANGED
@@ -82,7 +82,7 @@ module Loops
|
|
82
82
|
end
|
83
83
|
|
84
84
|
opt.on('-Rlibrary', '--require=library', 'require the library before executing the script') do |library|
|
85
|
-
require library
|
85
|
+
options[:require] << library
|
86
86
|
end
|
87
87
|
|
88
88
|
opt.on_tail("-h", '--help', 'Show this message') do
|
@@ -108,7 +108,8 @@ module Loops
|
|
108
108
|
:framework => 'rails',
|
109
109
|
:loops_root => 'app/loops',
|
110
110
|
:pid_file => nil,
|
111
|
-
:root => nil
|
111
|
+
:root => nil,
|
112
|
+
:require => [],
|
112
113
|
}
|
113
114
|
|
114
115
|
begin
|
@@ -209,6 +210,11 @@ module Loops
|
|
209
210
|
#
|
210
211
|
def bootstrap!
|
211
212
|
loops_env = ENV['LOOPS_ENV'] = options[:environment] if options[:environment]
|
213
|
+
|
214
|
+
options[:require].each do |library|
|
215
|
+
require library
|
216
|
+
end
|
217
|
+
|
212
218
|
case options[:framework]
|
213
219
|
when 'rails'
|
214
220
|
ENV['RAILS_ENV'] = loops_env
|
data/lib/loops/version.rb
CHANGED
data/spec/loops/cli_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec/spec_helper'
|
2
2
|
|
3
3
|
describe Loops::CLI do
|
4
|
+
before :each do
|
5
|
+
ENV['LOOPS_ENV'] = nil
|
6
|
+
end
|
7
|
+
|
4
8
|
it 'should include Loops::CLI::Options' do
|
5
9
|
Loops::CLI.included_modules.should include(Loops::CLI::Options)
|
6
10
|
end
|
@@ -71,13 +75,13 @@ describe Loops::CLI do
|
|
71
75
|
|
72
76
|
it 'should extract command arguments when passed' do
|
73
77
|
cli = Loops::CLI.parse(@args << 'arg1' << 'arg2')
|
74
|
-
cli.options[:command].should
|
75
|
-
cli.options[:args].should
|
78
|
+
cli.options[:command].should eq('list')
|
79
|
+
cli.options[:args].should eq(%w[arg1 arg2])
|
76
80
|
end
|
77
81
|
|
78
82
|
it 'should remove all unnecessary options' do
|
79
83
|
cli = Loops::CLI.parse(@args << '-r' << RAILS_ROOT << '-p' << 'loop.pid' << '-c' << 'config.yml' << '-l' << '.' << '-d')
|
80
|
-
cli.options.keys.map(&:to_s).sort.should == %w(command args daemonize).sort
|
84
|
+
cli.options.keys.map(&:to_s).sort.should == %w(command args daemonize require).sort
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
@@ -135,8 +139,14 @@ describe Loops::CLI do
|
|
135
139
|
it 'should set RAILS_ENV environment variable for Rails framework' do
|
136
140
|
@args = [ 'start', 'test', '-r', File.dirname(__FILE__) + '/../rails', '-e', 'production' ]
|
137
141
|
Loops::CLI.parse(@args)
|
138
|
-
ENV['LOOPS_ENV'].should
|
139
|
-
ENV['RAILS_ENV'].should
|
142
|
+
ENV['LOOPS_ENV'].should eq('production')
|
143
|
+
ENV['RAILS_ENV'].should eq('production')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should set LOOPS_ENV before require files throut -R' do
|
147
|
+
@args << '-R' << File.dirname(__FILE__) + '/../rails/config/init'
|
148
|
+
Loops::CLI.parse(@args)
|
149
|
+
::CURRENT_LOOPS_ENV.should == 'production'
|
140
150
|
end
|
141
151
|
end
|
142
152
|
end
|
@@ -149,11 +159,11 @@ describe Loops::CLI do
|
|
149
159
|
|
150
160
|
describe 'in #find_command_possibilities' do
|
151
161
|
it 'should return a list of possible commands' do
|
152
|
-
@cli.find_command_possibilities('s').sort.should
|
153
|
-
@cli.find_command_possibilities('sta').sort.should
|
154
|
-
@cli.find_command_possibilities('star').should
|
155
|
-
@cli.find_command_possibilities('l').should
|
156
|
-
@cli.find_command_possibilities('o').should
|
162
|
+
@cli.find_command_possibilities('s').sort.should eq(%w(start stats stop))
|
163
|
+
@cli.find_command_possibilities('sta').sort.should eq(%w(start stats))
|
164
|
+
@cli.find_command_possibilities('star').should eq(%w(start))
|
165
|
+
@cli.find_command_possibilities('l').should eq(%w(list))
|
166
|
+
@cli.find_command_possibilities('o').should eq([])
|
157
167
|
end
|
158
168
|
end
|
159
169
|
|
@@ -0,0 +1 @@
|
|
1
|
+
CURRENT_LOOPS_ENV = ENV['LOOPS_ENV']
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 6
|
10
|
+
version: 2.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Kovyrin
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-22 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- spec/rails/config.yml
|
106
106
|
- spec/rails/config/boot.rb
|
107
107
|
- spec/rails/config/environment.rb
|
108
|
+
- spec/rails/config/init.rb
|
108
109
|
- spec/rails/config/loops.yml
|
109
110
|
- spec/spec_helper.rb
|
110
111
|
has_rdoc: true
|
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
138
|
requirements: []
|
138
139
|
|
139
140
|
rubyforge_project:
|
140
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.3.7
|
141
142
|
signing_key:
|
142
143
|
specification_version: 3
|
143
144
|
summary: Simple background loops framework for ruby
|
@@ -152,5 +153,6 @@ test_files:
|
|
152
153
|
- spec/rails/config.yml
|
153
154
|
- spec/rails/config/boot.rb
|
154
155
|
- spec/rails/config/environment.rb
|
156
|
+
- spec/rails/config/init.rb
|
155
157
|
- spec/rails/config/loops.yml
|
156
158
|
- spec/spec_helper.rb
|