contentdm_api 0.3.11 → 0.4.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
- SHA1:
3
- metadata.gz: 1091e4cac477eae6eb4b55d3ef21439e96bac753
4
- data.tar.gz: 6f842e4a860ab125cb457533ca5379123b25eb7c
2
+ SHA256:
3
+ metadata.gz: '09e9d240768cafbc4e4ea26c4ae4f044d27b50760cf68b9ca95037ab634a763f'
4
+ data.tar.gz: 5d6dc41cd3b9a2ddebc049c43ef8dfc64d455cebeef870683d4797161ef5da0d
5
5
  SHA512:
6
- metadata.gz: d5a3aed8e06a2123112c03ec2feb4e15d8e1efe02fb6e934c52ef99cf38f041189b4bd56c3cbebe4bd5211c8c76bc11721225a3e50fcbca561c34f95aff92190
7
- data.tar.gz: d713927f824498d0702a51ede9c946e6b5ae2c956448c564146ceeebcc625574bd6970734b4828887a785b99851e04e5952f7a9796b45cabb95f3e63df204b1e
6
+ metadata.gz: d88357e27ad803be09e1390de563bf351f2f52b327fc81dea85f608899887b1fdf89a23c2846ffa02a9f3062a7c2c03776907b1152792e4ea99cc655d87c869b
7
+ data.tar.gz: d4e7d566a2bc8fe3b94c8acf4730cbb42ff461cd67360fa02bd016f6c5ab3ac16fa57faa6f6f57934cf45888fddee0f5fa576464a3c6553c95503fefeb05d1a8
@@ -17,10 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
+ spec.add_dependency "http", "~> 4.0.3"
20
21
  spec.add_development_dependency "bundler", "~> 1.11"
21
22
  spec.add_development_dependency "rake", "~> 10.0"
22
23
  spec.add_development_dependency "minitest", "~> 5.0"
23
- spec.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.0'
24
- spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
25
24
  spec.add_development_dependency "yard", "~> 0.9.0"
26
25
  end
@@ -42,14 +42,29 @@ module CONTENTdmAPI
42
42
  # dmGetCompoundObjectInfo functions
43
43
  def metadata
44
44
  if with_compound
45
- result_with_id.merge('page' => compounds(page))
45
+ result_with_id.merge('page' => compounds_to_h)
46
46
  else
47
47
  result_with_id.merge('page' => [])
48
48
  end
49
49
  end
50
50
 
51
+ def compounds_to_h
52
+ [page].flatten.map do |compound|
53
+ block_given? ? yield(compound(compound)) : compound(compound)
54
+ end
55
+ end
56
+
51
57
  private
52
58
 
59
+ def compound(compound)
60
+ # API gives inconsistent results
61
+ return {} unless compound.is_a?(Hash)
62
+ compound.merge(self.class.new(base_url: base_url,
63
+ collection: collection,
64
+ id: compound['pageptr'],
65
+ with_compound: false).metadata)
66
+ end
67
+
53
68
  def page
54
69
  result.fetch('page', [])
55
70
  end
@@ -62,17 +77,6 @@ module CONTENTdmAPI
62
77
  values.first.merge('page' => values.last.fetch('page', []))
63
78
  end
64
79
 
65
- def compounds(page)
66
- [page].flatten.map do |compound|
67
- # API gives inconsistent results
68
- return {} unless compound.is_a?(Hash)
69
- compound.merge(self.class.new(base_url: base_url,
70
- collection: collection,
71
- id: compound['pageptr'],
72
- with_compound: false).metadata)
73
- end
74
- end
75
-
76
80
  def remove_errors(value)
77
81
  value['code'] != '-2' ? value : {}
78
82
  end
@@ -1,4 +1,5 @@
1
- require 'net/http'
1
+ require 'http'
2
+
2
3
  module CONTENTdmAPI
3
4
  # Form requests to the ContentDM API
4
5
  class Request
@@ -10,7 +11,7 @@ module CONTENTdmAPI
10
11
  # params and format to request of the CONTENTdm API
11
12
  #
12
13
  # @return [Void]
13
- def initialize(base_url: '', client: Net::HTTP, service: Service.new)
14
+ def initialize(base_url: '', client: HTTP, service: Service.new)
14
15
  @base_url = base_url
15
16
  @client = client
16
17
  @service = service
@@ -20,25 +21,7 @@ module CONTENTdmAPI
20
21
  #
21
22
  # @return [String] either XML or JSON
22
23
  def fetch
23
- request.body
24
- end
25
-
26
- def uri
27
- @uri = URI.parse(unencoded_url)
28
- end
29
-
30
- private
31
-
32
- def http
33
- http = client.new(uri.host, uri.port)
34
- http.read_timeout = 1200
35
- http.open_timeout = 120
36
- http.use_ssl = (uri.scheme == "https")
37
- http
38
- end
39
-
40
- def request
41
- http.request(client::Get.new(uri.request_uri))
24
+ client.get(unencoded_url).to_s
42
25
  end
43
26
 
44
27
  # A URL for a given service
@@ -1,3 +1,3 @@
1
1
  module CONTENTdmAPI
2
- VERSION = '0.3.11'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,97 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentdm_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.4.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: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.11'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
19
+ version: 4.0.3
20
+ type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: 4.0.3
41
27
  - !ruby/object:Gem::Dependency
42
- name: minitest
28
+ name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '5.0'
33
+ version: '1.11'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '5.0'
40
+ version: '1.11'
55
41
  - !ruby/object:Gem::Dependency
56
- name: webmock
42
+ name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.24'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 1.24.0
47
+ version: '10.0'
65
48
  type: :development
66
49
  prerelease: false
67
50
  version_requirements: !ruby/object:Gem::Requirement
68
51
  requirements:
69
52
  - - "~>"
70
53
  - !ruby/object:Gem::Version
71
- version: '1.24'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 1.24.0
54
+ version: '10.0'
75
55
  - !ruby/object:Gem::Dependency
76
- name: vcr
56
+ name: minitest
77
57
  requirement: !ruby/object:Gem::Requirement
78
58
  requirements:
79
59
  - - "~>"
80
60
  - !ruby/object:Gem::Version
81
- version: '3.0'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 3.0.1
61
+ version: '5.0'
85
62
  type: :development
86
63
  prerelease: false
87
64
  version_requirements: !ruby/object:Gem::Requirement
88
65
  requirements:
89
66
  - - "~>"
90
67
  - !ruby/object:Gem::Version
91
- version: '3.0'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 3.0.1
68
+ version: '5.0'
95
69
  - !ruby/object:Gem::Dependency
96
70
  name: yard
97
71
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
125
  version: '0'
152
126
  requirements: []
153
127
  rubyforge_project:
154
- rubygems_version: 2.5.1
128
+ rubygems_version: 2.7.8
155
129
  signing_key:
156
130
  specification_version: 4
157
131
  summary: Ruby bindings for the CONTENTdm API