jsonapi-home 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 601793a236d6fba997f95f5da8d3ee6ae7db8621078b5a0ad23004718d42d52e
4
- data.tar.gz: eef20492884e0a429b1b48a678ce310fd7d9f404ffc4ec5a8984929918b62eb7
3
+ metadata.gz: dae3dce730469d379db6b92e620a703ad9a96a0383283ca534eb00377b6dc306
4
+ data.tar.gz: 334aa519caf6b30a3aa79b04aa997f4b6fff4b614f6242fa5a401f02d7c79dfd
5
5
  SHA512:
6
- metadata.gz: 89cd7ba9430afb7b818a6d0a0310349ede9d0803b88f29597b065cad632a667ac5d1b0afb61c3de8377e9381ac744dda17f7b5f32b933db1cae72ef2eafa68a1
7
- data.tar.gz: 469784ae1fd60ff93c62144aa93c04b77b08eddc6a09600022e244dbcdbf357061a16e389c9d252de6f653b1b3a00efebd887c56869c27a6bf91772383d2d581
6
+ metadata.gz: b0ecb55cca0971fca55f14fe2f9dba5ba6bee87e436cb9e134efc971031c6b7cbdfd7596ffdd98b970a010c4c91d6520ec1161e66214b1caf5dd8091a492db16
7
+ data.tar.gz: 0d448c2275db1e2390505b785813f0bb79dce856d19f1ac836f721fc550a49231f940d1fcde0368505e3a6da2bdd2e00adc214fbf264f7a820ebf0d4b55abe50
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jsonapi-home
2
2
 
3
- - [![Build](http://img.shields.io/travis-ci/krainboltgreene/jsonapi-home.svg?style=flat-square)](https://travis-ci.org/krainboltgreene/jsonapi-home)
3
+ - [![Build](http://img.shields.io/travis-ci/krainboltgreene/jsonapi-home.rb.svg?style=flat-square)](https://travis-ci.org/krainboltgreene/jsonapi-home.rb)
4
4
  - [![Downloads](http://img.shields.io/gem/dtv/jsonapi-home.svg?style=flat-square)](https://rubygems.org/gems/jsonapi-home)
5
5
  - [![Version](http://img.shields.io/gem/v/jsonapi-home.svg?style=flat-square)](https://rubygems.org/gems/jsonapi-home)
6
6
 
@@ -14,6 +14,7 @@ module JSONAPI
14
14
  def index
15
15
  realization = JSONAPI::Realizer.index(
16
16
  params,
17
+ scope: JSONAPI::Home::V1::Resource.with(main_app.routes.url_helpers.root_url),
17
18
  headers: request.headers,
18
19
  type: :jsonapi_home_resources
19
20
  )
@@ -24,6 +25,7 @@ module JSONAPI
24
25
  def show
25
26
  realization = JSONAPI::Realizer.show(
26
27
  params,
28
+ scope: JSONAPI::Home::V1::Resource.with(jsonapi_home_url),
27
29
  headers: request.headers,
28
30
  type: :jsonapi_home_resources
29
31
  )
@@ -7,11 +7,11 @@ module JSONAPI
7
7
  CREATED_AT = Time.now
8
8
  private_constant :CREATED_AT
9
9
 
10
- attr_reader :route
10
+ attr_accessor :route
11
11
  private :route
12
12
 
13
13
  def self.all
14
- routes.map(&method(:new)).select(&:valid?)
14
+ routes.map {|route| new(route: route)}.select(&:valid?)
15
15
  end
16
16
 
17
17
  def self.where(attributes)
@@ -22,6 +22,14 @@ module JSONAPI
22
22
  all.index_by(&:id).fetch(id)
23
23
  end
24
24
 
25
+ def self.with(url)
26
+ tap { @url = url }
27
+ end
28
+
29
+ def self.url
30
+ @url
31
+ end
32
+
25
33
  private_class_method def self.routes
26
34
  [
27
35
  *Rails.application.routes.routes.to_a,
@@ -29,10 +37,6 @@ module JSONAPI
29
37
  ]
30
38
  end
31
39
 
32
- def initialize(route)
33
- @route = route
34
- end
35
-
36
40
  def id
37
41
  "#{namespace}-#{version}-#{intent}"
38
42
  end
@@ -77,12 +81,6 @@ module JSONAPI
77
81
  File.join(location, path)
78
82
  end
79
83
 
80
- def location
81
- configuration.fetch(:location) ||
82
- ENV.fetch("HOME_LOCATION", nil) ||
83
- Rails.application.routes.url_helpers.root_path
84
- end
85
-
86
84
  def mediatype
87
85
  JSONAPI::MEDIA_TYPE
88
86
  end
@@ -99,6 +97,12 @@ module JSONAPI
99
97
  !route.internal && defaults.any? && controller.present? && configuration
100
98
  end
101
99
 
100
+ private def location
101
+ configuration.fetch(:location) ||
102
+ ENV.fetch("HOME_LOCATION", nil) ||
103
+ self.class.url
104
+ end
105
+
102
106
  private def payload
103
107
  route.parts.without(:format).map {|part| {part => "{#{part}}"}}.reduce(:merge) || {}
104
108
  end
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Home
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-home
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2018-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.7.6
193
+ rubygems_version: 2.7.3
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: An early implementation of JSONAPIHome, a fork of JSONHome