relaton-cli 0.1.6 → 0.1.7

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: 6bd6e317d9d7a6e68ddd69415cb603725984a91b3203f903cb92809e8e34a90a
4
- data.tar.gz: 5d6832c5016afe1d0d45371eb94aeea3866fa1d512d0877e9f517b51725a28e4
3
+ metadata.gz: b73f1ac92117d1c3426a66fbe8ece05535b4441696a62a84f9aa5ce93379900f
4
+ data.tar.gz: fb5ceb3383573256860f22af4eea6a2699b7a04e5d014b4764d1d9b4964674d6
5
5
  SHA512:
6
- metadata.gz: 7437bae620dc49e6ab0399af8281adfa41653628b94bf8b6c9926ecf4077195a007ff0432b0e7dfe745eab95101ec3cf2adccdf0e988c30140833b7d1cc8c139
7
- data.tar.gz: e11fff9015de3be53557b3fbb420d4b6d48be3d4dba04d864f7aeeeb9bb678e739f2785487a967ee0983684540aed73a0fdccd13b61ca1ac0243f3720b9ecab6
6
+ metadata.gz: f3274a54be270c3e9bd72aac19590a78a783015a0b1963b16cea1de3bc7f03924e11399c10324506119f384bdb5ea78392074b43c1666f832ec4eb58bd273b32
7
+ data.tar.gz: 99351248582ea4313b872ddcb59ead76c41f6fc4fd1dabde7666b9dae14516d889f734d81d08bf8ceb562dd87fcedb34570c3f18255ee316b35ee6d326650c1d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton-cli (0.1.6)
4
+ relaton-cli (0.1.7)
5
5
  liquid
6
6
  relaton (~> 0.3)
7
7
  thor
@@ -9,9 +9,9 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.5.2)
12
+ addressable (2.6.0)
13
13
  public_suffix (>= 2.0.2, < 4.0)
14
- algoliasearch (1.24.0)
14
+ algoliasearch (1.25.2)
15
15
  httpclient (~> 2.8, >= 2.8.3)
16
16
  json (>= 1.5.1)
17
17
  byebug (10.0.2)
@@ -35,7 +35,7 @@ GEM
35
35
  isoics (~> 0.1.6)
36
36
  nokogiri (~> 1.8.4)
37
37
  ruby_deep_clone (~> 0.8.0)
38
- isobib (0.4.2)
38
+ isobib (0.4.3)
39
39
  algoliasearch
40
40
  iecbib (~> 0.2.1)
41
41
  iso-bib-item (~> 0.4.2)
@@ -86,7 +86,7 @@ PLATFORMS
86
86
  ruby
87
87
 
88
88
  DEPENDENCIES
89
- bundler (~> 1.16)
89
+ bundler (~> 2.0.1)
90
90
  byebug (~> 10.0)
91
91
  equivalent-xml (~> 0.6)
92
92
  pry
@@ -97,4 +97,4 @@ DEPENDENCIES
97
97
  rspec-core (~> 3.4)
98
98
 
99
99
  BUNDLED WITH
100
- 1.17.2
100
+ 2.0.1
File without changes
@@ -62,13 +62,28 @@ module Relaton
62
62
 
63
63
  def self.from_xml(source)
64
64
 
65
+ datetype = "circulated"
66
+
65
67
  # bib.relaton_xml_path = URI.escape("#{relaton_root}/#{id_code}.xml")
66
68
  revdate = source.at(ns("./date[@type = 'published']")) ||
67
- source.at(ns("./date[@type = 'circulated']")) || source.at(ns("./date"))
68
- datetype = "circulated"
69
- datetype = revdate["type"] if revdate
69
+ source.at(ns("./date[@type = 'circulated']")) ||
70
+ source.at(ns("./date"))
71
+ revdate_value = revdate&.at(ns("./on")) || revdate&.at(ns("./from"))
72
+
73
+ if revdate && revdate_value
74
+ datetype = revdate["type"]
75
+ revdate = begin
76
+ Date.parse(revdate_value.text.strip).to_s
77
+ rescue
78
+ warn "[relaton] parsing published date '#{revdate.text}' failed."
79
+ revdate_value.text.strip
80
+ end || nil
81
+ else
82
+ revdate = nil
83
+ end
84
+
70
85
 
71
- new({
86
+ options = {
72
87
  uri: source.at(ns("./uri[not(@type)]"))&.text,
73
88
  xml: source.at(ns("./uri[@type='xml']"))&.text,
74
89
  pdf: source.at(ns("./uri[@type='pdf']"))&.text,
@@ -81,7 +96,7 @@ module Relaton
81
96
  stage: source.at(ns("./status"))&.text,
82
97
  technical_committee: source.at(ns("./editorialgroup/technical-committee"))&.text,
83
98
  abstract: source.at(ns("./abstract"))&.text,
84
- revdate: revdate ? Date.parse(revdate.text) : nil,
99
+ revdate: revdate,
85
100
  language: source.at(ns("./language"))&.text,
86
101
  script: source.at(ns("./script"))&.text,
87
102
  edition: source.at(ns("./edition"))&.text,
@@ -92,7 +107,9 @@ module Relaton
92
107
  contributor_publisher_role: source.at(ns("./contributor/role[@type='publisher']"))&.text,
93
108
  contributor_publisher_organization: source.at(ns("./contributor/role[@type='publisher']"))&.parent&.at(ns("./organization/name"))&.text,
94
109
  datetype: datetype
95
- })
110
+ }
111
+
112
+ new(options)
96
113
  end
97
114
 
98
115
  def to_xml
@@ -16,7 +16,7 @@ module Relaton
16
16
  io.puts(fetch_document(code, options) || supported_type_message)
17
17
  end
18
18
 
19
- desc "extract Metanorma-XML-Directory Relaton-XML-Directory", "Extract Relaton XML from folder of Metanorma XML"
19
+ desc "extract Metanorma-XML-File / Directory Relaton-XML-Directory", "Extract Relaton XML from Metanorma XML file / directory"
20
20
  option :extension, aliases: :x, desc: "File extension of Relaton XML files, defaults to 'rxl'"
21
21
 
22
22
  def extract(source_dir, outdir)
@@ -21,10 +21,11 @@ module Relaton
21
21
 
22
22
  # Extract files
23
23
  #
24
- # This interface expect us to provide a source directory, output
25
- # directory and custom configuration options. Then it wll extract
26
- # Relaton XML files to output directory from the source directory
27
- # During this process it will use custom options when available.
24
+ # This interface expect us to provide a source file / directory,
25
+ # output directory and custom configuration options. Then it wll
26
+ # extract Relaton XML file / files to output directory from the
27
+ # source file / directory. During this process it will use custom
28
+ # options when available.
28
29
  #
29
30
  # @param source [Dir] The source directory for files
30
31
  # @param outdir [Dir] The output directory for files
@@ -71,8 +72,16 @@ module Relaton
71
72
  Nokogiri.XML(document)
72
73
  end
73
74
 
75
+ def select_source_files
76
+ if File.file?(source)
77
+ [source]
78
+ else
79
+ select_files_with("xml")
80
+ end
81
+ end
82
+
74
83
  def extract_and_write_to_files
75
- select_files_with("xml").each do |file|
84
+ select_source_files.each do |file|
76
85
  xml = nokogiri_document(nil, file)
77
86
  xml.remove_namespaces!
78
87
 
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "0.1.6".freeze
3
+ VERSION = "0.1.7".freeze
4
4
  end
5
5
  end
data/relaton-cli.gemspec CHANGED
@@ -15,16 +15,16 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "BSD-2-Clause"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
18
+ f.match(%r{^(test|spec|features|docs)/})
19
19
  end
20
- spec.extra_rdoc_files = %w[README.adoc LICENSE]
20
+ spec.extra_rdoc_files = %w[docs/README.adoc LICENSE]
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.required_ruby_version = ">= 2.3.0"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "bundler", "~> 2.0.1"
28
28
  spec.add_development_dependency "rake", "~> 12.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  spec.add_development_dependency "byebug", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-19 00:00:00.000000000 Z
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.0.1
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: '1.16'
26
+ version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +171,7 @@ executables:
171
171
  - relaton
172
172
  extensions: []
173
173
  extra_rdoc_files:
174
- - README.adoc
174
+ - docs/README.adoc
175
175
  - LICENSE
176
176
  files:
177
177
  - ".gitignore"
@@ -181,9 +181,9 @@ files:
181
181
  - Gemfile
182
182
  - Gemfile.lock
183
183
  - LICENSE
184
- - README.adoc
185
184
  - Rakefile
186
185
  - bin/rspec
186
+ - docs/README.adoc
187
187
  - exe/relaton
188
188
  - i18n.yaml
189
189
  - lib/relaton/bibcollection.rb