dalliance 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -30,7 +30,7 @@ Handle your migrations:
30
30
  Create a method called dalliance_progress_meter_total_count
31
31
  (or provide the dalliance_progress_meter_total_count_method option)
32
32
 
33
- Inside process_method call progress_meter.increment! after each iteration
33
+ Inside process_method call dalliance_progress_meter.increment! after each iteration
34
34
 
35
35
  In your views you can then call dalliance_progress to get feedback on your asynchronous process
36
36
 
@@ -21,6 +21,14 @@ module Dalliance
21
21
  self[:total_count] ||= 1
22
22
  end
23
23
 
24
+ def total_count=(count)
25
+ if count <= 0
26
+ self[:total_count] = 1
27
+ else
28
+ self[:total_count] = count
29
+ end
30
+ end
31
+
24
32
  before_validation :calculate_progress
25
33
 
26
34
  def calculate_progress
@@ -2,7 +2,7 @@ module Dalliance
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
data/lib/dalliance.rb CHANGED
@@ -17,6 +17,10 @@ module Dalliance
17
17
  options[:background_processing]
18
18
  end
19
19
 
20
+ def background_processing=(value)
21
+ options[:background_processing] = value
22
+ end
23
+
20
24
  def configure
21
25
  yield(self) if block_given?
22
26
  end
@@ -28,10 +32,10 @@ module Dalliance
28
32
  serialize :dalliance_error_hash, Hash
29
33
 
30
34
  #BEGIN state_machine(s)
31
- scope :dalliance_pending, where(:dalliance_status => 'pending')
32
- scope :dalliance_processing, where(:dalliance_status => 'processing')
33
- scope :dalliance_processing_error, where(:dalliance_status => 'processing_error')
34
- scope :dalliance_completed, where(:dalliance_status => 'completed')
35
+ scope :pending, where(:dalliance_status => 'pending')
36
+ scope :processing, where(:dalliance_status => 'processing')
37
+ scope :processing_error, where(:dalliance_status => 'processing_error')
38
+ scope :completed, where(:dalliance_status => 'completed')
35
39
 
36
40
  state_machine :dalliance_status, :initial => :pending do
37
41
  state :pending
@@ -64,6 +68,14 @@ module Dalliance
64
68
  end
65
69
  end
66
70
 
71
+ def error_or_completed?
72
+ processing_error? || completed?
73
+ end
74
+
75
+ def pending_or_processing?
76
+ pending? || processing?
77
+ end
78
+
67
79
  #Force backgound_processing w/ true
68
80
  def dalliance_background_process(backgound_processing = nil)
69
81
  if backgound_processing || (backgound_processing.nil? && Dalliance.background_processing?)
@@ -93,7 +105,7 @@ module Dalliance
93
105
  raise e unless backgound_processing
94
106
  ensure
95
107
  if dalliance_progress_meter
96
- dalliance_progress_meter.destroy
108
+ dalliance_progress_meter.destroy
97
109
  end
98
110
  end
99
111
  end
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.1
4
+ version: 0.0.2
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-10 00:00:00.000000000 Z
12
+ date: 2012-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70098455466720 !ruby/object:Gem::Requirement
16
+ requirement: &70155485428960 !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: *70098455466720
24
+ version_requirements: *70155485428960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70098455466100 !ruby/object:Gem::Requirement
27
+ requirement: &70155485427560 !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: *70098455466100
35
+ version_requirements: *70155485427560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: delayed_job
38
- requirement: &70098455465500 !ruby/object:Gem::Requirement
38
+ requirement: &70155485426060 !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: *70098455465500
46
+ version_requirements: *70155485426060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: state_machine
49
- requirement: &70098455465020 !ruby/object:Gem::Requirement
49
+ requirement: &70155485425640 !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: *70098455465020
57
+ version_requirements: *70155485425640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70098455464440 !ruby/object:Gem::Requirement
60
+ requirement: &70155485425060 !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: *70098455464440
68
+ version_requirements: *70155485425060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: delayed_job_active_record
71
- requirement: &70098455463520 !ruby/object:Gem::Requirement
71
+ requirement: &70155485424360 !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: *70098455463520
79
+ version_requirements: *70155485424360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70098455462940 !ruby/object:Gem::Requirement
82
+ requirement: &70155485423580 !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: *70098455462940
90
+ version_requirements: *70155485423580
91
91
  description: ! ' Opinionated background processing for ActiveRecord w/ delayed_job
92
92
  & state_machine '
93
93
  email:
@@ -138,7 +138,7 @@ rubyforge_project: dalliance
138
138
  rubygems_version: 1.8.10
139
139
  signing_key:
140
140
  specification_version: 3
141
- summary: dalliance 0.0.1
141
+ summary: dalliance 0.0.2
142
142
  test_files:
143
143
  - spec/dalliance/asynchronous_spec.rb
144
144
  - spec/dalliance/dalliance_spec.rb