grape-hypertext_application_language 0.1.1 → 0.1.2

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: a0270f7fa287e3892d4b57867ba1ced85b3e524e
4
- data.tar.gz: 508c56ced3f8c7c52ed3cc6c537ffbb79a182372
3
+ metadata.gz: 0a2d086d0dfd63bb07696c1a7cdb4ca7f7a59a02
4
+ data.tar.gz: 5c0ff4939cac33e3b30280e2fb3a10dd216dcf97
5
5
  SHA512:
6
- metadata.gz: c8081adaec26fb9043931e1272e106d9f72ad2724b8da8123ba7cde3cd230954d0c782e43e2c6e53b0abc887cda355d4d6f59799b0a1032cd0ff6427c8167fe8
7
- data.tar.gz: 6b1af1d01b958aa8494679bae0d6bf85450f6ee882a634720aacd3ac1938a4bbc8bccc254d82b8177d50a92a4877da119fccef01cbc30914a70959165f7dfaea
6
+ metadata.gz: 0902df0e5337c4de29cd437909cd24ab2be0d3b1be14c4ae0363dfa64cbe0923c7e060219d8f9ce93c6ecbdfcb1e08daa93cf956309c802396b5e8bdd3512c74
7
+ data.tar.gz: d281a8e7d306cbff3f4bef2ab83e98dd8cfdac0b409f9937a2946e997ca9064e18b0d94c27c549c1fb62b74201d05c655969a27047fd34bc9e6f47332fcd3445
data/.gitignore CHANGED
@@ -1 +1,6 @@
1
+ # Ignore everything beneath the +pkg+ folder. The Bundler +build+ task places
2
+ # +*.gem+ packages in this folder.
1
3
  pkg
4
+
5
+ # Ignore the hidden folder where Yard builds documentation.
6
+ .yardoc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-hypertext_application_language (0.1.1)
4
+ grape-hypertext_application_language (0.1.2)
5
5
  addressable
6
6
  grape
7
7
  hypertext_application_language
@@ -42,7 +42,7 @@ GEM
42
42
  ice_nine (0.11.1)
43
43
  json (1.8.3)
44
44
  json (1.8.3-java)
45
- minitest (5.8.2)
45
+ minitest (5.8.3)
46
46
  multi_json (1.11.2)
47
47
  multi_xml (0.5.5)
48
48
  rack (1.6.4)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'grape-hypertext_application_language'
3
- spec.version = '0.1.1'
3
+ spec.version = '0.1.2'
4
4
  spec.summary = %q{Grape extensions for Hypertext Application Language}
5
5
  spec.description = %q{}
6
6
  spec.homepage = 'http://stateless.co/hal_specification.html'
@@ -28,16 +28,18 @@ module Grape::Formatter::Hal
28
28
  # representation conforming to a HAL collection where the collection
29
29
  # representation includes links to the elements in the collection as well as
30
30
  # embedding the nested resources. Uses the request path for the self link;
31
- # and uses the path, less its leading slash, as the relation.
31
+ # and uses the last element of the path as the relation. Uses duck typing to
32
+ # determine if the body is an array or not. If the body responds to +each+
33
+ # then it assumes that the response is some kind of enumeration.
32
34
  def self.call(body, env)
33
35
  unless body.is_a?(HypertextApplicationLanguage::Representation)
34
- if body.respond_to?(:first)
36
+ if body.respond_to?(:each)
35
37
  representation = HypertextApplicationLanguage::Representation.new
36
38
 
37
- rel = env['PATH_INFO'][1..-1]
38
39
  href = env['REQUEST_PATH']
39
40
  representation.with_link(HypertextApplicationLanguage::Link::SELF_REL, href)
40
41
 
42
+ rel = env['PATH_INFO'].split('/').last
41
43
  body.each do |resource|
42
44
  continue unless resource.respond_to?(:to_hal)
43
45
  resource_representation = resource.to_hal(env: env)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-hypertext_application_language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape