relaton-iso-bib 1.0.0 → 1.3.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.0".freeze
2
+ VERSION = "1.3.0".freeze
3
3
  end
@@ -15,8 +15,8 @@ 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
19
+ data[:stagename] = ext.at("./stagename")&.text
20
20
  data
21
21
  end
22
22
 
@@ -30,7 +30,7 @@ module RelatonIsoBib
30
30
  # @param ext [Nokogiri::XML::Element]
31
31
  # @return [RelatonIsoBib::StructuredIdentifier]
32
32
  def fetch_structuredidentifier(ext)
33
- sid = ext.at "./structuredidentifier"
33
+ sid = ext&.at "./structuredidentifier"
34
34
  return unless sid
35
35
 
36
36
  pn = sid.at "project-number"
@@ -43,27 +43,21 @@ module RelatonIsoBib
43
43
 
44
44
  # Override RelatonBib::XMLParser.ttitle method.
45
45
  # @param title [Nokogiri::XML::Element]
46
- # @return [RelatonIsoBib::TypedTitleString]
46
+ # @return [RelatonBib::TypedTitleString]
47
47
  def ttitle(title)
48
48
  return unless title
49
49
 
50
- TypedTitleString.new(
50
+ RelatonBib::TypedTitleString.new(
51
51
  type: title[:type], content: title.text, language: title[:language],
52
52
  script: title[:script], format: title[:format]
53
53
  )
54
54
  end
55
55
 
56
- # @param item [Nokogiri::XML::Element]
57
- # @return [Array<RelatonIsoBib::Ics>]
58
- def fetch_ics(ext)
59
- ext.xpath("./ics/code").map { |ics| Ics.new ics.text }
60
- end
61
-
62
56
  # @TODO Organization doesn't recreated
63
57
  # @param ext [Nokogiri::XML::Element]
64
58
  # @return [RelatonIsoBib::EditorialGroup]
65
- def fetch_editorialgroup(ext)
66
- eg = ext.at("./editorialgroup")
59
+ def fetch_editorialgroup(ext) # rubocop:disable Metrics/CyclomaticComplexity
60
+ eg = ext&.at("./editorialgroup")
67
61
  return unless eg
68
62
 
69
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.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.3.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.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.0
145
+ version: 1.3.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.0
152
+ version: 1.3.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
@@ -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