opsask 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/VERSION +1 -1
  4. data/lib/opsask/app.rb +42 -34
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53b67250a3b7e7db5e619794065276d5cb8b5967
4
- data.tar.gz: 3bdd20e256b8e3c565d5097587c5b59cc4e4a78c
3
+ metadata.gz: 51d05620360e3e9e71f076a5fd2c5540ebdd32d9
4
+ data.tar.gz: 5c74ef794d3bbee8af04a29f027ed836563a2f2e
5
5
  SHA512:
6
- metadata.gz: 34fc0675d2cc43bd15bca002494ebc781e29021c542abb61a55441c2992efa8acc2390b7b17085b5bed550b7ff3ff8835e6f51051cb0b093b205011da18c82af
7
- data.tar.gz: 1bfca809319e175787dab642108f3186deb26e2fb2f8c7702084723c913d5c6364f3dfd805b1ca88b872e48d1ddcdd30ef06645166913b2e4af2835feac4f422
6
+ metadata.gz: 81b22a140fcb111016dac13fe9e669719d41d9d7b492a96e649b2faaadce4059346c71913c2ad1eaf312e2d6c1ecdd2af7b21c856c6fb5d02a1b08f880b49937
7
+ data.tar.gz: 30efd17d6b0c1b37325ad91045cb492bafb773939ff804bb4f28371df77e7cf14e872a85d1186bf7c06cf9182dd9b8a78478b67fcad83c836a7049bbdc4c7897
data/.gitignore CHANGED
@@ -11,7 +11,7 @@
11
11
  doc
12
12
  pkg
13
13
  .DS_Store
14
- config.json
14
+ config*.json
15
15
  .bundle
16
16
  .yardoc
17
17
  etc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.2
1
+ 2.3.3
data/lib/opsask/app.rb CHANGED
@@ -36,7 +36,7 @@ module OpsAsk
36
36
 
37
37
  # Serve up our form
38
38
  get '/' do
39
- # $stderr.puts 'get-/'
39
+ debug 'get-/'
40
40
  erb :index, locals: {
41
41
  jiras_for_today: issues_for(today),
42
42
  jiras_for_tomorrow: issues_for(tomorrow),
@@ -46,7 +46,7 @@ module OpsAsk
46
46
  end
47
47
 
48
48
  get '/glance' do
49
- # $stderr.puts 'get-/glance'
49
+ debug 'get-/glance'
50
50
  erb :days, locals: {
51
51
  jiras_by_day: issues_for_days(2),
52
52
  untracked_jiras: untracked_issues,
@@ -55,7 +55,7 @@ module OpsAsk
55
55
  end
56
56
 
57
57
  get '/week' do
58
- # $stderr.puts 'get-/week'
58
+ debug 'get-/week'
59
59
  erb :days, locals: {
60
60
  jiras_by_day: issues_for_days(4),
61
61
  untracked_jiras: untracked_issues,
@@ -64,7 +64,7 @@ module OpsAsk
64
64
  end
65
65
 
66
66
  get '/days/:n' do
67
- # $stderr.puts 'get-/days/:n'
67
+ debug 'get-/days/:n'
68
68
  n, m = params[:n].split('+', 2)
69
69
  n = n.to_i
70
70
  m = m.nil? ? 0 : m.to_i
@@ -76,11 +76,11 @@ module OpsAsk
76
76
  end
77
77
 
78
78
  get '/room' do
79
- # $stderr.puts 'get-/room'
79
+ debug 'get-/room'
80
80
  content_type :json
81
81
  @@room ||= {}
82
82
  if @@room.empty?
83
- # $stderr.puts 'RECALC ROOM!'
83
+ debug 'RECALC ROOM!'
84
84
  (0..365).each do |n|
85
85
  date = today n * one_day
86
86
  @@room[date] = room_for_new_jiras_for? date
@@ -91,7 +91,7 @@ module OpsAsk
91
91
  end
92
92
 
93
93
  get '/untracked' do
94
- # $stderr.puts 'get-/untracked'
94
+ debug 'get-/untracked'
95
95
  erb :untracked, locals: {
96
96
  untracked_jiras: untracked_issues,
97
97
  stragglers: straggling_issues
@@ -99,7 +99,7 @@ module OpsAsk
99
99
  end
100
100
 
101
101
  get '/stragglers' do
102
- # $stderr.puts 'get-/stragglers'
102
+ debug 'get-/stragglers'
103
103
  erb :stragglers, locals: {
104
104
  untracked_jiras: untracked_issues,
105
105
  stragglers: straggling_issues
@@ -107,7 +107,7 @@ module OpsAsk
107
107
  end
108
108
 
109
109
  get '/sprint/:sprint_num' do
110
- # $stderr.puts 'get-/sprint/:n'
110
+ debug 'get-/sprint/:n'
111
111
  num = params[:sprint_num]
112
112
  sprint = get_sprint(num)
113
113
  id = sprint['id']
@@ -135,7 +135,7 @@ module OpsAsk
135
135
  end
136
136
 
137
137
  get '/sprint' do
138
- # $stderr.puts 'get-/sprint'
138
+ debug 'get-/sprint'
139
139
  num = current_sprint_num
140
140
  id = current_sprint_id
141
141
  sprint = current_sprint
@@ -164,13 +164,13 @@ module OpsAsk
164
164
 
165
165
  # I think everyone should do this
166
166
  get '/version' do
167
- # $stderr.puts 'get-/version'
167
+ debug 'get-/version'
168
168
  content_type :txt
169
169
  "opsask #{settings.config[:app_version]}"
170
170
  end
171
171
 
172
172
  get '/v' do
173
- # $stderr.puts 'get-/v'
173
+ debug 'get-/v'
174
174
  content_type :txt
175
175
  settings.config[:app_version]
176
176
  end
@@ -178,7 +178,7 @@ module OpsAsk
178
178
 
179
179
  # Try to create a JIRA
180
180
  post '/' do
181
- # $stderr.puts 'post-/'
181
+ debug 'post-/'
182
182
  component, summary, description, assign_to_me, epic, ops_only, datepicker = validate_jira_params
183
183
 
184
184
  if datepicker.nil? || datepicker.empty?
@@ -208,13 +208,13 @@ module OpsAsk
208
208
  # Public assets
209
209
  %w[ css img js fonts ].each do |asset|
210
210
  get "/#{asset}/:file" do
211
- # $stderr.puts 'get-/%s/:file' % asset
211
+ debug 'get-/%s/:file' % asset
212
212
  send_file "public/#{asset}/#{params[:file]}", :disposition => 'inline'
213
213
  end
214
214
  end
215
215
 
216
216
  get '/favicon.ico' do
217
- # $stderr.puts 'get-/favicon'
217
+ debug 'get-/favicon'
218
218
  send_file 'public/favicon.ico', :disposition => 'inline'
219
219
  end
220
220
 
@@ -224,7 +224,7 @@ module OpsAsk
224
224
  # OAuth consumer details including the consumer key, private key,
225
225
  # site uri, and the request token, access token, and authorize paths
226
226
  before do
227
- # $stderr.puts 'before-1'
227
+ debug 'before-1'
228
228
  options = {
229
229
  :site => settings.config[:jira_url],
230
230
  :context_path => '',
@@ -237,11 +237,11 @@ module OpsAsk
237
237
  :consumer_key => settings.config[:jira_consumer_key]
238
238
  }
239
239
 
240
- # $stderr.puts 'before-2'
240
+ debug 'before-2'
241
241
  @jira_client = JIRA::Client.new(options)
242
- # @jira_client.consumer.http.set_debug_output($stderr)
242
+ @jira_client.consumer.http.set_debug_output(logger)
243
243
 
244
- # $stderr.puts 'before-3'
244
+ debug 'before-3'
245
245
  # Add AccessToken if authorised previously.
246
246
  if session[:jira_auth]
247
247
  @jira_client.set_access_token(
@@ -254,7 +254,7 @@ module OpsAsk
254
254
  end
255
255
  end
256
256
 
257
- # $stderr.puts 'before-4'
257
+ debug 'before-4'
258
258
  # Keep a pointer to myself
259
259
  begin
260
260
  response = @jira_client.get(
@@ -266,10 +266,12 @@ module OpsAsk
266
266
  end
267
267
 
268
268
  back_to = request.fullpath
269
- # $stderr.puts 'before-5 (back_to=%s)' % back_to.inspect
269
+ debug 'before-5 (back_to=%s)' % back_to.inspect
270
270
  case back_to
271
271
  when /callback/
272
272
  when /login/
273
+ when /logout/
274
+ when /room/
273
275
  else
274
276
  session[:back_to] = back_to
275
277
  end
@@ -278,49 +280,47 @@ module OpsAsk
278
280
  # Retrieves the @access_token then stores it inside a session cookie. In a real app,
279
281
  # you'll want to persist the token in a datastore associated with the user.
280
282
  get '/callback/' do
281
- # $stderr.puts 'callback-1'
283
+ debug 'callback-1'
282
284
  request_token = @jira_client.set_request_token(
283
285
  session[:request_token], session[:request_secret]
284
286
  )
285
- # $stderr.puts 'callback-2'
287
+ debug 'callback-2'
286
288
  access_token = @jira_client.init_access_token(
287
289
  :oauth_verifier => params[:oauth_verifier]
288
290
  )
289
- # $stderr.puts 'callback-3'
291
+ debug 'callback-3'
290
292
  session[:jira_auth] = {
291
293
  :access_token => access_token.token,
292
294
  :access_key => access_token.secret
293
295
  }
294
- # $stderr.puts 'callback-4'
296
+ debug 'callback-4'
295
297
  session.delete(:request_token)
296
298
  session.delete(:request_secret)
297
299
  back_to = session.delete(:back_to) || '/'
298
- # $stderr.puts 'callback-5'
300
+ debug 'callback-5'
299
301
  redirect back_to
300
302
  end
301
303
 
302
304
  # Initialize the JIRA session
303
305
  get '/login' do
304
- # $stderr.puts 'get-/login-1'
306
+ debug 'get-/login-1'
305
307
  if logged_in?
306
- # $stderr.puts 'get-/login-3 (was logged in)'
308
+ debug 'get-/login-3 (was logged in)'
307
309
  session.clear
308
310
  redirect '/logout'
309
311
  end
310
- # $stderr.puts 'get-/login-2 (was logged out)'
312
+ debug 'get-/login-2 (was logged out)'
311
313
  request_token = @jira_client.request_token
312
314
  session[:request_token] = request_token.token
313
315
  session[:request_secret] = request_token.secret
316
+ debug 'get-login-3 request_token: %s' % request_token.inspect
314
317
  redirect request_token.authorize_url
315
318
  end
316
319
 
317
320
  # Expire the JIRA session
318
321
  get '/logout' do
319
- # $stderr.puts 'get-/logout'
320
- session.delete(:jira_auth)
321
- session.delete(:request_token)
322
- session.delete(:request_secret)
323
- session.delete(:back_to)
322
+ debug 'get-/logout'
323
+ session.clear
324
324
  redirect '/'
325
325
  end
326
326
 
@@ -334,6 +334,14 @@ module OpsAsk
334
334
  else ; '%s %ss'
335
335
  end % [ n, item ]
336
336
  end
337
+
338
+ def debug message
339
+ logger.debug JSON.generate({
340
+ message: message,
341
+ myself: @myself,
342
+ me: @me
343
+ })
344
+ end
337
345
  end
338
346
 
339
347
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opsask
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor