govdelivery-tms 0.8.9 → 0.8.10

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: beaa9bf643b1ed8a2db0bebfcc0c303e1a9eec63
4
- data.tar.gz: fa153c967d58070a3ee1cdc9a1d0777b8f7f2990
3
+ metadata.gz: 628273a3b62f2225d9cee7f37734a94c7fc03da2
4
+ data.tar.gz: f085b0197b197519a0e60c330072a821038f3335
5
5
  SHA512:
6
- metadata.gz: 30130e14bba971fd996209ea4918212be4bfcfea986a322ad68dc9c4d3ab246be61ea6dd78b6531e7fbc813563aa392125d083b27ef217e75c3582bf11f8818a
7
- data.tar.gz: 179a63f71c4ad59a988d59b0ad1675d9fcc37cf2afa03084ef361fa16de91c45eb5ab6f5ffa32bc048325f2bedfc025422f159537849100ce86e25946178fcbe
6
+ metadata.gz: 9e1c2de8489ec577db76e9b6a5c0bbe920c4d2a7310b76e8edaabaf7849ae72605219ffae9162095f5309aff91903c527762dd8126bc1bf094ea7bc118198491
7
+ data.tar.gz: 6e24bd50c6902f8236aa828f266c9b0e13ee2f6ee46608f3fdfab0dc915948f25d751aee4c2a6e311386615ea25d2484a4d6eed285b548475122e6715655a78a
@@ -90,8 +90,8 @@ class GovDelivery::TMS::Client
90
90
  private
91
91
 
92
92
  def setup_logging(debug)
93
- logger = Logger.new(STDOUT)
94
- logger.level = debug ? Logger::DEBUG : Logger::INFO
95
- logger
93
+ Logger.new(STDOUT).tap do |logger|
94
+ logger.level = debug ? Logger::DEBUG : Logger::INFO
95
+ end
96
96
  end
97
97
  end
@@ -30,7 +30,7 @@ module GovDelivery::TMS::Util
30
30
  subresources[rel] = klass.new(client, href)
31
31
  setup_subresource(link)
32
32
  else
33
- logger.info("Don't know what to do with link rel '#{rel}' for class #{self.class}!") if self.respond_to?(:logger)
33
+ logger.info("Don't know what to do with link rel '#{rel}' for class #{self.class}!") if self.respond_to?(:logger) && logger
34
34
  end
35
35
 
36
36
  end
@@ -38,7 +38,11 @@ module GovDelivery::TMS::Util
38
38
  end
39
39
 
40
40
  def relation_class(rel)
41
- ::GovDelivery::TMS.const_get(classify(rel)) rescue nil
41
+ ::GovDelivery::TMS.const_get(classify(rel)).tap do |klass|
42
+ return nil unless klass.name =~ /GovDelivery::TMS/
43
+ end
44
+ rescue NameError
45
+ nil
42
46
  end
43
47
 
44
48
  def setup_subresource(link)
@@ -1,5 +1,5 @@
1
1
  module GovDelivery
2
2
  module TMS #:nodoc:
3
- VERSION = '0.8.9'
3
+ VERSION = '0.8.10'
4
4
  end
5
5
  end
data/spec/client_spec.rb CHANGED
@@ -1,8 +1,30 @@
1
1
  require 'spec_helper'
2
2
  describe GovDelivery::TMS::Client do
3
+ let(:links) {
4
+ [{'self' => '/'},
5
+ {'horse' => '/horses/new'},
6
+ {'rabbits' => '/rabbits'}]
7
+ }
8
+ context 'a client with a missing rel' do
9
+ before do
10
+ response = double('response', status: 200,
11
+ body: {
12
+ 'sid' => 'abcd12345',
13
+ '_links' => (links + [{'missing' => '/fail'}])})
14
+ @raw_connection = double('raw_connection', get: response)
15
+ @connection = allow(GovDelivery::TMS::Connection).to receive(:new).and_return(double('connection', connection: @raw_connection))
16
+ end
17
+ it 'should not blow up or create a relation' do
18
+ @client = GovDelivery::TMS::Client.new('auth_token', api_root: 'null_url')
19
+ expect{@client.missing}.to raise_error(NoMethodError)
20
+ end
21
+ end
3
22
  context 'creating a new client' do
4
23
  before do
5
- response = double('response', status: 200, body: {'sid' => 'abcd12345', '_links' => [{ 'self' => '/' }, { 'horse' => '/horses/new' }, { 'rabbits' => '/rabbits' }] })
24
+ response = double('response', status: 200,
25
+ body: {
26
+ 'sid' => 'abcd12345',
27
+ '_links' => links})
6
28
  @raw_connection = double('raw_connection', get: response)
7
29
  @connection = allow(GovDelivery::TMS::Connection).to receive(:new).and_return(double('connection', connection: @raw_connection))
8
30
  @client = GovDelivery::TMS::Client.new('auth_token', api_root: 'null_url')
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,10 @@ class GovDelivery::TMS::Horse
6
6
  end
7
7
  end
8
8
 
9
+ module Missing
10
+ # this is for testing missing relations that expose strange const_get behavior
11
+ end
12
+
9
13
  class GovDelivery::TMS::Rabbits
10
14
  def initialize(_client, _href)
11
15
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govdelivery-tms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - GovDelivery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
16
  - - '>='
23
17
  - !ruby/object:Gem::Version
24
18
  version: '0'
19
+ name: activesupport
25
20
  prerelease: false
26
21
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: faraday
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
24
  - - '>='
32
25
  - !ruby/object:Gem::Version
33
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
30
  - - '>='
37
31
  - !ruby/object:Gem::Version
38
32
  version: '0'
33
+ name: faraday
39
34
  prerelease: false
40
35
  type: :runtime
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
38
  - - '>='
46
39
  - !ruby/object:Gem::Version
47
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
44
  - - '>='
51
45
  - !ruby/object:Gem::Version
52
46
  version: '0'
47
+ name: faraday_middleware
53
48
  prerelease: false
54
49
  type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
55
  description: "A reference implementation, written in Ruby,\n to\
56
56
  \ interact with GovDelivery's TMS API. The client is\n compatible\
57
57
  \ with Ruby 1.9 and 2.0. "
@@ -74,7 +74,6 @@ files:
74
74
  - lib/govdelivery/tms/instance_resource.rb
75
75
  - lib/govdelivery/tms/link_header.rb
76
76
  - lib/govdelivery/tms/logger.rb
77
- - lib/govdelivery/tms/version.rb
78
77
  - lib/govdelivery/tms/mail/delivery_method.rb
79
78
  - lib/govdelivery/tms/resource/collections.rb
80
79
  - lib/govdelivery/tms/resource/command.rb
@@ -93,6 +92,7 @@ files:
93
92
  - lib/govdelivery/tms/resource/webhook.rb
94
93
  - lib/govdelivery/tms/util/core_ext.rb
95
94
  - lib/govdelivery/tms/util/hal_link_parser.rb
95
+ - lib/govdelivery/tms/version.rb
96
96
  - spec/client_spec.rb
97
97
  - spec/command_types_spec.rb
98
98
  - spec/email_message_spec.rb
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.1.9
130
+ rubygems_version: 2.4.8
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: A ruby client to interact with the GovDelivery TMS REST API.