gared 0.0.26 → 0.0.27

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
  SHA256:
3
- metadata.gz: 3857f28b69b7cd0d1080208215cbf1bfc57a30a3af5df8162a98aee5b7558939
4
- data.tar.gz: a3cf8fbe5018b902db45f6d70c8223f32101c6eb747b070a7f7dc56a8a37c48c
3
+ metadata.gz: e8dcff1820d0b68f25346b0899c3417eb0aa758ef282c65bf008aa0c36e5dd2a
4
+ data.tar.gz: 21277a0b51dbd03c75598e1d5ca37c09875d32e62e668facec2c82f335f3c78c
5
5
  SHA512:
6
- metadata.gz: 69f3b46c6fa96f5bf2c2f440fbc9bf93bbe57ec8ac61e84a9621289e67b919342558a323a9b14008d58f7472e48651ee43bd584879b011d78741a6212b7e81b1
7
- data.tar.gz: f822f3a7f95e6c4ca38f78843a4309b764a624d053234bc880b672ec57cf011b88b3089f5a40836f328a8e1a366cb6660500609449a11eed16d5b0c7a86ac64e
6
+ metadata.gz: d37c27081fb9385373d0336ac2d8d3f270e35c520ae180bfcea85e51f5fe13ae157fe6c2d8c97407890f0a4f899c8f416a757941470e3cc0cb8471e65ce22cca
7
+ data.tar.gz: 86f92c9ca4609bdeb31180bc6e63f46c76f212bc5665b3acd6997510cb91459b5a11356b44be07f707a626d512074f19c466d9cc085caf38f2e8fde0230a2604
data/lib/gared/nli_api.rb CHANGED
@@ -83,7 +83,7 @@ module Gared
83
83
  end
84
84
  end
85
85
  # TODO: also collect IIIF links for the *subset* of titles that have them, using the availability_type param. No way to get that in the above query -- the fields are not emitted.
86
- # the URL is like https://api.nli.org.il/openlibrary/search?api_key=(((KEY)))&query=title,contains,querystring&availability_type=online_and_api_access&material_type=books
86
+ # the URL is like https://api.nli.org.il/openlibrary/search?api_key=(((KEY)))&query=title,contains,querystring&availability_type=online_and_api_access&material_type=book
87
87
  rescue Exception
88
88
  puts $!
89
89
  end
data/test/test_gared.rb CHANGED
@@ -4,12 +4,13 @@ require 'gared'
4
4
 
5
5
  class GaredTest < Minitest::Test
6
6
 
7
- def test_nli_api_query_publicatios_by_person
7
+ def test_nli_api_query_publications_by_person
8
8
  if ENV['NLI_API_KEY'].nil?
9
9
  puts "skipping NLI API test because NLI_API_KEY envvar is not set"
10
10
  return
11
11
  end
12
12
  puts "Testing NLI API"
13
+ byebug
13
14
  nli = Gared::Nli_Api.new('https://api.nli.org.il/openlibrary/search', ENV['NLI_API_KEY'])
14
15
  refute_nil nli
15
16
  #recs = nli.query_publications_by_person('ביאליק')
@@ -20,7 +21,7 @@ class GaredTest < Minitest::Test
20
21
  end
21
22
 
22
23
  # temporarily disabled until we find another Primo server to test against
23
- # def test_primo_query_publicatios_by_person
24
+ # def test_primo_query_publications_by_person
24
25
  # puts "Testing Primo"
25
26
  # primo = Gared::Primo.new('http://primo.nli.org.il/PrimoWebServices/xservice/search/brief', 'NNL')
26
27
  # refute_nil primo
@@ -30,18 +31,7 @@ class GaredTest < Minitest::Test
30
31
  # refute_empty(recs[0].title)
31
32
  # end
32
33
 
33
- # temporarily disabled until we find another Aleph server to test against
34
- # def test_aleph_query_publicatios_by_person
35
- # puts "Testing Aleph"
36
- # aleph = Gared::Aleph.new('aleph.nli.org.il', 9991, 'NNL01')
37
- # refute_nil aleph
38
- # recs = aleph.query_publications_by_person('אילנאה')
39
- # refute_nil recs
40
- # refute_empty(recs)
41
- # refute_empty(recs[0].title)
42
- # end
43
-
44
- def test_googlebooks_query_publicatios_by_person
34
+ def test_googlebooks_query_publications_by_person
45
35
  if ENV['GOOGLE_API_KEY'].nil?
46
36
  puts "skipping Google Books API test because GOOGLE_API_KEY envvar is not set"
47
37
  return
@@ -55,7 +45,7 @@ class GaredTest < Minitest::Test
55
45
  refute_empty(recs[0].title)
56
46
  end
57
47
 
58
- def test_hebrewbooks_query_publicatios_by_person
48
+ def test_hebrewbooks_query_publications_by_person
59
49
  skip("Skipping testing Hebrewbooks because chromedriver not found") unless `chromedriver -v` =~ /ChromeDriver/
60
50
  puts "Testing Hebrewbooks"
61
51
  hb = Gared::Hebrewbooks.new
@@ -66,7 +56,7 @@ class GaredTest < Minitest::Test
66
56
  refute_empty(recs[0].title)
67
57
  end
68
58
 
69
- def test_idea_query_publicatios_by_person
59
+ def test_idea_query_publications_by_person
70
60
  skip("Skipping testing IDEA because chromedriver not found") unless `chromedriver -v` =~ /ChromeDriver/
71
61
  puts "Testing IDEA"
72
62
  idea = Gared::Idea.new('http://infocenters.co.il/RAANANA/')
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asaf Bartov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2023-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: zoom
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.5'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.5'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: watir
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +73,6 @@ extensions: []
87
73
  extra_rdoc_files: []
88
74
  files:
89
75
  - lib/gared.rb
90
- - lib/gared/aleph.rb
91
76
  - lib/gared/googlebooks.rb
92
77
  - lib/gared/hebrewbooks.rb
93
78
  - lib/gared/holding.rb
@@ -102,7 +87,7 @@ homepage: https://gitlab.com/abartov/gared
102
87
  licenses:
103
88
  - MIT
104
89
  metadata: {}
105
- post_install_message:
90
+ post_install_message:
106
91
  rdoc_options: []
107
92
  require_paths:
108
93
  - lib
@@ -117,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
102
  - !ruby/object:Gem::Version
118
103
  version: '0'
119
104
  requirements: []
120
- rubygems_version: 3.1.4
121
- signing_key:
105
+ rubygems_version: 3.2.32
106
+ signing_key:
122
107
  specification_version: 4
123
108
  summary: Scrape Hebrew bibliography sources
124
109
  test_files:
data/lib/gared/aleph.rb DELETED
@@ -1,80 +0,0 @@
1
- # Z39.50 values according to https://www.loc.gov/z3950/agency/bib1.html
2
- # and NLI info according to http://web.nli.org.il/sites/NLI/Hebrew/infochannels/librarians/Pages/Z39.50.aspx
3
- # Name of Database: NNL01
4
- # Host name: aleph.nli.org.il
5
- # IP address: 192.114.7.200
6
- # Port: 9991
7
- # Character-set: UTF-8
8
- # We support the following record syntaxes:
9
- # USMARC, OPAC, XML
10
- # We support the following word searches:
11
- # 1016, 1017, 1,1003, 1004,4,21,30,31,7,12,1007,1031,1007,5028,1033
12
- # We support the following phrase searches:
13
- # 7,12,1,1003,1004,4,21,15
14
- # We support the following sorts:
15
- # 1,4,30,31,1003
16
-
17
- module Gared
18
- require 'zoom'
19
- require 'nokogiri'
20
- class Aleph
21
- def initialize(host, port, database, syntax = 'USMARC')
22
- @options = {host: host, port: port, database: database, syntax: syntax}
23
- end
24
- def query_persons(q)
25
- end
26
-
27
- def query_person(person)
28
- end
29
-
30
- def query_publications(q)
31
- end
32
-
33
- def query_publication(publication)
34
- end
35
-
36
- def query_publications_by_person(person, ctx = nil)
37
- ZOOM::Connection.open(@options[:host], @options[:port]) do |conn|
38
- conn.database_name = @options[:database] # 'aleph.nli.org.il',9991
39
- conn.preferred_record_syntax = @options[:syntax]
40
- rset = conn.search("@attr 1=1003 @attr 2=3 @attr 4=1 \"#{person}\"")
41
- rr = rset.records
42
- return nil if rr.nil? or rr.empty?
43
- ret = []
44
- rr.each do |r|
45
- xml = Nokogiri::Slop(r.xml)
46
- xml.remove_namespaces! # keeps biting me :)
47
- # these scrapes are based on the National Library of Israel usage. No attempt to make it generic. :)
48
- p = Publication.new(ctx)
49
- begin
50
- p.author_line = xml.xpath('//datafield[@tag=\'100\']/subfield[@code=\'a\']')[0].text
51
- # puts "author: #{p.author_line}" # DEBUG
52
- rescue
53
- nil
54
- end
55
- begin
56
- p.title = xml.xpath('//datafield[@tag=\'245\']/subfield[@code=\'a\']')[0].text
57
- # puts "title: #{p.title}" # DEBUG
58
- rescue
59
- nil
60
- end
61
- begin
62
- p.notes = xml.xpath('//datafield[@tag=\'500\']/subfield[@code=\'a\']').collect{|note| note.text}.join("\n")
63
- rescue
64
- nil
65
- end
66
- begin
67
- h = Holding.new
68
- h.source_id = xml.xpath('//datafield[@tag=\'090\']/subfield[@code=\'a\']')[0].text
69
- h.source_name = @options[:database]
70
- p.add_holding(h)
71
- ret << p
72
- rescue
73
- nil # ignore records with no holdings; they may be archival files or other non-publications
74
- end #
75
- end
76
- return ret
77
- end
78
- end
79
- end
80
- end