redminerb 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9f4f24f3042eab942ba77d07143a61b70bbed04
4
- data.tar.gz: 83f92876f8e3f995bf552e42edefd631f9a59c46
3
+ metadata.gz: 347a49accfc5f3a6e6d4eea8e48976443773c6ab
4
+ data.tar.gz: 1352e7491d1e6675829e95e2b1c94ade493a9aa3
5
5
  SHA512:
6
- metadata.gz: d077f662066d6838ab71cd26877358deb77a4d87980f14b2f702f455d5fabd7f6693db270daa9493112dd24705067e0be67bca386dd1a80fa4f562f7e2a8b315
7
- data.tar.gz: a64a0ee960d56e34ee43282c6a2712cf20266b87c111c7fc3a6aeb97377d98ca7961b106ee519a038573b5bf4e4c224b0429bc29b0cef3c1f413614f92d8a423
6
+ metadata.gz: a98f2a26498d4a7a1fce4b1f160901d755114b4b9d62d855389648657152144a06967688029fca52e0894e6b541e5bbb45761ca80c5490ba08a9c7717a0df600
7
+ data.tar.gz: e5958d2ad1fa6406815482acfb90068fa68e0f7eff5f3e925fdedc8d3248f7ef4c12df4e7c2b525be4696e392b2cbbd1575d448f31854fd38038d026c5107cfc
@@ -1,3 +1,7 @@
1
+ == 0.6, released 2015-09-28
2
+
3
+ * +templates/issue.erb+ uses a recursive OStruct for internal objects -letting us for example say +issue.author.name+ instead of +issue.author['name']+
4
+
1
5
  == 0.5, released 2015-09-23
2
6
 
3
7
  * Local or home +.redminerb/templates+ directory for resource output customizations
data/README.md CHANGED
@@ -45,7 +45,7 @@ For example, this `~/.redminerb.yml`:
45
45
  url: http://localhost:3000/
46
46
  api_key: 69b47d74e36a6757bac5d45f8398dd23bfa8f52c
47
47
 
48
- Would be the same as having the following in your environment (declared in `.bashrc`, for example):
48
+ Would be the same as having the following in your environment (declared in `~/.bashrc`, for example):
49
49
 
50
50
  export REDMINERB_URL=http://localhost:3000/
51
51
  export REDMINERB_API_KEY=69b47d74e36a6757bac5d45f8398dd23bfa8f52c
@@ -9,6 +9,7 @@ require_relative 'redminerb/template'
9
9
  # Main module
10
10
  module Redminerb
11
11
  class UninitializedError < StandardError; end
12
+ class NotFoundError < StandardError; end
12
13
 
13
14
  module_function
14
15
 
@@ -50,6 +51,6 @@ module Redminerb
50
51
  end
51
52
 
52
53
  def separator
53
- @separator ||= ('-' * TermInfo.screen_columns).green
54
+ @separator ||= ('' * TermInfo.screen_columns).green
54
55
  end
55
56
  end
@@ -20,12 +20,12 @@ module Redminerb
20
20
  # response parsed as JSON.
21
21
  def get_json(path, params = {})
22
22
  Redminerb.init_required!
23
- res = @connection.get do |req|
24
- req.url path
25
- req.headers['Content-Type'] = 'application/json'
26
- req.body = params.to_json if params.any?
23
+ res = _get(path, params)
24
+ if res.status == 404
25
+ fail Redminerb::NotFoundError, path
26
+ else
27
+ JSON.parse(res.body)
27
28
  end
28
- JSON.parse(res.body)
29
29
  rescue JSON::ParserError => e
30
30
  raise e, "HTTP status code #{res.status}"
31
31
  end
@@ -40,7 +40,7 @@ module Redminerb
40
40
  end
41
41
  end
42
42
 
43
- # It raises an exception giving the validation messages for 422 responses
43
+ # It raises an exception giving the validation messages for 422 responses.
44
44
  def self.raise_error!(res)
45
45
  if res.status == 422
46
46
  begin
@@ -53,5 +53,15 @@ module Redminerb
53
53
  fail StandardError, "ERROR (status code #{res.status})"
54
54
  end
55
55
  end
56
+
57
+ private
58
+
59
+ def _get(path, params)
60
+ @connection.get do |req|
61
+ req.url path
62
+ req.headers['Content-Type'] = 'application/json'
63
+ req.body = params.to_json if params.any?
64
+ end
65
+ end
56
66
  end
57
67
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) The Cocktail Experience S.L. (2015)
2
- require 'ostruct'
2
+ require 'recursive-open-struct'
3
3
 
4
4
  module Redminerb
5
5
  # Issues resource wrapper
@@ -28,7 +28,7 @@ module Redminerb
28
28
  # puts "#{issue.id}: #{issue.subject}"
29
29
  #
30
30
  def read(id)
31
- OpenStruct.new Redminerb.client.get_json("/issues/#{id}.json")['issue']
31
+ RecursiveOpenStruct.new Redminerb.client.get_json("/issues/#{id}.json")['issue']
32
32
  end
33
33
  end
34
34
  end
@@ -1,4 +1,4 @@
1
1
  # Copyright (c) The Cocktail Experience S.L. (2015)
2
2
  module Redminerb
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  end
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'colorize'
35
35
  spec.add_dependency 'faraday'
36
36
  spec.add_dependency 'ruby-terminfo'
37
+ spec.add_dependency 'recursive-open-struct'
37
38
 
38
39
  spec.add_development_dependency 'bundler', '~> 1.10'
39
40
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,10 +1,10 @@
1
1
  <%= Redminerb.separator %>
2
- <%= "[#{issue.tracker['name']}]".blue + "[#{issue.project['name']}:##{issue.id}]".green %> <%= issue.subject %>
2
+ <%= "[#{issue.tracker.name}]".blue + "[#{issue.project.name}:##{issue.id}]".green %> <%= issue.subject %>
3
3
  <%= Redminerb.separator %>
4
- Author: <%= issue.author['name'].red %>
5
- Assigned to: <%= issue.assigned_to['name'].red %>
6
- Status: <%= issue.status['name'].red %>
7
- Priority: <%= issue.priority['name'].red %>
4
+ Author: <%= issue.author.name.red %>
5
+ Assigned to: <%= issue.assigned_to.name.red %>
6
+ Status: <%= issue.status.name.red %>
7
+ Priority: <%= issue.priority.name.red %>
8
8
  <%= Redminerb.separator %>
9
9
  <%= issue.description %>
10
10
  <%= Redminerb.separator %>
@@ -1,7 +1,7 @@
1
1
  <%= Redminerb.separator %>
2
2
  <%= user.login.upcase.green %>
3
3
  <%= Redminerb.separator %>
4
- * Id: <%= user.id.to_s.blue %>
4
+ <%= "Id: #{user.id}".blue %>
5
5
  * Firstname: <%= user.firstname.red %>
6
6
  * Lastname: <%= user.lastname.red %>
7
7
  * Login: <%= user.login.red %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redminerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Garcia Samblas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: recursive-open-struct
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement