marc2linkeddata 0.0.6 → 0.0.7

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: bd3a379bcb2fe572912159e9576a34afff5622a7
4
- data.tar.gz: 6c911bd97a593049f7c13e77bbbcf25b7878f64e
3
+ metadata.gz: f54e31c819d0978629746c13c88690d5b2f1f392
4
+ data.tar.gz: 5325910c217a5e1bd3d45bb0a1f0bdb3b48fa11e
5
5
  SHA512:
6
- metadata.gz: 265a259a65ce550ee3b54f3d6c093136a658e2ec89821c0c40f2415bfe6446ac323e2de93691ea4d1622eff93798470bd0085215158329c904fdcd01cb7e58f4
7
- data.tar.gz: 29f7d365eca71e843782c0853d959012c0755e99e1037d3b92b63e5212abbd152984842432559af89ca60d86b5a9003af92c60b99beae373735073a32cfc0f63
6
+ metadata.gz: 2565a8648875bc22f3b62ccd7cd1aad47ce843d388a93f6e4e363f7bab77644abbf56a1a70f73de9d6ac9aa9be3857578b62c87e5ebc2d4e50b157afaea7c7ae
7
+ data.tar.gz: a8ba98f07795a0c97f4bd00d9c431ea7a4dd15d39952f1cdbc56a4136d4b6e60f2bb0a6d05cb6f3affe5d5eecd03dc6752b4093dcb8b149f61d36583911af610
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ script: "bundle exec rspec"
4
+
5
+ notifications:
6
+ email: false
7
+
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.5
12
+ - 2.2.0
13
+
@@ -52,7 +52,22 @@ module Marc2LinkedData
52
52
 
53
53
  def self.http_head_request(url)
54
54
  uri = URI.parse(url)
55
- Net::HTTP.start(uri.host, uri.port) {|http| req = Net::HTTP::Head.new(uri); http.request req }
55
+ begin
56
+ if RUBY_VERSION =~ /^1\.9/
57
+ req = Net::HTTP::Head.new(uri.path)
58
+ else
59
+ req = Net::HTTP::Head.new(uri)
60
+ end
61
+ Net::HTTP.start(uri.host, uri.port) {|http| http.request req }
62
+ rescue
63
+ @configuration.logger.error "Net::HTTP::Head failed for #{uri}"
64
+ begin
65
+ Net::HTTP.get_response(uri)
66
+ rescue
67
+ @configuration.logger.error "Net::HTTP.get_response failed for #{uri}"
68
+ nil
69
+ end
70
+ end
56
71
  end
57
72
 
58
73
  def self.write_prefixes(file)
@@ -18,9 +18,9 @@ module Marc2LinkedData
18
18
  # end
19
19
 
20
20
  def rdf
21
- return nil if iri.nil?
21
+ return nil if @iri.nil?
22
22
  return @rdf unless @rdf.nil?
23
- uri4rdf = iri.to_s + '.rdf'
23
+ uri4rdf = @iri.to_s + '.rdf'
24
24
  @rdf = get_rdf(uri4rdf)
25
25
  end
26
26
 
@@ -450,7 +450,10 @@ module Marc2LinkedData
450
450
  # Try to find LOC, VIAF, and ISNI IRIs in the MARC record
451
451
  @loc = Loc.new get_iri4loc rescue nil
452
452
  # Try to identify problems in getting an LOC IRI.
453
- binding.pry if (@@config.debug && @loc.nil?)
453
+ if @loc.nil?
454
+ binding.pry if @@config.debug
455
+ raise 'Failed to get authority at LOC'
456
+ end
454
457
  # might require LOC to get ISNI.
455
458
  @viaf = Viaf.new get_iri4viaf rescue nil
456
459
  # might require VIAF to get ISNI.
@@ -37,12 +37,6 @@ module Marc2LinkedData
37
37
  # end
38
38
 
39
39
 
40
- # For reference, note that there is an allegrograph ruby gem, see
41
- # https://github.com/emk/rdf-agraph
42
-
43
- # For reference, note that there is a ruby gem for RDF on mongodb, see
44
- # https://rubygems.org/gems/rdf-mongo
45
-
46
40
 
47
41
 
48
42
 
@@ -0,0 +1,48 @@
1
+ require 'base64'
2
+
3
+ module Marc2LinkedData
4
+
5
+ class SparqlPubmed
6
+
7
+ attr_reader :sparql
8
+
9
+ def initialize
10
+ # config = Marc2LinkedData.configuration
11
+ @sparql = SPARQL::Client.new('http://pubmed.bio2rdf.org/sparql')
12
+ end
13
+
14
+ # http://bio2rdf.org/pubmed_vocabulary:Author
15
+ # dcterms:identifier pubmed_resource:author:a71b95197f579ff09cc6d9a7d4856535
16
+ # http://bio2rdf.org/pubmed_vocabulary:fore_name Alison
17
+ # http://bio2rdf.org/pubmed_vocabulary:initials A
18
+ # http://bio2rdf.org/pubmed_vocabulary:last_name Callahan
19
+
20
+ # e.g. run this SPARQL at http://pubmed.bio2rdf.org/sparql
21
+ # SELECT DISTINCT ?author $fn $ln WHERE {
22
+ # ?author a <http://bio2rdf.org/pubmed_vocabulary:Author> .
23
+ # ?author <http://bio2rdf.org/pubmed_vocabulary:fore_name> $fn .
24
+ # ?author <http://bio2rdf.org/pubmed_vocabulary:last_name> $ln .
25
+ # }
26
+ # LIMIT 100
27
+
28
+ # Note, might have to use first name initial for matching.
29
+
30
+ def find_author(last_name, first_name=nil, middle_initial=nil)
31
+ q = 'SELECT DISTINCT ?author ?fn WHERE { '
32
+ q += '?author a <http://bio2rdf.org/pubmed_vocabulary:Author> . '
33
+ q += '?author <http://bio2rdf.org/pubmed_vocabulary:fore_name> ?fn . '
34
+ q += "?author <http://bio2rdf.org/pubmed_vocabulary:last_name> \"#{last_name}\"^^<http://www.w3.org/2001/XMLSchema#string> . "
35
+ q += '}'
36
+ result = @sparql.query(q)
37
+ result.each_solution do |s|
38
+ # match on first_name? or initials?
39
+ puts s.inspect
40
+ end
41
+ binding.pry
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+
@@ -7,19 +7,19 @@ module Marc2LinkedData
7
7
  PREFIX = 'http://viaf.org/viaf/'
8
8
 
9
9
  # def id
10
- # return nil if iri.nil?
10
+ # return nil if @iri.nil?
11
11
  # iri.path.gsub('viaf/','').gsub('/','')
12
12
  # end
13
13
 
14
14
  def rdf
15
- return nil if iri.nil?
15
+ return nil if @iri.nil?
16
16
  return @rdf unless @rdf.nil?
17
- uri4rdf = iri.to_s + '/rdf.xml'
17
+ uri4rdf = @iri.to_s + '/rdf.xml'
18
18
  @rdf = get_rdf(uri4rdf)
19
19
  end
20
20
 
21
21
  def get_isni
22
- return nil if iri.nil?
22
+ return nil if @iri.nil?
23
23
  return nil unless rdf_valid?
24
24
  return @isni_iri unless @isni_iri.nil?
25
25
  # Try to get ISNI source for VIAF
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'marc2linkeddata'
7
- s.version = '0.0.6'
7
+ s.version = '0.0.7'
8
8
  s.licenses = ['Apache-2.0']
9
9
 
10
10
  s.platform = Gem::Platform::RUBY
@@ -15,18 +15,27 @@ Gem::Specification.new do |s|
15
15
  s.homepage = 'https://github.com/darrenleeweber/marc2linkeddata'
16
16
 
17
17
  s.required_rubygems_version = '>= 1.3.6'
18
- s.required_ruby_version = '>= 2.1.0'
18
+ # s.required_ruby_version = '>= 2.1.0'
19
19
 
20
20
  s.add_dependency 'addressable'
21
21
  s.add_dependency 'linkeddata'
22
22
  s.add_dependency 'marc'
23
- s.add_dependency 'rdf-4store'
24
23
  s.add_dependency 'ruby-progressbar'
24
+
25
+ # Use ENV for config
25
26
  s.add_dependency 'dotenv'
26
27
 
28
+ # ruby gem for RDF on 4store, see https://github.com/emk/rdf-4store
29
+ s.add_dependency 'rdf-4store'
30
+ # ruby gem for RDF on allegrograph, see https://github.com/emk/rdf-agraph
31
+ s.add_dependency 'rdf-agraph'
32
+ # ruby gem for RDF on mongodb, see https://rubygems.org/gems/rdf-mongo
33
+ s.add_dependency 'rdf-mongo'
34
+ # cache simple RDF on redis
27
35
  s.add_dependency 'hiredis'
28
36
  s.add_dependency 'redis'
29
37
 
38
+ # Use pry for console and debug config
30
39
  s.add_dependency 'pry'
31
40
  s.add_dependency 'pry-doc'
32
41
  s.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marc2linkeddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Weber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-progressbar
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rdf-4store
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +95,7 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: ruby-progressbar
98
+ name: rdf-agraph
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -81,7 +109,7 @@ dependencies:
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
- name: dotenv
112
+ name: rdf-mongo
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
@@ -180,6 +208,7 @@ extra_rdoc_files: []
180
208
  files:
181
209
  - ".env_example"
182
210
  - ".rspec"
211
+ - ".travis.yml"
183
212
  - Gemfile
184
213
  - LICENSE
185
214
  - README.md
@@ -203,6 +232,7 @@ files:
203
232
  - lib/marc2linkeddata/readMarcCatalog.rb
204
233
  - lib/marc2linkeddata/resource.rb
205
234
  - lib/marc2linkeddata/sparql.rb
235
+ - lib/marc2linkeddata/sparql_pubmed.rb
206
236
  - lib/marc2linkeddata/viaf.rb
207
237
  - marc2linkeddata.gemspec
208
238
  - spec/marc2linkeddata/configuration_spec.rb
@@ -223,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
253
  requirements:
224
254
  - - ">="
225
255
  - !ruby/object:Gem::Version
226
- version: 2.1.0
256
+ version: '0'
227
257
  required_rubygems_version: !ruby/object:Gem::Requirement
228
258
  requirements:
229
259
  - - ">="
@@ -231,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
261
  version: 1.3.6
232
262
  requirements: []
233
263
  rubyforge_project:
234
- rubygems_version: 2.2.2
264
+ rubygems_version: 2.4.5
235
265
  signing_key:
236
266
  specification_version: 4
237
267
  summary: Convert Marc21 records to linked data, for use in SUL/DLSS projects