alma 0.3.1 → 0.3.2

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
  SHA256:
3
- metadata.gz: ed295d076116c3da468f65bfb17ba476b171e60565adddec420a2328f9b88fa6
4
- data.tar.gz: 146c04496209f27833a0d0881e5f21a2fe7d55c9aa2886e5c2833efd05a80fc1
3
+ metadata.gz: f162f9bb1a3b0eee2af44a379b1d094141b6cc9c06767d17acb39d909eb27ed1
4
+ data.tar.gz: 98eb300d6c0ab62ae07790fa64449c65839f89bd3903b3c0e010e911bf4d3ce0
5
5
  SHA512:
6
- metadata.gz: bd111915aa21143de049c78f1ccd51f91db677b228c304ffddbd8820349e10525aec2a7fd7b423ab6cab8154b8322ab899a7472c84b09c0518ea28cc1d6ad0c9
7
- data.tar.gz: fdc24540723c168bfd8779a53dc233e353b564ab1a6f6eeaa7b053675a18aecfc28f1a324a905281dc0e8d9efe998d0167d3012164889ab9c9169d3fd5952d31
6
+ metadata.gz: bff5a50e3f546962f71c3ce2fbfe2ed553b63fc4698df62b1ce2828e53c86c62c018716a476005759ed8b94102d371911e9b3ef69f6b03752b96fe85bcbf7f97
7
+ data.tar.gz: 8159b943d247e6bd34f3efcd09325191806ca26471252d39d3f54be4182a5b45bc875b2eb7c5bc432b492b70e932cbac8c12054ba0b64883ac14e974933c215f
@@ -0,0 +1,54 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.1.2
4
+
5
+ workflows:
6
+ version: 2
7
+ test-deploy:
8
+ jobs:
9
+ - build
10
+ - deploy:
11
+ filters:
12
+ tags:
13
+ only: /.*/
14
+ branches:
15
+ ignore: /.*/
16
+
17
+ jobs:
18
+ build:
19
+ docker:
20
+ - image: cimg/ruby:2.7.2-node
21
+ auth:
22
+ username: $DOCKERHUB_USER
23
+ password: $DOCKERHUB_PASSWORD
24
+
25
+ executor: ruby/default
26
+ steps:
27
+ - checkout
28
+ - run:
29
+ name: Which bundler?
30
+ command: bundle -v
31
+ - ruby/bundle-install
32
+ - run:
33
+ name: lint
34
+ command: bundle exec rubocop
35
+ - run:
36
+ name: test
37
+ command: bundle exec rake
38
+ deploy:
39
+ docker:
40
+ - image: circleci/ruby:2.7.2-node-browsers
41
+
42
+ working_directory: ~/repo
43
+
44
+ steps:
45
+ - checkout
46
+ - run:
47
+ name: Setup Rubygems
48
+ command: bash .circleci/setup-rubygems.sh
49
+
50
+ - run:
51
+ name: Publish to Rubygems
52
+ command: |
53
+ gem build alma.gemspec
54
+ gem push "$(ls alma-*.gem)"
@@ -0,0 +1,3 @@
1
+ mkdir ~/.gem
2
+ echo -e "---\r\n:rubygems_api_key: $ALMA_RUBYGEMS" > ~/.gem/credentials
3
+ chmod 0600 /home/circleci/.gem/credentials
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .byebug_history
11
+ .DS_Store
12
+ spec/.DS_Store
data/.rubocop.yml ADDED
@@ -0,0 +1,134 @@
1
+ require:
2
+ - rubocop-rails
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
7
+ # to ignore them, so only the ones explicitly set in this file are enabled.
8
+ DisabledByDefault: true
9
+ Exclude:
10
+ - 'node_modules/**/*'
11
+ - '**/templates/**/*'
12
+ - '**/vendor/**/*'
13
+ - 'actionpack/lib/action_dispatch/journey/parser.rb'
14
+ - 'bin/*'
15
+ - 'solr/**/*'
16
+
17
+ # Prefer &&/|| over and/or.
18
+ Style/AndOr:
19
+ Enabled: true
20
+
21
+ # Align `when` with `case`.
22
+ Layout/CaseIndentation:
23
+ Enabled: true
24
+
25
+ # Align comments with method definitions.
26
+ Layout/CommentIndentation:
27
+ Enabled: true
28
+
29
+ Layout/EmptyLineAfterMagicComment:
30
+ Enabled: true
31
+
32
+ # In a regular class definition, no empty lines around the body.
33
+ Layout/EmptyLinesAroundClassBody:
34
+ Enabled: true
35
+
36
+ # In a regular method definition, no empty lines around the body.
37
+ Layout/EmptyLinesAroundMethodBody:
38
+ Enabled: true
39
+
40
+ # In a regular module definition, no empty lines around the body.
41
+ Layout/EmptyLinesAroundModuleBody:
42
+ Enabled: true
43
+
44
+ Layout/FirstArgumentIndentation:
45
+ Enabled: true
46
+
47
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
48
+ Style/HashSyntax:
49
+ Enabled: true
50
+
51
+ # Method definitions after `private` or `protected` isolated calls need one
52
+ # extra level of indentation.
53
+ Layout/IndentationConsistency:
54
+ Enabled: true
55
+ EnforcedStyle: indented_internal_methods
56
+
57
+ # Two spaces, no tabs (for indentation).
58
+ Layout/IndentationWidth:
59
+ Enabled: true
60
+
61
+ Layout/SpaceAfterColon:
62
+ Enabled: true
63
+
64
+ Layout/SpaceAfterComma:
65
+ Enabled: true
66
+
67
+ Layout/SpaceAroundEqualsInParameterDefault:
68
+ Enabled: true
69
+
70
+ Layout/SpaceAroundKeyword:
71
+ Enabled: true
72
+
73
+ Layout/SpaceAroundOperators:
74
+ Enabled: true
75
+
76
+ Layout/SpaceBeforeFirstArg:
77
+ Enabled: true
78
+
79
+ # Defining a method with parameters needs parentheses.
80
+ Style/MethodDefParentheses:
81
+ Enabled: true
82
+
83
+ Style/FrozenStringLiteralComment:
84
+ Enabled: true
85
+ EnforcedStyle: always
86
+ Exclude:
87
+ - 'app/models/traject_indexer.rb'
88
+ - 'db/schema.rb'
89
+
90
+ # Use `foo {}` not `foo{}`.
91
+ Layout/SpaceBeforeBlockBraces:
92
+ Enabled: true
93
+
94
+ # Use `foo { bar }` not `foo {bar}`.
95
+ Layout/SpaceInsideBlockBraces:
96
+ Enabled: true
97
+
98
+ # Use `{ a: 1 }` not `{a:1}`.
99
+ Layout/SpaceInsideHashLiteralBraces:
100
+ Enabled: true
101
+
102
+ Layout/SpaceInsideParens:
103
+ Enabled: true
104
+
105
+ # Check quotes usage according to lint rule below.
106
+ Style/StringLiterals:
107
+ Enabled: true
108
+ EnforcedStyle: double_quotes
109
+
110
+ # Detect hard tabs, no hard tabs.
111
+ Layout/IndentationStyle:
112
+ Enabled: true
113
+
114
+ # Blank lines should not have any spaces.
115
+ Layout/TrailingEmptyLines:
116
+ Enabled: true
117
+
118
+ # No trailing whitespace.
119
+ Layout/TrailingWhitespace:
120
+ Enabled: true
121
+
122
+ # Use quotes for string literals when they are enough.
123
+ Style/RedundantPercentQ:
124
+ Enabled: true
125
+
126
+ # Align `end` with the matching keyword or starting expression except for
127
+ # assignments, where it should be aligned with the LHS.
128
+ Layout/EndAlignment:
129
+ Enabled: true
130
+ EnforcedStyleAlignWith: variable
131
+
132
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
133
+ Lint/RequireParentheses:
134
+ Enabled: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.5
1
+ ruby-2.7.2
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in alma.gemspec
4
6
  gemspec
5
7
 
6
- gem 'simplecov', require: false, group: :test
7
-
8
+ gem "simplecov", require: false, group: :test
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/alma.gemspec CHANGED
@@ -1,16 +1,18 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'alma/version'
6
+ require "alma/version"
5
7
 
6
8
  Gem::Specification.new do |spec|
7
9
  spec.name = "alma"
8
10
  spec.version = Alma::VERSION
9
- spec.authors = ["Chad Nelson"]
10
- spec.email = ["chad.nelson@temple.edu"]
11
+ spec.authors = ["Jennifer Anton", "David Kinzer", "Chad Nelson"]
12
+ spec.email = ["jennifer.anton@temple.edu", "david.kinzer@temple.edu", "chad.nelson@temple.edu"]
11
13
 
12
- spec.summary = %q{Client for Ex Libris Alma Web Services}
13
- spec.description = %q{Client for Ex Libris Alma Web Services}
14
+ spec.summary = "Client for Ex Libris Alma Web Services"
15
+ spec.description = "Client for Ex Libris Alma Web Services"
14
16
  spec.homepage = "https://github.com/tulibraries/alma_rb"
15
17
  spec.license = "MIT"
16
18
 
@@ -21,21 +23,19 @@ Gem::Specification.new do |spec|
21
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
24
  spec.require_paths = ["lib"]
23
25
 
24
- spec.add_dependency 'ezwadl'
25
- spec.add_dependency 'httparty'
26
- spec.add_dependency 'xml-simple'
27
- spec.add_dependency 'activesupport'
28
-
29
-
30
-
26
+ spec.add_dependency "ezwadl"
27
+ spec.add_dependency "httparty"
28
+ spec.add_dependency "xml-simple"
29
+ spec.add_dependency "activesupport"
31
30
 
32
31
  spec.add_development_dependency "bundler", "~> 2.0"
33
32
  spec.add_development_dependency "rake", "~> 13.0"
34
33
  spec.add_development_dependency "rspec", "~> 3.0"
35
- spec.add_development_dependency 'webmock'
36
- spec.add_development_dependency 'pry'
37
- spec.add_development_dependency 'byebug'
34
+ spec.add_development_dependency "webmock"
35
+ spec.add_development_dependency "pry"
36
+ spec.add_development_dependency "rubocop"
37
+ spec.add_development_dependency "rubocop-rails"
38
+ spec.add_development_dependency "byebug"
38
39
  spec.add_development_dependency "guard"
39
40
  spec.add_development_dependency "guard-rspec"
40
-
41
41
  end
data/lib/alma.rb CHANGED
@@ -1,31 +1,39 @@
1
- require 'alma/version'
2
- require 'alma/config'
3
- require 'alma/api_defaults'
4
- require 'alma/error'
5
- require 'alma/alma_record'
6
- require 'alma/response'
7
- require 'alma/user'
8
- require 'alma/bib'
9
- require 'alma/loan'
10
- require 'alma/result_set'
11
- require 'alma/loan_set'
12
- require 'alma/user_set'
13
- require 'alma/fine_set'
14
- require 'alma/fine'
15
- require 'alma/user_set'
16
- require 'alma/bib_set'
17
- require 'alma/request_set'
18
- require 'alma/renewal_response'
19
- require 'alma/availability_response'
20
- require 'alma/bib_item'
21
- require 'alma/request_options'
22
- require 'alma/item_request_options'
23
- require 'alma/request'
24
- require 'alma/user_request'
25
- require 'alma/electronic'
1
+ # frozen_string_literal: true
2
+
3
+ require "alma/version"
4
+ require "alma/config"
5
+ require "alma/api_defaults"
6
+ require "alma/error"
7
+ require "alma/alma_record"
8
+ require "alma/response"
9
+ require "alma/user"
10
+ require "alma/bib"
11
+ require "alma/loan"
12
+ require "alma/result_set"
13
+ require "alma/loan_set"
14
+ require "alma/user_set"
15
+ require "alma/fine_set"
16
+ require "alma/fine"
17
+ require "alma/bib_set"
18
+ require "alma/request_set"
19
+ require "alma/renewal_response"
20
+ require "alma/availability_response"
21
+ require "alma/bib_item"
22
+ require "alma/request_options"
23
+ require "alma/item_request_options"
24
+ require "alma/request"
25
+ require "alma/user_request"
26
+ require "alma/electronic"
27
+ require "alma/bib_holding"
28
+ require "alma/library"
29
+ require "alma/library_set"
30
+ require "alma/location"
31
+ require "alma/location_set"
32
+ require "alma/course_set"
33
+ require "alma/course"
26
34
 
27
35
  module Alma
28
- require 'httparty'
36
+ require "httparty"
29
37
 
30
38
  ROOT = File.dirname __dir__
31
39
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alma
2
4
  class AlmaRecord
3
-
4
5
  def initialize(record)
5
6
  @raw_record = record
6
7
  post_initialize()
@@ -23,6 +24,5 @@ module Alma
23
24
  # Subclasses can define this method to perform extra initialization
24
25
  # after the super class init.
25
26
  end
26
-
27
27
  end
28
- end
28
+ end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alma
2
4
  module ApiDefaults
3
-
4
5
  def apikey
5
6
  Alma.configuration.apikey
6
7
  end
@@ -23,6 +24,14 @@ module Alma
23
24
  "#{self.region}/almaws/v1/users"
24
25
  end
25
26
 
27
+ def items_base_path
28
+ "#{self.region}/almaws/v1/items"
29
+ end
30
+
31
+ def configuration_base_path
32
+ "#{self.region}/almaws/v1/conf"
33
+ end
34
+
26
35
  def timeout
27
36
  Alma.configuration.timeout
28
37
  end
@@ -1,91 +1,88 @@
1
- require 'xmlsimple'
1
+ # frozen_string_literal: true
2
+
3
+ require "xmlsimple"
2
4
 
3
5
  module Alma
4
6
  class AvailabilityResponse
5
-
6
-
7
7
  attr_accessor :availability
8
8
 
9
9
  def initialize(response)
10
10
  @availability = parse_bibs_data(response.each)
11
11
  end
12
12
 
13
- # Data structure for holdings information of bib records.
13
+ # Data structure for holdings information of bib records.
14
14
  # A hash with mms ids as keys, with values of an array of
15
15
  # one or more hashes of holdings info
16
16
  def parse_bibs_data(bibs)
17
17
  bibs.reduce(Hash.new) { |acc, bib|
18
- acc.merge({"#{bib.id}" => {holdings: build_holdings_for(bib)}})
18
+ acc.merge({ "#{bib.id}" => { holdings: build_holdings_for(bib) } })
19
19
  }
20
20
  end
21
21
 
22
22
  def build_holdings_for(bib)
23
23
  get_inventory_fields_for(bib).map do |inventory_field|
24
24
  # Use the mapping for this inventory type
25
- subfield_codes = Alma::INVENTORY_SUBFIELD_MAPPING[inventory_field['tag']]
26
-
25
+ subfield_codes = Alma::INVENTORY_SUBFIELD_MAPPING[inventory_field["tag"]]
26
+
27
27
  inventory_field.
28
28
  # Get all the subfields for this inventory field
29
- fetch('subfield', []).
29
+ fetch("subfield", []).
30
30
  # Limit to only subfields codes for which we have a mapping
31
- select {|sf| subfield_codes.key? sf['code'] }.
32
- # Transform the array of subfields into a hash with mapped code as key
33
- reduce(Hash.new) { |acc, subfield|
34
- acc.merge({"#{subfield_codes[subfield['code']]}" => subfield['content']})
31
+ select { |sf| subfield_codes.key? sf["code"] }.
32
+ # Transform the array of subfields into a hash with mapped code as key
33
+ reduce(Hash.new) { |acc, subfield|
34
+ acc.merge({ "#{subfield_codes[subfield['code']]}" => subfield["content"] })
35
35
  }.
36
36
  # Include the inventory type
37
- merge({'inventory_type' => subfield_codes['INVENTORY_TYPE']})
37
+ merge({ "inventory_type" => subfield_codes["INVENTORY_TYPE"] })
38
38
  end
39
39
  end
40
40
 
41
41
  def get_inventory_fields_for(bib)
42
- # Return only the datafields with tags AVA, AVD, or AVE
42
+ # Return only the datafields with tags AVA, AVD, or AVE
43
43
  bib.record
44
- .fetch('datafield', [])
45
- .select { |df| Alma::INVENTORY_SUBFIELD_MAPPING.key?(df['tag']) }
44
+ .fetch("datafield", [])
45
+ .select { |df| Alma::INVENTORY_SUBFIELD_MAPPING.key?(df["tag"]) }
46
46
  end
47
47
  end
48
48
 
49
49
  INVENTORY_SUBFIELD_MAPPING =
50
50
  {
51
- 'AVA' => {
52
- 'INVENTORY_TYPE' => 'physical',
53
- 'a' => 'institution',
54
- 'b' => 'library_code',
55
- 'c' => 'location',
56
- 'd' => 'call_number',
57
- 'e' => 'availability',
58
- 'f' => 'total_items',
59
- 'g' => 'non_available_items',
60
- 'j' => 'location_code',
61
- 'k' => 'call_number_type',
62
- 'p' => 'priority',
63
- 'q' => 'library',
64
- 't' => 'holding_info',
65
- '8' => 'holding_id',
51
+ "AVA" => {
52
+ "INVENTORY_TYPE" => "physical",
53
+ "a" => "institution",
54
+ "b" => "library_code",
55
+ "c" => "location",
56
+ "d" => "call_number",
57
+ "e" => "availability",
58
+ "f" => "total_items",
59
+ "g" => "non_available_items",
60
+ "j" => "location_code",
61
+ "k" => "call_number_type",
62
+ "p" => "priority",
63
+ "q" => "library",
64
+ "t" => "holding_info",
65
+ "8" => "holding_id",
66
66
  },
67
- 'AVD' => {
68
- 'INVENTORY_TYPE' => 'digital',
69
- 'a' => 'institution',
70
- 'b' => 'representations_id',
71
- 'c' => 'representation',
72
- 'd' => 'repository_name',
73
- 'e' => 'label',
67
+ "AVD" => {
68
+ "INVENTORY_TYPE" => "digital",
69
+ "a" => "institution",
70
+ "b" => "representations_id",
71
+ "c" => "representation",
72
+ "d" => "repository_name",
73
+ "e" => "label",
74
74
  },
75
- 'AVE' => {
76
- 'INVENTORY_TYPE' => 'electronic',
77
- 'c' => 'collection_id',
78
- 'e' => 'activation_status',
79
- 'l' => 'library_code',
80
- 'm' => 'collection',
81
- 'n' => 'public_note',
82
- 's' => 'coverage_statement',
83
- 't' => 'interface_name',
84
- 'u' => 'link_to_service_page',
85
- '8' => 'portfolio_pid',
75
+ "AVE" => {
76
+ "INVENTORY_TYPE" => "electronic",
77
+ "c" => "collection_id",
78
+ "e" => "activation_status",
79
+ "l" => "library_code",
80
+ "m" => "collection",
81
+ "n" => "public_note",
82
+ "s" => "coverage_statement",
83
+ "t" => "interface_name",
84
+ "u" => "link_to_service_page",
85
+ "8" => "portfolio_pid",
86
86
  }
87
87
  }
88
-
89
-
90
-
91
88
  end