relaton-bib 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +57 -0
- data/LICENSE.txt +21 -0
- data/README.adoc +272 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/relaton_bib.rb +7 -0
- data/lib/relaton_bib/bib_item_locality.rb +46 -0
- data/lib/relaton_bib/bibliographic_date.rb +76 -0
- data/lib/relaton_bib/bibliographic_item.rb +343 -0
- data/lib/relaton_bib/classification.rb +22 -0
- data/lib/relaton_bib/contribution_info.rb +61 -0
- data/lib/relaton_bib/contributor.rb +121 -0
- data/lib/relaton_bib/copyright_association.rb +38 -0
- data/lib/relaton_bib/document_identifier.rb +26 -0
- data/lib/relaton_bib/document_relation.rb +49 -0
- data/lib/relaton_bib/document_relation_collection.rb +21 -0
- data/lib/relaton_bib/document_status.rb +24 -0
- data/lib/relaton_bib/formatted_ref.rb +11 -0
- data/lib/relaton_bib/formatted_string.rb +33 -0
- data/lib/relaton_bib/localized_string.rb +45 -0
- data/lib/relaton_bib/medium.rb +24 -0
- data/lib/relaton_bib/organization.rb +103 -0
- data/lib/relaton_bib/person.rb +131 -0
- data/lib/relaton_bib/series.rb +96 -0
- data/lib/relaton_bib/typed_title_string.rb +41 -0
- data/lib/relaton_bib/typed_uri.rb +20 -0
- data/lib/relaton_bib/validity.rb +31 -0
- data/lib/relaton_bib/version.rb +3 -0
- data/lib/relaton_bib/xml_parser.rb +289 -0
- data/relaton-bib.gemspec +34 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 05365dd34321a3c2f80a6d73fd16abe5c530f3c5
|
4
|
+
data.tar.gz: 5d7fdd3b5eaea30767632c884a803e615e9eea00
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a88c9d5bc6fc001f6a6f8b13813e5225c662d25f97d0cd6fc852169886480a9210b590c69620c6a2f4ac1eb223328e525c0ef0f0da7b8f730b582c1e66e89882
|
7
|
+
data.tar.gz: b7b48023c0bd6f22e4685a0b8e44d9d07672f37cd82d861ab2dda33c9675b3288d665c712d0308e2c001b738eabec9cb8294b6776ffe8149375f14637c03ba90
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# This project follows the Ribose OSS style guide.
|
2
|
+
# https://github.com/riboseinc/oss-guides
|
3
|
+
# All project-specific additions and overrides should be specified in this file.
|
4
|
+
|
5
|
+
inherit_from:
|
6
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.3
|
9
|
+
Rails:
|
10
|
+
Enabled: true
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
relaton-bib (0.1.0)
|
5
|
+
nokogiri (~> 1.8.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
debase (0.2.2)
|
11
|
+
debase-ruby_core_source (>= 0.10.2)
|
12
|
+
debase-ruby_core_source (0.10.4)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
docile (1.3.1)
|
15
|
+
equivalent-xml (0.6.0)
|
16
|
+
nokogiri (>= 1.4.3)
|
17
|
+
json (2.2.0)
|
18
|
+
mini_portile2 (2.3.0)
|
19
|
+
nokogiri (1.8.5)
|
20
|
+
mini_portile2 (~> 2.3.0)
|
21
|
+
rake (10.5.0)
|
22
|
+
rspec (3.8.0)
|
23
|
+
rspec-core (~> 3.8.0)
|
24
|
+
rspec-expectations (~> 3.8.0)
|
25
|
+
rspec-mocks (~> 3.8.0)
|
26
|
+
rspec-core (3.8.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-expectations (3.8.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-mocks (3.8.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.8.0)
|
34
|
+
rspec-support (3.8.0)
|
35
|
+
ruby-debug-ide (0.6.1)
|
36
|
+
rake (>= 0.8.1)
|
37
|
+
simplecov (0.16.1)
|
38
|
+
docile (~> 1.1)
|
39
|
+
json (>= 1.8, < 3)
|
40
|
+
simplecov-html (~> 0.10.0)
|
41
|
+
simplecov-html (0.10.2)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler (~> 2.0)
|
48
|
+
debase
|
49
|
+
equivalent-xml (~> 0.6)
|
50
|
+
rake (~> 10.0)
|
51
|
+
relaton-bib!
|
52
|
+
rspec (~> 3.0)
|
53
|
+
ruby-debug-ide
|
54
|
+
simplecov
|
55
|
+
|
56
|
+
BUNDLED WITH
|
57
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Andrei Kislichenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.adoc
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
= RelatonBib
|
2
|
+
|
3
|
+
image:https://img.shields.io/gem/v/relaton-bib.svg["Gem Version", link="https://rubygems.org/gems/relaton-bib"]
|
4
|
+
image:https://img.shields.io/travis/metanorma/relaton-bib["Build Status", link="https://travis-ci.com/metanorma/relaton-bib"]
|
5
|
+
image:https://codeclimate.com/github/metanorma/relaton-bib["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-bib"]
|
6
|
+
|
7
|
+
RlatonBib is a Ruby gem that implements the https://github.com/metanorma/relaton-models#bibliography-uml-models[BibliographicItem model].
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
[source,ruby]
|
14
|
+
----
|
15
|
+
gem 'relaton-bib'
|
16
|
+
----
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install relaton-bib
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
=== Create bibliographic item
|
29
|
+
|
30
|
+
[source,ruby]
|
31
|
+
----
|
32
|
+
item = RelatonBib::BibliographicItem.new(
|
33
|
+
id: "ISO/TC211",
|
34
|
+
fetched: Date.today.to_s,
|
35
|
+
type: "standard",
|
36
|
+
titles: [
|
37
|
+
{ type: "main", content: "Geographic information", language: "en", script: "Latn" },
|
38
|
+
{
|
39
|
+
content: "Information géographique", language: "fr", script: "Latn"
|
40
|
+
},
|
41
|
+
],
|
42
|
+
link: [
|
43
|
+
{ type: "src", content: "https://www.iso.org/standard/53798.html" },
|
44
|
+
{ type: "obp",
|
45
|
+
content: "https://www.iso.org/obp/ui/#!iso:std:53798:en" },
|
46
|
+
{ type: "rss", content: "https://www.iso.org/contents/data/standard"\
|
47
|
+
"/05/37/53798.detail.rss" }
|
48
|
+
],
|
49
|
+
docid: [
|
50
|
+
RelatonBib::DocumentIdentifier.new(id: "TC211", type: "ISO")
|
51
|
+
],
|
52
|
+
docnumber: "123456",
|
53
|
+
dates: [
|
54
|
+
{ type: "published", on: "2014-04" },
|
55
|
+
{ type: "accessed", on: "2015" }
|
56
|
+
],
|
57
|
+
contributors: [
|
58
|
+
{ entity: {
|
59
|
+
name: "International Organization for Standardization",
|
60
|
+
url: "www.iso.org", abbreviation: "ISO", subdivision: "division" },
|
61
|
+
roles: [["publisher", ["Publisher role"]]], }
|
62
|
+
],
|
63
|
+
edition: "1",
|
64
|
+
version: RelatonBib::BibliographicItem::Version.new("2019-04-01", ["draft"]),
|
65
|
+
language: ["en", "fr"],
|
66
|
+
script: ["Latn"],
|
67
|
+
abstract: [
|
68
|
+
{ content: "ISO 19115-1:2014 defines the schema required for ...",
|
69
|
+
language: "en", script: "Latn", format: "text/plain" },
|
70
|
+
{ content: "L'ISO 19115-1:2014 définit le schéma requis pour ...",
|
71
|
+
language: "fr", script: "Latn", format: "text/plain" },
|
72
|
+
],
|
73
|
+
docstatus: RelatonBib::DocumentStatus.new(
|
74
|
+
RelatonBib::LocalizedString.new("standard", "en", "Latn")
|
75
|
+
),
|
76
|
+
copyright: { owner: {
|
77
|
+
name: "International Organization for Standardization",
|
78
|
+
abbreviation: "ISO", url: "www.iso.org"
|
79
|
+
},
|
80
|
+
from: "2014", to: "2020" },
|
81
|
+
relations: [
|
82
|
+
{ type: "updates",
|
83
|
+
bibitem: RelatonBib::BibliographicItem.new(
|
84
|
+
formattedref: RelatonBib::FormattedRef.new(content: "ISO 19115:2003"),
|
85
|
+
),
|
86
|
+
bib_locality: [RelatonBib::BibItemLocality.new("updates", "Reference form")],
|
87
|
+
}
|
88
|
+
],
|
89
|
+
series: [
|
90
|
+
RelatonBib::Series.new(
|
91
|
+
type: "main",
|
92
|
+
title: RelatonBib::TypedTitleString.new(
|
93
|
+
type: "original", content: "ISO/IEC FDIS 10118-3", language: "en",
|
94
|
+
script: "Latn", format: "text/plain",
|
95
|
+
),
|
96
|
+
place: "Serie's place",
|
97
|
+
organization: "Serie's organization",
|
98
|
+
abbreviation: RelatonBib::LocalizedString.new("ABVR", "en", "Latn"),
|
99
|
+
from: "2009-02-01",
|
100
|
+
to: "2010-12-20",
|
101
|
+
number: "serie1234",
|
102
|
+
partnumber: "part5678",
|
103
|
+
),
|
104
|
+
RelatonBib::Series.new(
|
105
|
+
type: "alt",
|
106
|
+
formattedref: RelatonBib::FormattedRef.new(
|
107
|
+
content: "serieref", language: "en", script: "Latn"
|
108
|
+
),
|
109
|
+
)
|
110
|
+
],
|
111
|
+
medium: RelatonBib::Medium.new(
|
112
|
+
form: "medium form", size: "medium size", scale: "medium scale"
|
113
|
+
),
|
114
|
+
place: ["bib place"],
|
115
|
+
extent: [
|
116
|
+
RelatonBib::BibItemLocality.new(
|
117
|
+
"section", "Reference from", "Reference to"
|
118
|
+
),
|
119
|
+
],
|
120
|
+
accesslocation: ["accesslocation1", "accesslocation2"],
|
121
|
+
classification: RelatonBib::Classification.new(type: "type", value: "value"),
|
122
|
+
validity: RelatonBib::Validity.new(
|
123
|
+
begins: Time.new(2010, 10, 10, 12, 21),
|
124
|
+
ends: Time.new(2011, 2, 3, 18,30),
|
125
|
+
revision: Time.new(2011, 3, 4, 9, 0)
|
126
|
+
)
|
127
|
+
)
|
128
|
+
----
|
129
|
+
|
130
|
+
=== BibliographicItem Typed Title Strings
|
131
|
+
|
132
|
+
[source,ruby]
|
133
|
+
----
|
134
|
+
item.title
|
135
|
+
=> [#<RelatonBib::TypedTitleString:0x007fa49a360290
|
136
|
+
@title=#<RelatonBib::FormattedString:0x007fa49a360088 @content="Geographic information", @format=nil, @language=["en"], @script=["Latn"]>,
|
137
|
+
@type="main">,
|
138
|
+
#<RelatonBib::TypedTitleString:0x007fa49a35bf38
|
139
|
+
@title=#<RelatonBib::FormattedString:0x007fa49a35bdd0 @content="Information géographique", @format=nil, @language=["fr"], @script=["Latn"]>,
|
140
|
+
@type=nil>]
|
141
|
+
----
|
142
|
+
|
143
|
+
=== BibliographicItem Formatted Strings
|
144
|
+
|
145
|
+
[source,ruby]
|
146
|
+
----
|
147
|
+
item.abstract
|
148
|
+
=> [#<RelatonBib::FormattedString:0x007fa49a35aed0 @content="ISO 19115-1:2014 defines the schema required for ...", @format="text/plain", @language=["en"], @script=["Latn"]>,
|
149
|
+
#<RelatonBib::FormattedString:0x007fa49a35ae08 @content="L'ISO 19115-1:2014 définit le schéma requis pour ...", @format="text/plain", @language=["fr"], @script=["Latn"]>]
|
150
|
+
|
151
|
+
item.abstract(lang: "en").to_s
|
152
|
+
=> "ISO 19115-1:2014 defines the schema required for ..."
|
153
|
+
"
|
154
|
+
----
|
155
|
+
|
156
|
+
=== BibliographicItem references
|
157
|
+
|
158
|
+
[source,ruby]
|
159
|
+
----
|
160
|
+
item.shortref item
|
161
|
+
=> "ISO/TC211:2014"
|
162
|
+
----
|
163
|
+
|
164
|
+
=== XML serialization
|
165
|
+
|
166
|
+
[source,ruby]
|
167
|
+
----
|
168
|
+
item.to_xml
|
169
|
+
=>"<bibitem id=\"ISO/TC211\" type=\"standard\">
|
170
|
+
<fetched>2019-04-30</fetched>
|
171
|
+
<title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
|
172
|
+
<title language=\"fr\" script=\"Latn\">Information géographique</title>
|
173
|
+
<uri type=\"src\">https://www.iso.org/standard/53798.html</uri>
|
174
|
+
<uri type=\"obp\">https://www.iso.org/obp/ui/#!iso:std:53798:en</uri>
|
175
|
+
<uri type=\"rss\">https://www.iso.org/contents/data/standard/05/37/53798.detail.rss</uri>
|
176
|
+
<docidentifier type=\"ISO\">TC211</docidentifier>
|
177
|
+
<docnumber>123456</docnumber>
|
178
|
+
<date type=\"published\">
|
179
|
+
<on>2014-04</on>
|
180
|
+
</date>
|
181
|
+
<date type=\"accessed\">
|
182
|
+
<on>2015-01</on>
|
183
|
+
</date>
|
184
|
+
<contributor>
|
185
|
+
<role type=\"publisher\">
|
186
|
+
<description>Publisher role</description>
|
187
|
+
</role>
|
188
|
+
<organization>
|
189
|
+
<name>International Organization for Standardization</name>
|
190
|
+
<subdivision>division</subdivision>
|
191
|
+
<abbreviation>ISO</abbreviation>
|
192
|
+
<uri>www.iso.org</uri>
|
193
|
+
</organization>
|
194
|
+
</contributor>
|
195
|
+
<edition>1</edition>
|
196
|
+
<version>
|
197
|
+
<revision_date>2019-04-01</revision_date>
|
198
|
+
<draft>draft</draft>
|
199
|
+
</version>
|
200
|
+
<language>en</language>
|
201
|
+
<language>fr</language>
|
202
|
+
<script>Latn</script>
|
203
|
+
<abstract format=\"text/plain\" language=\"en\" script=\"Latn\">ISO 19115-1:2014 defines the schema required for ...</abstract>
|
204
|
+
<abstract format=\"text/plain\" language=\"fr\" script=\"Latn\">L'ISO 19115-1:2014 définit le schéma requis pour ...</abstract>
|
205
|
+
<status language=\"en\" script=\"Latn\">standard</status>
|
206
|
+
<copyright>
|
207
|
+
<from>2014</from>
|
208
|
+
<to>2020</to>
|
209
|
+
<owner>
|
210
|
+
<organization>
|
211
|
+
<name>International Organization for Standardization</name>
|
212
|
+
<abbreviation>ISO</abbreviation>
|
213
|
+
<uri>www.iso.org</uri>
|
214
|
+
</organization>
|
215
|
+
</owner>
|
216
|
+
</copyright>
|
217
|
+
<relation type=\"updates\">
|
218
|
+
<bibitem>
|
219
|
+
<formattedref>ISO 19115:2003</formattedref>
|
220
|
+
</bibitem>
|
221
|
+
<locality type=\"updates\">
|
222
|
+
<referenceFrom>Reference form</referenceFrom>
|
223
|
+
</locality>
|
224
|
+
</relation>
|
225
|
+
<series type=\"main\">
|
226
|
+
<title type=\"original\" format=\"text/plain\" language=\"en\" script=\"Latn\">ISO/IEC FDIS 10118-3</title>
|
227
|
+
<place>Serie's place</place>
|
228
|
+
<organization>Serie's organization</organization>
|
229
|
+
<abbreviation language=\"en\" script=\"Latn\">ABVR</abbreviation>
|
230
|
+
<from>2009-02-01</from>
|
231
|
+
<to>2010-12-20</to>
|
232
|
+
<number>serie1234</number>
|
233
|
+
<partnumber>part5678</partnumber>
|
234
|
+
</series>
|
235
|
+
<series type=\"alt\">
|
236
|
+
<formattedref language=\"en\" script=\"Latn\">serieref</formattedref>
|
237
|
+
</series>
|
238
|
+
<medium>
|
239
|
+
<form>medium form</form>
|
240
|
+
<size>medium size</size>
|
241
|
+
<scale>medium scale</scale>
|
242
|
+
</medium>
|
243
|
+
<place>bib place</place>
|
244
|
+
<locality type=\"section\">
|
245
|
+
<referenceFrom>Reference from</referenceFrom>
|
246
|
+
<referenceTo>Reference to</referenceTo>
|
247
|
+
</locality>
|
248
|
+
<accesslocation>accesslocation1</accesslocation>
|
249
|
+
<accesslocation>accesslocation2</accesslocation>
|
250
|
+
<classification type=\"type\">value</classification>
|
251
|
+
<validity>
|
252
|
+
<validityBegins>2010-10-10 12:21</validityBegins>
|
253
|
+
<validityEnds>2011-02-03 18:30</validityEnds>
|
254
|
+
<validityRevision>2011-03-04 09:00</validityRevision>
|
255
|
+
</validity>
|
256
|
+
</bibitem>"
|
257
|
+
----
|
258
|
+
|
259
|
+
== Development
|
260
|
+
|
261
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
262
|
+
|
263
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
264
|
+
|
265
|
+
== Contributing
|
266
|
+
|
267
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/relaton-bib.
|
268
|
+
|
269
|
+
== License
|
270
|
+
|
271
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
272
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "relaton_bib"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED