contentdm_api 0.3.10 → 0.5.1

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
- SHA1:
3
- metadata.gz: e404ef195d629d4b4033bb60cd07ee42f371600d
4
- data.tar.gz: a23b64b53391c519b4b708b286c14478382645f7
2
+ SHA256:
3
+ metadata.gz: 8667262333abc85a067f57a5187f06078acc1042b67f79eb67905574536dc428
4
+ data.tar.gz: abe33c8fe01963274831cd32bb36338bed4dc2e86488a79956b699eb243dcbac
5
5
  SHA512:
6
- metadata.gz: c9a4e8a92d52aa85788123d472939868000f2108dc717457d365aad9965c1c6e4b49a24f2509f0e66ae375c5d983afd3e91fd55153c3baf08667c0c3686f8c24
7
- data.tar.gz: a905df0911346e74ef562fbe1fa897af3bfa59763c89267d1de2766680f93f87faf7a4d799a49e0f8438e6f9327ec924f6c180b84c5d9071684c0cbf9f5a3fda
6
+ metadata.gz: 35bcb8e393b06220bcd7d189b255648ecd9dcad06eb433853420cb2a0360c9c5170671d8a90cc0eb2f586f93222c626906d9694dc83a4b98a359b4075300cfc9
7
+ data.tar.gz: 220978c118d1ab0180145a969a67737b721d174411dc7ddf96eb0d23633a2e6850461c5612f8adec820a08f54c53f70dbab6c9f67ab997a467575eadcacc0522
@@ -0,0 +1,36 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+
10
+ on: [push]
11
+
12
+ jobs:
13
+ test:
14
+
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby-version: ['2.6']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
24
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
25
+ # uses: ruby/setup-ruby@v1
26
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ - name: Pin bundler
30
+ run: gem install bundler:2.0.2
31
+ - name: Lock bundler
32
+ run: bundle _2.0.2_ lock
33
+ - name: Run bundler
34
+ run: bundle install
35
+ - name: Run tests
36
+ run: bundle exec rake test
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CONTENTdm API for Ruby
2
2
 
3
- [![Build Status](https://travis-ci.org/UMNLibraries/contentdm_api.svg?branch=master)](https://travis-ci.org/UMNLibraries/contentdm_api)
3
+ ![CI](https://github.com/UMNLibraries/contentdm_api/actions/workflows/ci.yml/badge.svg)
4
4
 
5
5
  Ruby bindings for the [CONTENTdm API](https://www.oclc.org/support/services/contentdm_api/help/customizing-website-help/other-customizations/contentdm_api-api-reference.en.html).
6
6
 
@@ -17,10 +17,11 @@ 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_development_dependency "bundler", "~> 1.11"
20
+ spec.add_dependency "http", "~> 4.0.3"
21
+ spec.add_development_dependency "bundler", "~> 2.0.1"
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"
25
+ spec.add_development_dependency "vcr", "~> 6.0"
26
+ spec.add_development_dependency "webmock", "~> 3.0"
26
27
  end
@@ -15,7 +15,10 @@ module CONTENTdmAPI
15
15
  # @param [String] collection The CONTENTdm API calls this an "alias"
16
16
  # @param [Integer] id The CONTENTdm API calls this a "pointer". It is the
17
17
  # identifier for a a given CONTENTdm item.
18
- # @param [Boolean] with_compound Include compound object info?
18
+ # @param [Boolean] with_compound Recursively request and in clude full
19
+ # compound item data? If false, basic compound data will STILL be
20
+ # included in the array value of the item hash key 'page'. 'page' is the
21
+ # term CONTENTdm uses to signify a list of child pages for an item.
19
22
  # @param [Boolean] enrich_compount Fetch and merge full item info for each
20
23
  # compound?
21
24
  # @param [Object] requester A class to make requests of the API.
@@ -42,16 +45,33 @@ module CONTENTdmAPI
42
45
  # dmGetCompoundObjectInfo functions
43
46
  def metadata
44
47
  if with_compound
45
- result_with_id.merge('page' => compounds(page))
48
+ result_with_id.merge('page' => compounds_to_h)
46
49
  else
47
- result_with_id.merge('page' => [])
50
+ result_with_id.merge('page' => page)
51
+ end
52
+ end
53
+
54
+ def compounds_to_h
55
+ page.map do |compound|
56
+ block_given? ? yield(compound(compound)) : compound(compound)
48
57
  end
49
58
  end
50
59
 
51
60
  private
52
61
 
62
+ def compound(compound)
63
+ # API gives inconsistent results
64
+ return {} unless compound.is_a?(Hash)
65
+ compound.merge(self.class.new(base_url: base_url,
66
+ collection: collection,
67
+ id: compound['pageptr'],
68
+ with_compound: false).metadata)
69
+ end
70
+
53
71
  def page
54
- result.fetch('page', [])
72
+ # Single result pages come back as a hash. Cast them into and array to
73
+ # make our api more consistent
74
+ [result.fetch('page', [])].flatten
55
75
  end
56
76
 
57
77
  def result_with_id
@@ -62,17 +82,6 @@ module CONTENTdmAPI
62
82
  values.first.merge('page' => values.last.fetch('page', []))
63
83
  end
64
84
 
65
- def compounds(page)
66
- page.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
85
  def remove_errors(value)
77
86
  value['code'] != '-2' ? value : {}
78
87
  end
@@ -90,7 +99,7 @@ module CONTENTdmAPI
90
99
  end
91
100
 
92
101
  def service_configs
93
- with_compound ? item_config.concat(compound_config) : item_config
102
+ item_config.concat(compound_config)
94
103
  end
95
104
 
96
105
  def item_config
@@ -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.10'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentdm_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.5.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-12-13 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '1.11'
33
+ version: 2.0.1
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '1.11'
40
+ version: 2.0.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,59 +67,47 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '5.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: webmock
70
+ name: yard
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '1.24'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 1.24.0
75
+ version: 0.9.0
65
76
  type: :development
66
77
  prerelease: false
67
78
  version_requirements: !ruby/object:Gem::Requirement
68
79
  requirements:
69
80
  - - "~>"
70
81
  - !ruby/object:Gem::Version
71
- version: '1.24'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 1.24.0
82
+ version: 0.9.0
75
83
  - !ruby/object:Gem::Dependency
76
84
  name: vcr
77
85
  requirement: !ruby/object:Gem::Requirement
78
86
  requirements:
79
87
  - - "~>"
80
88
  - !ruby/object:Gem::Version
81
- version: '3.0'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 3.0.1
89
+ version: '6.0'
85
90
  type: :development
86
91
  prerelease: false
87
92
  version_requirements: !ruby/object:Gem::Requirement
88
93
  requirements:
89
94
  - - "~>"
90
95
  - !ruby/object:Gem::Version
91
- version: '3.0'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 3.0.1
96
+ version: '6.0'
95
97
  - !ruby/object:Gem::Dependency
96
- name: yard
98
+ name: webmock
97
99
  requirement: !ruby/object:Gem::Requirement
98
100
  requirements:
99
101
  - - "~>"
100
102
  - !ruby/object:Gem::Version
101
- version: 0.9.0
103
+ version: '3.0'
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
107
  requirements:
106
108
  - - "~>"
107
109
  - !ruby/object:Gem::Version
108
- version: 0.9.0
110
+ version: '3.0'
109
111
  description:
110
112
  email:
111
113
  - fenne035@umn.edu
@@ -113,8 +115,8 @@ executables: []
113
115
  extensions: []
114
116
  extra_rdoc_files: []
115
117
  files:
118
+ - ".github/workflows/ci.yml"
116
119
  - ".gitignore"
117
- - ".travis.yml"
118
120
  - CHANGELOG.txt
119
121
  - CODE_OF_CONDUCT.md
120
122
  - Gemfile
@@ -150,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
152
  - !ruby/object:Gem::Version
151
153
  version: '0'
152
154
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.5.1
155
+ rubygems_version: 3.0.3
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: Ruby bindings for the CONTENTdm API
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.2.3
5
- - 2.3.1
6
- before_install: gem install bundler -v 1.11.2