tc211-termbase 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,107 +2,117 @@ require_relative "metadata_section"
2
2
  require_relative "terms_section"
3
3
 
4
4
  module Tc211::Termbase
5
+ class TerminologySheet
6
+ attr_accessor :sheet, :language_code
5
7
 
6
- class TerminologySheet
7
- attr_accessor :sheet, :language_code
8
+ def initialize(sheet)
9
+ @sheet = sheet
10
+ self
11
+ end
8
12
 
9
- def initialize(sheet)
10
- @sheet = sheet
11
- self
12
- end
13
+ def language
14
+ @sheet.name
15
+ end
13
16
 
14
- def language
15
- @sheet.name
16
- end
17
+ def language_code
18
+ return @language_code unless @language_code.nil?
17
19
 
18
- def language_code
19
- return @language_code unless @language_code.nil?
20
- raise StandardError.new("Language code not parsed yet for sheet: #{language}")
21
- end
20
+ raise StandardError.new(
21
+ "Language code not parsed yet for sheet: #{language}",
22
+ )
23
+ end
22
24
 
23
- # Read language_code from sheet
24
- def set_language_code(code)
25
- # puts "language_code is #{code}"
26
- return @language_code unless @language_code.nil?
27
-
28
- @language_code = case code
29
- when "dut/nld"
30
- "dut"
31
- when "工作语言代码"
32
- "chn"
33
- else
34
- code
25
+ # Read language_code from sheet
26
+ def set_language_code(code)
27
+ # puts "language_code is #{code}"
28
+ return @language_code unless @language_code.nil?
29
+
30
+ @language_code = case code
31
+ when "dut/nld"
32
+ "dut"
33
+ when "工作语言代码"
34
+ "chn"
35
+ when "pl"
36
+ "pol"
37
+ else
38
+ code
39
+ end
35
40
  end
36
- end
37
41
 
38
- def sections_raw
39
- # Sections either start with "A" => "Item", or they have empty lines between
40
- raw_sections = @sheet.simple_rows.to_a
42
+ def sections_raw
43
+ # Sections either start with "A" => "Item",
44
+ # or they have empty lines between
45
+ raw_sections = @sheet.simple_rows.to_a
41
46
 
42
- raw_sections.reject! do |section|
43
- section.empty?
44
- end
47
+ raw_sections.reject!(&:empty?)
45
48
 
46
- raw_sections = raw_sections.slice_before do |row|
47
- row["A"].to_s == "Item" || row["A"].to_s.match(/^ISO 19135 Field/)
48
- end.to_a
49
- end
49
+ raw_sections.slice_before do |row|
50
+ row["A"].to_s == "Item" || row["A"].to_s.match(/^ISO 19135 Field/)
51
+ end.to_a
52
+ end
50
53
 
51
- def terms_section
52
- sections
54
+ def terms_section
55
+ sections
53
56
 
54
- sections.detect do |section|
55
- section.is_a?(TermsSection)
57
+ sections.detect do |section|
58
+ section.is_a?(TermsSection)
59
+ end
56
60
  end
57
- end
58
61
 
59
- def metadata_section
60
- sections
62
+ def metadata_section
63
+ sections
61
64
 
62
- sections.detect do |section|
63
- section.is_a?(MetadataSection)
65
+ sections.detect do |section|
66
+ section.is_a?(MetadataSection)
67
+ end
64
68
  end
65
- end
66
69
 
67
- def sections
68
- return @sections if @sections
70
+ def sections
71
+ return @sections if @sections
72
+
73
+ @sections = []
74
+ sections_raw.each_with_index do |x,i|
75
+ section = get_section(x)
76
+
77
+ unless section
78
+ raise SheetSection::UnknownHeaderError.new(
79
+ "Unable to find header row match for section #{i} header," +
80
+ " contents: #{x.inspect}",
81
+ )
82
+ end
83
+
84
+ # MetadataSections always go first, so the language_code must already
85
+ # be set at the time of parsing the TermsSection
86
+ if section.is_a?(MetadataSection)
87
+ code = section.fields["operating-language-code"]
88
+ # puts "lang code is detected as #{code}, #{@language_code}"
89
+ unless code.nil?
90
+ # puts "setting lang code is detected as #{code}"
91
+ set_language_code(code)
92
+ end
93
+ end
69
94
 
70
- @sections = []
71
- sections_raw.each_with_index do |x,i|
72
- # puts "rows: #{x.inspect}"
95
+ puts "--------- Section #{i} is a #{section.class.name} ---------"
73
96
 
97
+ @sections << section
98
+ end
99
+ end
100
+
101
+ def get_section(x)
74
102
  section = nil
103
+
75
104
  %w(MetadataSection TermsSection).each do |t|
76
105
  break if section
106
+
77
107
  begin
78
108
  # puts "rows: #{x.inspect}"
79
- section = ::Tc211::Termbase.const_get(t).new(x, {parent_sheet: self})
109
+ section = ::Tc211::Termbase.const_get(t)
110
+ .new(x, { parent_sheet: self })
80
111
  rescue SheetSection::RowHeaderMatchError
81
112
  end
82
113
  end
83
114
 
84
- unless section
85
- raise SheetSection::UnknownHeaderError.new("Unable to find header row match for section #{i} header, contents: #{x.inspect}")
86
- end
87
-
88
- # MetadataSections always go first, so the language_code must already
89
- # be set at the time of parsing the TermsSection
90
- if section.is_a?(MetadataSection)
91
- code = section.fields["operating-language-code"]
92
- # puts "lang code is detected as #{code}, #{@language_code}"
93
- unless code.nil?
94
- # puts "setting lang code is detected as #{code}"
95
- set_language_code(code)
96
- end
97
- end
98
-
99
- puts "--------- Section #{i} is a #{section.class.name} ---------"
100
-
101
- @sections << section
115
+ section
102
116
  end
103
-
104
117
  end
105
-
106
118
  end
107
-
108
- end
@@ -4,10 +4,8 @@ require_relative "relaton_db"
4
4
  require "relaton_bib"
5
5
 
6
6
  module Tc211::Termbase
7
-
8
7
  class TermsSection < SheetSection
9
- attr_accessor :structure
10
- attr_accessor :header_row
8
+ attr_accessor :structure, :header_row
11
9
 
12
10
  TERM_HEADER_ROW_MATCH = {
13
11
  "A" => ["ISO 19135 Field\nRE_RegisterItem.itemIdentifier"],
@@ -15,7 +13,7 @@ module Tc211::Termbase
15
13
  "C" => ["ISO 19135 Field\nRE_RegisterItem.\nalternativeExpression"],
16
14
  "D" => ["Country_Code"],
17
15
  # ... We don't need to match all the cells
18
- }
16
+ }.freeze
19
17
 
20
18
  TERM_BODY_COLUMN_MAP = {
21
19
  "Term_ID" => "id",
@@ -75,9 +73,13 @@ module Tc211::Termbase
75
73
  "Note_7" => "note-7",
76
74
  "Example_8" => "example-8",
77
75
  "Note_8" => "note-8",
78
- "Glossary Release" => "release"
79
- ## Must be one of the following codes 'release1' = 1 'release1_retired' = -1 'release2' = 2 'release2_retired' = -2 etc "
80
- }
76
+ "Glossary Release" => "release",
77
+ ## Must be one of the following codes
78
+ # 'release1' = 1
79
+ # 'release1_retired' = -1
80
+ # 'release2' = 2
81
+ # 'release2_retired' = -2 etc
82
+ }.freeze
81
83
 
82
84
  def initialize(rows, options={})
83
85
  super
@@ -126,7 +128,6 @@ module Tc211::Termbase
126
128
  else
127
129
  acc
128
130
  end
129
-
130
131
  end
131
132
  end
132
133
 
@@ -1,5 +1,5 @@
1
1
  module Tc211
2
2
  module Termbase
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require "glossarist"
1
2
  require "tc211/termbase/version"
2
3
 
3
4
  module Tc211
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_runtime_dependency "creek"
26
- spec.add_runtime_dependency "relaton", "~> 1.0"
26
+ spec.add_runtime_dependency "relaton"
27
+ spec.add_runtime_dependency "glossarist", "~> 2.0"
28
+
29
+ spec.add_development_dependency "bundler"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
+ spec.add_development_dependency "rspec", "~> 3.12"
27
32
 
28
- spec.add_development_dependency "bundler", ">= 2.0.1", "< 3"
29
- spec.add_development_dependency "debase"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.0"
32
- spec.add_development_dependency "ruby-debug-ide"
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tc211-termbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-13 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: creek
@@ -28,38 +28,32 @@ dependencies:
28
28
  name: relaton
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: glossarist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 2.0.1
48
- - - "<"
45
+ - - "~>"
49
46
  - !ruby/object:Gem::Version
50
- version: '3'
51
- type: :development
47
+ version: '2.0'
48
+ type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 2.0.1
58
- - - "<"
52
+ - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '3'
54
+ version: '2.0'
61
55
  - !ruby/object:Gem::Dependency
62
- name: debase
56
+ name: bundler
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - ">="
@@ -78,42 +72,28 @@ dependencies:
78
72
  requirements:
79
73
  - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: '10.0'
75
+ version: '13.0'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '10.0'
82
+ version: '13.0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: rspec
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '3.0'
89
+ version: '3.12'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: '3.0'
103
- - !ruby/object:Gem::Dependency
104
- name: ruby-debug-ide
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
96
+ version: '3.12'
117
97
  description: Build scripts for the ISO/TC 211 Termbase
118
98
  email:
119
99
  - open.source@ribose.com
@@ -122,11 +102,12 @@ executables:
122
102
  extensions: []
123
103
  extra_rdoc_files: []
124
104
  files:
105
+ - ".github/workflows/rake.yml"
106
+ - ".github/workflows/release.yml"
125
107
  - ".gitignore"
126
108
  - ".rspec"
127
109
  - CODE_OF_CONDUCT.md
128
110
  - Gemfile
129
- - Gemfile.lock
130
111
  - README.adoc
131
112
  - Rakefile
132
113
  - bin/console
@@ -165,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
146
  - !ruby/object:Gem::Version
166
147
  version: '0'
167
148
  requirements: []
168
- rubygems_version: 3.0.3
149
+ rubygems_version: 3.3.26
169
150
  signing_key:
170
151
  specification_version: 4
171
152
  summary: Build scripts for the ISO/TC 211 Termbase
data/Gemfile.lock DELETED
@@ -1,122 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- tc211-termbase (0.1.13)
5
- creek
6
- relaton (~> 1.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.7.0)
12
- public_suffix (>= 2.0.2, < 5.0)
13
- bibtex-ruby (5.1.4)
14
- latex-decode (~> 0.0)
15
- cnccs (0.1.5)
16
- creek (2.5.2)
17
- nokogiri (>= 1.10.0)
18
- rubyzip (>= 1.0.0)
19
- debase (0.2.4.1)
20
- debase-ruby_core_source (>= 0.10.2)
21
- debase-ruby_core_source (0.10.9)
22
- diff-lcs (1.3)
23
- domain_name (0.5.20190701)
24
- unf (>= 0.0.5, < 1.0.0)
25
- faraday (1.0.1)
26
- multipart-post (>= 1.2, < 3)
27
- gb-agencies (0.0.6)
28
- http-cookie (1.0.3)
29
- domain_name (~> 0.5)
30
- iso639 (1.3.2)
31
- isoics (0.1.8)
32
- latex-decode (0.3.1)
33
- mini_portile2 (2.4.0)
34
- multipart-post (2.1.1)
35
- nokogiri (1.10.9)
36
- mini_portile2 (~> 2.4.0)
37
- public_suffix (4.0.5)
38
- rake (10.5.0)
39
- relaton (1.0.1)
40
- relaton-calconnect (~> 1.0.0)
41
- relaton-gb (~> 1.0.0)
42
- relaton-iec (~> 1.0.0)
43
- relaton-ietf (~> 1.0.0)
44
- relaton-iso (~> 1.0.0)
45
- relaton-itu (~> 1.0.0)
46
- relaton-nist (~> 1.0.0)
47
- relaton-ogc (~> 1.0.0)
48
- relaton-omg (~> 1.0.0)
49
- relaton-un (~> 1.0.0)
50
- relaton-w3c (~> 1.0.0)
51
- relaton-bib (1.0.2)
52
- addressable
53
- bibtex-ruby
54
- iso639
55
- nokogiri
56
- relaton-calconnect (1.0.0)
57
- faraday
58
- relaton-iso-bib (~> 1.0.0)
59
- relaton-gb (1.0.0)
60
- cnccs (~> 0.1.1)
61
- gb-agencies (~> 0.0.1)
62
- relaton-iso-bib (~> 1.0.0)
63
- relaton-iec (1.0.0)
64
- addressable
65
- relaton-iso-bib (~> 1.0.0)
66
- relaton-ietf (1.0.0)
67
- relaton-bib (~> 1.0.0)
68
- relaton-iso (1.0.1)
69
- relaton-iec (~> 1.0.0)
70
- relaton-iso-bib (~> 1.0.0)
71
- relaton-iso-bib (1.0.0)
72
- isoics (~> 0.1.6)
73
- relaton-bib (~> 1.0.0)
74
- relaton-itu (1.0.2)
75
- relaton-iso-bib (~> 1.0.0)
76
- relaton-nist (1.0.0)
77
- relaton-bib (~> 1.0.0)
78
- rubyzip
79
- relaton-ogc (1.0.0)
80
- faraday (~> 1.0.0)
81
- relaton-iso-bib (~> 1.0.0)
82
- relaton-omg (1.0.0)
83
- relaton-bib (~> 1.0.0)
84
- relaton-un (1.0.0)
85
- faraday
86
- http-cookie
87
- relaton-iso-bib (~> 1.0.0)
88
- unf_ext (>= 0.0.7.7)
89
- relaton-w3c (1.0.0)
90
- relaton-bib (>= 1.0.0)
91
- rspec (3.9.0)
92
- rspec-core (~> 3.9.0)
93
- rspec-expectations (~> 3.9.0)
94
- rspec-mocks (~> 3.9.0)
95
- rspec-core (3.9.2)
96
- rspec-support (~> 3.9.3)
97
- rspec-expectations (3.9.2)
98
- diff-lcs (>= 1.2.0, < 2.0)
99
- rspec-support (~> 3.9.0)
100
- rspec-mocks (3.9.1)
101
- diff-lcs (>= 1.2.0, < 2.0)
102
- rspec-support (~> 3.9.0)
103
- rspec-support (3.9.3)
104
- ruby-debug-ide (0.7.2)
105
- rake (>= 0.8.1)
106
- rubyzip (2.3.0)
107
- unf (0.1.4)
108
- unf_ext
109
- unf_ext (0.0.7.7)
110
-
111
- PLATFORMS
112
- ruby
113
-
114
- bundler (>= 2.0.1, < 3)
115
- debase
116
- rake (~> 10.0)
117
- rspec (~> 3.0)
118
- ruby-debug-ide
119
- tc211-termbase!
120
-
121
- BUNDLED WITH
122
- 2.1.4