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 CHANGED
@@ -6,3 +6,5 @@ pkg
6
6
  spec/rails/logs
7
7
  spec/rails/tmp
8
8
  *.pid
9
+ Gemfile.lock
10
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/Rakefile CHANGED
@@ -1,48 +1,21 @@
1
1
  require 'rake'
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
2
4
 
3
- begin
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
- desc 'Default: run unit tests.'
23
- task :default => :spec
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
24
9
 
25
- desc 'Test the loops plugin.'
26
- Spec::Rake::SpecTask.new(:spec) do |t|
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
- begin
37
- require 'yard'
38
- YARD::Rake::YardocTask.new(:yard) do |t|
39
- t.options = ['--title', 'Loops Documentation']
40
- if ENV['PRIVATE']
41
- t.options.concat ['--protected', '--private']
42
- else
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
@@ -14,7 +14,6 @@ module Loops
14
14
  autoload :Queue, __p('queue')
15
15
  autoload :Worker, __p('worker')
16
16
  autoload :WorkerPool, __p('worker_pool')
17
- autoload :Version, __p('version')
18
17
 
19
18
  include Errors
20
19
  end
@@ -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'] = options[:environment] if options[:environment]
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'] = options[:environment] if options[:environment]
225
+ ENV['MERB_ENV'] = loops_env
225
226
 
226
227
  # Bootstrap Merb
227
228
  Merb.start_environment(:adapter => 'runner', :environment => ENV['MERB_ENV'] || 'development')
@@ -205,7 +205,11 @@ class Loops::Engine
205
205
 
206
206
  def fix_ar_after_fork
207
207
  if Object.const_defined?('ActiveRecord')
208
- ActiveRecord::Base.allow_concurrency = true
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
@@ -1,31 +1,8 @@
1
1
  # Contains information about currently used Loops version.
2
2
  #
3
3
  # @example
4
- # puts "Loops #{Loops::Version}"
4
+ # puts "Loops #{Loops::VERSION}"
5
5
  #
6
- class Loops::Version
7
- # @return [Hash<Symbol, Integer>]
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
@@ -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 = %q{loops}
8
- s.version = "2.0.4"
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.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Alexey Kovyrin", "Dmytro Shteflyuk"]
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
- if s.respond_to? :specification_version then
89
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
90
- s.specification_version = 3
91
-
92
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
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
-
@@ -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 << 'list')
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 = [ 'list', '-r', File.dirname(__FILE__) + '/../rails' ]
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: 7
5
- prerelease: false
4
+ hash: 5
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 4
10
- version: 2.0.4
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: 2010-07-30 00:00:00 -04:00
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.3.7
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
@@ -1,5 +0,0 @@
1
- ---
2
- :minor: 0
3
- :build:
4
- :patch: 4
5
- :major: 2