tc211-termbase 0.1.13 → 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.1.13"
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"
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.1.13
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-12 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,24 +28,24 @@ 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
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: debase
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -72,42 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '3.12'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
97
- - !ruby/object:Gem::Dependency
98
- name: ruby-debug-ide
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '3.12'
111
97
  description: Build scripts for the ISO/TC 211 Termbase
112
98
  email:
113
99
  - open.source@ribose.com
@@ -116,11 +102,12 @@ executables:
116
102
  extensions: []
117
103
  extra_rdoc_files: []
118
104
  files:
105
+ - ".github/workflows/rake.yml"
106
+ - ".github/workflows/release.yml"
119
107
  - ".gitignore"
120
108
  - ".rspec"
121
109
  - CODE_OF_CONDUCT.md
122
110
  - Gemfile
123
- - Gemfile.lock
124
111
  - README.adoc
125
112
  - Rakefile
126
113
  - bin/console
@@ -159,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
146
  - !ruby/object:Gem::Version
160
147
  version: '0'
161
148
  requirements: []
162
- rubygems_version: 3.0.3
149
+ rubygems_version: 3.3.26
163
150
  signing_key:
164
151
  specification_version: 4
165
152
  summary: Build scripts for the ISO/TC 211 Termbase
data/Gemfile.lock DELETED
@@ -1,123 +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
- DEPENDENCIES
115
- bundler (~> 2.0)
116
- debase
117
- rake (~> 10.0)
118
- rspec (~> 3.0)
119
- ruby-debug-ide
120
- tc211-termbase!
121
-
122
- BUNDLED WITH
123
- 2.1.4