v2gpti 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,13 +8,19 @@ require 'json'
8
8
 
9
9
  require 'awesome_print' # for debug output
10
10
 
11
+ class TogglException < StandardError
12
+ def initialize(message)
13
+ @message = "[Toggl] #{message}"
14
+ end
15
+ end
16
+
11
17
  class Toggl
12
18
  attr_accessor :conn, :debug
13
19
 
14
20
  def initialize(username=nil, password='api_token', debug=nil)
15
21
  self.debug_on(debug) if !debug.nil?
16
22
  if (password.to_s == 'api_token' && username.to_s == '')
17
- toggl_api_file = self.toggl_file
23
+ toggl_api_file = self.toggl_file
18
24
  username = IO.read(toggl_api_file)
19
25
 
20
26
  end
@@ -385,26 +391,36 @@ class Toggl
385
391
  # ap full_res.env if @debug
386
392
  res = JSON.parse(full_res.env[:body])
387
393
  res.is_a?(Array) || res['data'].nil? ? res : res['data']
394
+ rescue Faraday::ClientError => e
395
+ raise TogglException, "GET #{resource} Failed"
388
396
  end
389
397
 
390
398
  def post(resource, data)
391
399
  puts "POST #{resource} / #{data}" if @debug
392
400
  full_res = self.conn.post(resource, JSON.generate(data))
393
- ap full_res.env if @debug
401
+ #ap full_res.env if @debug
394
402
  if (200 == full_res.env[:status]) then
395
403
  res = JSON.parse(full_res.env[:body])
396
404
  res['data'].nil? ? res : res['data']
397
405
  else
398
406
  puts(full_res.env[:body])
399
407
  end
408
+ rescue Faraday::ClientError => e
409
+ raise TogglException, "POST #{resource} / #{data} Failed"
400
410
  end
401
411
 
402
412
  def put(resource, data)
403
413
  puts "PUT #{resource} / #{data}" if @debug
404
414
  full_res = self.conn.put(resource, JSON.generate(data))
405
415
  # ap full_res.env if @debug
406
- res = JSON.parse(full_res.env[:body])
407
- res['data'].nil? ? res : res['data']
416
+ if (200 == full_res.env[:status]) then
417
+ res = JSON.parse(full_res.env[:body])
418
+ res['data'].nil? ? res : res['data']
419
+ else
420
+ puts(full_res.env[:body])
421
+ end
422
+ rescue Faraday::ClientError => e
423
+ raise TogglException, "PUT #{resource} / #{data} Failed"
408
424
  end
409
425
 
410
426
  def delete(resource)
@@ -412,6 +428,8 @@ class Toggl
412
428
  full_res = self.conn.delete(resource)
413
429
  # ap full_res.env if @debug
414
430
  (200 == full_res.env[:status]) ? "" : puts(full_res.env[:body])
431
+ rescue Faraday::ClientError => e
432
+ raise TogglException, "DELETE #{resource} Failed"
415
433
  end
416
434
 
417
- end
435
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: v2gpti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Wolski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-07 00:00:00.000000000 Z
13
+ date: 2014-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -124,6 +124,20 @@ dependencies:
124
124
  - - ~>
125
125
  - !ruby/object:Gem::Version
126
126
  version: 0.1.8
127
+ - !ruby/object:Gem::Dependency
128
+ name: os
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.9.6
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ~>
139
+ - !ruby/object:Gem::Version
140
+ version: 0.9.6
127
141
  - !ruby/object:Gem::Dependency
128
142
  name: bundler
129
143
  requirement: !ruby/object:Gem::Requirement
@@ -214,9 +228,13 @@ email: jeff@xxxxxxxxx.com
214
228
  executables:
215
229
  - git-deliver
216
230
  - git-finish
231
+ - git-newbug
232
+ - git-newfeature
233
+ - git-qa
217
234
  - git-release
218
235
  - git-report
219
236
  - git-start
237
+ - git-uat
220
238
  extensions: []
221
239
  extra_rdoc_files: []
222
240
  files:
@@ -225,14 +243,21 @@ files:
225
243
  - README.md
226
244
  - bin/git-deliver
227
245
  - bin/git-finish
246
+ - bin/git-newbug
247
+ - bin/git-newfeature
248
+ - bin/git-qa
228
249
  - bin/git-release
229
250
  - bin/git-report
230
251
  - bin/git-start
252
+ - bin/git-uat
231
253
  - lib/git-pivotal-tracker-integration/command/base.rb
232
254
  - lib/git-pivotal-tracker-integration/command/command.rb
233
255
  - lib/git-pivotal-tracker-integration/command/configuration.rb
234
256
  - lib/git-pivotal-tracker-integration/command/deliver.rb
235
257
  - lib/git-pivotal-tracker-integration/command/finish.rb
258
+ - lib/git-pivotal-tracker-integration/command/newbug.rb
259
+ - lib/git-pivotal-tracker-integration/command/newfeature.rb
260
+ - lib/git-pivotal-tracker-integration/command/prepare-commit-msg-win.sh
236
261
  - lib/git-pivotal-tracker-integration/command/prepare-commit-msg.sh
237
262
  - lib/git-pivotal-tracker-integration/command/release.rb
238
263
  - lib/git-pivotal-tracker-integration/command/report.rb
@@ -274,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
299
  version: '0'
275
300
  requirements: []
276
301
  rubyforge_project:
277
- rubygems_version: 2.2.2
302
+ rubygems_version: 2.4.1
278
303
  signing_key:
279
304
  specification_version: 4
280
305
  summary: Git commands for integration with Pivotal Tracker