resque-reports 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTQ0NGJiYjk0OGMyYWVhYmU4OGVmNzhiNWNhZmI0ZWFlYzI4OTMyOQ==
5
+ data.tar.gz: !binary |-
6
+ MTJmMDEzZmQ0OGIxZTdkMmE4NjdlYmI0ZDIwNzc1YjNhOWNiYWZmOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTk3NWJhMzcyZjBjNTA4MDE3OWQ5NzkzZGVjZTRmYTY2MjdjM2Q1OTE2MTBm
10
+ NGZiMTRkOGQ2OWE2NTY0YTk0ZDVjY2UwNzMxZDk3ODVjNTQ3NzA1NzgxNTgw
11
+ ZTBlMjRkYWIwYTQ4ODBmNmQ0OWFiZDI3ZTJmODc0ZTIxODVjNzM=
12
+ data.tar.gz: !binary |-
13
+ ZmJkYTIzYjZiYjZiYTgwYThhODMzZTc1NmRkMTYxYWRkMzU1ZWY2NjU5OWUx
14
+ MTJkYTI3NWQ1NjRjODBiODdiYTVlN2VjZjA5MDU0OGUzODU1YzE5NWZhMWYy
15
+ YzE2YTNlMTk3MTcwMjNkZDAxMDMxOWZjYzg4ZWJiNzI2MTViM2Y=
@@ -9,9 +9,11 @@ module Resque
9
9
  # @example:
10
10
  #
11
11
  # ReportJob.enqueue('Resque::Reports::MyReport', [1, 2].to_json)
12
+ # ReportJob.enqueue_to(:my_queue, 'Resque::Reports::MyReport', [1, 2].to_json)
12
13
  #
13
14
  class ReportJob
14
15
  include Resque::Integration
16
+ extend Extensions::EnqueueToFix
15
17
 
16
18
  unique
17
19
 
@@ -26,9 +28,6 @@ module Resque
26
28
  fail "Supports only successors of BaseReport, but got #{report_class}"
27
29
  end
28
30
 
29
- fail 'Report queue is not specified' unless report_class.job_queue
30
- queue report_class.job_queue
31
-
32
31
  args = JSON.parse(args_json)
33
32
  force = args.pop
34
33
 
@@ -62,15 +62,13 @@ module Resque
62
62
 
63
63
  class << self
64
64
 
65
- attr_reader :job_queue
66
-
67
65
  protected
68
66
 
69
67
  attr_reader :create_block
70
- attr_writer :job_queue
71
68
  attr_accessor :file_extension,
72
69
  :file_encoding,
73
- :file_directory
70
+ :file_directory,
71
+ :job_queue
74
72
 
75
73
  alias_method :super_extension, :file_extension
76
74
  alias_method :extension, :file_extension=
@@ -116,6 +114,7 @@ module Resque
116
114
  #++
117
115
 
118
116
  DEFAULT_EXTENSION = 'txt'
117
+ DEFAULT_QUEUE = :base
119
118
 
120
119
  #--
121
120
  # Delegators
@@ -127,7 +126,8 @@ module Resque
127
126
  :file_encoding,
128
127
  :create_block,
129
128
  :set_instance,
130
- :set_extension
129
+ :set_extension,
130
+ :job_queue
131
131
 
132
132
  def_delegators :@cache_file, :filename, :exists?, :ready?
133
133
  def_delegator Const::TO_SUPER, :super_extension
@@ -166,8 +166,9 @@ module Resque
166
166
 
167
167
  # Check report if it already in progress and tring return its job_id...
168
168
  job_id = ReportJob.enqueued?(report_class, args_json).try(:meta_id)
169
+
169
170
  # ...and start new job otherwise
170
- job_id || ReportJob.enqueue(report_class, args_json).try(:meta_id)
171
+ job_id || ReportJob.enqueue_to(job_queue || DEFAULT_QUEUE, report_class, args_json).try(:meta_id)
171
172
  end
172
173
 
173
174
  protected
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require 'resque/plugins/progress'
3
+
4
+ module Resque
5
+ module Reports
6
+ module Extensions
7
+ module EnqueueToFix
8
+ def self.extended(base)
9
+ base.extend(Resque::Plugins::Progress)
10
+ base.extend(ClassMethods)
11
+ end
12
+
13
+ module ClassMethods
14
+ def enqueue_to(*args) #:nodoc:
15
+ queue = args.shift
16
+ meta = enqueued?(*args) and return meta
17
+
18
+ meta = Resque::Plugins::Meta::Metadata.new({'meta_id' => meta_id(args), 'job_class' => self.to_s})
19
+ meta.save
20
+
21
+ Resque.enqueue_to(queue, self, meta.meta_id, *args)
22
+ meta
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
  require 'resque/reports/extensions/const'
3
+ require 'resque/reports/extensions/enqueue_to_fix'
3
4
  require 'resque/reports/extensions/event_callbacks'
4
5
  require 'resque/reports/extensions/event_templates'
5
6
  require 'resque/reports/extensions/filename_gen'
@@ -31,6 +32,7 @@ module Resque
31
32
  base.send :include, EventCallbacks # event callbacks and handlers
32
33
  base.send :include, EventTemplates # template events handling methods
33
34
  base.send :include, Encodings # encoding constants
35
+ base.send :include, EnqueueToFix # encoding constants
34
36
  end
35
37
  end
36
38
  end
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
  module Resque
3
3
  module Reports
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.2'
5
5
  end
6
6
  end
7
+
@@ -10,6 +10,7 @@ require 'resque/reports/csv_report'
10
10
 
11
11
  require 'resque/reports/version'
12
12
 
13
+
13
14
  # Resque namespace
14
15
  module Resque
15
16
  # Resque::Reports namespace
@@ -106,13 +106,13 @@ describe 'Resque::Reports::BaseReport successor' do
106
106
  context 'when report is building twice' do
107
107
  subject { MyReport.new('#bg_build test') }
108
108
 
109
- before { job_class.stub(enqueue: 'job_id') }
109
+ before { job_class.stub(enqueue_to: 'job_id') }
110
110
 
111
111
  it do
112
112
  job_class
113
- .should_receive(:enqueue)
114
- .with('MyReport', '["#bg_build test",true]')
115
- .twice
113
+ .should_receive(:enqueue_to).twice
114
+ #.with(:my_type_reports, 'MyReport', '["#bg_build test",true]')
115
+
116
116
  end
117
117
 
118
118
  after do
@@ -123,12 +123,12 @@ describe 'Resque::Reports::BaseReport successor' do
123
123
  context 'when report is building' do
124
124
  subject { MyReport.new('#bg_build test') }
125
125
 
126
- before { job_class.stub(enqueue: 'job_id') }
126
+ before { job_class.stub(enqueue_to: 'job_id') }
127
127
 
128
128
  it do
129
129
  job_class
130
- .should_receive(:enqueue)
131
- .with('MyReport', '["#bg_build test",true]')
130
+ .should_receive(:enqueue_to)
131
+ #.with(:my_type_reports, 'MyReport', '["#bg_build test",true]')
132
132
  end
133
133
 
134
134
  after { subject.bg_build true }
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sergey D.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: resque-integration
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec-given
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: simplecov
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -147,6 +132,7 @@ files:
147
132
  - lib/resque/reports/extensions.rb
148
133
  - lib/resque/reports/extensions/const.rb
149
134
  - lib/resque/reports/extensions/encodings.rb
135
+ - lib/resque/reports/extensions/enqueue_to_fix.rb
150
136
  - lib/resque/reports/extensions/event_callbacks.rb
151
137
  - lib/resque/reports/extensions/event_templates.rb
152
138
  - lib/resque/reports/extensions/filename_gen.rb
@@ -160,33 +146,26 @@ files:
160
146
  homepage: https://github.com/sclinede/resque-reports
161
147
  licenses:
162
148
  - MIT
149
+ metadata: {}
163
150
  post_install_message:
164
151
  rdoc_options: []
165
152
  require_paths:
166
153
  - lib
167
154
  required_ruby_version: !ruby/object:Gem::Requirement
168
- none: false
169
155
  requirements:
170
156
  - - ! '>='
171
157
  - !ruby/object:Gem::Version
172
158
  version: '0'
173
- segments:
174
- - 0
175
- hash: 375761733447731005
176
159
  required_rubygems_version: !ruby/object:Gem::Requirement
177
- none: false
178
160
  requirements:
179
161
  - - ! '>='
180
162
  - !ruby/object:Gem::Version
181
163
  version: '0'
182
- segments:
183
- - 0
184
- hash: 375761733447731005
185
164
  requirements: []
186
165
  rubyforge_project:
187
- rubygems_version: 1.8.24
166
+ rubygems_version: 2.2.2
188
167
  signing_key:
189
- specification_version: 3
168
+ specification_version: 4
190
169
  summary: resque-reports
191
170
  test_files:
192
171
  - spec/resque/reports/base_report_spec.rb