tengine_rails_plugin 0.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tengine_rails_plugin (0.0.1)
4
+ tengine_rails_plugin (1.1.0)
5
5
  rails (~> 3.2.8)
6
- tengine_event (~> 0.4.0)
7
- tengine_support (~> 0.3.27)
6
+ tengine_event (~> 1.1.0)
7
+ tengine_support (~> 1.1.0)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
+ ZenTest (4.8.2)
12
13
  actionmailer (3.2.8)
13
14
  actionpack (= 3.2.8)
14
15
  mail (~> 2.4.4)
@@ -45,9 +46,12 @@ GEM
45
46
  amq-protocol (~> 0.8.4)
46
47
  eventmachine
47
48
  arel (3.0.2)
49
+ autotest (4.4.6)
50
+ ZenTest (>= 4.4.1)
48
51
  builder (3.0.0)
52
+ diff-lcs (1.1.3)
49
53
  erubis (2.7.0)
50
- eventmachine (0.12.10)
54
+ eventmachine (1.0.0)
51
55
  hike (1.2.1)
52
56
  i18n (0.6.0)
53
57
  journey (1.0.4)
@@ -87,34 +91,55 @@ GEM
87
91
  rdoc (~> 3.4)
88
92
  thor (>= 0.14.6, < 2.0)
89
93
  rake (0.9.2.2)
94
+ rdiscount (1.6.8)
90
95
  rdoc (3.12)
91
96
  json (~> 1.4)
97
+ rspec (2.10.0)
98
+ rspec-core (~> 2.10.0)
99
+ rspec-expectations (~> 2.10.0)
100
+ rspec-mocks (~> 2.10.0)
101
+ rspec-core (2.10.1)
102
+ rspec-expectations (2.10.0)
103
+ diff-lcs (~> 1.1.3)
104
+ rspec-mocks (2.10.1)
105
+ simplecov (0.6.4)
106
+ multi_json (~> 1.0)
107
+ simplecov-html (~> 0.5.3)
108
+ simplecov-html (0.5.3)
92
109
  sprockets (2.1.3)
93
110
  hike (~> 1.2)
94
111
  rack (~> 1.0)
95
112
  tilt (~> 1.1, != 1.3.0)
96
113
  sqlite3 (1.3.6)
97
114
  systemu (2.5.2)
98
- tengine_event (0.4.9)
115
+ tengine_event (1.1.0)
99
116
  activesupport (>= 3.0.0)
100
117
  amqp (~> 0.8.0)
101
- tengine_support (>= 0.3.27)
118
+ tengine_support (~> 1.1.0)
102
119
  uuid (~> 2.3.4)
103
- tengine_support (0.3.27)
120
+ tengine_support (1.1.0)
104
121
  activesupport (>= 3.0.0)
105
122
  thor (0.16.0)
106
123
  tilt (1.3.3)
107
- treetop (1.4.10)
124
+ treetop (1.4.12)
108
125
  polyglot
109
126
  polyglot (>= 0.3.1)
110
- tzinfo (0.3.33)
127
+ tzinfo (0.3.35)
111
128
  uuid (2.3.5)
112
129
  macaddr (~> 1.0)
130
+ yard (0.8.2.1)
113
131
 
114
132
  PLATFORMS
115
133
  ruby
116
134
 
117
135
  DEPENDENCIES
136
+ autotest
137
+ bundler
118
138
  jquery-rails
139
+ rake (~> 0.9.2.2)
140
+ rdiscount
141
+ rspec (~> 2.10.0)
142
+ simplecov (~> 0.6.4)
119
143
  sqlite3
120
144
  tengine_rails_plugin!
145
+ yard (~> 0.8.1)
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ require "eventmachine"
4
+
5
+ module TengineRailsPlugin
6
+ module Progress
7
+ STATUS_TYPES = SelectableAttr::Enum.new do
8
+ name "Tengine進捗状態"
9
+ entry 0, :initial, "初期状態"
10
+ entry 1, :sended, "送信済み"
11
+ entry 2, :send_failure, "送信失敗"
12
+ entry 3, :starting, "実行中"
13
+ entry 4, :starting_failure, "実行開始失敗"
14
+ entry 5, :error, "実行失敗"
15
+ entry 6, :success, "実行成功"
16
+ end
17
+
18
+ EVENT_NAME_PREFIX = "tengine.progress."
19
+
20
+ def event_name(name)
21
+ "#{EVENT_NAME_PREFIX}#{name}"
22
+ end
23
+
24
+ def add_logs(*logs)
25
+ if self.respond_to?(:tengine_logs) and self.respond_to?(:tengine_logs=)
26
+ self.tengine_logs ||= []
27
+ self.tengine_logs += logs
28
+ end
29
+ end
30
+
31
+ def set_status(status)
32
+ if self.respond_to?(:status_cd=)
33
+ self.status_cd = status
34
+ end
35
+ end
36
+
37
+ def fire(batch_name, options={}, &block)
38
+ add_logs("#{Time.zone.now.rfc2822} sending the event to start")
39
+ set_status(1)
40
+ begin
41
+ properties = { batch_id: self.id, batch_name: batch_name }.update(options || {})
42
+ EventMachine.run do
43
+ Tengine::Event.fire(event_name(batch_name), properties: properties)
44
+ end
45
+ rescue Exception
46
+ add_logs("#{Time.zone.now.rfc2822} #{$!.class.name} #{$!.message}\n " + $!.backtrace.join("\n "))
47
+ set_status(2)
48
+ self.save!
49
+ raise
50
+ end
51
+ end
52
+
53
+ def self.run(model, event)
54
+ progress = model.find(event[:batch_id])
55
+ progress.extend(self)
56
+ progress.add_logs("#{Time.zone.now.rfc2822} Starting")
57
+ progress.set_status(3)
58
+ progress.save!
59
+ begin
60
+ yield(progress) if block_given?
61
+ rescue
62
+ progress.add_logs("#{Time.zone.now.rfc2822} [#{$!.class.name}] #{$!.message}\n " + $!.backtrace.join("\n "))
63
+ progress.set_status(5)
64
+ progress.save!
65
+ raise
66
+ else
67
+ progress.add_logs("#{Time.zone.now.rfc2822} SUCCESS")
68
+ progress.set_status(6)
69
+ progress.save!
70
+ end
71
+ end
72
+
73
+ module Driveable
74
+ extend ActiveSupport::Concern
75
+
76
+ included do
77
+ include Tengine::Core::Driveable
78
+ end
79
+
80
+ module ClassMethods
81
+ def batch(batch_name)
82
+ on "#{EVENT_NAME_PREFIX}#{batch_name}"
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -1,3 +1,3 @@
1
1
  module TengineRailsPlugin
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tengine_rails_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-10-09 00:00:00.000000000 Z
16
+ date: 2012-12-19 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
20
- requirement: &70175160393640 !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ~>
@@ -25,32 +25,159 @@ dependencies:
25
25
  version: 3.2.8
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *70175160393640
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.8
29
34
  - !ruby/object:Gem::Dependency
30
35
  name: tengine_event
31
- requirement: &70175160392600 !ruby/object:Gem::Requirement
36
+ requirement: !ruby/object:Gem::Requirement
32
37
  none: false
33
38
  requirements:
34
39
  - - ~>
35
40
  - !ruby/object:Gem::Version
36
- version: 0.4.0
41
+ version: 1.1.0
37
42
  type: :runtime
38
43
  prerelease: false
39
- version_requirements: *70175160392600
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: 1.1.0
40
50
  - !ruby/object:Gem::Dependency
41
51
  name: tengine_support
42
- requirement: &70175160391720 !ruby/object:Gem::Requirement
52
+ requirement: !ruby/object:Gem::Requirement
43
53
  none: false
44
54
  requirements:
45
55
  - - ~>
46
56
  - !ruby/object:Gem::Version
47
- version: 0.3.27
57
+ version: 1.1.0
48
58
  type: :runtime
49
59
  prerelease: false
50
- version_requirements: *70175160391720
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.1.0
66
+ - !ruby/object:Gem::Dependency
67
+ name: bundler
68
+ requirement: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ requirement: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.2.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 0.9.2.2
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec
100
+ requirement: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: 2.10.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ version: 2.10.0
114
+ - !ruby/object:Gem::Dependency
115
+ name: yard
116
+ requirement: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: 0.8.1
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ version: 0.8.1
130
+ - !ruby/object:Gem::Dependency
131
+ name: simplecov
132
+ requirement: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ version: 0.6.4
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 0.6.4
146
+ - !ruby/object:Gem::Dependency
147
+ name: autotest
148
+ requirement: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ - !ruby/object:Gem::Dependency
163
+ name: rdiscount
164
+ requirement: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ type: :development
171
+ prerelease: false
172
+ version_requirements: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
51
178
  - !ruby/object:Gem::Dependency
52
179
  name: sqlite3
53
- requirement: &70175160390860 !ruby/object:Gem::Requirement
180
+ requirement: !ruby/object:Gem::Requirement
54
181
  none: false
55
182
  requirements:
56
183
  - - ! '>='
@@ -58,7 +185,12 @@ dependencies:
58
185
  version: '0'
59
186
  type: :development
60
187
  prerelease: false
61
- version_requirements: *70175160390860
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
62
194
  description: tengine_rails_plugin supports the use of tengine in Rails application.
63
195
  email: tengine-info@groovenauts.jp
64
196
  executables: []
@@ -66,6 +198,7 @@ extensions: []
66
198
  extra_rdoc_files: []
67
199
  files:
68
200
  - lib/tasks/tengine_rails_plugin_tasks.rake
201
+ - lib/tengine_rails_plugin/progress.rb
69
202
  - lib/tengine_rails_plugin/version.rb
70
203
  - lib/tengine_rails_plugin.rb
71
204
  - Gemfile
@@ -84,17 +217,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
217
  - - ! '>='
85
218
  - !ruby/object:Gem::Version
86
219
  version: '0'
220
+ segments:
221
+ - 0
222
+ hash: -338025004054856420
87
223
  required_rubygems_version: !ruby/object:Gem::Requirement
88
224
  none: false
89
225
  requirements:
90
226
  - - ! '>='
91
227
  - !ruby/object:Gem::Version
92
228
  version: '0'
229
+ segments:
230
+ - 0
231
+ hash: -338025004054856420
93
232
  requirements: []
94
233
  rubyforge_project:
95
- rubygems_version: 1.8.10
234
+ rubygems_version: 1.8.23
96
235
  signing_key:
97
236
  specification_version: 3
98
237
  summary: tengine_rails_plugin supports the use of tengine in Rails application.
99
238
  test_files: []
100
- has_rdoc: