contentdm_api 0.2.1 → 0.3.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: 7a6a33fcbb1e545ed9c15fc211ef732c61c3d8b6
4
- data.tar.gz: 8d7d3675d3703a126b0bae9316d55b0fc21bb383
3
+ metadata.gz: a99e0e09f6f03e49d1cc865298d95210d9d64061
4
+ data.tar.gz: addb4954df2d7194eaed207298d7e4aa0e3d9504
5
5
  SHA512:
6
- metadata.gz: 6433e76f1b4bdd7694941b52e70528bd0c6dc9ede4ddb17d58489032807398405f0da0dbb84dcd66510cc4d7f49b2b0e23d072dd1b5df6ecaccc92ca7e3c20f1
7
- data.tar.gz: 69864f2865c29bc0646a070ded4acf1e6995146e141009f51e9d534ed0720cb4ad98e153cb70ade1dcb0125f1d6fa8db2a8f7c8057ddd80bd0ab20fb33cdb399
6
+ metadata.gz: e87ac286838d39786bafb05d9e6755e9d96ce9644a5fe176498e5f38fab9ad859de2436480e4ec7647fa5ada9898ca4e54487aef9243a25f2f4a103290c400fd
7
+ data.tar.gz: 66f938079601e6a7a9b92ef13d17abcbadaa07cd07e07524cd7b6f95194e22c5110acb49612fdf1d4c1ecc9fe37f282fe0739ad80cc84ec1eca879582e2b31f7
@@ -1,14 +1,23 @@
1
1
  module CONTENTdmAPI
2
2
  # A convenience method to retrive a Ruby hash of Item data from the CONTENTdm
3
- # API
3
+ # API along with an optional call to fetch Compound Object Info
4
4
  class Item
5
- attr_reader :collection, :id, :requester, :base_url, :response, :with_compound
5
+ attr_reader :collection,
6
+ :id,
7
+ :requester,
8
+ :base_url,
9
+ :response,
10
+ :with_compound,
11
+ :page
6
12
 
7
13
  # @param [String] base_url URL to the CONTENTdm API
8
14
  # "http://CdmServer.com:port/dmwebservices/index.php"
9
15
  # @param [String] collection The CONTENTdm API calls this an "alias"
10
16
  # @param [Integer] id The CONTENTdm API calls this a "pointer". It is the
11
17
  # identifier for a a given CONTENTdm item.
18
+ # @param [Boolean] with_compound Include compound object info?
19
+ # @param [Boolean] enrich_compount Fetch and merge full item info for each
20
+ # compound?
12
21
  # @param [Object] requester A class to make requests of the API.
13
22
  # @param [Object] response A class to parse API responses.
14
23
  #
@@ -19,12 +28,12 @@ module CONTENTdmAPI
19
28
  with_compound: true,
20
29
  requester: RequestBatch,
21
30
  response: Response)
22
- @collection = collection
23
- @id = id
24
- @with_compound = with_compound
25
- @requester = requester
26
- @base_url = base_url
27
- @response = response
31
+ @collection = collection
32
+ @id = id
33
+ @with_compound = with_compound
34
+ @requester = requester
35
+ @base_url = base_url
36
+ @response = response
28
37
  end
29
38
 
30
39
  # A hash of item metadata with optional compound data for the given item
@@ -32,13 +41,28 @@ module CONTENTdmAPI
32
41
  # @return [Hash] Merged responses from the dmGetItemInfo and
33
42
  # dmGetCompoundObjectInfo functions
34
43
  def metadata
35
- values.first.merge(values.last).merge('id' => "#{collection}/#{id}")
44
+ result.merge('id' => "#{collection}/#{id}")
45
+ .merge('page' => compounds(result.fetch('page', [])))
36
46
  end
37
47
 
38
48
  private
39
49
 
50
+ def result
51
+ values.first.merge(values.last)
52
+ end
53
+
54
+ def compounds(page)
55
+ return page unless with_compound
56
+ page.map do |compound|
57
+ compound.merge(self.class.new(base_url: base_url,
58
+ collection: collection,
59
+ id: compound['pageptr'],
60
+ with_compound: false).metadata)
61
+ end
62
+ end
63
+
40
64
  def remove_errors(value)
41
- (value['code'] != '-2') ? value : {}
65
+ value['code'] != '-2' ? value : {}
42
66
  end
43
67
 
44
68
  def values
@@ -54,7 +78,7 @@ module CONTENTdmAPI
54
78
  end
55
79
 
56
80
  def service_configs
57
- (with_compound) ? item_config.concat(compound_config) : item_config
81
+ with_compound ? item_config.concat(compound_config) : item_config
58
82
  end
59
83
 
60
84
  def item_config
@@ -1,3 +1,3 @@
1
1
  module CONTENTdmAPI
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentdm_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fennell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-24 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.4.8
154
+ rubygems_version: 2.5.1
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Ruby bindings for the CONTENTdm API
158
158
  test_files: []
159
- has_rdoc: