gutenberg_rdf 0.4.0 → 1.0.0
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 +5 -5
- data/.gitignore +12 -16
- data/.rspec +2 -1
- data/Gemfile +4 -2
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +5 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/gutenberg_rdf.gemspec +11 -8
- data/lib/gutenberg_rdf.rb +4 -6
- data/lib/gutenberg_rdf/rdf.rb +1 -2
- data/lib/gutenberg_rdf/rdf/agent.rb +1 -2
- data/lib/gutenberg_rdf/rdf/media.rb +1 -2
- data/lib/gutenberg_rdf/version.rb +1 -1
- metadata +15 -24
- data/spec/gutenberg_rdf/rdf/agent_spec.rb +0 -122
- data/spec/gutenberg_rdf/rdf/media_spec.rb +0 -44
- data/spec/gutenberg_rdf/rdf_spec.rb +0 -411
- data/spec/gutenberg_rdf_spec.rb +0 -16
- data/spec/spec_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0be60949cba5d85382505e3f733dd10c8073a195686445eb8155d7daccc5f1be
|
4
|
+
data.tar.gz: 52891b85fe5c929dde273c1f88d917088c5ae59208d6bc3586399dabc9b433a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 410da42160bc5de3f58c8317e2e822bf9f1b47ad436b43293c0bb32585c8786e377c7f3b0598dd5842227b628a167655f6915adc88f123978d1a7120fdc5429a
|
7
|
+
data.tar.gz: b2211f3aec3f89b6aca3576f76ce4bddd2867e1ef341f4090fd4ceff9478fe65a7cec6f94c8044da86178f3b5a9a04bfe93ea4f91d7c57ad6879427b7da25a52
|
data/.gitignore
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
# rspec failure tracking
|
11
|
+
.rspec_status
|
12
|
+
|
1
13
|
*.gem
|
2
14
|
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
15
|
|
19
|
-
.ruby-*
|
20
16
|
.DS_Store
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gutenberg_rdf (0.4.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rspec (3.8.0)
|
11
|
+
rspec-core (~> 3.8.0)
|
12
|
+
rspec-expectations (~> 3.8.0)
|
13
|
+
rspec-mocks (~> 3.8.0)
|
14
|
+
rspec-core (3.8.0)
|
15
|
+
rspec-support (~> 3.8.0)
|
16
|
+
rspec-expectations (3.8.1)
|
17
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
18
|
+
rspec-support (~> 3.8.0)
|
19
|
+
rspec-mocks (3.8.0)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.8.0)
|
22
|
+
rspec-support (3.8.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
gutenberg_rdf!
|
29
|
+
rspec (>= 3.4.0)
|
30
|
+
|
31
|
+
BUNDLED WITH
|
32
|
+
1.16.1
|
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
7
|
+
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
9
|
+
# require "pry"
|
10
|
+
# Pry.start
|
11
|
+
|
12
|
+
require "irb"
|
13
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/gutenberg_rdf.gemspec
CHANGED
@@ -1,23 +1,26 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require "gutenberg_rdf/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "gutenberg_rdf"
|
7
7
|
spec.version = GutenbergRdf::VERSION
|
8
|
-
spec.authors = ["
|
9
|
-
spec.email = ["
|
8
|
+
spec.authors = ["Michael R. Cook"]
|
9
|
+
spec.email = ["git@mrcook.uk"]
|
10
|
+
|
10
11
|
spec.summary = %q{A Ruby wrapper for the Project Gutenberg RDF catalog files.}
|
11
12
|
spec.description = %q{A Ruby wrapper for the Project Gutenberg RDF catalog files (requires Ruby 2).}
|
12
13
|
spec.homepage = "https://github.com/mrcook/gutenberg_rdf"
|
13
14
|
spec.license = "MIT"
|
14
15
|
|
15
|
-
spec.files = `git ls-files`.split(
|
16
|
-
|
17
|
-
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
21
|
spec.require_paths = ["lib"]
|
19
22
|
|
20
23
|
spec.required_ruby_version = ">= 2.0.0" # so we have UTF-8 by default
|
21
24
|
|
22
|
-
spec.add_development_dependency "rspec", "
|
25
|
+
spec.add_development_dependency "rspec", ">= 3.4.0"
|
23
26
|
end
|
data/lib/gutenberg_rdf.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'rexml/document'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require 'gutenberg_rdf/rdf'
|
4
|
+
require 'gutenberg_rdf/rdf/agent'
|
5
|
+
require 'gutenberg_rdf/rdf/media'
|
6
|
+
require 'gutenberg_rdf/version'
|
7
7
|
|
8
8
|
module GutenbergRdf
|
9
|
-
|
10
9
|
def self.parse(path)
|
11
10
|
Rdf.new(REXML::Document.new(File.new(path)))
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
data/lib/gutenberg_rdf/rdf.rb
CHANGED
@@ -52,7 +52,7 @@ module GutenbergRdf
|
|
52
52
|
entries
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
private
|
56
56
|
|
57
57
|
def name_parts
|
58
58
|
parts = xml.elements['pgterms:name'].text.split(/, */)
|
@@ -61,7 +61,6 @@ module GutenbergRdf
|
|
61
61
|
|
62
62
|
{first: first, last: last}
|
63
63
|
end
|
64
|
-
|
65
64
|
end
|
66
65
|
end
|
67
66
|
end
|
@@ -23,7 +23,7 @@ module GutenbergRdf
|
|
23
23
|
DateTime.parse(xml.elements['dcterms:modified'].text + '-07:00')
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
private
|
27
27
|
|
28
28
|
def datatype
|
29
29
|
parts = xml.elements['dcterms:format/rdf:Description/rdf:value'].text.split(/; */)
|
@@ -31,7 +31,6 @@ module GutenbergRdf
|
|
31
31
|
e = parts.join(';').sub('charset=', '')
|
32
32
|
{type: t, encoding: e}
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
metadata
CHANGED
@@ -1,56 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gutenberg_rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Michael R. Cook
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.4.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.4.0
|
27
27
|
description: A Ruby wrapper for the Project Gutenberg RDF catalog files (requires
|
28
28
|
Ruby 2).
|
29
29
|
email:
|
30
|
-
-
|
31
|
-
executables:
|
32
|
-
- rdf
|
30
|
+
- git@mrcook.uk
|
31
|
+
executables: []
|
33
32
|
extensions: []
|
34
33
|
extra_rdoc_files: []
|
35
34
|
files:
|
36
35
|
- ".gitignore"
|
37
36
|
- ".rspec"
|
38
37
|
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
39
|
- LICENSE.txt
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
|
+
- bin/console
|
42
43
|
- bin/rdf
|
44
|
+
- bin/setup
|
43
45
|
- gutenberg_rdf.gemspec
|
44
46
|
- lib/gutenberg_rdf.rb
|
45
47
|
- lib/gutenberg_rdf/rdf.rb
|
46
48
|
- lib/gutenberg_rdf/rdf/agent.rb
|
47
49
|
- lib/gutenberg_rdf/rdf/media.rb
|
48
50
|
- lib/gutenberg_rdf/version.rb
|
49
|
-
- spec/gutenberg_rdf/rdf/agent_spec.rb
|
50
|
-
- spec/gutenberg_rdf/rdf/media_spec.rb
|
51
|
-
- spec/gutenberg_rdf/rdf_spec.rb
|
52
|
-
- spec/gutenberg_rdf_spec.rb
|
53
|
-
- spec/spec_helper.rb
|
54
51
|
homepage: https://github.com/mrcook/gutenberg_rdf
|
55
52
|
licenses:
|
56
53
|
- MIT
|
@@ -71,14 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
68
|
version: '0'
|
72
69
|
requirements: []
|
73
70
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
71
|
+
rubygems_version: 2.7.6
|
75
72
|
signing_key:
|
76
73
|
specification_version: 4
|
77
74
|
summary: A Ruby wrapper for the Project Gutenberg RDF catalog files.
|
78
|
-
test_files:
|
79
|
-
- spec/gutenberg_rdf/rdf/agent_spec.rb
|
80
|
-
- spec/gutenberg_rdf/rdf/media_spec.rb
|
81
|
-
- spec/gutenberg_rdf/rdf_spec.rb
|
82
|
-
- spec/gutenberg_rdf_spec.rb
|
83
|
-
- spec/spec_helper.rb
|
84
|
-
has_rdoc:
|
75
|
+
test_files: []
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module GutenbergRdf
|
4
|
-
class Rdf
|
5
|
-
describe Agent do
|
6
|
-
let(:xml) do
|
7
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:marcrel="http://id.loc.gov/vocabulary/relators/">
|
8
|
-
<pgterms:ebook rdf:about="ebooks/99999999">
|
9
|
-
<dcterms:creator>
|
10
|
-
<pgterms:agent rdf:about="2009/agents/402">
|
11
|
-
<pgterms:deathdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1905</pgterms:deathdate>
|
12
|
-
<pgterms:birthdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1830</pgterms:birthdate>
|
13
|
-
<pgterms:name>Doe, Jon James</pgterms:name>
|
14
|
-
<pgterms:alias>Doe, Jon</pgterms:alias>
|
15
|
-
<pgterms:alias>Doe, J. J.</pgterms:alias>
|
16
|
-
<pgterms:webpage rdf:resource="http://en.wikipedia.org/wiki/Jon_James_Doe"/>
|
17
|
-
</pgterms:agent>
|
18
|
-
</dcterms:creator>
|
19
|
-
</pgterms:ebook>
|
20
|
-
</rdf:RDF>'
|
21
|
-
end
|
22
|
-
let(:agent) do
|
23
|
-
Agent.new(REXML::Document.new(xml).root.elements['pgterms:ebook/dcterms:creator/pgterms:agent'])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "expects an agent ID" do
|
27
|
-
expect(agent.id).to eq '402'
|
28
|
-
end
|
29
|
-
|
30
|
-
it "sets a default role" do
|
31
|
-
expect(agent.role).to eq 'oth'
|
32
|
-
end
|
33
|
-
|
34
|
-
it "expects the last name" do
|
35
|
-
expect(agent.lastname).to eq 'Doe'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "expects the first name(s)" do
|
39
|
-
expect(agent.firstname).to eq 'Jon James'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "expects the full name" do
|
43
|
-
expect(agent.fullname).to eq 'Jon James Doe'
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns the #fullname when to_s is called" do
|
47
|
-
expect(agent.to_s).to eq 'Jon James Doe'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "expects a birth date" do
|
51
|
-
expect(agent.birthdate).to eq '1830'
|
52
|
-
end
|
53
|
-
|
54
|
-
it "expects a death date" do
|
55
|
-
expect(agent.deathdate).to eq '1905'
|
56
|
-
end
|
57
|
-
|
58
|
-
it "expects a webpage" do
|
59
|
-
expect(agent.webpage).to eq 'http://en.wikipedia.org/wiki/Jon_James_Doe'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "expects any alias names" do
|
63
|
-
expect(agent.aliases[0]).to eq 'Doe, Jon'
|
64
|
-
expect(agent.aliases[1]).to eq 'Doe, J. J.'
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when only a single name is given" do
|
68
|
-
let(:agent) do
|
69
|
-
xml = '<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
70
|
-
<pgterms:agent rdf:about="2009/agents/402">
|
71
|
-
<pgterms:name>Dato</pgterms:name>
|
72
|
-
</pgterms:agent>
|
73
|
-
</rdf:RDF>'
|
74
|
-
Agent.new(REXML::Document.new(xml).root.elements['pgterms:agent'])
|
75
|
-
end
|
76
|
-
|
77
|
-
it "expects it to be assigned to the last name" do
|
78
|
-
expect(agent.lastname).to eq 'Dato'
|
79
|
-
end
|
80
|
-
it "expects firstname to be an empty string" do
|
81
|
-
expect(agent.firstname).to eq ''
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when the name has a suffix" do
|
86
|
-
let(:agent) do
|
87
|
-
xml = '<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
88
|
-
<pgterms:agent rdf:about="2009/agents/402">
|
89
|
-
<pgterms:name>Doe, Jon, Sir</pgterms:name>
|
90
|
-
</pgterms:agent>
|
91
|
-
</rdf:RDF>'
|
92
|
-
Agent.new(REXML::Document.new(xml).root.elements['pgterms:agent'])
|
93
|
-
end
|
94
|
-
|
95
|
-
it "expects the correct name order" do
|
96
|
-
expect(agent.firstname).to eq 'Sir Jon'
|
97
|
-
expect(agent.lastname).to eq 'Doe'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "when full name is given in (brackets)" do
|
102
|
-
let(:agent) do
|
103
|
-
xml = '<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
104
|
-
<pgterms:agent agent:about="2009/agents/402">
|
105
|
-
<pgterms:name>Doe, J. J. (Jon James)</pgterms:name>
|
106
|
-
</pgterms:agent>
|
107
|
-
</rdf:RDF>'
|
108
|
-
Agent.new(REXML::Document.new(xml).root.elements['pgterms:agent'])
|
109
|
-
end
|
110
|
-
|
111
|
-
it "expects initials to replaced by name in brackets" do
|
112
|
-
pending "Not yet implemented"
|
113
|
-
expect(agent.firstname).to eq 'Jon James'
|
114
|
-
expect(agent.lastname).to eq 'Doe'
|
115
|
-
end
|
116
|
-
it "expects the name (excluding name in brackets) to be added to the aliases"
|
117
|
-
it "should not have duplicate aliases"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module GutenbergRdf
|
4
|
-
class Rdf
|
5
|
-
describe Media do
|
6
|
-
let(:xml) do
|
7
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
8
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
9
|
-
<dcterms:hasFormat>
|
10
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/98765.txt.utf-8">
|
11
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
12
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">293684</dcterms:extent>
|
13
|
-
<dcterms:format>
|
14
|
-
<rdf:Description rdf:nodeID="N87dfy78yd78s6gsg6f8970d76g0f6d9b">
|
15
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain; charset=utf-8</rdf:value>
|
16
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
17
|
-
</rdf:Description>
|
18
|
-
</dcterms:format>
|
19
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2010-02-16T08:29:52.373092</dcterms:modified>
|
20
|
-
</pgterms:file>
|
21
|
-
</dcterms:hasFormat>
|
22
|
-
</pgterms:ebook>
|
23
|
-
</rdf:RDF>'
|
24
|
-
end
|
25
|
-
let(:media) { Media.new(REXML::Document.new(xml).elements['rdf:RDF/pgterms:ebook/dcterms:hasFormat/pgterms:file']) }
|
26
|
-
|
27
|
-
it "expects the file URI" do
|
28
|
-
expect(media.uri).to eql 'http://www.gutenberg.org/ebooks/98765.txt.utf-8'
|
29
|
-
end
|
30
|
-
it "expects the file media type" do
|
31
|
-
expect(media.media_type).to eql 'text/plain'
|
32
|
-
end
|
33
|
-
it "expects the file encoding" do
|
34
|
-
expect(media.encoding).to eql 'utf-8'
|
35
|
-
end
|
36
|
-
it "expects modified to be a DateTime" do
|
37
|
-
expect(media.modified.class).to be DateTime
|
38
|
-
end
|
39
|
-
it "should return the modified datetime" do
|
40
|
-
expect(media.modified.to_s).to eql '2010-02-16T08:29:52-07:00'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,411 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module GutenbergRdf
|
4
|
-
describe Rdf do
|
5
|
-
|
6
|
-
describe "basic metadata" do
|
7
|
-
let(:xml) do
|
8
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
9
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
10
|
-
<dcterms:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2006-09-28</dcterms:issued>
|
11
|
-
<dcterms:language>
|
12
|
-
<rdf:Description rdf:nodeID="N88989dfs7984987df987cvcsd876ew79">
|
13
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/RFC4646">en</rdf:value>
|
14
|
-
</rdf:Description>
|
15
|
-
</dcterms:language>
|
16
|
-
<dcterms:publisher>Project Gutenberg</dcterms:publisher>
|
17
|
-
<dcterms:rights>Public domain in the USA.</dcterms:rights>
|
18
|
-
</pgterms:ebook>
|
19
|
-
</rdf:RDF>'
|
20
|
-
end
|
21
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
22
|
-
|
23
|
-
it "expects an id" do
|
24
|
-
expect(rdf.id).to eql "98765"
|
25
|
-
end
|
26
|
-
it "expects a published date" do
|
27
|
-
expect(rdf.published).to eql "2006-09-28"
|
28
|
-
end
|
29
|
-
it "expects a publisher" do
|
30
|
-
expect(rdf.publisher).to eql "Project Gutenberg"
|
31
|
-
end
|
32
|
-
it "expects a language" do
|
33
|
-
expect(rdf.language).to eql "en"
|
34
|
-
end
|
35
|
-
it "expects the rights" do
|
36
|
-
expect(rdf.rights).to eql "Public domain in the USA."
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#type" do
|
41
|
-
let(:xml) do
|
42
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
43
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
44
|
-
<dcterms:type>
|
45
|
-
<rdf:Description rdf:nodeID="Nd89943yhljdsf93489ydfs897g7fd897">
|
46
|
-
<rdf:value>Text</rdf:value>
|
47
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/DCMIType"/>
|
48
|
-
</rdf:Description>
|
49
|
-
</dcterms:type>
|
50
|
-
</pgterms:ebook>
|
51
|
-
</rdf:RDF>'
|
52
|
-
end
|
53
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
54
|
-
|
55
|
-
it "expect the type of entity" do
|
56
|
-
expect(rdf.type).to eql 'Text'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "Titles" do
|
61
|
-
let(:xml) do
|
62
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
63
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
64
|
-
<dcterms:title>A Great Title</dcterms:title>
|
65
|
-
</pgterms:ebook>
|
66
|
-
</rdf:RDF>'
|
67
|
-
end
|
68
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
69
|
-
|
70
|
-
it "expects a title" do
|
71
|
-
expect(rdf.title).to eql 'A Great Title'
|
72
|
-
end
|
73
|
-
it "expects subtitle to be empty" do
|
74
|
-
expect(rdf.subtitle).to eql ''
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with a title and subtitle, on separate lines" do
|
78
|
-
let(:xml) do
|
79
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
80
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
81
|
-
<dcterms:title>A Great Multi-Title
|
82
|
-
Or, a Subtitle</dcterms:title>
|
83
|
-
</pgterms:ebook>
|
84
|
-
</rdf:RDF>'
|
85
|
-
end
|
86
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
87
|
-
|
88
|
-
it "expects the title to be the first line" do
|
89
|
-
expect(rdf.title).to eql 'A Great Multi-Title'
|
90
|
-
end
|
91
|
-
it "expects the subtitle to be the second line" do
|
92
|
-
expect(rdf.subtitle).to eql 'Or, a Subtitle'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "with; title, or, subtitle (we need to split on the 'or')" do
|
97
|
-
let(:xml) do
|
98
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
99
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
100
|
-
<dcterms:title>A Great Multi-Title, or, a Subtitle</dcterms:title>
|
101
|
-
</pgterms:ebook>
|
102
|
-
</rdf:RDF>'
|
103
|
-
end
|
104
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
105
|
-
|
106
|
-
it "expects the title to be the first line" do
|
107
|
-
expect(rdf.title).to eql 'A Great Multi-Title'
|
108
|
-
end
|
109
|
-
it "expects the subtitle to be the second line" do
|
110
|
-
expect(rdf.subtitle).to eql 'a Subtitle'
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context "when title:subtitle are separated by a colon" do
|
115
|
-
let(:xml) do
|
116
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
117
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
118
|
-
<dcterms:title>A Great Multi-Title: And a Subtitle</dcterms:title>
|
119
|
-
</pgterms:ebook>
|
120
|
-
</rdf:RDF>'
|
121
|
-
end
|
122
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
123
|
-
|
124
|
-
it "expects a title" do
|
125
|
-
expect(rdf.title).to eql 'A Great Multi-Title'
|
126
|
-
end
|
127
|
-
it "expects a subtitle" do
|
128
|
-
expect(rdf.subtitle).to eql 'And a Subtitle'
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "when title; and subtitle are separated by a semi-colon" do
|
133
|
-
let(:xml) do
|
134
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
135
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
136
|
-
<dcterms:title>A Great Multi-Title; Or, a Subtitle</dcterms:title>
|
137
|
-
</pgterms:ebook>
|
138
|
-
</rdf:RDF>'
|
139
|
-
end
|
140
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
141
|
-
it "expects a title" do
|
142
|
-
expect(rdf.title).to eql 'A Great Multi-Title'
|
143
|
-
end
|
144
|
-
it "expects a subtitle" do
|
145
|
-
expect(rdf.subtitle).to eql 'Or, a Subtitle'
|
146
|
-
end
|
147
|
-
|
148
|
-
context "...except when subtitles already exists" do
|
149
|
-
let(:xml) do
|
150
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
151
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
152
|
-
<dcterms:title>A Great Multi-Title; and some other text
|
153
|
-
Then a Subtitle on a newline</dcterms:title>
|
154
|
-
</pgterms:ebook>
|
155
|
-
</rdf:RDF>'
|
156
|
-
end
|
157
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
158
|
-
it "expects a title" do
|
159
|
-
expect(rdf.title).to eql 'A Great Multi-Title; and some other text'
|
160
|
-
end
|
161
|
-
it "expects a subtitle" do
|
162
|
-
expect(rdf.subtitle).to eql 'Then a Subtitle on a newline'
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#authors" do
|
169
|
-
let(:xml) do
|
170
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:marcrel="http://id.loc.gov/vocabulary/relators/">
|
171
|
-
<pgterms:ebook rdf:about="ebooks/99999999">
|
172
|
-
<dcterms:creator>
|
173
|
-
<pgterms:agent rdf:about="2009/agents/116">
|
174
|
-
<pgterms:alias>Verschillende</pgterms:alias>
|
175
|
-
<pgterms:name>Various</pgterms:name>
|
176
|
-
</pgterms:agent>
|
177
|
-
</dcterms:creator>
|
178
|
-
<marcrel:ctb>
|
179
|
-
<pgterms:agent rdf:about="2009/agents/402">
|
180
|
-
<pgterms:deathdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1830</pgterms:deathdate>
|
181
|
-
<pgterms:birthdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1905</pgterms:birthdate>
|
182
|
-
<pgterms:name>Dodge, Mary Mapes</pgterms:name>
|
183
|
-
<pgterms:alias>Dodge, Mary</pgterms:alias>
|
184
|
-
<pgterms:webpage rdf:resource="http://en.wikipedia.org/wiki/Mary_Mapes_Dodge"/>
|
185
|
-
</pgterms:agent>
|
186
|
-
</marcrel:ctb>
|
187
|
-
</pgterms:ebook>
|
188
|
-
</rdf:RDF>'
|
189
|
-
end
|
190
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
191
|
-
|
192
|
-
it "returns the correct number of authors" do
|
193
|
-
expect(rdf.authors.count).to be 2
|
194
|
-
end
|
195
|
-
it "expects an Agent object" do
|
196
|
-
expect(rdf.authors[0]).to be_an_instance_of Rdf::Agent
|
197
|
-
end
|
198
|
-
it "expects the author to have an aut role" do
|
199
|
-
expect(rdf.authors[0].role).to eq 'aut'
|
200
|
-
end
|
201
|
-
it "has the correct author names" do
|
202
|
-
expect(rdf.authors[1].fullname).to eq 'Mary Mapes Dodge'
|
203
|
-
end
|
204
|
-
it "expects other agents to have the correct role" do
|
205
|
-
expect(rdf.authors[1].role).to eq 'ctb'
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "#subjects" do
|
210
|
-
let(:xml) do
|
211
|
-
%q{<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
212
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
213
|
-
<dcterms:subject>
|
214
|
-
<rdf:Description rdf:nodeID="Ndfsc8xdsfwar734897n7sdofyhod11b9">
|
215
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCC"/>
|
216
|
-
<rdf:value>PZ</rdf:value>
|
217
|
-
</rdf:Description>
|
218
|
-
</dcterms:subject>
|
219
|
-
<dcterms:subject>
|
220
|
-
<rdf:Description rdf:nodeID="Ndfcdh8934hsdljkfh98y89hlfhltyab8">
|
221
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/>
|
222
|
-
<rdf:value>Children's literature -- Periodicals</rdf:value>
|
223
|
-
<rdf:value>Children's periodicals, American</rdf:value>
|
224
|
-
</rdf:Description>
|
225
|
-
</dcterms:subject>
|
226
|
-
</pgterms:ebook>
|
227
|
-
</rdf:RDF>}
|
228
|
-
end
|
229
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
230
|
-
it "expects correct number to be returned" do
|
231
|
-
expect(rdf.subjects.count).to be 2
|
232
|
-
end
|
233
|
-
it "expects the correct data" do
|
234
|
-
expect(rdf.subjects.first).to eql "Children's literature -- Periodicals"
|
235
|
-
expect(rdf.subjects.last).to eql "Children's periodicals, American"
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "#covers" do
|
240
|
-
describe "official PG covers" do
|
241
|
-
let(:xml) do
|
242
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
243
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
244
|
-
<dcterms:hasFormat>
|
245
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/cache/epub/98765/pg98765.cover.small.jpg">
|
246
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2699</dcterms:extent>
|
247
|
-
<dcterms:format>
|
248
|
-
<rdf:Description rdf:nodeID="N9u34589eyfdiuy8934y787d8f97sg786">
|
249
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
250
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">image/jpeg</rdf:value>
|
251
|
-
</rdf:Description>
|
252
|
-
</dcterms:format>
|
253
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
254
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2013-03-25T20:57:55.668737</dcterms:modified>
|
255
|
-
</pgterms:file>
|
256
|
-
</dcterms:hasFormat>
|
257
|
-
<pgterms:marc901>http://www.gutenberg.org/files/98765/98765-h/images/cover.jpg</pgterms:marc901>
|
258
|
-
<pgterms:marc901>file:///public/vhost/g/gutenberg/html/files/98765/98765-h/images/cover.jpg</pgterms:marc901>
|
259
|
-
<pgterms:marc901>file:///public/vhost/g/gutenberg/html/files/98765/98765-rst/images/cover.jpg</pgterms:marc901>
|
260
|
-
<dcterms:hasFormat>
|
261
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/cache/epub/98765/pg98765.cover.medium.jpg">
|
262
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2013-03-25T20:57:55.889736</dcterms:modified>
|
263
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
264
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10856</dcterms:extent>
|
265
|
-
<dcterms:format>
|
266
|
-
<rdf:Description rdf:nodeID="N8df89ys8993p4qu89uenf89dusp38a07">
|
267
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
268
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">image/jpeg</rdf:value>
|
269
|
-
</rdf:Description>
|
270
|
-
</dcterms:format>
|
271
|
-
</pgterms:file>
|
272
|
-
</dcterms:hasFormat>
|
273
|
-
</pgterms:ebook>
|
274
|
-
</rdf:RDF>'
|
275
|
-
end
|
276
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
277
|
-
|
278
|
-
it "expects the correct number of entries returned" do
|
279
|
-
expect(rdf.covers.count).to be 4
|
280
|
-
end
|
281
|
-
it "expect medium cover url to be first in the list" do
|
282
|
-
expect(rdf.covers[0]).to eql 'http://www.gutenberg.org/cache/epub/98765/pg98765.cover.medium.jpg'
|
283
|
-
end
|
284
|
-
it "expect the small cover url after the medium" do
|
285
|
-
expect(rdf.covers[1]).to eql 'http://www.gutenberg.org/cache/epub/98765/pg98765.cover.small.jpg'
|
286
|
-
end
|
287
|
-
it "expects any other images to be listed after the official ones" do
|
288
|
-
expect(rdf.covers[2]).to eql 'http://www.gutenberg.org/files/98765/98765-h/images/cover.jpg'
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe "HTML ebook cover image" do
|
293
|
-
let(:xml) do
|
294
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
295
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
296
|
-
<pgterms:marc901>file:///public/vhost/g/gutenberg/html/files/98765/98765-rst/images/cover.jpg</pgterms:marc901>
|
297
|
-
<pgterms:marc901>file:///public/vhost/g/gutenberg/html/files/98765/98765-h/images/cover.jpg</pgterms:marc901>
|
298
|
-
<pgterms:marc901>http://www.gutenberg.org/files/98765/98765-h/images/cover.jpg</pgterms:marc901>
|
299
|
-
</pgterms:ebook>
|
300
|
-
</rdf:RDF>'
|
301
|
-
end
|
302
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
303
|
-
|
304
|
-
it "expects only unique entries" do
|
305
|
-
expect(rdf.covers.count).to be 2
|
306
|
-
end
|
307
|
-
it "should convert File URIs to the Gutenberg URL" do
|
308
|
-
expect(rdf.covers.first).to match 'http://www.gutenberg.org'
|
309
|
-
end
|
310
|
-
it "expects the HTML cover to be listed first" do
|
311
|
-
expect(rdf.covers[0]).to eql 'http://www.gutenberg.org/files/98765/98765-h/images/cover.jpg'
|
312
|
-
end
|
313
|
-
it "expects the RST cover to be listed after the HTML" do
|
314
|
-
expect(rdf.covers[1]).to eql 'http://www.gutenberg.org/files/98765/98765-rst/images/cover.jpg'
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "#ebook" do
|
320
|
-
let(:xml) do
|
321
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
322
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
323
|
-
<dcterms:hasFormat>
|
324
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/98765.txt.utf-8">
|
325
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
326
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">293684</dcterms:extent>
|
327
|
-
<dcterms:format>
|
328
|
-
<rdf:Description rdf:nodeID="N87dfy78yd78s6gsg6f8970d76g0f6d9b">
|
329
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain</rdf:value>
|
330
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
331
|
-
</rdf:Description>
|
332
|
-
</dcterms:format>
|
333
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2010-02-16T08:29:52.373092</dcterms:modified>
|
334
|
-
</pgterms:file>
|
335
|
-
</dcterms:hasFormat>
|
336
|
-
<dcterms:hasFormat>
|
337
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/files/98765/98765.zip">
|
338
|
-
<dcterms:format>
|
339
|
-
<rdf:Description rdf:nodeID="Ndfsd78tf34tukjehdsouyo4yrefh6dea">
|
340
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/zip</rdf:value>
|
341
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
342
|
-
</rdf:Description>
|
343
|
-
</dcterms:format>
|
344
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2006-09-28T12:37:26</dcterms:modified>
|
345
|
-
<dcterms:format>
|
346
|
-
<rdf:Description rdf:nodeID="Nfy7we43yhluwe9syrqyp2ewufy0f6d1e">
|
347
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain; charset=us-ascii</rdf:value>
|
348
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
349
|
-
</rdf:Description>
|
350
|
-
</dcterms:format>
|
351
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
352
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">116685</dcterms:extent>
|
353
|
-
</pgterms:file>
|
354
|
-
</dcterms:hasFormat>
|
355
|
-
</pgterms:ebook>
|
356
|
-
</rdf:RDF>'
|
357
|
-
end
|
358
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
359
|
-
|
360
|
-
it "expects the correct number of entries" do
|
361
|
-
expect(rdf.ebooks.count).to be 2
|
362
|
-
end
|
363
|
-
it "expects an entry to be a Media class" do
|
364
|
-
expect(rdf.ebooks.first).to be_an_instance_of Rdf::Media
|
365
|
-
end
|
366
|
-
|
367
|
-
context "only collect ebook media files" do
|
368
|
-
let(:xml) do
|
369
|
-
'<rdf:RDF xml:base="http://www.gutenberg.org/" xmlns:cc="http://web.resource.org/cc/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
370
|
-
<pgterms:ebook rdf:about="ebooks/98765">
|
371
|
-
<dcterms:hasFormat>
|
372
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/98765.txt.utf-8">
|
373
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
374
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">293684</dcterms:extent>
|
375
|
-
<dcterms:format>
|
376
|
-
<rdf:Description rdf:nodeID="N87dfy78yd78s6gsg6f8970d76g0f6d9b">
|
377
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain</rdf:value>
|
378
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
379
|
-
</rdf:Description>
|
380
|
-
</dcterms:format>
|
381
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2010-02-16T08:29:52.373092</dcterms:modified>
|
382
|
-
</pgterms:file>
|
383
|
-
</dcterms:hasFormat>
|
384
|
-
<dcterms:hasFormat>
|
385
|
-
<pgterms:file rdf:about="http://www.gutenberg.org/cache/epub/98765/pg98765.cover.small.jpg">
|
386
|
-
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2699</dcterms:extent>
|
387
|
-
<dcterms:format>
|
388
|
-
<rdf:Description rdf:nodeID="N9u34589eyfdiuy8934y787d8f97sg786">
|
389
|
-
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
|
390
|
-
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">image/jpeg</rdf:value>
|
391
|
-
</rdf:Description>
|
392
|
-
</dcterms:format>
|
393
|
-
<dcterms:isFormatOf rdf:resource="ebooks/98765"/>
|
394
|
-
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2013-03-25T20:57:55.668737</dcterms:modified>
|
395
|
-
</pgterms:file>
|
396
|
-
</dcterms:hasFormat>
|
397
|
-
</pgterms:ebook>
|
398
|
-
</rdf:RDF>'
|
399
|
-
end
|
400
|
-
let(:rdf) { Rdf.new(REXML::Document.new(xml)) }
|
401
|
-
|
402
|
-
it "only extracts one media file" do
|
403
|
-
expect(rdf.ebooks.count).to be 1
|
404
|
-
end
|
405
|
-
it "expects the media type to be for an ebook" do
|
406
|
-
expect(rdf.ebooks[0].media_type).to eq 'text/plain'
|
407
|
-
end
|
408
|
-
end
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
data/spec/gutenberg_rdf_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module GutenbergRdf
|
4
|
-
describe ".parse" do
|
5
|
-
let(:file) { StringIO.new('<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><pgterms:ebook rdf:about="ebooks/98765"/></rdf:RDF>') }
|
6
|
-
|
7
|
-
it "expects an Rdf object" do
|
8
|
-
File.stub(:new).and_return(file)
|
9
|
-
book = GutenbergRdf.parse(file)
|
10
|
-
|
11
|
-
expect(book.class).to be Rdf
|
12
|
-
expect(book.id).to eql '98765'
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
data/spec/spec_helper.rb
DELETED