relaton-iso-bib 1.0.1 → 1.4.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.
@@ -26,7 +26,6 @@ module RelatonIsoBib
26
26
  @project_number = args[:project_number]
27
27
  @part = args[:part]
28
28
  @subpart = args[:subpart]
29
- # @prefix = args[:prefix]
30
29
  @type = args[:type]
31
30
  end
32
31
 
@@ -34,18 +33,19 @@ module RelatonIsoBib
34
33
  def remove_part
35
34
  @part_number = nil
36
35
  @subpart_number = nil
37
- case @type
38
- when "Chinese Standard" then @project_number = @project_number.sub(/\.\d+/, "")
39
- else
40
- @project_number = @project_number.sub(/-\d+/, "")
41
- end
36
+ @project_number = case @type
37
+ when "Chinese Standard"
38
+ @project_number.sub(/\.\d+/, "")
39
+ else
40
+ @project_number = @project_number.sub(/-\d+/, "")
41
+ end
42
42
  end
43
43
 
44
44
  def remove_date
45
- case @type
46
- when "Chinese Standard" then @project_number = @project_number.sub(/-[12]\d\d\d/, "")
45
+ if @type == "Chinese Standard"
46
+ @project_number.sub!(/-[12]\d\d\d/, "")
47
47
  else
48
- @project_number = @project_number.sub(/:[12]\d\d\d/, "")
48
+ @project_number.sub!(/:[12]\d\d\d/, "")
49
49
  end
50
50
  end
51
51
 
@@ -63,7 +63,9 @@ module RelatonIsoBib
63
63
  pn = builder.send "project-number", project_number
64
64
  pn[:part] = part if part
65
65
  pn[:subpart] = subpart if subpart
66
- builder.send "tc-document-number", tc_document_number if tc_document_number
66
+ if tc_document_number
67
+ builder.send "tc-document-number", tc_document_number
68
+ end
67
69
  end
68
70
  xml[:type] = type if type
69
71
  end
@@ -78,5 +80,27 @@ module RelatonIsoBib
78
80
  hash["type"] = type if type
79
81
  hash
80
82
  end
83
+
84
+ # @param prefix [String]
85
+ # @return [String]
86
+ def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
87
+ pref = prefix.empty? ? prefix : prefix + "."
88
+ pref += "structured_identifier"
89
+ out = ""
90
+ if tc_document_number
91
+ out += "#{pref}.tc_document_number:: #{tc_document_number}\n"
92
+ end
93
+ if project_number
94
+ out += "#{pref}.project_number:: #{project_number}\n"
95
+ end
96
+ out += "#{pref}.part:: #{part}\n" if part
97
+ out += "#{pref}.subpart:: #{subpart}\n" if subpart
98
+ out += "#{pref}.type:: #{type}\n" if type
99
+ out
100
+ end
101
+
102
+ def presence?
103
+ true
104
+ end
81
105
  end
82
106
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIsoBib
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
@@ -15,7 +15,6 @@ module RelatonIsoBib
15
15
 
16
16
  data[:doctype] = ext.at("./doctype")&.text
17
17
  data[:editorialgroup] = fetch_editorialgroup ext
18
- data[:ics] = fetch_ics ext
19
18
  data[:structuredidentifier] = fetch_structuredidentifier ext
20
19
  data[:stagename] = ext.at("./stagename")&.text
21
20
  data
@@ -31,7 +30,7 @@ module RelatonIsoBib
31
30
  # @param ext [Nokogiri::XML::Element]
32
31
  # @return [RelatonIsoBib::StructuredIdentifier]
33
32
  def fetch_structuredidentifier(ext)
34
- sid = ext.at "./structuredidentifier"
33
+ sid = ext&.at "./structuredidentifier"
35
34
  return unless sid
36
35
 
37
36
  pn = sid.at "project-number"
@@ -44,27 +43,21 @@ module RelatonIsoBib
44
43
 
45
44
  # Override RelatonBib::XMLParser.ttitle method.
46
45
  # @param title [Nokogiri::XML::Element]
47
- # @return [RelatonIsoBib::TypedTitleString]
46
+ # @return [RelatonBib::TypedTitleString]
48
47
  def ttitle(title)
49
48
  return unless title
50
49
 
51
- TypedTitleString.new(
50
+ RelatonBib::TypedTitleString.new(
52
51
  type: title[:type], content: title.text, language: title[:language],
53
52
  script: title[:script], format: title[:format]
54
53
  )
55
54
  end
56
55
 
57
- # @param item [Nokogiri::XML::Element]
58
- # @return [Array<RelatonIsoBib::Ics>]
59
- def fetch_ics(ext)
60
- ext.xpath("./ics/code").map { |ics| Ics.new ics.text }
61
- end
62
-
63
56
  # @TODO Organization doesn't recreated
64
57
  # @param ext [Nokogiri::XML::Element]
65
58
  # @return [RelatonIsoBib::EditorialGroup]
66
- def fetch_editorialgroup(ext)
67
- eg = ext.at("./editorialgroup")
59
+ def fetch_editorialgroup(ext) # rubocop:disable Metrics/CyclomaticComplexity
60
+ eg = ext&.at("./editorialgroup")
68
61
  return unless eg
69
62
 
70
63
  tc = eg&.xpath("technical-committee")&.map { |t| iso_subgroup(t) }
@@ -16,7 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.license = "BSD-2-Clause"
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added
20
+ # into git.
20
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
23
  end
@@ -35,5 +36,5 @@ Gem::Specification.new do |spec|
35
36
  spec.add_development_dependency "simplecov"
36
37
 
37
38
  spec.add_dependency "isoics", "~> 0.1.6"
38
- spec.add_dependency "relaton-bib", ">= 1.0.3"
39
+ spec.add_dependency "relaton-bib", "~> 1.4.0"
39
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: relaton-bib
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.3
145
+ version: 1.4.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.0.3
152
+ version: 1.4.0
153
153
  description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
154
154
  email:
155
155
  - open.source@ribose.com
@@ -181,7 +181,6 @@ files:
181
181
  - lib/relaton_iso_bib/iso_bibliographic_item.rb
182
182
  - lib/relaton_iso_bib/iso_document_relation.rb
183
183
  - lib/relaton_iso_bib/structured_identifier.rb
184
- - lib/relaton_iso_bib/typed_title_string.rb
185
184
  - lib/relaton_iso_bib/version.rb
186
185
  - lib/relaton_iso_bib/xml_parser.rb
187
186
  - relaton_iso_bib.gemspec
@@ -189,7 +188,7 @@ homepage: https://github.com/relaton/relaton-iso-bib
189
188
  licenses:
190
189
  - BSD-2-Clause
191
190
  metadata: {}
192
- post_install_message:
191
+ post_install_message:
193
192
  rdoc_options: []
194
193
  require_paths:
195
194
  - lib
@@ -205,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
204
  version: '0'
206
205
  requirements: []
207
206
  rubygems_version: 3.0.6
208
- signing_key:
207
+ signing_key:
209
208
  specification_version: 4
210
209
  summary: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
211
210
  test_files: []
@@ -1,32 +0,0 @@
1
- module RelatonIsoBib
2
- class TypedTitleString < RelatonBib::TypedTitleString
3
- # TITLE_TYPES = %w[title-main title-intro title-part main].freeze
4
-
5
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
6
-
7
- # @param type [String]
8
- # @param title [RelatonBib::FormattedString, Hash]
9
- # @param content [String]
10
- # @param language [String]
11
- # @param script [String]
12
- def initialize(**args)
13
- # if args[:type] && !TITLE_TYPES.include?(args[:type])
14
- # raise ArgumentError, %{The type #{args[:type]} is invalid.}
15
- # end
16
-
17
- unless args[:title] || args[:content]
18
- raise ArgumentError, %{Keyword "title" or "content" should be passed.}
19
- end
20
-
21
- @type = args[:type]
22
-
23
- if args[:title]
24
- @title = args[:title]
25
- else
26
- fsargs = args.select { |k, _v| %i[content language script format].include? k }
27
- @title = RelatonBib::FormattedString.new(fsargs)
28
- end
29
- end
30
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
31
- end
32
- end