dalliance 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ require 'dalliance'
2
+
3
+ module Dalliance
4
+ if defined? Rails::Railtie
5
+ class Railtie < Rails::Railtie
6
+ initializer 'dalliance.active_record' do
7
+ ActiveSupport.on_load :active_record do
8
+ include Dalliance::Glue
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,7 @@ module Dalliance
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
data/lib/dalliance.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'dalliance/version'
2
+ require 'dalliance/railtie'
2
3
 
3
4
  require 'dalliance/progress_meter'
4
5
 
@@ -130,22 +131,51 @@ module Dalliance
130
131
  1
131
132
  end
132
133
  end
133
- end
134
-
135
- #http://yehudakatz.com/2009/11/12/better-ruby-idioms/
136
- class ActiveRecord::Base
137
- def self.dalliance(*args)
138
- options = args.last.is_a?(Hash) ? Dalliance.options.merge(args.pop) : Dalliance.options
134
+
135
+ module Glue
136
+ extend ActiveSupport::Concern
139
137
 
140
- case args.length
141
- when 1
142
- options[:dalliance_method] = args[0]
143
- else
144
- raise ArgumentError, "Incorrect number of Arguements provided"
138
+ included do
139
+ class_attribute :dalliance_options if respond_to?(:class_attribute)
145
140
  end
146
141
 
147
- cattr_accessor :dalliance_options
148
- self.dalliance_options = options
149
- include Dalliance
142
+ module ClassMethods
143
+ def dalliance(*args)
144
+ options = args.last.is_a?(Hash) ? Dalliance.options.merge(args.pop) : Dalliance.options
145
+
146
+ case args.length
147
+ when 1
148
+ options[:dalliance_method] = args[0]
149
+ else
150
+ raise ArgumentError, "Incorrect number of Arguements provided"
151
+ end
152
+
153
+ if dalliance_options.nil?
154
+ if respond_to?(:class_attribute)
155
+ self.dalliance_options = {}
156
+ else
157
+ write_inheritable_attribute(:dalliance_options, {})
158
+ end
159
+ else
160
+ if respond_to?(:class_attribute)
161
+ self.dalliance_options = self.dalliance_options.dup
162
+ else
163
+ write_inheritable_attribute(:dalliance_options, self.dalliance_options.dup)
164
+ end
165
+ end
166
+
167
+ self.dalliance_options.merge!(options)
168
+
169
+ include Dalliance
170
+ end
171
+
172
+ def dalliance_options
173
+ if respond_to?(:class_attribute)
174
+ self.dalliance_options
175
+ else
176
+ read_inheritable_attribute(:dalliance_options)
177
+ end
178
+ end
179
+ end
150
180
  end
151
181
  end
@@ -42,6 +42,9 @@ end
42
42
 
43
43
  # Purely useful for test cases...
44
44
  class DallianceModel < ActiveRecord::Base
45
+ #We're not using the railtie in tests...
46
+ include Dalliance::Glue
47
+
45
48
  dalliance :dalliance_success_method
46
49
 
47
50
  def dalliance_success_method
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalliance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-16 00:00:00.000000000 Z
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70155485428960 !ruby/object:Gem::Requirement
16
+ requirement: &70192797957220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70155485428960
24
+ version_requirements: *70192797957220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70155485427560 !ruby/object:Gem::Requirement
27
+ requirement: &70192797956080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70155485427560
35
+ version_requirements: *70192797956080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: delayed_job
38
- requirement: &70155485426060 !ruby/object:Gem::Requirement
38
+ requirement: &70192797954180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70155485426060
46
+ version_requirements: *70192797954180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: state_machine
49
- requirement: &70155485425640 !ruby/object:Gem::Requirement
49
+ requirement: &70192797953760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70155485425640
57
+ version_requirements: *70192797953760
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70155485425060 !ruby/object:Gem::Requirement
60
+ requirement: &70192797953260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70155485425060
68
+ version_requirements: *70192797953260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: delayed_job_active_record
71
- requirement: &70155485424360 !ruby/object:Gem::Requirement
71
+ requirement: &70192797952420 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70155485424360
79
+ version_requirements: *70192797952420
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70155485423580 !ruby/object:Gem::Requirement
82
+ requirement: &70192797951660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70155485423580
90
+ version_requirements: *70192797951660
91
91
  description: ! ' Opinionated background processing for ActiveRecord w/ delayed_job
92
92
  & state_machine '
93
93
  email:
@@ -105,6 +105,7 @@ files:
105
105
  - dalliance.gemspec
106
106
  - lib/dalliance.rb
107
107
  - lib/dalliance/progress_meter.rb
108
+ - lib/dalliance/railtie.rb
108
109
  - lib/dalliance/version.rb
109
110
  - lib/generators/dalliance/progress_meter/progress_meter_generator.rb
110
111
  - lib/generators/dalliance/progress_meter/templates/migration.rb
@@ -138,7 +139,7 @@ rubyforge_project: dalliance
138
139
  rubygems_version: 1.8.10
139
140
  signing_key:
140
141
  specification_version: 3
141
- summary: dalliance 0.0.2
142
+ summary: dalliance 0.0.3
142
143
  test_files:
143
144
  - spec/dalliance/asynchronous_spec.rb
144
145
  - spec/dalliance/dalliance_spec.rb