pubid 2.0.42 → 2.0.44
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 +4 -4
- data/data/parg/arxiv.json +1 -0
- data/data/parg/bsi_pfs.json +1 -1
- data/data/parg/eu.json +1 -0
- data/lib/pubid/arxiv/CLAUDE.md +58 -0
- data/lib/pubid/arxiv/builder.rb +100 -0
- data/lib/pubid/arxiv/identifier.rb +111 -0
- data/lib/pubid/arxiv/identifiers/eprint.rb +20 -0
- data/lib/pubid/arxiv/identifiers.rb +9 -0
- data/lib/pubid/arxiv/parser.rb +18 -0
- data/lib/pubid/arxiv/pubid_urn_schema.rb +26 -0
- data/lib/pubid/arxiv/renderer.rb +30 -0
- data/lib/pubid/arxiv.rb +55 -0
- data/lib/pubid/bsi_pfs/adopted_base.rb +67 -14
- data/lib/pubid/bsi_pfs/builder.rb +37 -2
- data/lib/pubid/bsi_pfs/identifier.rb +9 -10
- data/lib/pubid/bsi_pfs/identifiers/adopted_european_norm.rb +21 -11
- data/lib/pubid/bsi_pfs/identifiers/adopted_international_standard.rb +21 -11
- data/lib/pubid/bsi_pfs/identifiers/consolidated_identifier.rb +25 -9
- data/lib/pubid/bsi_pfs/identifiers/draft_document.rb +6 -6
- data/lib/pubid/bsi_pfs/identifiers/publicly_available_specification.rb +6 -6
- data/lib/pubid/bsi_pfs/identifiers/published_document.rb +6 -6
- data/lib/pubid/bsi_pfs/identifiers/technical_specification.rb +6 -6
- data/lib/pubid/bsi_pfs/pubid_urn_schema.rb +17 -4
- data/lib/pubid/bsi_pfs/renderer.rb +18 -2
- data/lib/pubid/bsi_pfs/urn_generator.rb +31 -6
- data/lib/pubid/eu/CLAUDE.md +92 -0
- data/lib/pubid/eu/builder.rb +129 -0
- data/lib/pubid/eu/identifier.rb +117 -0
- data/lib/pubid/eu/identifiers/decision.rb +14 -0
- data/lib/pubid/eu/identifiers/directive.rb +14 -0
- data/lib/pubid/eu/identifiers/regulation.rb +14 -0
- data/lib/pubid/eu/identifiers.rb +11 -0
- data/lib/pubid/eu/parser.rb +10 -0
- data/lib/pubid/eu/pubid_urn_schema.rb +23 -0
- data/lib/pubid/eu/renderer.rb +38 -0
- data/lib/pubid/eu.rb +52 -0
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid.rb +2 -0
- metadata +23 -1
|
@@ -5,8 +5,8 @@ module Pubid
|
|
|
5
5
|
# (feature 6) — the publisher group, the adopted document's
|
|
6
6
|
# fused MR string, the composed code, the year, the draft
|
|
7
7
|
# stage. A wrapper reads through to its subject and appends
|
|
8
|
-
# its declared chain; the
|
|
9
|
-
# member
|
|
8
|
+
# its declared chain; the marker-less bundle appends each
|
|
9
|
+
# member's chain directly (the coded-BSI shape).
|
|
10
10
|
class UrnGenerator < ::Pubid::UrnGenerator::Base
|
|
11
11
|
def urn_namespace
|
|
12
12
|
"bsi"
|
|
@@ -31,7 +31,6 @@ module Pubid
|
|
|
31
31
|
parts.concat(official_segments)
|
|
32
32
|
parts.concat(wrapper)
|
|
33
33
|
members&.each do |member|
|
|
34
|
-
parts << "plus"
|
|
35
34
|
parts.concat(wrapper_segments(member))
|
|
36
35
|
end
|
|
37
36
|
parts.concat(frag_segments)
|
|
@@ -43,13 +42,39 @@ module Pubid
|
|
|
43
42
|
def official_segments
|
|
44
43
|
segments = []
|
|
45
44
|
segments << @identifier.publisher.to_s.downcase if @identifier.publisher
|
|
46
|
-
segments <<
|
|
47
|
-
segments << "-" +
|
|
48
|
-
|
|
45
|
+
segments << identity(:number) if identity(:number)
|
|
46
|
+
segments << "-" + identity(:part).to_s if identity(:part)
|
|
47
|
+
segments << "-" + identity(:subpart).to_s if identity(:subpart)
|
|
48
|
+
date = [identity(:date)&.year].compact
|
|
49
49
|
segments << date.join("-") unless date.empty?
|
|
50
|
+
segments << "v" + @identifier.edition.to_s if @identifier.edition
|
|
51
|
+
if @identifier.type
|
|
52
|
+
type = @identifier.type&.abbr || @identifier.type.to_s
|
|
53
|
+
segments << type.to_s.downcase if type && type.to_s != "BS"
|
|
54
|
+
end
|
|
55
|
+
# The typed trio's own stage segment (the declared published
|
|
56
|
+
# form): it fires for published rows too — the coded
|
|
57
|
+
# generator's own comparison (a stage_code String is never
|
|
58
|
+
# the :published Symbol).
|
|
59
|
+
code = @identifier.typed_stage&.stage_code
|
|
60
|
+
segments << "stage." + code.to_s if code && code != :published
|
|
50
61
|
segments
|
|
51
62
|
end
|
|
52
63
|
|
|
64
|
+
# An identity attribute of the identifier, or of the document
|
|
65
|
+
# it wraps (the declared root-through): the adoption wrapper
|
|
66
|
+
# carries no identity of its own, so its official segments
|
|
67
|
+
# read the ROOT document's. #root is +self+ for a non-wrapper,
|
|
68
|
+
# so an ordinary identifier reads its own value and nothing
|
|
69
|
+
# changes.
|
|
70
|
+
def identity(attr)
|
|
71
|
+
own = @identifier.public_send(attr)
|
|
72
|
+
return own if own
|
|
73
|
+
|
|
74
|
+
root = @identifier.root
|
|
75
|
+
root.equal?(@identifier) ? nil : root.public_send(attr)
|
|
76
|
+
end
|
|
77
|
+
|
|
53
78
|
# One wrapper's declared URN chain: the kind word, then the
|
|
54
79
|
# wrapper's columns (the ordinal, the year-month date).
|
|
55
80
|
def wrapper_segments(id)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# EU legal acts (`Pubid::Eu`)
|
|
2
|
+
|
|
3
|
+
Regulations, directives and decisions of the Official Journal (CELEX sector 3,
|
|
4
|
+
type letters R / L / D). Requested by relaton/relaton#44 for the `Relaton::Eu`
|
|
5
|
+
flavor, whose `Relaton::Db` cache keys on this pubid.
|
|
6
|
+
|
|
7
|
+
## Forms
|
|
8
|
+
|
|
9
|
+
| input | example | `to_s` |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| canonical (round-trips) | `EU Regulation 1227/2011` | same |
|
|
12
|
+
| Official Journal long form | `Regulation (EU) No 1227/2011`, `Directive 2010/75/EU` | canonical; sets `family` |
|
|
13
|
+
| CELEX | `32011R1227`, `CELEX 32011R1227`, `CELEX:32011R1227` | canonical |
|
|
14
|
+
| ELI | `http(s)://data.europa.eu/eli/reg/2011/1227[/oj]` | canonical |
|
|
15
|
+
|
|
16
|
+
`#to_celex` and `#to_eli` give the two official identifiers back. `to_urn`
|
|
17
|
+
(`urn:eu:reg:2011:1227`) is pubid-invented: the EU has no URN namespace.
|
|
18
|
+
|
|
19
|
+
`Pubid.parse` routes only the canonical form (the prefix `EU`). The other
|
|
20
|
+
forms do not start with `EU` and do not round-trip, and prefix routing lets
|
|
21
|
+
only a prefix owner give a non-exact parse, so call `Pubid::Eu.parse` for
|
|
22
|
+
them. relaton queries with the canonical form only.
|
|
23
|
+
|
|
24
|
+
## The number order is spelling, kept in `number_first`
|
|
25
|
+
|
|
26
|
+
The order of the two numbers is not derivable from the string:
|
|
27
|
+
`Regulation (EC) No 2003/2003` exists, and a pre-2015 number can look like a
|
|
28
|
+
year. Before 2015 a regulation printed `<number>/<year>`; directives printed
|
|
29
|
+
`<year>/<number>`; **decisions used both** (`Decision No 1082/2013/EU`, an
|
|
30
|
+
act of the Parliament and the Council, and `Decision 2010/87/EU`, a
|
|
31
|
+
Commission act). From 2015 every act prints `<year>/<number>`.
|
|
32
|
+
|
|
33
|
+
- **Render rule** (`Identifier#default_number_first?`): a regulation with a
|
|
34
|
+
year before 2015 prints `<number>/<year>`; everything else prints
|
|
35
|
+
`<year>/<number>`. The builder stores `number_first` **only when the input
|
|
36
|
+
order differs from this rule** (`EU Decision 1082/2013` → `true`), so a
|
|
37
|
+
normal index row carries no flag. It is `equality_ignored` and a URN facet:
|
|
38
|
+
the order is spelling, and `EU Decision 1082/2013` equals `32013D1082`.
|
|
39
|
+
- **Parse rule** (`Builder.number_first_for`), for every form: `No` marks
|
|
40
|
+
`<number>/<year>` (the Official Journal convention, exact for the long
|
|
41
|
+
form). Without `No`, a value is a plausible year when it has 4 digits in
|
|
42
|
+
1952..2099; one plausible value is the year; with two, a first value from
|
|
43
|
+
2015 is the year, else a regulation reads `<number>/<year>` and another act
|
|
44
|
+
`<year>/<number>`; none raises `Pubid::Errors::ParseError` (from the
|
|
45
|
+
builder, not the grammar). The long form uses the same rule, so
|
|
46
|
+
`to_s(with_publisher: false)` (`Regulation 1227/2011`) parses back.
|
|
47
|
+
- **Two acts can share one plain print**: `32015R2014` and `32014R2015` both
|
|
48
|
+
print `2015/2014`. The renderer asks the parse rule how the plain pair
|
|
49
|
+
reads back; when that is another act it prints `EU Regulation No 2015/2014`
|
|
50
|
+
instead. So `parse(id.to_s) == id` for every act, in both orders and without
|
|
51
|
+
the publisher; `spec/pubid/eu/identifier_spec.rb` sweeps a year × number
|
|
52
|
+
grid to lock it. A canonical input always reads back as itself, so it
|
|
53
|
+
never gains a `No`.
|
|
54
|
+
- CELEX and ELI years are checked against the same range, and a number of
|
|
55
|
+
0 is rejected. The bracketed family and the suffixed one are separate
|
|
56
|
+
captures; two different ones (`Regulation (EU) No 1227/2011/EC`) raise.
|
|
57
|
+
|
|
58
|
+
## Identity and matching
|
|
59
|
+
|
|
60
|
+
Identity is the leaf class, `date` (year) and `number` (leading CELEX zeros
|
|
61
|
+
stripped). `family` is part of identity but nil on a canonical reference, so
|
|
62
|
+
`EU Regulation 1227/2011 === parse("Regulation (EU) No 1227/2011")` is true
|
|
63
|
+
(the default SubsetMatch wildcard), and the reverse is false. Every reference
|
|
64
|
+
states the year, so the `partial_ref_spec` entry is `omits: []`.
|
|
65
|
+
|
|
66
|
+
## Known gaps
|
|
67
|
+
|
|
68
|
+
- Two-digit years (`Directive 95/46/EC`, `Regulation (EEC) No 1408/71`) are
|
|
69
|
+
rejected. They need a century rule, and relaton did not ask for them.
|
|
70
|
+
- Joint families (`(EU, Euratom)`) and the CELEX suffixes `(01)` for colliding
|
|
71
|
+
numbers are not parsed.
|
|
72
|
+
- The author words of the Official Journal title (`Commission Implementing
|
|
73
|
+
Regulation (EU) 2019/947`, `Council Directive …`) are not parsed; strip
|
|
74
|
+
them first. They name no other act, so they would not be identity.
|
|
75
|
+
- Other CELEX sectors (treaties, case law) are out of scope.
|
|
76
|
+
|
|
77
|
+
## The grammar is baked here ahead of pubid-grammar
|
|
78
|
+
|
|
79
|
+
`data/parg/eu.json` was compiled in this repo at parsanol **1.5.1.0** (the
|
|
80
|
+
Gemfile pin), because `pubid-grammar` had no `grammars/eu.parg` yet. Hand-off
|
|
81
|
+
`pubid__pubid-grammar__eu-flavor-grammar` carries the source. To change the
|
|
82
|
+
grammar, extract the source with `jq -j .source data/parg/eu.json`, edit,
|
|
83
|
+
then:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
bundle exec parsanol parg compile eu.parg -o data/parg/eu.json
|
|
87
|
+
bundle exec parsanol parg test data/parg/eu.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use raw `"/"` and `" "` literals, not `slash`/`space` rule references: a rule
|
|
91
|
+
reference makes a tree node, and the alternatives then warn about duplicate
|
|
92
|
+
`slash` subtrees (the same note sits in the UN grammar).
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
# Bound captures (data/parg/eu.json) → an EU identifier.
|
|
6
|
+
#
|
|
7
|
+
# CELEX and ELI give the year and the number by position. The canonical
|
|
8
|
+
# and the long forms give two numbers, +first+ and +second+, and the
|
|
9
|
+
# order is not in the grammar: `Regulation (EC) No 2003/2003` exists, and
|
|
10
|
+
# a pre-2015 number can look like a year. See .number_first_for.
|
|
11
|
+
class Builder
|
|
12
|
+
TYPES_BY_WORD = {
|
|
13
|
+
"Regulation" => :Regulation,
|
|
14
|
+
"Directive" => :Directive,
|
|
15
|
+
"Decision" => :Decision,
|
|
16
|
+
}.freeze
|
|
17
|
+
TYPES_BY_CELEX = {
|
|
18
|
+
"R" => :Regulation, "L" => :Directive, "D" => :Decision
|
|
19
|
+
}.freeze
|
|
20
|
+
TYPES_BY_ELI = {
|
|
21
|
+
"reg" => :Regulation, "dir" => :Directive, "dec" => :Decision
|
|
22
|
+
}.freeze
|
|
23
|
+
|
|
24
|
+
# The first Official Journal acts (ECSC) date from 1952.
|
|
25
|
+
YEARS = (1952..2099)
|
|
26
|
+
|
|
27
|
+
# One parsed act before it becomes an identifier.
|
|
28
|
+
Act = Struct.new(:klass, :year, :number, :number_first)
|
|
29
|
+
|
|
30
|
+
def self.build(data, input = nil)
|
|
31
|
+
new(input).build(data)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def initialize(input)
|
|
35
|
+
@input = input
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Which of two printed numbers is the year, when the input has no
|
|
39
|
+
# "No". Only one plausible year: that one. Both: a first value from
|
|
40
|
+
# 2015 is the year (every act prints <year>/<number> from 2015);
|
|
41
|
+
# otherwise a regulation prints <number>/<year> and other acts
|
|
42
|
+
# <year>/<number>. Neither: nil. The renderer calls this too, to know
|
|
43
|
+
# when a plain print would read back as another act.
|
|
44
|
+
def self.number_first_for(klass, first, second)
|
|
45
|
+
first_year = year?(first)
|
|
46
|
+
second_year = year?(second)
|
|
47
|
+
return nil unless first_year || second_year
|
|
48
|
+
return !first_year if first_year != second_year
|
|
49
|
+
return false if first.to_i >= Identifier::FIXED_ORDER_YEAR
|
|
50
|
+
|
|
51
|
+
klass == :Regulation
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.year?(value)
|
|
55
|
+
value.length == 4 && YEARS.cover?(value.to_i)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def build(data)
|
|
59
|
+
act = positional(data) || from_pair(data)
|
|
60
|
+
fail!("#{act.year} is not a year") unless self.class.year?(act.year)
|
|
61
|
+
number = strip_zeros(act.number)
|
|
62
|
+
fail!("number 0") if number == "0"
|
|
63
|
+
|
|
64
|
+
id = Identifiers.const_get(act.klass).new(
|
|
65
|
+
number: number,
|
|
66
|
+
date: ::Pubid::Components::Date.new(year: act.year),
|
|
67
|
+
family: family(data),
|
|
68
|
+
)
|
|
69
|
+
keep_order(id, act.number_first)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
# CELEX and ELI: the year and the number have fixed places.
|
|
75
|
+
def positional(data)
|
|
76
|
+
klass = if data[:celex_letter]
|
|
77
|
+
TYPES_BY_CELEX.fetch(data[:celex_letter])
|
|
78
|
+
elsif data[:eli_type]
|
|
79
|
+
TYPES_BY_ELI.fetch(data[:eli_type])
|
|
80
|
+
end
|
|
81
|
+
klass && Act.new(klass, data[:year], data[:number], nil)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def from_pair(data)
|
|
85
|
+
klass = TYPES_BY_WORD.fetch(data[:type_word])
|
|
86
|
+
first = data[:first]
|
|
87
|
+
second = data[:second]
|
|
88
|
+
# "No" marks <number>/<year> (Regulation (EU) No 1227/2011,
|
|
89
|
+
# Decision No 1082/2013/EU); every other pair reads by the rule.
|
|
90
|
+
number_first = !data[:no].nil? ||
|
|
91
|
+
self.class.number_first_for(klass, first, second)
|
|
92
|
+
fail!("no year in #{first}/#{second}") if number_first.nil?
|
|
93
|
+
|
|
94
|
+
year, number = number_first ? [second, first] : [first, second]
|
|
95
|
+
Act.new(klass, year, number, number_first)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Keep the order only when it is not what the render rule prints.
|
|
99
|
+
def keep_order(id, number_first)
|
|
100
|
+
unless number_first.nil? || number_first == id.default_number_first?
|
|
101
|
+
id.number_first = number_first
|
|
102
|
+
end
|
|
103
|
+
id
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def family(data)
|
|
107
|
+
bracket = data[:family]
|
|
108
|
+
suffix = data[:family_suffix]
|
|
109
|
+
if bracket && suffix && bracket != suffix
|
|
110
|
+
fail!("two families, #{bracket} and #{suffix}")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
bracket || suffix
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def strip_zeros(number)
|
|
117
|
+
number.sub(/\A0+(?=\d)/, "")
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def fail!(message)
|
|
121
|
+
raise Pubid::Errors::ParseError.new(
|
|
122
|
+
"EU legal act: #{message}", nil, input: @input, flavor: "eu"
|
|
123
|
+
)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
Pubid::Eu::Builder.prepend(Pubid::Builder::AllPartsWrap)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
# Base class for every EU legal act AND the flavor's parse entry point.
|
|
6
|
+
#
|
|
7
|
+
# Identity is the type (the leaf class), the year (+date+) and the
|
|
8
|
+
# +number+ — the three parts of a CELEX number. +family+ is the bracketed
|
|
9
|
+
# legal family of the Official Journal form (`(EU)`, `(EC)` …); the
|
|
10
|
+
# canonical reference omits it, so a reference with no family matches a
|
|
11
|
+
# row that has one (`===`).
|
|
12
|
+
class Identifier < ::Pubid::Identifier
|
|
13
|
+
# The legal family: EU, EC, EEC, Euratom or CFSP.
|
|
14
|
+
attribute :family, :string
|
|
15
|
+
|
|
16
|
+
# The print order of the two numbers. nil applies the default rule
|
|
17
|
+
# (#default_number_first?); the builder sets it only when the input
|
|
18
|
+
# used the other order, so the flag is rare in an index row.
|
|
19
|
+
attribute :number_first, :boolean
|
|
20
|
+
|
|
21
|
+
# The order is spelling, not identity: "EU Decision 1082/2013" and the
|
|
22
|
+
# CELEX number 32013D1082 name one act.
|
|
23
|
+
equality_ignored :number_first
|
|
24
|
+
|
|
25
|
+
EU_TYPE_MAP = {
|
|
26
|
+
"pubid:eu:regulation" => "Pubid::Eu::Identifiers::Regulation",
|
|
27
|
+
"pubid:eu:directive" => "Pubid::Eu::Identifiers::Directive",
|
|
28
|
+
"pubid:eu:decision" => "Pubid::Eu::Identifiers::Decision",
|
|
29
|
+
}.freeze
|
|
30
|
+
|
|
31
|
+
key_value do
|
|
32
|
+
map "_type", to: :_type, polymorphic_map: EU_TYPE_MAP
|
|
33
|
+
map "number", to: :number
|
|
34
|
+
map "date", to: :date
|
|
35
|
+
map "family", to: :family
|
|
36
|
+
map "number_first", to: :number_first
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
PUBLISHER = "EU"
|
|
40
|
+
|
|
41
|
+
# From 2015 every act prints <year>/<number>. Before 2015 a regulation
|
|
42
|
+
# printed <number>/<year>; other acts used both orders, so they default
|
|
43
|
+
# to <year>/<number> and keep the input order in +number_first+.
|
|
44
|
+
FIXED_ORDER_YEAR = 2015
|
|
45
|
+
|
|
46
|
+
def self.type
|
|
47
|
+
{ key: :identifier, title: "", celex: nil, eli: nil }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# The year is identity, not an edition: 1227/2011 and 1227/2012 are two
|
|
51
|
+
# acts. So an all-parts wrapper keeps the date (the default drops it,
|
|
52
|
+
# which printed "EU Regulation 1227/ (all parts)").
|
|
53
|
+
def self.all_parts_edition_keys
|
|
54
|
+
super - %i[date year]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def default_number_first?
|
|
58
|
+
is_a?(Identifiers::Regulation) && year.to_i < FIXED_ORDER_YEAR
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def number_first?
|
|
62
|
+
number_first.nil? ? default_number_first? : number_first
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def to_s(**opts)
|
|
66
|
+
render(format: :human, **opts)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# EU keeps its publisher in the PUBLISHER constant, not the attribute.
|
|
70
|
+
def publisher_prefixes
|
|
71
|
+
[PUBLISHER]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# The CELEX number: sector 3, year, type letter, number padded to 4.
|
|
75
|
+
def to_celex
|
|
76
|
+
"3#{year}#{self.class.type[:celex]}#{number.rjust(4, '0')}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# The ELI of the act as published in the Official Journal.
|
|
80
|
+
def to_eli
|
|
81
|
+
"http://data.europa.eu/eli/#{self.class.type[:eli]}/#{year}/#{number}/oj"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# The EU has no registered URN namespace (the ELI is its official
|
|
85
|
+
# identifier, #to_eli). This pubid-invented form keeps the act type,
|
|
86
|
+
# so a regulation and a decision with the same numbers do not collide.
|
|
87
|
+
def to_urn
|
|
88
|
+
"urn:eu:#{self.class.type[:eli]}:#{year}:#{number}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# MR string: eu.<eli type>.<number>.<year>, e.g. eu.reg.1227.2011.
|
|
92
|
+
def mr_publisher
|
|
93
|
+
PUBLISHER.downcase
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def mr_type
|
|
97
|
+
self.class.type[:eli]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def self.parse(identifier)
|
|
101
|
+
unless identifier.is_a?(String)
|
|
102
|
+
raise Pubid::Errors::InvalidInputError,
|
|
103
|
+
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if identifier.length > Pubid::MAX_INPUT_LENGTH
|
|
107
|
+
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
identifier = ::Pubid.utf8_input(identifier)
|
|
111
|
+
|
|
112
|
+
parsed = Pubid::Parg::Model.bound(:eu, identifier)
|
|
113
|
+
Builder.build(parsed, identifier)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
module Identifiers
|
|
6
|
+
# An EU decision (CELEX sector 3, letter D; ELI segment "dec").
|
|
7
|
+
class Decision < Identifier
|
|
8
|
+
def self.type
|
|
9
|
+
{ key: :decision, title: "Decision", celex: "D", eli: "dec" }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
module Identifiers
|
|
6
|
+
# An EU directive (CELEX sector 3, letter L; ELI segment "dir").
|
|
7
|
+
class Directive < Identifier
|
|
8
|
+
def self.type
|
|
9
|
+
{ key: :directive, title: "Directive", celex: "L", eli: "dir" }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
module Identifiers
|
|
6
|
+
# An EU regulation (CELEX sector 3, letter R; ELI segment "reg").
|
|
7
|
+
class Regulation < Identifier
|
|
8
|
+
def self.type
|
|
9
|
+
{ key: :regulation, title: "Regulation", celex: "R", eli: "reg" }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
module Identifiers
|
|
6
|
+
autoload :Regulation, "#{__dir__}/identifiers/regulation"
|
|
7
|
+
autoload :Directive, "#{__dir__}/identifiers/directive"
|
|
8
|
+
autoload :Decision, "#{__dir__}/identifiers/decision"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
# The pubid-scheme URN of EU legal acts (docs/URN-SCHEMES.adoc, [[urn-eu]]).
|
|
6
|
+
#
|
|
7
|
+
# EU Regulation 1227/2011 -> urn:pubid:eu:reg:2011:1227
|
|
8
|
+
# EU Decision 1082/2013 ->
|
|
9
|
+
# urn:pubid:eu:dec:2013:1082:f:0.numberfirst-true
|
|
10
|
+
#
|
|
11
|
+
# Every act has a year and a number, so both are the positional core,
|
|
12
|
+
# year first (the CELEX and ELI order). The legal family is an atom; the
|
|
13
|
+
# number-order flag records only the spelling, so it is a facet.
|
|
14
|
+
PubidUrnSchema = Pubid::PubidUrn.define("eu") do
|
|
15
|
+
atom "family", "family"
|
|
16
|
+
facet "number_first", "numberfirst", kind: :bool
|
|
17
|
+
|
|
18
|
+
type "pubid:eu:regulation", "reg", core: %w[year number]
|
|
19
|
+
type "pubid:eu:directive", "dir", core: %w[year number]
|
|
20
|
+
type "pubid:eu:decision", "dec", core: %w[year number]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Eu
|
|
5
|
+
# The canonical form: "EU <Type> <a>/<b>", the order from
|
|
6
|
+
# Identifier#number_first?.
|
|
7
|
+
#
|
|
8
|
+
# Two acts can share one plain print: 32015R2014 and 32014R2015 both give
|
|
9
|
+
# "2015/2014". The parser reads the plain pair by
|
|
10
|
+
# Builder.number_first_for, so when that reading is not this act, the
|
|
11
|
+
# renderer prints "No <number>/<year>" instead — "No" always marks
|
|
12
|
+
# <number>/<year>, so every print parses back to the act that made it.
|
|
13
|
+
class Renderer < ::Pubid::Renderers::Base
|
|
14
|
+
def render(**_opts)
|
|
15
|
+
"#{Identifier::PUBLISHER} #{@id.class.type[:title]} #{numbers}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def numbers
|
|
21
|
+
number = @id.number
|
|
22
|
+
year = @id.year
|
|
23
|
+
return number.to_s if year.nil?
|
|
24
|
+
|
|
25
|
+
number_first = @id.number_first?
|
|
26
|
+
pair = number_first ? [number, year] : [year, number]
|
|
27
|
+
return pair.join("/") if reads_back?(pair, number_first)
|
|
28
|
+
|
|
29
|
+
"No #{number}/#{year}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def reads_back?(pair, number_first)
|
|
33
|
+
klass = @id.class.name.split("::").last.to_sym
|
|
34
|
+
Builder.number_first_for(klass, *pair) == number_first
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/pubid/eu.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pubid"
|
|
4
|
+
module Pubid
|
|
5
|
+
# EU legal acts: regulations, directives and decisions (CELEX sector 3).
|
|
6
|
+
#
|
|
7
|
+
# EU Regulation 1227/2011 canonical, pre-2015 regulation: number/year
|
|
8
|
+
# EU Regulation 2016/679 canonical, from 2015: year/number
|
|
9
|
+
# EU Directive 2016/680 canonical, directives: year/number
|
|
10
|
+
#
|
|
11
|
+
# Parse-only alternates: the Official Journal long form
|
|
12
|
+
# (`Regulation (EU) No 1227/2011`), CELEX (`32011R1227`) and ELI
|
|
13
|
+
# (`http://data.europa.eu/eli/reg/2011/1227/oj`). See lib/pubid/eu/CLAUDE.md.
|
|
14
|
+
module Eu
|
|
15
|
+
extend Pubid::PrefixesSupport
|
|
16
|
+
|
|
17
|
+
PREFIXES = ["EU"].freeze
|
|
18
|
+
|
|
19
|
+
autoload :Builder, "#{__dir__}/eu/builder"
|
|
20
|
+
autoload :Identifier, "#{__dir__}/eu/identifier"
|
|
21
|
+
autoload :Identifiers, "#{__dir__}/eu/identifiers"
|
|
22
|
+
autoload :Parser, "#{__dir__}/eu/parser"
|
|
23
|
+
autoload :Renderer, "#{__dir__}/eu/renderer"
|
|
24
|
+
autoload :PubidUrnSchema, "#{__dir__}/eu/pubid_urn_schema"
|
|
25
|
+
|
|
26
|
+
def self.parse(identifier)
|
|
27
|
+
Identifier.parse(identifier)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Identifier.format_registry =
|
|
31
|
+
FormatRegistry.new(parent: Identifier.format_registry)
|
|
32
|
+
Identifier.format_registry.register(:human, renderer: Eu::Renderer)
|
|
33
|
+
|
|
34
|
+
def self.identifier_types
|
|
35
|
+
[Identifiers::Regulation, Identifiers::Directive, Identifiers::Decision]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.all_typed_stages
|
|
39
|
+
[]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.locate_type(code)
|
|
43
|
+
identifier_types.find { |t| t.type[:key].to_s == code.to_s }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.locate_stage(_abbr)
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Pubid::Registry.register(:eu, Pubid::Eu)
|
data/lib/pubid/version.rb
CHANGED
data/lib/pubid.rb
CHANGED
|
@@ -221,6 +221,7 @@ module Pubid
|
|
|
221
221
|
autoload :Amca, "pubid/amca"
|
|
222
222
|
autoload :Ansi, "pubid/ansi"
|
|
223
223
|
autoload :Api, "pubid/api"
|
|
224
|
+
autoload :Arxiv, "pubid/arxiv"
|
|
224
225
|
autoload :Ashrae, "pubid/ashrae"
|
|
225
226
|
autoload :Asme, "pubid/asme"
|
|
226
227
|
autoload :Doi, "pubid/doi"
|
|
@@ -258,6 +259,7 @@ module Pubid
|
|
|
258
259
|
# beside the coded flavor, never routed by Pubid.parse (registry keys
|
|
259
260
|
# sort "etsi" first).
|
|
260
261
|
autoload :EtsiPfs, "pubid/etsi_pfs"
|
|
262
|
+
autoload :Eu, "pubid/eu"
|
|
261
263
|
autoload :Evs, "pubid/evs"
|
|
262
264
|
autoload :Gost, "pubid/gost"
|
|
263
265
|
autoload :Gb, "pubid/gb"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.44
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -83,6 +83,7 @@ files:
|
|
|
83
83
|
- data/parg/amca.json
|
|
84
84
|
- data/parg/ansi.json
|
|
85
85
|
- data/parg/api.json
|
|
86
|
+
- data/parg/arxiv.json
|
|
86
87
|
- data/parg/ashrae.json
|
|
87
88
|
- data/parg/asme.json
|
|
88
89
|
- data/parg/astm.json
|
|
@@ -104,6 +105,7 @@ files:
|
|
|
104
105
|
- data/parg/ecma.json
|
|
105
106
|
- data/parg/etsi.json
|
|
106
107
|
- data/parg/etsi_pfs.json
|
|
108
|
+
- data/parg/eu.json
|
|
107
109
|
- data/parg/evs.json
|
|
108
110
|
- data/parg/gb.json
|
|
109
111
|
- data/parg/gost.json
|
|
@@ -219,6 +221,15 @@ files:
|
|
|
219
221
|
- lib/pubid/api/single_identifier.rb
|
|
220
222
|
- lib/pubid/api/urn_generator.rb
|
|
221
223
|
- lib/pubid/api/urn_parser.rb
|
|
224
|
+
- lib/pubid/arxiv.rb
|
|
225
|
+
- lib/pubid/arxiv/CLAUDE.md
|
|
226
|
+
- lib/pubid/arxiv/builder.rb
|
|
227
|
+
- lib/pubid/arxiv/identifier.rb
|
|
228
|
+
- lib/pubid/arxiv/identifiers.rb
|
|
229
|
+
- lib/pubid/arxiv/identifiers/eprint.rb
|
|
230
|
+
- lib/pubid/arxiv/parser.rb
|
|
231
|
+
- lib/pubid/arxiv/pubid_urn_schema.rb
|
|
232
|
+
- lib/pubid/arxiv/renderer.rb
|
|
222
233
|
- lib/pubid/ashrae.rb
|
|
223
234
|
- lib/pubid/ashrae/CLAUDE.md
|
|
224
235
|
- lib/pubid/ashrae/builder.rb
|
|
@@ -594,6 +605,17 @@ files:
|
|
|
594
605
|
- lib/pubid/etsi_pfs/pubid_urn_schema.rb
|
|
595
606
|
- lib/pubid/etsi_pfs/renderer.rb
|
|
596
607
|
- lib/pubid/etsi_pfs/urn_generator.rb
|
|
608
|
+
- lib/pubid/eu.rb
|
|
609
|
+
- lib/pubid/eu/CLAUDE.md
|
|
610
|
+
- lib/pubid/eu/builder.rb
|
|
611
|
+
- lib/pubid/eu/identifier.rb
|
|
612
|
+
- lib/pubid/eu/identifiers.rb
|
|
613
|
+
- lib/pubid/eu/identifiers/decision.rb
|
|
614
|
+
- lib/pubid/eu/identifiers/directive.rb
|
|
615
|
+
- lib/pubid/eu/identifiers/regulation.rb
|
|
616
|
+
- lib/pubid/eu/parser.rb
|
|
617
|
+
- lib/pubid/eu/pubid_urn_schema.rb
|
|
618
|
+
- lib/pubid/eu/renderer.rb
|
|
597
619
|
- lib/pubid/evs.rb
|
|
598
620
|
- lib/pubid/evs/CLAUDE.md
|
|
599
621
|
- lib/pubid/evs/builder.rb
|