duties 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/duties.gemspec +1 -1
- data/lib/duties.rb +1 -0
- data/lib/duties/activity.rb +13 -3
- data/lib/duties/status.rb +1 -0
- data/lib/duties/subscriber.rb +29 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16135defc8a376ddd750c3c472871114dd33026
|
4
|
+
data.tar.gz: dc244747cf9e295f6ea85013765be92ee88b9b44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8753e2f67c5dca66359e92ace124b3ee94f89efeed00f64b068ea13a4cc6cc27c7ab8b76cdef87c5280a1458d8a40a0bebb01914329686de3ee3a56f001e2de0
|
7
|
+
data.tar.gz: 32a7e38308648b74798e5d6a81338157602810da3069a8c465fa452bcc3d0fa732d9d12018bf53c6947f4d06dba66f93dbc16181fdf67fde51da432af35a2947
|
data/README.md
CHANGED
data/duties.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = 'duties'
|
4
|
-
spec.version = '0.0.
|
4
|
+
spec.version = '0.0.3'
|
5
5
|
spec.authors = ['Pat Allan']
|
6
6
|
spec.email = ['pat@freelancing-gods.com']
|
7
7
|
spec.summary = %q{Run activities related to a duty in a specific order}
|
data/lib/duties.rb
CHANGED
data/lib/duties/activity.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
class Duties::Activity
|
2
2
|
def self.call(record)
|
3
|
-
|
3
|
+
instrument 'activity', activity: record do
|
4
|
+
instrument 'starting_activity', activity: record
|
5
|
+
|
6
|
+
new(record).call
|
7
|
+
end
|
4
8
|
|
5
9
|
record.status = record.failures.any? ? 'failure' : 'success'
|
6
10
|
record.save!
|
7
11
|
|
12
|
+
instrument 'finished_activity', activity: record
|
13
|
+
|
8
14
|
Duties::Next.call record.duty_record, record.position
|
9
15
|
end
|
10
16
|
|
17
|
+
def self.instrument(event, options, &block)
|
18
|
+
ActiveSupport::Notifications.instrument "#{event}.duties", options, &block
|
19
|
+
end
|
20
|
+
|
11
21
|
def initialize(activity)
|
12
22
|
@activity = activity
|
13
23
|
end
|
@@ -16,6 +26,6 @@ class Duties::Activity
|
|
16
26
|
|
17
27
|
attr_reader :activity
|
18
28
|
|
19
|
-
delegate :
|
20
|
-
delegate :data,
|
29
|
+
delegate :duty_record, to: :activity
|
30
|
+
delegate :data, to: :duty_record
|
21
31
|
end
|
data/lib/duties/status.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class Duties::Subscriber < ActiveSupport::LogSubscriber
|
2
|
+
def activity(event)
|
3
|
+
identifier = color 'Duties (%.1fms)' % event.duration, GREEN, true
|
4
|
+
debug " #{identifier} Running #{activity_message event}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def starting_activity(event)
|
8
|
+
identifier = color 'Duties', GREEN, true
|
9
|
+
debug " #{identifier} Starting #{activity_message event}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def finished_activity(event)
|
13
|
+
identifier = color 'Duties', GREEN, true
|
14
|
+
activity = event.payload[:activity]
|
15
|
+
debug [" #{identifier} ",
|
16
|
+
"Finished #{activity_message event} (#{activity.status})"].join('')
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def activity_message(event)
|
22
|
+
activity = event.payload[:activity]
|
23
|
+
[activity.duty_record, activity].collect { |object|
|
24
|
+
"#{object.name} (#{object.id})"
|
25
|
+
}.join(' / ')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Duties::Subscriber.attach_to :duties
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/duties/engine.rb
|
122
122
|
- lib/duties/next.rb
|
123
123
|
- lib/duties/status.rb
|
124
|
+
- lib/duties/subscriber.rb
|
124
125
|
- spec/acceptance/running_duties_spec.rb
|
125
126
|
- spec/internal/config/database.yml
|
126
127
|
- spec/internal/config/routes.rb
|