ncore 1.2.0 → 1.2.1

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: ef94f6b1037f27d30294786117a465ad2f884c18
4
- data.tar.gz: 105361f8d4f0cc2639078bc48053d20ddaa6e9f1
3
+ metadata.gz: ec1bdffa679ca20445f4b48c4f7dd4cfcf6b2076
4
+ data.tar.gz: 7403cc773dc32014c0b9717fcb8d8fac6c433eb3
5
5
  SHA512:
6
- metadata.gz: 14c748af57d663dcf4b7881e1ed6cda3df04105310a3858095e853bc7be8f5b1cd9016ec5c10f498b1de0736f3b501658947ed490f906c219461938378266d0a
7
- data.tar.gz: 311dee415e76cbb165e19114502b47124b1c5c9d8cc819ca8998e9b8d59cafe8efd2c4cf3bf52a1e6336950f036e22d412907198f90580e736891d1a73d97ac2
6
+ metadata.gz: 4d98693b19a89b725457faf351417e64d150964a8dfddb17d49535479f7b4410836dd47f6c90da96d2ea18b8073ab172ff9d5e7a2c022f2283caa6c55eb36318
7
+ data.tar.gz: b187d445f6273acc6b777a0adad97dfaeb41541573c3566f3d7c4d78fcbfe3f3e519df4d90dc9a178676e3e13a33af05d43ef2947b7a75f1de46fdce84be5687
@@ -0,0 +1,15 @@
1
+ #### 1.2.1
2
+
3
+ - Connection errors should raise NCore::ConnectionError
4
+
5
+ #### 1.2.0
6
+
7
+ - Add delete association methods
8
+
9
+ #### 1.1.0
10
+
11
+ - Fix compatibility with ActiveModel 4.2
12
+
13
+ #### 1.0.0
14
+
15
+ - Initial release
@@ -36,8 +36,6 @@ module NCore
36
36
  obj = find_#{assoc.singularize}(aid)
37
37
  obj.update(params)
38
38
  obj
39
- # raise UnsavedObjectError unless id
40
- # #{klass}.update(aid, {#{key}: id}.reverse_merge(params), api_creds)
41
39
  end
42
40
  M4
43
41
  class_eval <<-M5, __FILE__, __LINE__+1
@@ -58,8 +56,6 @@ module NCore
58
56
  obj = find_#{assoc.singularize}(aid)
59
57
  obj.delete(params)
60
58
  obj
61
- # raise UnsavedObjectError unless id
62
- # #{klass}.delete(aid, {#{key}: id}.reverse_merge(params), api_creds)
63
59
  end
64
60
  M7
65
61
  class_eval <<-M8, __FILE__, __LINE__+1
@@ -70,34 +66,6 @@ module NCore
70
66
  M8
71
67
  end
72
68
 
73
- # def embeds_many(assoc)
74
- # assoc = assoc.to_s
75
- # class_eval <<-M1, __FILE__, __LINE__+1
76
- # def #{assoc}(params={})
77
- # @attribs[:#{assoc}] ||= []
78
- # end
79
- # M1
80
- # class_eval <<-M2, __FILE__, __LINE__+1
81
- # def find_#{assoc.singularize}(aid)
82
- # #{assoc}.detect{|o| o.id == aid} || raise(RecordNotFound)
83
- # end
84
- # M2
85
- #
86
- # # appease activerecord:
87
- # class_eval <<-M3, __FILE__, __LINE__+1
88
- # def #{assoc}_attributes=(v)
89
- # v = v.values if v.is_a?(Hash)
90
- # if v.is_a?(Array)
91
- # v.each{|o| o['object'] ||= '#{assoc.singularize}' if o.is_a?(Hash) }
92
- # @attribs[:#{assoc}] = self.class.interpret_type(v, api_creds)
93
- # else
94
- # @attribs[:#{assoc}] = v
95
- # end
96
- # end
97
- # alias :#{assoc}= :#{assoc}_attributes=
98
- # M3
99
- # end
100
-
101
69
  def belongs_to(assoc, klass=nil)
102
70
  assoc = assoc.to_s
103
71
  klass ||= "#{module_name}::#{assoc.camelize}"
@@ -105,7 +73,6 @@ module NCore
105
73
  attr :#{assoc}_id
106
74
  def #{assoc}(params={})
107
75
  return nil unless #{assoc}_id
108
- # @attribs[:#{assoc}] ||= #{klass}.find(#{assoc}_id, params, api_creds)
109
76
  if params.empty?
110
77
  # only cache unfiltered, default api call
111
78
  @attribs[:#{assoc}] ||= #{klass}.find(#{assoc}_id, {}, api_creds)
@@ -178,10 +178,13 @@ module NCore
178
178
  rescue Errno::ECONNREFUSED
179
179
  raise parent::ConnectionError, "Connection error for #{host_for_error rest_opts[:url]} : check network and DNS or visit #{status_page}."
180
180
  rescue Excon::Errors::SocketError => e
181
- if e.message =~ /Unable to verify certificate/
181
+ case e.message
182
+ when /Unable to verify certificate/
182
183
  raise parent::ConnectionError, "Unable to verify certificate for #{host_for_error rest_opts[:url]} : verify URL or disable SSL certificate verification (insecure)."
183
- elsif e.message =~ /Name or service not known/
184
+ when /Name or service not known/
184
185
  raise parent::ConnectionError, "DNS error for #{host_for_error rest_opts[:url]} : check network and DNS or visit #{status_page}."
186
+ when /Errno::ECONNREFUSED/
187
+ raise parent::ConnectionError, "Connection error for #{host_for_error rest_opts[:url]} : check network and DNS or visit #{status_page}."
185
188
  else
186
189
  raise e
187
190
  end
@@ -200,9 +203,7 @@ module NCore
200
203
  raise parent::AccessDenied, "Access denied; check your API credentials and permissions."
201
204
  when 404
202
205
  raise parent::RecordNotFound
203
- # when 409
204
- # raise parent::Conflict
205
- when 422, 409 # todo: is this really universally true (check both AR + PS)
206
+ when 422
206
207
  # pass through
207
208
  when 429
208
209
  raise parent::RateLimited
@@ -48,13 +48,8 @@ module NCore
48
48
 
49
49
  mattr_accessor :logger
50
50
  self.logger = Logger.new(STDOUT)
51
- # self.logger.level = Logger::DEBUG
52
51
  end
53
52
 
54
- # def credentials=(v)
55
- # super v.with_indifferent_access
56
- # end
57
-
58
53
  end
59
54
 
60
55
  end
@@ -1,3 +1,3 @@
1
1
  module NCore
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -10,9 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["hello@notioneer.com"]
11
11
  spec.description = %q{NCore - Ruby gem useful for building REST API clients}
12
12
  spec.summary = %q{NCore - Gem for building REST API clients}
13
- # spec.homepage = "https://github.com/notioneer/ncore-ruby"
14
13
  spec.homepage = 'http://notioneer.com/'
15
- # spec.homepage = 'https://authrocket.com/'
16
14
  spec.license = "MIT"
17
15
 
18
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,6 +94,7 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
+ - CHANGELOG.md
97
98
  - Gemfile
98
99
  - LICENSE
99
100
  - README.md