loops 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Rakefile +14 -41
- data/lib/loops/autoload.rb +0 -1
- data/lib/loops/cli/options.rb +3 -2
- data/lib/loops/engine.rb +5 -1
- data/lib/loops/version.rb +3 -26
- data/loops.gemspec +18 -92
- data/spec/loops/cli_spec.rb +28 -4
- metadata +39 -9
- data/VERSION.yml +0 -5
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,48 +1,21 @@
|
|
1
1
|
require 'rake'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
2
4
|
|
3
|
-
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gemspec|
|
6
|
-
gemspec.name = 'loops'
|
7
|
-
gemspec.summary = 'Simple background loops framework for ruby'
|
8
|
-
gemspec.description = 'Loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby frameworks created to support simple background loops in your application which are usually used to do some background data processing on your servers (queue workers, batch tasks processors, etc).'
|
9
|
-
gemspec.email = 'alexey@kovyrin.net'
|
10
|
-
gemspec.homepage = 'http://github.com/kovyrin/loops'
|
11
|
-
gemspec.authors = ['Alexey Kovyrin', 'Dmytro Shteflyuk']
|
12
|
-
gemspec.files.include ['lib/**/*']
|
13
|
-
end
|
14
|
-
Jeweler::GemcutterTasks.new
|
15
|
-
rescue LoadError
|
16
|
-
puts 'Jeweler not available. Install it with: sudo gem install jeweler'
|
17
|
-
end
|
18
|
-
|
19
|
-
begin
|
20
|
-
require 'spec/rake/spectask'
|
5
|
+
require 'rspec/core/rake_task'
|
21
6
|
|
22
|
-
|
23
|
-
|
7
|
+
desc 'Default: run specs.'
|
8
|
+
task :default => :spec
|
24
9
|
|
25
|
-
|
26
|
-
|
27
|
-
t.libs << 'lib'
|
28
|
-
t.pattern = 'spec/**/*_spec.rb'
|
29
|
-
t.verbose = true
|
30
|
-
t.spec_opts = ['-cfs']
|
31
|
-
end
|
32
|
-
rescue LoadError
|
33
|
-
puts 'RSpec not available. Install it with: sudo gem install rspec'
|
34
|
-
end
|
10
|
+
desc 'Test the loops plugin.'
|
11
|
+
RSpec::Core::RakeTask.new
|
35
12
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
t.options.concat ['--protected', '--no-private']
|
44
|
-
end
|
13
|
+
require 'yard'
|
14
|
+
YARD::Rake::YardocTask.new(:yard) do |t|
|
15
|
+
t.options = ['--title', 'Loops Documentation']
|
16
|
+
if ENV['PRIVATE']
|
17
|
+
t.options.concat ['--protected', '--private']
|
18
|
+
else
|
19
|
+
t.options.concat ['--protected', '--no-private']
|
45
20
|
end
|
46
|
-
rescue LoadError
|
47
|
-
puts 'Yard not available. Install it with: sudo gem install yard'
|
48
21
|
end
|
data/lib/loops/autoload.rb
CHANGED
data/lib/loops/cli/options.rb
CHANGED
@@ -208,9 +208,10 @@ module Loops
|
|
208
208
|
# occurred when unknown framework option value passed.
|
209
209
|
#
|
210
210
|
def bootstrap!
|
211
|
+
loops_env = ENV['LOOPS_ENV'] = options[:environment] if options[:environment]
|
211
212
|
case options[:framework]
|
212
213
|
when 'rails'
|
213
|
-
ENV['RAILS_ENV'] =
|
214
|
+
ENV['RAILS_ENV'] = loops_env
|
214
215
|
|
215
216
|
# Bootstrap Rails
|
216
217
|
require Loops.root + 'config/boot'
|
@@ -221,7 +222,7 @@ module Loops
|
|
221
222
|
when 'merb'
|
222
223
|
require 'merb-core'
|
223
224
|
|
224
|
-
ENV['MERB_ENV'] =
|
225
|
+
ENV['MERB_ENV'] = loops_env
|
225
226
|
|
226
227
|
# Bootstrap Merb
|
227
228
|
Merb.start_environment(:adapter => 'runner', :environment => ENV['MERB_ENV'] || 'development')
|
data/lib/loops/engine.rb
CHANGED
@@ -205,7 +205,11 @@ class Loops::Engine
|
|
205
205
|
|
206
206
|
def fix_ar_after_fork
|
207
207
|
if Object.const_defined?('ActiveRecord')
|
208
|
-
|
208
|
+
if Rails::VERSION::MAJOR < 3
|
209
|
+
ActiveRecord::Base.allow_concurrency = true
|
210
|
+
else
|
211
|
+
Rails.application.config.allow_concurrency = true
|
212
|
+
end
|
209
213
|
ActiveRecord::Base.clear_active_connections!
|
210
214
|
ActiveRecord::Base.verify_active_connections!
|
211
215
|
end
|
data/lib/loops/version.rb
CHANGED
@@ -1,31 +1,8 @@
|
|
1
1
|
# Contains information about currently used Loops version.
|
2
2
|
#
|
3
3
|
# @example
|
4
|
-
# puts "Loops #{Loops::
|
4
|
+
# puts "Loops #{Loops::VERSION}"
|
5
5
|
#
|
6
|
-
|
7
|
-
|
8
|
-
# a +Hash+ containing major, minor, and patch version parts.
|
9
|
-
CURRENT = YAML.load_file(File.join(Loops::LIB_ROOT, '../VERSION.yml'))
|
10
|
-
|
11
|
-
# @return [Integer]
|
12
|
-
# a major part of the Loops version.
|
13
|
-
MAJOR = CURRENT[:major]
|
14
|
-
# @return [Integer]
|
15
|
-
# a minor part of the Loops version.
|
16
|
-
MINOR = CURRENT[:minor]
|
17
|
-
# @return [Integer]
|
18
|
-
# a patch part of the Loops version.
|
19
|
-
PATCH = CURRENT[:patch]
|
20
|
-
|
21
|
-
# @return [String]
|
22
|
-
# a string representation of the Loops version.
|
23
|
-
STRING = "%d.%d.%d" % [MAJOR, MINOR, PATCH]
|
24
|
-
|
25
|
-
# @return [String]
|
26
|
-
# a string representation of the Loops version.
|
27
|
-
#
|
28
|
-
def self.to_s
|
29
|
-
STRING
|
30
|
-
end
|
6
|
+
module Loops
|
7
|
+
VERSION = '2.0.5'
|
31
8
|
end
|
data/loops.gemspec
CHANGED
@@ -1,98 +1,24 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'loops/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = 'loops'
|
7
|
+
s.version = Loops::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Alexey Kovyrin', 'Dmytro Shteflyuk']
|
10
|
+
s.email = %q{alexey@kovyrin.net}
|
11
|
+
s.homepage = %q{http://github.com/kovyrin/loops}
|
12
|
+
s.summary = %q{Simple background loops framework for ruby}
|
13
|
+
s.description = %q{Loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby frameworks created to support simple background loops in your application which are usually used to do some background data processing on your servers (queue workers, batch tasks processors, etc).}
|
14
|
+
s.rdoc_options = ['--charset=UTF-8']
|
9
15
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = %q{2010-07-30}
|
13
|
-
s.description = %q{Loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby frameworks created to support simple background loops in your application which are usually used to do some background data processing on your servers (queue workers, batch tasks processors, etc).}
|
14
|
-
s.email = %q{alexey@kovyrin.net}
|
15
|
-
s.executables = ["loops", "loops-memory-stats"]
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"LICENSE",
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION.yml",
|
26
|
-
"bin/loops",
|
27
|
-
"bin/loops-memory-stats",
|
28
|
-
"generators/loops/loops_generator.rb",
|
29
|
-
"generators/loops/templates/app/loops/APP_README",
|
30
|
-
"generators/loops/templates/app/loops/queue_loop.rb",
|
31
|
-
"generators/loops/templates/app/loops/simple_loop.rb",
|
32
|
-
"generators/loops/templates/config/loops.yml",
|
33
|
-
"generators/loops/templates/script/loops",
|
34
|
-
"init.rb",
|
35
|
-
"lib/loops.rb",
|
36
|
-
"lib/loops/autoload.rb",
|
37
|
-
"lib/loops/base.rb",
|
38
|
-
"lib/loops/cli.rb",
|
39
|
-
"lib/loops/cli/commands.rb",
|
40
|
-
"lib/loops/cli/options.rb",
|
41
|
-
"lib/loops/command.rb",
|
42
|
-
"lib/loops/commands/debug_command.rb",
|
43
|
-
"lib/loops/commands/list_command.rb",
|
44
|
-
"lib/loops/commands/start_command.rb",
|
45
|
-
"lib/loops/commands/stats_command.rb",
|
46
|
-
"lib/loops/commands/stop_command.rb",
|
47
|
-
"lib/loops/daemonize.rb",
|
48
|
-
"lib/loops/engine.rb",
|
49
|
-
"lib/loops/errors.rb",
|
50
|
-
"lib/loops/logger.rb",
|
51
|
-
"lib/loops/process_manager.rb",
|
52
|
-
"lib/loops/queue.rb",
|
53
|
-
"lib/loops/version.rb",
|
54
|
-
"lib/loops/worker.rb",
|
55
|
-
"lib/loops/worker_pool.rb",
|
56
|
-
"loops.gemspec",
|
57
|
-
"spec/loop_lock_spec.rb",
|
58
|
-
"spec/loops/base_spec.rb",
|
59
|
-
"spec/loops/cli_spec.rb",
|
60
|
-
"spec/loops_spec.rb",
|
61
|
-
"spec/rails/another_loop.rb",
|
62
|
-
"spec/rails/app/loops/complex_loop.rb",
|
63
|
-
"spec/rails/app/loops/simple_loop.rb",
|
64
|
-
"spec/rails/config.yml",
|
65
|
-
"spec/rails/config/boot.rb",
|
66
|
-
"spec/rails/config/environment.rb",
|
67
|
-
"spec/rails/config/loops.yml",
|
68
|
-
"spec/spec_helper.rb"
|
69
|
-
]
|
70
|
-
s.homepage = %q{http://github.com/kovyrin/loops}
|
71
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
72
|
-
s.require_paths = ["lib"]
|
73
|
-
s.rubygems_version = %q{1.3.7}
|
74
|
-
s.summary = %q{Simple background loops framework for ruby}
|
75
|
-
s.test_files = [
|
76
|
-
"spec/loop_lock_spec.rb",
|
77
|
-
"spec/loops/base_spec.rb",
|
78
|
-
"spec/loops/cli_spec.rb",
|
79
|
-
"spec/loops_spec.rb",
|
80
|
-
"spec/rails/another_loop.rb",
|
81
|
-
"spec/rails/app/loops/complex_loop.rb",
|
82
|
-
"spec/rails/app/loops/simple_loop.rb",
|
83
|
-
"spec/rails/config/boot.rb",
|
84
|
-
"spec/rails/config/environment.rb",
|
85
|
-
"spec/spec_helper.rb"
|
86
|
-
]
|
16
|
+
s.add_development_dependency 'rspec'
|
17
|
+
s.add_development_dependency 'yard'
|
87
18
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
else
|
94
|
-
end
|
95
|
-
else
|
96
|
-
end
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ['lib']
|
23
|
+
s.extra_rdoc_files = ['LICENSE', 'README.rdoc']
|
97
24
|
end
|
98
|
-
|
data/spec/loops/cli_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe Loops::CLI do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should extract command when passed' do
|
68
|
-
cli = Loops::CLI.parse(@args
|
68
|
+
cli = Loops::CLI.parse(@args)
|
69
69
|
cli.options[:command].should == 'list'
|
70
70
|
end
|
71
71
|
|
@@ -99,7 +99,7 @@ describe Loops::CLI do
|
|
99
99
|
|
100
100
|
context 'with Rails framework' do
|
101
101
|
before :each do
|
102
|
-
@args = [ '
|
102
|
+
@args = [ 'start', 'test', '-r', File.dirname(__FILE__) + '/../rails' ]
|
103
103
|
Loops::CLI.parse(@args)
|
104
104
|
end
|
105
105
|
|
@@ -114,6 +114,30 @@ describe Loops::CLI do
|
|
114
114
|
it 'should inialize default logger' do
|
115
115
|
Loops.default_logger.should == 'rails default logger'
|
116
116
|
end
|
117
|
+
|
118
|
+
it 'should not have LOOPS_ENV envionment variable by default' do
|
119
|
+
Loops::CLI.parse(@args)
|
120
|
+
ENV['LOOPS_ENV'].should be_nil
|
121
|
+
ENV['RAILS_ENV'].should be_nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with environment passed in arguments' do
|
126
|
+
before :each do
|
127
|
+
@args << '-e' << 'production'
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should set LOOPS_ENV environment variable' do
|
131
|
+
Loops::CLI.parse(@args)
|
132
|
+
ENV['LOOPS_ENV'].should == 'production'
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should set RAILS_ENV environment variable for Rails framework' do
|
136
|
+
@args = [ 'start', 'test', '-r', File.dirname(__FILE__) + '/../rails', '-e', 'production' ]
|
137
|
+
Loops::CLI.parse(@args)
|
138
|
+
ENV['LOOPS_ENV'].should == 'production'
|
139
|
+
ENV['RAILS_ENV'].should == 'production'
|
140
|
+
end
|
117
141
|
end
|
118
142
|
end
|
119
143
|
|
@@ -125,8 +149,8 @@ describe Loops::CLI do
|
|
125
149
|
|
126
150
|
describe 'in #find_command_possibilities' do
|
127
151
|
it 'should return a list of possible commands' do
|
128
|
-
@cli.find_command_possibilities('s').should == %w(start stats stop)
|
129
|
-
@cli.find_command_possibilities('sta').should == %w(start stats)
|
152
|
+
@cli.find_command_possibilities('s').sort.should == %w(start stats stop)
|
153
|
+
@cli.find_command_possibilities('sta').sort.should == %w(start stats)
|
130
154
|
@cli.find_command_possibilities('star').should == %w(start)
|
131
155
|
@cli.find_command_possibilities('l').should == %w(list)
|
132
156
|
@cli.find_command_possibilities('o').should == []
|
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: 5
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 5
|
10
|
+
version: 2.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Kovyrin
|
@@ -16,10 +16,37 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-06-21 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: rspec
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
23
50
|
description: Loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby frameworks created to support simple background loops in your application which are usually used to do some background data processing on your servers (queue workers, batch tasks processors, etc).
|
24
51
|
email: alexey@kovyrin.net
|
25
52
|
executables:
|
@@ -32,10 +59,11 @@ extra_rdoc_files:
|
|
32
59
|
- README.rdoc
|
33
60
|
files:
|
34
61
|
- .gitignore
|
62
|
+
- .rspec
|
63
|
+
- Gemfile
|
35
64
|
- LICENSE
|
36
65
|
- README.rdoc
|
37
66
|
- Rakefile
|
38
|
-
- VERSION.yml
|
39
67
|
- bin/loops
|
40
68
|
- bin/loops-memory-stats
|
41
69
|
- generators/loops/loops_generator.rb
|
@@ -109,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
137
|
requirements: []
|
110
138
|
|
111
139
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.6.2
|
113
141
|
signing_key:
|
114
142
|
specification_version: 3
|
115
143
|
summary: Simple background loops framework for ruby
|
@@ -121,6 +149,8 @@ test_files:
|
|
121
149
|
- spec/rails/another_loop.rb
|
122
150
|
- spec/rails/app/loops/complex_loop.rb
|
123
151
|
- spec/rails/app/loops/simple_loop.rb
|
152
|
+
- spec/rails/config.yml
|
124
153
|
- spec/rails/config/boot.rb
|
125
154
|
- spec/rails/config/environment.rb
|
155
|
+
- spec/rails/config/loops.yml
|
126
156
|
- spec/spec_helper.rb
|