pubid-iso 0.7.0 → 0.7.2

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: e4fd0f754d87e7496c307221422d69bb36c6d4b497843eafa27a547d68bcd4e6
4
- data.tar.gz: c1d58a83fb0d672111b9fe6d0dc28df87c0070e483c3c19d487e7c2618c99293
3
+ metadata.gz: 1be767645c955bb6ca456984b088d443786947ced66241b01f0ece4e772e37cc
4
+ data.tar.gz: ed2de74d63898105105b3edba5afa50c4e0133619c17be50c42c0e2a2c58dc32
5
5
  SHA512:
6
- metadata.gz: aff91d1b6b5bc709bb4929b2901ac7ee53e35a2e67e403f4c3eec4123b8ab29a4d42604ae06ff0777be19b29d598139b224bfd7f34fe206595f3946147fb440b
7
- data.tar.gz: ec6219d66f0b62c97bb20c09adcb3c53f3d63f7fb245228e3463fe47b33d37087574f6a327461f839b0eef1f713c8ce33dd1408619194814fda9ccc8938fdab1
6
+ metadata.gz: b9faf9bc67c1995284a1e68cef72f4b52324875c16371f0c0ab37db06a565a2673134931808426edddfaad775db7cc10c586bb3b66f835f56a8a90a8775afb68
7
+ data.tar.gz: c97332b884ecfa4f4a363c0a0825d028ca1899405f1d1d133cbd5538baf6683716fb5c5e530ffa4a186b53da6521c6d678308f370755a89e4be40163d90da76a
@@ -13,7 +13,7 @@ module Pubid::Iso
13
13
  },
14
14
  }.freeze
15
15
  def self.type
16
- { key: :add, title: "Addendum" }
16
+ { key: :add, title: "Addendum", short: "ADD" }
17
17
  end
18
18
 
19
19
  def self.get_renderer_class
@@ -21,7 +21,7 @@ module Pubid::Iso
21
21
  },
22
22
  }.freeze
23
23
  def self.type
24
- { key: :amd, title: "Amendment" }
24
+ { key: :amd, title: "Amendment", short: "AMD" }
25
25
  end
26
26
 
27
27
  def self.get_renderer_class
@@ -12,16 +12,17 @@ module Pubid::Iso
12
12
  :tctype, :sctype, :wgtype, :tcnumber, :scnumber, :wgnumber,
13
13
  :dirtype,
14
14
  :base,
15
- # :typed_stage,
16
15
  :supplements,
17
- :addendum
16
+ :addendum,
17
+ :jtc_dir,
18
+ :month
18
19
 
19
20
  # Creates new identifier from options provided, includes options from
20
21
  # Pubid::Core::Identifier#initialize
21
22
  #
22
23
  # @param stage [Stage, Symbol, String] stage or typed stage, e.g. "PWI", "NP", "50.00", Stage.new(abbr: :WD), "DTR"
23
24
  # @param iteration [Integer] document iteration, eg. "1", "2", "3"
24
- # @param joint_document [Identifier] joint document
25
+ # @param joint_document [Identifier, Hash] joint document
25
26
  # @param supplements [Array<Supplement>] supplements
26
27
  # @param tctype [String] Technical Committee type, eg. "TC", "JTC"
27
28
  # @param sctype [String] TC subsommittee, eg. "SC"
@@ -30,8 +31,9 @@ module Pubid::Iso
30
31
  # @param scnumber [Integer] Subsommittee number, eg. "1", "2"
31
32
  # @param wgnumber [Integer] Working group number, eg. "1", "2"
32
33
  # @param dirtype [String] Directives document type, eg. "JTC"
33
- # @param base [Identifier] base document for supplement's identifier
34
+ # @param base [Identifier, Hash] base document for supplement's identifier
34
35
  # @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type] document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
36
+ # @param jtc_dir [String] String to indicate "JTC 1 Directives" identifier
35
37
  # @raise [Errors::SupplementWithoutYearOrStageError] when trying to apply
36
38
  # supplement to the document without edition year or stage
37
39
  # @raise [Errors::IsStageIterationError] when trying to apply iteration
@@ -47,7 +49,7 @@ module Pubid::Iso
47
49
  scnumber: nil, wgnumber:nil,
48
50
  dir: nil, dirtype: nil, year: nil, amendments: nil,
49
51
  corrigendums: nil, type: nil, base: nil, supplements: nil,
50
- part: nil, addendum: nil, edition: nil, **opts)
52
+ part: nil, addendum: nil, edition: nil, jtc_dir: nil, month: nil, **opts)
51
53
  super(**opts.merge(number: number, publisher: publisher, year: year,
52
54
  amendments: amendments, corrigendums: corrigendums))
53
55
 
@@ -68,7 +70,13 @@ module Pubid::Iso
68
70
  end
69
71
 
70
72
  @iteration = iteration.to_i if iteration
71
- @joint_document = joint_document if joint_document
73
+ if joint_document
74
+ if joint_document.is_a?(Hash)
75
+ @joint_document = Identifier.create(**joint_document)
76
+ else
77
+ @joint_document = joint_document
78
+ end
79
+ end
72
80
  @tctype = tctype if tctype
73
81
  @sctype = sctype.to_s if sctype
74
82
  @wgtype = wgtype.to_s if wgtype
@@ -77,10 +85,20 @@ module Pubid::Iso
77
85
  @wgnumber = wgnumber.to_s if wgnumber
78
86
  @dir = dir.to_s if dir
79
87
  @dirtype = dirtype.to_s if dirtype
80
- @base = base if base
88
+ if jtc_dir
89
+ @jtc_dir = jtc_dir
90
+ end
91
+ if base
92
+ if base.is_a?(Hash)
93
+ @base = Identifier.create(**base)
94
+ else
95
+ @base = base
96
+ end
97
+ end
81
98
  @part = part if part
82
99
  @addendum = addendum if addendum
83
100
  @edition = edition
101
+ @month = month
84
102
  end
85
103
 
86
104
  class << self
@@ -97,6 +115,7 @@ module Pubid::Iso
97
115
  def transform_supplements(supplements_params, base_params)
98
116
  supplements = supplements_params.map do |supplement|
99
117
  Identifier.create(number: supplement[:number], year: supplement[:year],
118
+ month: supplement[:month],
100
119
  stage: supplement[:typed_stage], edition: supplement[:edition],
101
120
  iteration: supplement[:iteration], type: (supplement[:type] || !supplement[:typed_stage] && :sup),
102
121
  publisher: supplement[:publisher], base: Identifier.create(**base_params))
@@ -22,7 +22,7 @@ module Pubid::Iso
22
22
  }.freeze
23
23
 
24
24
  def self.type
25
- { key: :cor, title: "Corrigendum" }
25
+ { key: :cor, title: "Corrigendum", short: "COR" }
26
26
  end
27
27
 
28
28
  def self.get_renderer_class
@@ -0,0 +1,17 @@
1
+ require_relative "../renderer/data"
2
+
3
+ module Pubid::Iso
4
+ module Identifier
5
+ class Data < Base
6
+ def_delegators 'Pubid::Iso::Identifier::Data', :type
7
+
8
+ def self.type
9
+ { key: :data, title: "Data", short: "DATA" }
10
+ end
11
+
12
+ def self.get_renderer_class
13
+ Renderer::Data
14
+ end
15
+ end
16
+ end
17
+ end
@@ -16,7 +16,7 @@ module Pubid::Iso
16
16
  end
17
17
 
18
18
  def self.type
19
- { key: :dir, title: "Directives" }
19
+ { key: :dir, title: "Directives", short: "DIR" }
20
20
  end
21
21
 
22
22
  def self.get_renderer_class
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :ext, title: "Extract" }
11
+ { key: :ext, title: "Extract", short: "EXT" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -25,7 +25,7 @@ module Pubid::Iso
25
25
  end
26
26
 
27
27
  def self.type
28
- { key: :guide, title: "Guide" }
28
+ { key: :guide, title: "Guide", short: "GUIDE" }
29
29
  end
30
30
  end
31
31
  end
@@ -39,7 +39,7 @@ module Pubid::Iso
39
39
  end
40
40
 
41
41
  def self.type
42
- { key: :is, title: "International Standard" }
42
+ { key: :is, title: "International Standard", short: nil }
43
43
  end
44
44
  end
45
45
  end
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :isp, title: "International Standardized Profile" }
22
+ { key: :isp, title: "International Standardized Profile", short: "ISP" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -14,7 +14,7 @@ module Pubid::Iso
14
14
  }.freeze
15
15
 
16
16
  def self.type
17
- { key: :iwa, title: "International Workshop Agreement" }
17
+ { key: :iwa, title: "International Workshop Agreement", short: "IWA" }
18
18
  end
19
19
 
20
20
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :pas, title: "Publicly Available Specification" }
22
+ { key: :pas, title: "Publicly Available Specification", short: "PAS" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :r, title: "Recommendation" }
11
+ { key: :r, title: "Recommendation", short: "R" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -24,7 +24,7 @@ module Pubid::Iso
24
24
  end
25
25
 
26
26
  def self.type
27
- { key: :sup, title: "Supplement", values: %w[Supplement Suppl SUP] }
27
+ { key: :sup, title: "Supplement", values: %w[Supplement Suppl SUP], short: "SUP" }
28
28
  end
29
29
 
30
30
  def self.get_renderer_class
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :tc, title: "Technical Committee" }
11
+ { key: :tc, title: "Technical Committee", short: "TC" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :tr, title: "Technical Report" }
22
+ { key: :tr, title: "Technical Report", short: "TR" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :ts, title: "Technical Specification" }
22
+ { key: :ts, title: "Technical Specification", short: "TS" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :tta, title: "Technology Trends Assessments" }
22
+ { key: :tta, title: "Technology Trends Assessments", short: "TTA" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -169,9 +169,10 @@ module Pubid::Iso
169
169
  ((str("DIR") | str("Directives Part") | str("Directives, Part") | str("Directives,")).as(:type) >> space).maybe >>
170
170
  (str("JTC").as(:dirtype) >> space).maybe >>
171
171
  (digits.as(:number) >> (str(":") >> year).maybe).maybe >>
172
+ (space >> str("DIR").as(:jtc_dir) >> (str(":") >> year).maybe).maybe >>
172
173
  (str(" -- Consolidated").maybe >> (str("").as(:mark) >> space? >>
173
174
  (organization.as(:publisher) >> space?).maybe >>
174
- array_to_str(DIR_SUPPLEMENTS) >> (str(":") >> year).maybe >>
175
+ array_to_str(DIR_SUPPLEMENTS) >> (str(":") >> (year >> (dash >> month_digits.as(:month)).maybe)).maybe >>
175
176
  dir_supplement_edition.maybe).repeat(1).as(:supplements)).maybe >>
176
177
  # parse identifiers with publisher at the end, e.g. "ISO/IEC DIR 2 ISO"
177
178
  (space >> organization.as(:publisher) >> (str(":") >> year).maybe).as(:edition).maybe
@@ -0,0 +1,11 @@
1
+ require_relative "base"
2
+
3
+ module Pubid::Iso::Renderer
4
+ class Data < Base
5
+ TYPE = "DATA".freeze
6
+
7
+ def omit_post_publisher_symbol?(_typed_stage, _stage, _opts)
8
+ false
9
+ end
10
+ end
11
+ end
@@ -4,7 +4,11 @@ module Pubid::Iso::Renderer
4
4
  class Dir < Base
5
5
 
6
6
  def render_identifier(params, opts)
7
- res = ("%{publisher} DIR%{dirtype}%{number}%{year}%{edition}" % params)
7
+ if params.key?(:jtc_dir)
8
+ res = ("%{publisher}%{dirtype}%{number} DIR%{year}%{edition}" % params)
9
+ else
10
+ res = ("%{publisher} DIR%{dirtype}%{number}%{year}%{edition}" % params)
11
+ end
8
12
 
9
13
  if params.key?(:joint_document)
10
14
  joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
@@ -32,7 +32,7 @@ module Pubid::Iso::Renderer
32
32
 
33
33
  if self.class == Supplement
34
34
  if opts[:base_type] == :dir
35
- "%{stage}%{publisher} SUP%{number}%{part}%{iteration}%{year}%{edition}" % params
35
+ "%{stage}%{publisher} SUP%{number}%{part}%{iteration}%{year}%{month}%{edition}" % params
36
36
  else
37
37
  # type_prefix = "/#{type_prefix}" unless type_prefix.empty?
38
38
  "/%{stage}#{type_prefix}%{number}%{part}%{iteration}%{year}%{edition}" % params
@@ -60,5 +60,9 @@ module Pubid::Iso::Renderer
60
60
  def render_edition(edition, opts, _params)
61
61
  " Edition #{edition}" if opts[:with_edition]
62
62
  end
63
+
64
+ def render_month(month, _opts, _params)
65
+ "-#{month}"
66
+ end
63
67
  end
64
68
  end
@@ -114,6 +114,11 @@ module Pubid::Iso
114
114
  context.select { |k, v| k != :dir_joint_document }
115
115
  end
116
116
 
117
+ rule(jtc_dir: simple(:jtc_dir)) do |context|
118
+ context[:type] = "DIR"
119
+ context
120
+ end
121
+
117
122
  def self.convert_stage(code)
118
123
  russian_code = Pubid::Iso::Renderer::Base::TRANSLATION[:russian][:stage].key(code.to_s)
119
124
  return { stage: russian_code } if russian_code
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iso
3
- VERSION = "0.7.0".freeze
3
+ VERSION = "0.7.2".freeze
4
4
  end
5
5
  end
data/lib/pubid/iso.rb CHANGED
@@ -30,6 +30,7 @@ require_relative "iso/identifier/technology_trends_assessments"
30
30
  require_relative "iso/identifier/international_workshop_agreement"
31
31
  require_relative "iso/identifier/extract"
32
32
  require_relative "iso/identifier/addendum"
33
+ require_relative "iso/identifier/data"
33
34
 
34
35
  config = Pubid::Core::Configuration.new
35
36
  config.stages = YAML.load_file(File.join(File.dirname(__FILE__), "../../stages.yaml"))
@@ -50,7 +51,8 @@ config.types = [Pubid::Iso::Identifier::InternationalStandard,
50
51
  Pubid::Iso::Identifier::TechnologyTrendsAssessments,
51
52
  Pubid::Iso::Identifier::Guide,
52
53
  Pubid::Iso::Identifier::Extract,
53
- Pubid::Iso::Identifier::Addendum]
54
+ Pubid::Iso::Identifier::Addendum,
55
+ Pubid::Iso::Identifier::Data]
54
56
  config.type_names = { tr: {
55
57
  long: "Technical Report",
56
58
  short: "TR",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2024-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -85,6 +85,7 @@ files:
85
85
  - lib/pubid/iso/identifier/amendment.rb
86
86
  - lib/pubid/iso/identifier/base.rb
87
87
  - lib/pubid/iso/identifier/corrigendum.rb
88
+ - lib/pubid/iso/identifier/data.rb
88
89
  - lib/pubid/iso/identifier/directives.rb
89
90
  - lib/pubid/iso/identifier/extract.rb
90
91
  - lib/pubid/iso/identifier/guide.rb
@@ -103,6 +104,7 @@ files:
103
104
  - lib/pubid/iso/renderer/amendment.rb
104
105
  - lib/pubid/iso/renderer/base.rb
105
106
  - lib/pubid/iso/renderer/corrigendum.rb
107
+ - lib/pubid/iso/renderer/data.rb
106
108
  - lib/pubid/iso/renderer/dir.rb
107
109
  - lib/pubid/iso/renderer/extract.rb
108
110
  - lib/pubid/iso/renderer/guide.rb