yaml_conditions 0.0.0.2 → 0.0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -2
- data/README.rdoc +10 -1
- data/Rakefile +1 -1
- data/TESTS.rdoc +1 -1
- data/lib/orms/active_record/version2/delayed_job.rb +5 -0
- data/lib/orms/active_record/version_2.rb +2 -2
- data/lib/yaml/conditions.rb +1 -1
- data/lib/yaml/query_builder.rb +4 -0
- data/spec/cases/orms/active_record/version_2_delayed_job_spec.rb +230 -107
- data/spec/cases/orms/active_record/version_2_spec.rb +1 -1
- data/spec/models/support_classes.rb +12 -0
- data/spec/spec_helper.rb +14 -3
- data/tasks/yaml_conditions.rake +1 -1
- data/yaml_conditions.gemspec +2 -2
- metadata +4 -5
- data/spec/models/delayed/job.rb +0 -6
- data/spec/models/delayed/performable_method.rb +0 -4
data/Manifest
CHANGED
@@ -21,11 +21,10 @@ spec/cases/orms/active_record/version_2_spec.rb
|
|
21
21
|
spec/connections/mysql/connection.rb
|
22
22
|
spec/connections/postgresql/connection.rb
|
23
23
|
spec/datamapper_spec_helper.rb
|
24
|
-
spec/models/delayed/job.rb
|
25
|
-
spec/models/delayed/performable_method.rb
|
26
24
|
spec/models/job.rb
|
27
25
|
spec/models/period.rb
|
28
26
|
spec/models/priority.rb
|
27
|
+
spec/models/support_classes.rb
|
29
28
|
spec/models/user.rb
|
30
29
|
spec/models/user_data.rb
|
31
30
|
spec/schema.rb
|
data/README.rdoc
CHANGED
@@ -39,12 +39,21 @@ Just to give you a little background, I build this gem/plugin just to filter my
|
|
39
39
|
|
40
40
|
So, I added some custom magic for filtering Delayed::Job objects, like this:
|
41
41
|
|
42
|
-
Delayed::Job.first(:yaml_conditions => { :
|
42
|
+
Delayed::Job.first(:yaml_conditions => { :handler => { :class => Delayed::PerformableMethod, :method => :new_registration, :args => [ User.find(1), '*', '*' ] } })
|
43
43
|
|
44
44
|
Delayed::Job.first(:yaml_conditions => { :handler => { :args => [ { :user => { :last_name => 'Marcelo', :address => { :city => 'Rio Negro' } } } ] } })
|
45
45
|
|
46
46
|
As you probably realize, '*' is interpreted as a wildcard.
|
47
47
|
|
48
|
+
If :handler is not provided as top level key of the hash, then the hash will be wrapped inside a handler key. For example, the following queries return the same results:
|
49
|
+
|
50
|
+
Delayed::Job.last(:yaml_conditions => { :handler => { :class => SimpleJob, :method => :new_registration }})
|
51
|
+
Delayed::Job.last(:yaml_conditions => { :class => SimpleJob, :method => :new_registration })
|
52
|
+
|
53
|
+
This wrapping magic it's only available for Delayed::Job for now.
|
54
|
+
|
55
|
+
BTW: You can check more details about the API by looking on the specs.
|
56
|
+
|
48
57
|
== Installation
|
49
58
|
|
50
59
|
$ ruby script/plugin install git://github.com/marklazz/yaml_conditions.git
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'echoe'
|
|
3
3
|
|
4
4
|
# PACKAGING ============================================================
|
5
5
|
|
6
|
-
Echoe.new('yaml_conditions', '0.0.0.
|
6
|
+
Echoe.new('yaml_conditions', '0.0.0.3') do |p|
|
7
7
|
p.description = ''
|
8
8
|
p.url = 'http://github.com/marklazz/yaml_conditions'
|
9
9
|
p.author = 'Marcelo Giorgi'
|
data/TESTS.rdoc
CHANGED
@@ -2,7 +2,7 @@ Before running the tests, you must create a user called yaml_conditions (with no
|
|
2
2
|
|
3
3
|
Then to run the suite you should be able to do:
|
4
4
|
|
5
|
-
rake
|
5
|
+
rake (which will run both suites for mysql and postgres)
|
6
6
|
|
7
7
|
Or run them individually:
|
8
8
|
|
@@ -16,6 +16,11 @@ module Orms
|
|
16
16
|
AR_STRING_FORMAT = /^AR\:([A-Z][\w\:]+)\:(\d+)$/
|
17
17
|
LOAD_AR_STRING_FORMAT = /^LOAD;([A-Z][\w\:]+);(\d+)$/
|
18
18
|
|
19
|
+
def __prepare_yaml_conditions__(yaml_conditions)
|
20
|
+
return yaml_conditions if yaml_conditions.has_key?(:handler) || yaml_conditions.has_key?('handler')
|
21
|
+
{ :handler => yaml_conditions }
|
22
|
+
end
|
23
|
+
|
19
24
|
def __delayed_job_ar_to_string_(obj)
|
20
25
|
Delayed::PerformableMethod.new(obj, :to_s, []).object
|
21
26
|
end
|
@@ -19,14 +19,14 @@ module Orms
|
|
19
19
|
adapted_args = args << refactor_options(options)
|
20
20
|
selector = adapted_args.shift
|
21
21
|
result = find_without_yaml_conditions(:all, *adapted_args).select do |o|
|
22
|
-
__check_yaml_nested_hierarchy__(o, yaml_conditions)
|
22
|
+
__check_yaml_nested_hierarchy__(o, __prepare_yaml_conditions__(yaml_conditions))
|
23
23
|
end
|
24
24
|
selector == :all ? result : result.send(selector.to_sym)
|
25
25
|
end
|
26
26
|
|
27
27
|
def refactor_options(options)
|
28
28
|
sql_conditions = sanitize_sql(options.delete(:conditions))
|
29
|
-
yaml_conditions = options.delete(:yaml_conditions)
|
29
|
+
yaml_conditions = __prepare_yaml_conditions__(options.delete(:yaml_conditions))
|
30
30
|
yaml_conditions.symbolize_keys! if yaml_conditions.is_a?(Hash)
|
31
31
|
options.merge!({ :conditions => __join_yaml_conditions__(sql_conditions, __build_yaml_conditions__(yaml_conditions)) })
|
32
32
|
end
|
data/lib/yaml/conditions.rb
CHANGED
data/lib/yaml/query_builder.rb
CHANGED
@@ -2,8 +2,14 @@ require File.join( File.dirname(__FILE__), '..', '..', '..', 'ar_spec_helper')
|
|
2
2
|
require File.join( File.dirname(__FILE__), '..', '..', '..', 'models', 'job')
|
3
3
|
require File.join( File.dirname(__FILE__), '..', '..', '..', 'models', 'user')
|
4
4
|
require File.join( File.dirname(__FILE__), '..', '..', '..', 'models', 'priority')
|
5
|
-
require File.join( File.dirname(__FILE__), '..', '..', '..', 'models', '
|
6
|
-
require
|
5
|
+
require File.join( File.dirname(__FILE__), '..', '..', '..', 'models', 'support_classes')
|
6
|
+
# require delayed_job if available
|
7
|
+
begin
|
8
|
+
require "delayed_job"
|
9
|
+
rescue LoadError
|
10
|
+
# not installed
|
11
|
+
end
|
12
|
+
|
7
13
|
|
8
14
|
describe ::Orms::ActiveRecordVersion2 do
|
9
15
|
|
@@ -13,165 +19,282 @@ describe ::Orms::ActiveRecordVersion2 do
|
|
13
19
|
end
|
14
20
|
|
15
21
|
describe 'Delayed::Job#find' do
|
22
|
+
context "Used with PerformableMethod's jobs" do
|
16
23
|
|
17
|
-
|
24
|
+
before do
|
25
|
+
user = User.create(:name => 'marcelo')
|
26
|
+
@job = Delayed::Job.enqueue Delayed::PerformableMethod.new(NotificationMailer, :deliver_admin_login, [ User.find_by_name('marcelo'), nil ] )
|
27
|
+
end
|
18
28
|
|
19
|
-
|
20
|
-
user = User.create(:name => 'marcelo')
|
21
|
-
@performable_method = Delayed::PerformableMethod.new(NotificationMailer, :deliver_admin_login, [ user, nil ])
|
22
|
-
@job = Delayed::Job.create(:handler => "--- !ruby/struct:Delayed::PerformableMethod \nobject: CLASS:NotificationMailer\nmethod: :deliver_admin_login\nargs: \n- AR:User:#{user.id}\n- \n")
|
23
|
-
end
|
29
|
+
subject { Delayed::Job.first(:yaml_conditions => @yaml_conditions) }
|
24
30
|
|
25
|
-
|
31
|
+
context 'test filter by args' do
|
26
32
|
|
27
|
-
|
33
|
+
before do
|
34
|
+
@yaml_conditions = { :handler => { :class => Delayed::PerformableMethod, :args => [ User.find_by_name('marcelo'), nil ] } }
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
37
|
+
it { should == @job }
|
38
|
+
end
|
32
39
|
|
33
|
-
|
34
|
-
|
40
|
+
context 'test filtering by object and args' do
|
41
|
+
before do
|
42
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :args => [ User.find_by_name('marcelo'), nil ] } }
|
43
|
+
end
|
35
44
|
|
36
|
-
|
37
|
-
|
38
|
-
@yaml_conditions = { :handler => { :object => NotificationMailer, :args => [ User.find_by_name('marcelo'), nil ] } }
|
39
|
-
end
|
45
|
+
it { should == @job }
|
46
|
+
end
|
40
47
|
|
41
|
-
|
42
|
-
|
48
|
+
context 'test filtering by object, method and args' do
|
49
|
+
before do
|
50
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login, :args => [ User.find_by_name('marcelo'), nil ] } }
|
51
|
+
end
|
43
52
|
|
44
|
-
|
45
|
-
|
46
|
-
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login, :args => [ User.find_by_name('marcelo'), nil ] } }
|
47
|
-
end
|
53
|
+
it { should == @job }
|
54
|
+
end
|
48
55
|
|
49
|
-
|
50
|
-
|
56
|
+
context 'test filtering by object, method and wrong args' do
|
57
|
+
before do
|
58
|
+
user2 = User.create(:name => 'andres')
|
59
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login, :args => [ User.find_by_name('andres'), nil ] } }
|
60
|
+
end
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
user2 = User.create(:name => 'andres')
|
55
|
-
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login, :args => [ User.find_by_name('andres'), nil ] } }
|
56
|
-
end
|
62
|
+
it { should be_nil }
|
63
|
+
end
|
57
64
|
|
58
|
-
|
59
|
-
|
65
|
+
context 'test filtering by object, args and wrong method' do
|
66
|
+
before do
|
67
|
+
user2 = User.create(:name => 'andres')
|
68
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login2, :args => [ User.find_by_name('andres'), nil ] } }
|
69
|
+
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
user2 = User.create(:name => 'andres')
|
64
|
-
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => :deliver_admin_login2, :args => [ User.find_by_name('andres'), nil ] } }
|
65
|
-
end
|
71
|
+
it { should be_nil }
|
72
|
+
end
|
66
73
|
|
67
|
-
|
68
|
-
|
74
|
+
context 'test filtering by method, args and wrong object' do
|
75
|
+
before do
|
76
|
+
user2 = User.create(:name => 'andres')
|
77
|
+
@yaml_conditions = { :handler => { :object => Object, :method => :deliver_admin_login2, :args => [ User.find_by_name('andres'), nil ] } }
|
78
|
+
end
|
69
79
|
|
70
|
-
|
71
|
-
|
72
|
-
user2 = User.create(:name => 'andres')
|
73
|
-
@yaml_conditions = { :handler => { :object => Object, :method => :deliver_admin_login2, :args => [ User.find_by_name('andres'), nil ] } }
|
74
|
-
end
|
80
|
+
it { should be_nil }
|
81
|
+
end
|
75
82
|
|
76
|
-
|
77
|
-
|
83
|
+
context 'test filtering by object and args' do
|
84
|
+
before do
|
85
|
+
user2 = User.create(:name => 'andres')
|
86
|
+
@job = Delayed::Job.create(:handler => "--- !ruby/struct:Delayed::PerformableMethod \nobject: CLASS:NotificationMailer\nmethod: :deliver_admin_login\nargs: \n- AR:User:#{user2.id}\n- Pablo\n")
|
87
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :args => [ User.find_by_name('andres'), 'Pablo' ] } }
|
88
|
+
end
|
78
89
|
|
79
|
-
|
80
|
-
|
81
|
-
user2 = User.create(:name => 'andres')
|
82
|
-
@job = Delayed::Job.create(:handler => "--- !ruby/struct:Delayed::PerformableMethod \nobject: CLASS:NotificationMailer\nmethod: :deliver_admin_login\nargs: \n- AR:User:#{user2.id}\n- Pablo\n")
|
83
|
-
@yaml_conditions = { :handler => { :object => NotificationMailer, :args => [ User.find_by_name('andres'), 'Pablo' ] } }
|
84
|
-
end
|
90
|
+
it { should == @job }
|
91
|
+
end
|
85
92
|
|
86
|
-
|
87
|
-
end
|
93
|
+
context 'test filter by args using wildcard' do
|
88
94
|
|
89
|
-
|
95
|
+
before do
|
96
|
+
@yaml_conditions = { :handler => { :args => [ User.find_by_name('marcelo'), '*' ] } }
|
97
|
+
end
|
90
98
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
99
|
+
it { should == @job }
|
100
|
+
end
|
94
101
|
|
95
|
-
|
96
|
-
end
|
102
|
+
context 'test filter by using wildcard on args and specifying object' do
|
97
103
|
|
98
|
-
|
104
|
+
before do
|
105
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :args => [ User.find_by_name('marcelo'), '*' ] } }
|
106
|
+
end
|
99
107
|
|
100
|
-
|
101
|
-
|
102
|
-
end
|
108
|
+
it { should == @job }
|
109
|
+
end
|
103
110
|
|
104
|
-
|
105
|
-
end
|
111
|
+
context 'test filter by using wildcard on args and method, also specifying object' do
|
106
112
|
|
107
|
-
|
113
|
+
before do
|
114
|
+
@yaml_conditions = { :handler => { :object => NotificationMailer, :method => '*', :args => [ User.find_by_name('marcelo'), '*' ] } }
|
115
|
+
end
|
108
116
|
|
109
|
-
|
110
|
-
|
111
|
-
end
|
117
|
+
it { should == @job }
|
118
|
+
end
|
112
119
|
|
113
|
-
|
114
|
-
end
|
120
|
+
context 'test filter by using wildcard on object, method and args also specified' do
|
115
121
|
|
116
|
-
|
122
|
+
before do
|
123
|
+
@yaml_conditions = { :handler => { :object => '*', :method => :deliver_admin_login, :args => [ User.find_by_name('marcelo'), nil ] } }
|
124
|
+
end
|
117
125
|
|
118
|
-
|
119
|
-
|
120
|
-
end
|
126
|
+
it { should == @job }
|
127
|
+
end
|
121
128
|
|
122
|
-
|
123
|
-
|
129
|
+
context 'test filter by using wildcard on object, method and args also specified (withuod handler wrapper)' do
|
130
|
+
|
131
|
+
before do
|
132
|
+
@yaml_conditions = { :object => '*', :method => :deliver_admin_login, :args => [ User.find_by_name('marcelo'), nil ] }
|
133
|
+
end
|
134
|
+
|
135
|
+
it { should == @job }
|
136
|
+
end
|
137
|
+
|
138
|
+
context "job with nested hash: { :user => { :first_name => 'Marcelo', :last_name => 'Giorgi', :address => { :city => 'Montevideo', :country => 'Uruguay' } }}" do
|
139
|
+
before do
|
140
|
+
@job_with_nested = Delayed::Job.create(:handler => "--- !ruby/struct:Delayed::PerformableMethod \nobject: CLASS:NotificationMailer\nmethod: :deliver_test_email\nargs: \n- :user: \n :first_name: Marcelo\n :last_name: Giorgi\n :address: \n :city: Montevideo\n :country: Uruguay\n")
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'query first_name hash value of the delayed::job argument' do
|
144
|
+
context 'with proper value' do
|
145
|
+
before do
|
146
|
+
@yaml_conditions = { :handler => { :args => [ { :user => { :first_name => 'Marcelo' }} ] } }
|
147
|
+
end
|
148
|
+
it { should == @job_with_nested }
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'with wrong value' do
|
152
|
+
before do
|
153
|
+
@yaml_conditions = { :handler => { :args => [ { :user => { :first_name => 'Pablo' }} ] } }
|
154
|
+
end
|
155
|
+
it { should be_nil }
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'with wrong hierarchy' do
|
159
|
+
before do
|
160
|
+
@yaml_conditions = { :handler => { :args => [ { :first_name => 'Marcelo' } ] } }
|
161
|
+
end
|
162
|
+
it { should be_nil }
|
163
|
+
end
|
164
|
+
end
|
124
165
|
|
125
|
-
|
126
|
-
|
127
|
-
|
166
|
+
context 'query last_name and city vlues of the delayed::job argument' do
|
167
|
+
context 'with proper values' do
|
168
|
+
before do
|
169
|
+
@yaml_conditions = { :handler => { :args => [ { :user => { :last_name => 'Giorgi', :address => { :city => 'Montevideo' } } } ] } }
|
170
|
+
end
|
171
|
+
it { should == @job_with_nested }
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'with wrong value' do
|
175
|
+
before do
|
176
|
+
@yaml_conditions = { :handler => { :args => [ { :user => { :last_name => 'Marcelo', :address => { :city => 'Rio Negro' } } } ] } }
|
177
|
+
end
|
178
|
+
it { should be_nil }
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'with wrong hierarchy' do
|
182
|
+
before do
|
183
|
+
@yaml_conditions = { :handler => { :args => [ { :city => 'Montevideo' } ] } }
|
184
|
+
end
|
185
|
+
it { should be_nil }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'query the same as before but wihtout handler key' do
|
190
|
+
context 'with proper values' do
|
191
|
+
before do
|
192
|
+
@yaml_conditions = { :args => [ { :user => { :last_name => 'Giorgi', :address => { :city => 'Montevideo' } } } ] }
|
193
|
+
end
|
194
|
+
it { should == @job_with_nested }
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'with wrong value' do
|
198
|
+
before do
|
199
|
+
@yaml_conditions = { :args => [ { :user => { :last_name => 'Marcelo', :address => { :city => 'Rio Negro' } } } ] }
|
200
|
+
end
|
201
|
+
it { should be_nil }
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'with wrong hierarchy' do
|
205
|
+
before do
|
206
|
+
@yaml_conditions = { :args => [ { :city => 'Montevideo' } ] }
|
207
|
+
end
|
208
|
+
it { should be_nil }
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
128
212
|
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'Used with a custom struct' do
|
216
|
+
|
217
|
+
before do
|
218
|
+
user = User.create(:name => 'marcelo')
|
219
|
+
simple_job = SimpleJob.new
|
220
|
+
simple_job.name = 'job_name'
|
221
|
+
simple_job.kind = 'my_kind'
|
222
|
+
@job = Delayed::Job.enqueue simple_job
|
223
|
+
end
|
224
|
+
|
225
|
+
subject { Delayed::Job.first(:yaml_conditions => @yaml_conditions) }
|
226
|
+
|
227
|
+
context 'filter by correct class' do
|
228
|
+
|
229
|
+
before do
|
230
|
+
@yaml_conditions = { :handler => { :class => SimpleJob } }
|
231
|
+
end
|
232
|
+
|
233
|
+
it { should == @job }
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'filter by correct class (Without handler wrapper)' do
|
129
237
|
|
130
|
-
context 'query first_name hash value of the delayed::job argument' do
|
131
|
-
context 'with proper value' do
|
132
238
|
before do
|
133
|
-
@yaml_conditions = { :
|
239
|
+
@yaml_conditions = { :class => SimpleJob }
|
134
240
|
end
|
135
|
-
|
241
|
+
|
242
|
+
it { should == @job }
|
136
243
|
end
|
137
244
|
|
138
|
-
context '
|
245
|
+
context 'filter by wrong class (Without handler wrapper)' do
|
246
|
+
|
139
247
|
before do
|
140
|
-
@yaml_conditions = { :
|
248
|
+
@yaml_conditions = { :class => NotificationMailer }
|
141
249
|
end
|
142
|
-
|
250
|
+
|
251
|
+
it { should be_nil }
|
143
252
|
end
|
144
253
|
|
145
|
-
context '
|
254
|
+
context 'filter by correct name' do
|
255
|
+
|
146
256
|
before do
|
147
|
-
@yaml_conditions = { :handler => { :
|
257
|
+
@yaml_conditions = { :handler => { :class => SimpleJob, :name => 'job_name' } }
|
148
258
|
end
|
149
|
-
|
259
|
+
|
260
|
+
it { should == @job }
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'filter by correct name and kind (without handler wrapper)' do
|
264
|
+
|
265
|
+
before do
|
266
|
+
@yaml_conditions = { :class => SimpleJob, :name => 'job_name', :kind => 'my_kind' }
|
267
|
+
end
|
268
|
+
|
269
|
+
it { should == @job }
|
150
270
|
end
|
151
|
-
end
|
152
271
|
|
153
|
-
|
154
|
-
|
272
|
+
context 'filter by wrong name but correct kind (without handler wrapper)' do
|
273
|
+
|
155
274
|
before do
|
156
|
-
@yaml_conditions = { :
|
275
|
+
@yaml_conditions = { :class => SimpleJob, :name => 'wrong_name', :kind => 'my_kind' }
|
157
276
|
end
|
158
|
-
|
277
|
+
|
278
|
+
it { should be_nil }
|
159
279
|
end
|
160
280
|
|
161
|
-
context '
|
281
|
+
context 'filter by correct name, kind and realted_user (not serialized field)' do
|
282
|
+
|
162
283
|
before do
|
163
|
-
@yaml_conditions = { :
|
284
|
+
@yaml_conditions = { :class => SimpleJob, :name => 'job_name', :kind => 'my_kind', :related_user => Yaml::NotSerializedField.new(User.find_by_name('marcelo')) }
|
164
285
|
end
|
165
|
-
|
286
|
+
|
287
|
+
it { should == @job }
|
166
288
|
end
|
167
289
|
|
168
|
-
context '
|
290
|
+
context 'filter by correct name, kind and realted_user (not serialized field)' do
|
291
|
+
|
169
292
|
before do
|
170
|
-
|
293
|
+
User.create(:name => 'andres')
|
294
|
+
@yaml_conditions = { :class => SimpleJob, :name => 'job_name', :kind => 'my_kind', :related_user => Yaml::NotSerializedField.new(User.find_by_name('andres')) }
|
171
295
|
end
|
172
|
-
|
296
|
+
|
297
|
+
it { should be_nil }
|
173
298
|
end
|
174
|
-
end
|
175
299
|
end
|
176
|
-
|
177
|
-
end
|
300
|
+
end if defined?(Delayed::Job)
|
@@ -139,7 +139,7 @@ describe Orms::ActiveRecordVersion2 do
|
|
139
139
|
context 'there is a Job(data: #Struct{:method => :new_email, :handler => User#(email => marcelo) })' do
|
140
140
|
|
141
141
|
before do
|
142
|
-
|
142
|
+
silence_warnings { @struct = Struct.new('MyStruct', :method, :handler, :email, :number, :some_rate) }
|
143
143
|
@user = User.create(:name => 'marcelo', :address => 'address1')
|
144
144
|
struct_instance = @struct.new(:new_email, @user.to_yaml, 'foo@gmail.com', 4, 0.005)
|
145
145
|
@job = Job.create(:name => 'job1', :data => struct_instance)
|
data/spec/spec_helper.rb
CHANGED
@@ -5,9 +5,20 @@ else
|
|
5
5
|
gem 'activesupport', [ '>= 2.3.4', '<= 2.3.10' ], :require => 'active_support'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Kernel
|
9
|
+
def silence_warnings
|
10
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
11
|
+
yield
|
11
12
|
ensure
|
12
13
|
$VERBOSE = old_verbose
|
14
|
+
end
|
15
|
+
|
16
|
+
def without_output
|
17
|
+
orig_stdout = $stderr
|
18
|
+
# redirect stdout to /dev/null
|
19
|
+
$stderr = File.new('/dev/null', 'w')
|
20
|
+
yield
|
21
|
+
# restore stdout
|
22
|
+
$stderr = orig_stdout
|
23
|
+
end
|
13
24
|
end
|
data/tasks/yaml_conditions.rake
CHANGED
@@ -61,7 +61,7 @@ for adapter in %w( mysql postgresql )
|
|
61
61
|
end
|
62
62
|
|
63
63
|
namespace adapter do
|
64
|
-
|
64
|
+
task "spec_#{adapter}" => [ "rebuild_#{adapter}_databases" ]
|
65
65
|
task :spec => "spec_#{adapter}"
|
66
66
|
end
|
67
67
|
end
|
data/yaml_conditions.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{yaml_conditions}
|
5
|
-
s.version = "0.0.0.
|
5
|
+
s.version = "0.0.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marcelo Giorgi"]
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.email = %q{marklazz.uy@gmail.com}
|
13
13
|
s.executables = ["console.sh"]
|
14
14
|
s.extra_rdoc_files = ["README.rdoc", "bin/console.sh", "lib/orms/active_record.rb", "lib/orms/active_record/version2/delayed_job.rb", "lib/orms/active_record/version_2.rb", "lib/orms/active_record/version_3.rb", "lib/orms/datamapper.rb", "lib/yaml/conditions.rb", "lib/yaml/query_builder.rb", "lib/yaml/query_builder/sql/mysql.rb", "lib/yaml/query_builder/sql/postgresql.rb", "lib/yaml_conditions.rb", "tasks/yaml_conditions.rake"]
|
15
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "TESTS.rdoc", "bin/console.sh", "init.rb", "lib/orms/active_record.rb", "lib/orms/active_record/version2/delayed_job.rb", "lib/orms/active_record/version_2.rb", "lib/orms/active_record/version_3.rb", "lib/orms/datamapper.rb", "lib/yaml/conditions.rb", "lib/yaml/query_builder.rb", "lib/yaml/query_builder/sql/mysql.rb", "lib/yaml/query_builder/sql/postgresql.rb", "lib/yaml_conditions.rb", "out.txt", "spec/ar_spec_helper.rb", "spec/cases/orms/active_record/version_2_delayed_job_spec.rb", "spec/cases/orms/active_record/version_2_spec.rb", "spec/connections/mysql/connection.rb", "spec/connections/postgresql/connection.rb", "spec/datamapper_spec_helper.rb", "spec/models/
|
15
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "TESTS.rdoc", "bin/console.sh", "init.rb", "lib/orms/active_record.rb", "lib/orms/active_record/version2/delayed_job.rb", "lib/orms/active_record/version_2.rb", "lib/orms/active_record/version_3.rb", "lib/orms/datamapper.rb", "lib/yaml/conditions.rb", "lib/yaml/query_builder.rb", "lib/yaml/query_builder/sql/mysql.rb", "lib/yaml/query_builder/sql/postgresql.rb", "lib/yaml_conditions.rb", "out.txt", "spec/ar_spec_helper.rb", "spec/cases/orms/active_record/version_2_delayed_job_spec.rb", "spec/cases/orms/active_record/version_2_spec.rb", "spec/connections/mysql/connection.rb", "spec/connections/postgresql/connection.rb", "spec/datamapper_spec_helper.rb", "spec/models/job.rb", "spec/models/period.rb", "spec/models/priority.rb", "spec/models/support_classes.rb", "spec/models/user.rb", "spec/models/user_data.rb", "spec/schema.rb", "spec/spec_helper.rb", "tasks/yaml_conditions.rake", "yaml_conditions.gemspec"]
|
16
16
|
s.homepage = %q{http://github.com/marklazz/yaml_conditions}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Yaml_conditions", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml_conditions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 73
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.0.0.
|
10
|
+
- 3
|
11
|
+
version: 0.0.0.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Marcelo Giorgi
|
@@ -77,11 +77,10 @@ files:
|
|
77
77
|
- spec/connections/mysql/connection.rb
|
78
78
|
- spec/connections/postgresql/connection.rb
|
79
79
|
- spec/datamapper_spec_helper.rb
|
80
|
-
- spec/models/delayed/job.rb
|
81
|
-
- spec/models/delayed/performable_method.rb
|
82
80
|
- spec/models/job.rb
|
83
81
|
- spec/models/period.rb
|
84
82
|
- spec/models/priority.rb
|
83
|
+
- spec/models/support_classes.rb
|
85
84
|
- spec/models/user.rb
|
86
85
|
- spec/models/user_data.rb
|
87
86
|
- spec/schema.rb
|
data/spec/models/delayed/job.rb
DELETED