DPLibrary 0.0.6 → 0.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
  SHA1:
3
- metadata.gz: 6166b6bbe53de1f1767df9a4e301023800991ebc
4
- data.tar.gz: bfdd4479ec2f7b2417f8c600ca9800edda4f491d
3
+ metadata.gz: f0727bdb53be1deb64eee19342878b3ce944aa4a
4
+ data.tar.gz: 7c124cdc650f49a209110360ee42f74bda7e0005
5
5
  SHA512:
6
- metadata.gz: 09f4b32bccb5d3d194342c55db07fbe3272e8e9e3d491ca82254e386deac016d56c0a2764fb4e77d3eae92784a9fced65254fcfb5654bd8d47006377038abcb2
7
- data.tar.gz: bbe92b8c27c1c15a57747e8780a9132670fafcb880c4b1cb22e53ad0303c368976cdd32ee3d9bccce3090fdc8ba6f047ed4c2af832a460c3d6a37adc6beec51d
6
+ metadata.gz: 4f6b92a0a34d0f766c4d78b796e54a92764075c1839912b6a1b0aeb2151c78c0ec2035fd2ef0245b01e08858f2a6a363e534b4490b209025e78ac2d47ee9c5b5
7
+ data.tar.gz: ab5cc718d403757caef6ecf768853cca5deea3b04beb37b1bb02d954f75d292c1ae4d2daf6ec2c42738c9a474e16ba56087e333153abeff7311711b3447216e2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.2.2
data/README.md CHANGED
@@ -67,8 +67,14 @@ Let's get started!
67
67
 
68
68
  ## Attributes for documents
69
69
  :id, :url, :source, :title, :description, :subject, :language, :format,
70
- :type, :publisher, :creaetor, :provider, :collection, :score,
71
- :original_record
70
+ :type, :publisher, :creaetor, :provider, :collection, :intermediate_provider,
71
+ :score, :original_record
72
+ ```
73
+
74
+ You can retrieve multiple records by ID by passing an array for the `:id`
75
+ parameter, like this:
76
+ ```
77
+ @documents_collection = DPLibrary::DocumentCollection.new({id: ['id1', 'id2']})
72
78
  ```
73
79
 
74
80
  Now there are many types of parameters you can pass in the
@@ -113,6 +119,7 @@ isShownAt
113
119
  object
114
120
  provider.@id
115
121
  provider.name
122
+ intermediateProvider
116
123
  ```
117
124
 
118
125
  ## ToDo's
@@ -13,6 +13,7 @@ module DPLibrary
13
13
  :creator,
14
14
  :provider,
15
15
  :collection,
16
+ :intermediate_provider,
16
17
  :original_record,
17
18
  :score
18
19
 
@@ -25,6 +26,7 @@ module DPLibrary
25
26
  self.id = hash['id']
26
27
  self.url = hash['isShownAt']
27
28
  self.source = hash['dataProvider']
29
+ self.intermediate_provider = hash['intermediateProvider']
28
30
  self.title = hash['sourceResource']['title']
29
31
  self.description = hash['sourceResource']['description']
30
32
  self.subject = hash['sourceResource']['subject']
@@ -14,8 +14,30 @@ module DPLibrary
14
14
  end
15
15
 
16
16
  private
17
+
17
18
  def find(parameters)
18
- get('items', parameters)
19
+ p = path!(parameters)
20
+ get(p, parameters)
21
+ end
22
+
23
+ ##
24
+ # Return the appropriate URI path, which depends upon whether IDs are given
25
+ #
26
+ # Remove an `id' parameter from the parameters if it exists, because it
27
+ # will become part of the path, and should not be included in the
28
+ # querystring parameters.
29
+ #
30
+ # @param [Hash] parameters Query parameters
31
+ # @return [String]
32
+ # @api private
33
+ #
34
+ def path!(parameters)
35
+ if parameters.include? :id
36
+ id = parameters.delete(:id)
37
+ "items/#{Array(id).join(',')}"
38
+ else
39
+ 'items'
40
+ end
19
41
  end
20
42
 
21
43
  def set_method(values)
@@ -1,3 +1,3 @@
1
1
  module DPLibrary
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1 +1,41 @@
1
1
  require 'spec_helper'
2
+
3
+ describe DPLibrary::DocumentCollection do
4
+ let (:base_response_json) do
5
+ { 'count' => 0, 'start' => 1, 'limit' => 1, 'docs' => [] }
6
+ end
7
+ let (:response_body) { JSON.dump(base_response_json) }
8
+
9
+ describe '#initialize' do
10
+
11
+ context 'with a string :id parameter' do
12
+ it 'results in a request for items/<id>' do
13
+ expect_any_instance_of(described_class)
14
+ .to receive(:get)
15
+ .with('items/1abc', {})
16
+ .and_return(response_body)
17
+ dc = described_class.new(id: '1abc')
18
+ end
19
+ end
20
+
21
+ context 'with an array :id parameter' do
22
+ it 'results in a request for items/<id>,<id>' do
23
+ expect_any_instance_of(described_class)
24
+ .to receive(:get)
25
+ .with('items/1abc,2def', {})
26
+ .and_return(response_body)
27
+ dc = described_class.new(id: ['1abc', '2def'])
28
+ end
29
+ end
30
+
31
+ context 'with no :id parameter' do
32
+ it 'results in a request for "items" with querystring params' do
33
+ expect_any_instance_of(described_class)
34
+ .to receive(:get)
35
+ .with('items', {:'sourceResource.title' => 'ducks'})
36
+ .and_return(response_body)
37
+ dc = described_class.new(:'sourceResource.title' => 'ducks')
38
+ end
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DPLibrary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - phereford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  requirements: []
196
196
  rubyforge_project:
197
- rubygems_version: 2.5.1
197
+ rubygems_version: 2.4.5
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: A ruby gem that is an API wrapper for the DPLA