whois_slacking 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/whois_slacking.rb +18 -6
- data/lib/whois_slacking/version.rb +1 -1
- data/slackcron.rb +7 -0
- data/spec/client_spec.rb +13 -7
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b4aca75b625140a4019efa60cb8af78e89d80dc
|
4
|
+
data.tar.gz: 75a6421c82aac3cf1b57a5d98ff65ebf0c8da180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88115cc516d9739cfd9d524ac50487f130d4578d973929e05dd2eff76beb9acc595abfa7d3a2a2f99d0a2773c6db3b3f4c0938a667284326f986e349dae1c200
|
7
|
+
data.tar.gz: 449be7d50e8830191efcce26284a22f3ad49c68299c49c2a1ea4742f983c12fa96a4da5070628c9f00ef51c84cf1268e943dd51d357dd10e61e687e8c122270a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
Whois Slacking.
|
2
2
|
=================
|
3
|
+
[](http://badge.fury.io/rb/whois_slacking)
|
3
4
|
|
4
5
|
This is a ruby library that integrates Pivotal Tracker and Slack.
|
5
6
|
The library will send a message into a slack channel for every uncompleted task in pivotal, saying how long
|
data/lib/whois_slacking.rb
CHANGED
@@ -55,7 +55,11 @@ module WhoIsSlacking
|
|
55
55
|
.pivotal_project( WhoIsSlacking::Pivotal.project_name)
|
56
56
|
tasks = WhoIsSlacking::Pivotal.project_stories(project_object)
|
57
57
|
tasks.each do |task|
|
58
|
-
if task.current_state != 'unstarted' &&
|
58
|
+
if task.current_state != 'unstarted' &&
|
59
|
+
task.owned_by &&
|
60
|
+
task.current_state != 'restart' &&
|
61
|
+
task.current_state != 'unestimated' &&
|
62
|
+
task.current_state != 'unscheduled' &&
|
59
63
|
task.current_state != 'accepted'
|
60
64
|
WhoIsSlacking::DataTools.save_task(project_object.name, task.id, task.name, task.owned_by, task.current_state, task.accepted_at )
|
61
65
|
end
|
@@ -138,7 +142,8 @@ module WhoIsSlacking
|
|
138
142
|
mkey = self.whois_key(project, task_id, user)
|
139
143
|
entity_exists = store[mkey]
|
140
144
|
|
141
|
-
if entity_exists
|
145
|
+
if entity_exists &&
|
146
|
+
entity_exists[:current_state] != 'finished' # -- if task/username combo exists and is not delivered/finished in db
|
142
147
|
# -- calculate how long (realtime) the task has been worked on in days (.5, 1.5 etc)
|
143
148
|
# -- update time on task
|
144
149
|
# -- save who started task
|
@@ -150,10 +155,10 @@ module WhoIsSlacking
|
|
150
155
|
|
151
156
|
days_worked = TimeDifference.between(DateTime.now, start_dt).in_days
|
152
157
|
if days_worked >= 1.0
|
153
|
-
message = "
|
158
|
+
message = "*#{user} has spent #{days_worked.to_i} days working on #{task}*"
|
154
159
|
else # show hours instead
|
155
160
|
hours_worked = TimeDifference.between(DateTime.now, start_dt).in_hours
|
156
|
-
message = "
|
161
|
+
message = "*#{user} has spent #{hours_worked.to_i} hours working on #{task}*"
|
157
162
|
end
|
158
163
|
# keep the created dt and start_dt
|
159
164
|
created_dt = entity_exists[:created_dt]
|
@@ -162,6 +167,8 @@ module WhoIsSlacking
|
|
162
167
|
task_entity["start_dt"] = start_dt
|
163
168
|
store[mkey] = task_entity
|
164
169
|
|
170
|
+
elsif entity_exists && entity_exists[:current_state] == 'finished'
|
171
|
+
# don't do anything
|
165
172
|
else # -- if task/username combo does not exist in db
|
166
173
|
# -- save project/task/user
|
167
174
|
# -- save when task was started
|
@@ -172,13 +179,18 @@ module WhoIsSlacking
|
|
172
179
|
# -- save status as status not-completed
|
173
180
|
# -- publish message task/user started today
|
174
181
|
# -- "Today Johnny started 'As a user I should be able to log in'"
|
175
|
-
message = "Today #{user} started #{task}"
|
182
|
+
message = "*Today #{user} started #{task}*"
|
176
183
|
|
177
184
|
elsif current_state == "finished" # -- if task is completed in pivotal
|
178
185
|
# -- save status as status completed
|
179
186
|
# -- publish message task/user started today
|
180
187
|
# -- "Today Johnny completed 'As a user I should be able to log in'"
|
181
|
-
message = "Today #{user} finished #{task}"
|
188
|
+
message = "*Today #{user} finished #{task}*"
|
189
|
+
elsif current_state == "delivered" # -- if task is completed in pivotal
|
190
|
+
# -- save status as status completed
|
191
|
+
# -- publish message task/user started today
|
192
|
+
# -- "Today Johnny completed 'As a user I should be able to log in'"
|
193
|
+
message = "*Today #{user} delivered #{task}*"
|
182
194
|
end
|
183
195
|
|
184
196
|
end
|
data/slackcron.rb
ADDED
data/spec/client_spec.rb
CHANGED
@@ -103,23 +103,23 @@ describe "json client" do
|
|
103
103
|
|
104
104
|
it "should post to slack 'Today xx started xxx' when a non completed task exists in pivotal but not in the db" do
|
105
105
|
expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt)
|
106
|
-
.fetch("message", nil).fetch("text", nil)) .to eql "Today user started task"
|
106
|
+
.fetch("message", nil).fetch("text", nil)) .to eql "*Today user started task*"
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should post to slack 'Today xx completed xxx' when a completed task exists in pivotal but not in the db" do
|
110
110
|
current_state = 'finished'
|
111
111
|
expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt)
|
112
|
-
.fetch("message", nil).fetch("text", nil)) .to eql "Today user finished task"
|
112
|
+
.fetch("message", nil).fetch("text", nil)) .to eql "*Today user finished task*"
|
113
113
|
end
|
114
114
|
|
115
|
-
|
115
|
+
|
116
|
+
def direct_save(start_dt = (DateTime.now - 1), cstate = current_state)
|
116
117
|
accepted_at = accepted_at
|
117
118
|
created_dt = DateTime.now.to_s
|
118
119
|
updated_dt = created_dt
|
119
|
-
current_state = current_state
|
120
120
|
active = true
|
121
121
|
message = nil
|
122
|
-
task_entity = {project: project, task_id: task_id, task: task, user: user, current_state:
|
122
|
+
task_entity = {project: project, task_id: task_id, task: task, user: user, current_state: cstate, active: active, start_dt: start_dt, created_dt: created_dt, accepted_at: accepted_at, updated_dt: updated_dt}
|
123
123
|
store = WhoIsSlacking::DataTools.whois_store
|
124
124
|
mutex = Moneta::Mutex.new(store, 'moneta')
|
125
125
|
mutex.synchronize do
|
@@ -128,18 +128,24 @@ describe "json client" do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
it "should not post to slack when a finished task exists in pivotal *and* in the db" do
|
132
|
+
accepted_dt = DateTime.now - 1
|
133
|
+
direct_save(accepted_dt, 'finished')
|
134
|
+
expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt)).to eql nil
|
135
|
+
end
|
136
|
+
|
131
137
|
it "should post to slack 'xx has spent xx days working on xxx' when a non completed task exists in pivotal and in the db" do
|
132
138
|
accepted_dt = DateTime.now - 1
|
133
139
|
direct_save
|
134
140
|
expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt)
|
135
|
-
.fetch("message", nil).fetch("text", nil)) .to eql "user has spent 1 days working on task"
|
141
|
+
.fetch("message", nil).fetch("text", nil)) .to eql "*user has spent 1 days working on task*"
|
136
142
|
end
|
137
143
|
|
138
144
|
it "should post to slack 'xx has spent xx hours working on xxx' when a non completed task exists in pivotal and in the db and the days worked is less than 1" do
|
139
145
|
start_dt = DateTime.now - 0.5
|
140
146
|
direct_save(start_dt)
|
141
147
|
expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt)
|
142
|
-
.fetch("message", nil).fetch("text", nil)) .to eql "user has spent 12 hours working on task"
|
148
|
+
.fetch("message", nil).fetch("text", nil)) .to eql "*user has spent 12 hours working on task*"
|
143
149
|
end
|
144
150
|
|
145
151
|
it "should run through all tasks for a project, sending a message into slack for each of them" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whois_slacking
|
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
|
- W Watson
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- README.md
|
196
196
|
- lib/whois_slacking.rb
|
197
197
|
- lib/whois_slacking/version.rb
|
198
|
+
- slackcron.rb
|
198
199
|
- spec/client_spec.rb
|
199
200
|
- spec/spec_helper.rb
|
200
201
|
- spec/support/vcr_setup.rb
|