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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 013c8b5618ef3e40423bceb965c8ae365c79a706
4
- data.tar.gz: 4d0b9eb620ee4b5bd2a1d1c041e325e1425f7e8b
3
+ metadata.gz: 3b4aca75b625140a4019efa60cb8af78e89d80dc
4
+ data.tar.gz: 75a6421c82aac3cf1b57a5d98ff65ebf0c8da180
5
5
  SHA512:
6
- metadata.gz: 0add0467f293ca46aae40d3283cde9e9ffe0e41fadda4b6804b5b737bd14c6d510a89b330becd2bee07931da52bf13462c00d4d4a00161a20ef7e7c1c3d27756
7
- data.tar.gz: 172cda972ab24acf5fabd38780e874bcba5f6bfe200fecd53d35f74a0db204dc5eeb5550ed2ffd3862b4dd88bc97c94cf2250e7611ec49dc893b95543fae82a4
6
+ metadata.gz: 88115cc516d9739cfd9d524ac50487f130d4578d973929e05dd2eff76beb9acc595abfa7d3a2a2f99d0a2773c6db3b3f4c0938a667284326f986e349dae1c200
7
+ data.tar.gz: 449be7d50e8830191efcce26284a22f3ad49c68299c49c2a1ea4742f983c12fa96a4da5070628c9f00ef51c84cf1268e943dd51d357dd10e61e687e8c122270a
data/.gitignore CHANGED
@@ -30,6 +30,7 @@ config/database.yml
30
30
  .*.swp
31
31
  .*.swo
32
32
  .env
33
+ .env-*
33
34
  *.gem
34
35
  /spec/vcr_cassettes/*
35
36
  /tags
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whois_slacking (0.0.1)
4
+ whois_slacking (0.0.2)
5
5
  dotenv (~> 2.0.2)
6
6
  moneta (~> 0.8.0)
7
7
  multi_xml (~> 0.5)
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  Whois Slacking.
2
2
  =================
3
+ [![Gem Version](https://badge.fury.io/rb/whois_slacking.svg)](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
@@ -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' && task.owned_by &&
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 # -- if task/username combo exists and is not completed in db
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 = "#{user} has spent #{days_worked.to_i} days working on #{task}"
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 = "#{user} has spent #{hours_worked.to_i} hours working on #{task}"
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
@@ -1,3 +1,3 @@
1
1
  module WhoIsSlacking
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/slackcron.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'whois_slacking'
2
+ require 'moneta'
3
+
4
+ @store = Moneta.new(:File, :dir => 'moneta')
5
+ WhoIsSlacking::Pivotal.connect_to_pivotal
6
+ WhoIsSlacking::Start.now
7
+ puts 'job finished'
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
- def direct_save(start_dt = (DateTime.now - 1))
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: current_state, active: active, start_dt: start_dt, created_dt: created_dt, accepted_at: accepted_at, updated_dt: updated_dt}
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.2
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