aptible-resource 0.2.3 → 0.2.4

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: 03c14911033f9dd23c815dc816b43a418ac9ce54
4
- data.tar.gz: de6b7c5e169afa2b016b40de4336a144adec998f
3
+ metadata.gz: e6dd09f09c123aa97db1dbc12164bf4de42839dc
4
+ data.tar.gz: 612245ce2f669992f48d517265711902183063ba
5
5
  SHA512:
6
- metadata.gz: ca1f047e498cb48028a4f458863643157cd831984f4576cda701132f74db2a5d26dddd4793db5e9307d9db8114dfd8c7a0728504e95e352d40df7ad045ec86bd
7
- data.tar.gz: fa2eba2e5bd33f31f3abd1df397eeacf2f1a327ce3abd3b64a74f242244d310187e3fa4065683330a4f8032c5373de64a5c1509b3443307bfe0c5c020e039374
6
+ metadata.gz: 8cfeca915e75863425e7cf47a87d3ea16182a081d432d13aa95c5fd7e1803f21343fad1049219093b377e6e743a5922c07bc1c59ad980c7cb3830b15b267e347
7
+ data.tar.gz: 9833ece6f2f41875f380241e0119b7d5abdd988719ac8a194208211269327616365bc559a2846fe69c4fe861fdee4c900458872ed1d4d6a14fb06ae8629c2bfa
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.version = Aptible::Resource::VERSION
11
11
  spec.authors = ['Frank Macreery']
12
12
  spec.email = ['frank@macreery.com']
13
- spec.description = %q(Foundation classes for Aptible resource server gems)
14
- spec.summary = %q(Foundation classes for Aptible resource server gems)
13
+ spec.description = 'Foundation classes for Aptible resource server gems'
14
+ spec.summary = 'Foundation classes for Aptible resource server gems'
15
15
  spec.homepage = 'https://github.com/aptible/aptible-resource'
16
16
  spec.license = 'MIT'
17
17
 
@@ -7,12 +7,11 @@ module Aptible
7
7
 
8
8
  # TODO: Only reference _type
9
9
  # See https://github.com/aptible/auth.aptible.com/issues/61
10
- if (type = object['_type'] || object['type'])
11
- if type.respond_to?(:camelize)
12
- type.camelize
13
- else
14
- type[0].upcase + type[1..-1]
15
- end
10
+ return nil unless (type = object['_type'] || object['type'])
11
+ if type.respond_to?(:camelize)
12
+ type.camelize
13
+ else
14
+ type[0].upcase + type[1..-1]
16
15
  end
17
16
  end
18
17
  end
@@ -1,5 +1,6 @@
1
1
  require 'fridge'
2
2
  require 'active_support/inflector'
3
+ require 'active_support/core_ext'
3
4
  require 'date'
4
5
 
5
6
  # Require vendored HyperResource
@@ -39,6 +40,11 @@ module Aptible
39
40
  resource.send(basename).entries
40
41
  end
41
42
 
43
+ def self.where(options = {})
44
+ params = options.except(:token, :root, :namespace, :headers)
45
+ find_by_url("#{collection_href}?#{params.to_query}", options).entries
46
+ end
47
+
42
48
  def self.find(id, options = {})
43
49
  find_by_url("#{collection_href}/#{id}", options)
44
50
  end
@@ -147,20 +153,23 @@ module Aptible
147
153
  end
148
154
  end
149
155
 
156
+ # rubocop:disable MethodLength
150
157
  def initialize(options = {})
151
158
  if options.is_a?(Hash)
152
159
  self.token = options[:token]
153
160
 
154
161
  options[:root] ||= root_url
155
162
  options[:namespace] ||= namespace
156
- options[:headers] ||= { 'Content-Type' => 'application/json' }
163
+ options[:headers] ||= {}
157
164
  options[:headers].merge!(
165
+ 'Content-Type' => 'application/json',
158
166
  'Authorization' => "Bearer #{bearer_token}"
159
167
  ) if options[:token]
160
168
  end
161
169
 
162
170
  super(options)
163
171
  end
172
+ # rubocop:enable MethodLength
164
173
 
165
174
  def adapter
166
175
  self.class.adapter
@@ -218,6 +227,10 @@ module Aptible
218
227
  def errors
219
228
  @errors ||= Aptible::Resource::Errors.new
220
229
  end
230
+
231
+ def error_html
232
+ errors.full_messages.join('<br />')
233
+ end
221
234
  end
222
235
  # rubocop:enable ClassLength
223
236
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Resource
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-03 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri_template