pubid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd779f3a277fdc04a542443c5c636061fb2b112eca6799681f3b256c535800d7
4
+ data.tar.gz: feba7c57f219a063c29f7322a2d3a946c1b734b81876d5c1cf89136e0a00fdc3
5
+ SHA512:
6
+ metadata.gz: 8a757e63f5d98c06d453cf1369a2a85e507482e9036e17fde6c6092aa555c59b25fc2343e20c97d223765fb159a542c250a2291ae79f2489810b5660ccdb917f
7
+ data.tar.gz: debfe72e6c57c45da4a1a296b905328a7a61f1fedda71d310f26719341b19bed85335f56118faeae4b5985ca481e2de1581ab0a1be327a04720216273e5bfbc7
data/LICENSE.txt ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2022, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,127 @@
1
+ = IEEE publication identifiers ("IEEE PubID")
2
+
3
+ == Purpose
4
+
5
+ Implements a mechanism to parse and utilize IEEE publication identifers.
6
+
7
+ == Historic identifier patterns
8
+
9
+ There are at least two major "pattern series" of identifiers due to historical reasons: old (type I) and new (type II).
10
+ This implementation attempts to support both types of publication identifier patterns.
11
+
12
+ == Use cases to support
13
+
14
+ * analyze a pattern of type I idetifier
15
+ * parse type II idetifier into components
16
+ * generate a filename from the components similar to type I pattern
17
+
18
+ == Elements of the PubID
19
+
20
+ === Publisher
21
+
22
+ |===
23
+ | Name | Abbrev
24
+
25
+ | Institute of Electrical and Electronics Engineers
26
+ | IEEE
27
+
28
+ |===
29
+
30
+ === Report number
31
+
32
+ `{number}` - is a set of one or more digits and optional letters
33
+
34
+ === Part
35
+
36
+ `{part}` - is a set of digits and optional letters; starts with a digit; if a letter or letters are present then they are in the end; optional
37
+
38
+ === Subpart
39
+
40
+ `{subpart}` - is a set of digits and optional letters; optional, many subparts are possible
41
+
42
+ === Year
43
+
44
+ `{year}` - is a set of 4 digits; optional
45
+
46
+ === Corrigendum & Amendment
47
+
48
+ `{cor}` - is a corrigendum or an amendments with the pattern `Cor {cornum}-{year}` or `Amd {cornum}:{year}` where {cornum} is a set of digits; optional
49
+
50
+ == Type I pattern
51
+
52
+ [source]
53
+ ----
54
+ {publisher} {type} {series} {number}{part}.{subpart}{year} {edition}/{conform}/{correction}
55
+ ----
56
+
57
+ * `{publisher}` IEEE
58
+ * `{type}` one of the values: `Standard`, `Std`, `Draft`, `Draft Standard`, `Draft Supplement` ^*^
59
+ * `{series}` one of the values: `ISO/IEC`, `ISO/IEC/IEEE` ^*^
60
+ * `{number}` set of digits optionally prefixed with uppercase letter and optionally suffixed with letter
61
+ * `{part}` from 1 to 2 digits prefixed with `.` or `-` and optionally suffixed with up to 4 letters ^*^
62
+ * `{subpart}` 1 digit optionally suffixed with a letter ^*^
63
+ * `{year}` 4 digits prefixed with `-`, `:`, ` - `, or breakspace ^*^
64
+ * `{edition}` prefix `Edition` followed by a reference in brackets or prefix `First edition` followed by date in format `YYYY-MM-DD` ^*^
65
+ * `{conform}` prefix `Conformance` followed by 2 digits, dash, and 4 digits year ^*^
66
+ * `{correction}` prefix `Cor` optionally followed by breakspace, or prefix `Amd` followed by `.`, followed by from 1 to 2 digits, dash and 4 digits year ^*^
67
+
68
+ (*) - optional
69
+
70
+ An identifier can be composed of 2 other identifiers with breakspace delimiter. Only the first identifier needs to cnatain puplisher, for the secont it's optional
71
+
72
+ Following RegEx expression parses 100% of identifiers from the type I https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ieee/[dataset]:
73
+ [source,regex]
74
+
75
+ ----
76
+ {
77
+ ^IEEE\s
78
+ ((?<type1>Standard|Std|Draft(\sStandard|\sSupplement)?)\s)?
79
+ ((?<series>ISO\/IEC(\/IEEE)?)\s)?
80
+ (?<number1>[A-Z]?\d+[[:alpha:]]?)
81
+ ([.-](?<part1>\d{1,2}(?!\d)[[:alpha:]]{0,4}))?
82
+ (\.(?<subpart1>\d[[:alpha:]]?))?
83
+ (?<year1>([-:]|\s-\s|,\s)\d{4})?
84
+ (\s(IEEE\s(?<type2>Std)\s)?(?<number2>[A-Z]?\d+[[:alpha:]]?)
85
+ ([.-](?<part2>\d{1,2}(?!\d)[[:alpha:]]{0,4}))?
86
+ ([.](?<subpart2>\d[[:alpha:]]?))?
87
+ (?<year2>([-:.]|_-|\s-\s|,\s)\d{4})?)?
88
+ (\s(?<edition>Edition(\s\([^)]+\))?|First\sedition\s[\d-]+))?
89
+ (\/(?<conform>Conformance\d{2})-(?<confyear>\d{4}))?
90
+ (\/(?<correction>(Cor\s?|(Amd\.)\d{1,2})
91
+ (?<coryear>(:|-|:-)\d{4}))?$
92
+ }x
93
+ ----
94
+
95
+ == Pasing PubID elements from type II identifiers
96
+
97
+ To parse PubID elements from the type II pattern identifiers we can use a RegEx expression:
98
+
99
+ [source,regex]
100
+ ----
101
+ {
102
+ ^IEEE\s(?<number1>\w+(\.[A-Z]\d|\sHBK)?)
103
+ (?<part1>(\.|\s)\d{1,4}[[:alpha:],]{0,7}|-\d?[A-Z]+|-\d(?=[-.]))?
104
+ (?<subpart11>\.\d{1,3}[a-z]?|-\d{5}[a-z]?|-\d+(?=[-:_]))?
105
+ (?<subpart12>\.\d|-\d+(?=-))?
106
+ (?<year1>([-:.]|_-|\s-)\d{4})?
107
+ (\/(?<number2>([A-Z]?\d+[a-z]?|Conformance\d+))
108
+ ((\.|-)(?<part2>\d{1,3}[a-z]?)(?!\d))?
109
+ (\.(?<subpart21>\d{1,2}))?)?
110
+ (\/(?<number3>\d+)(\.(?<part3>\d))?)?
111
+ (?<year2>([-:.]|_-|\s-)\d{4})?
112
+ ((\/|_|-|\s\/)(?<correction>(Cor|(?i)Amd(?-i))(\s|\.|\.\s)?\d{1,2})
113
+ (?<coryear>(:|-|:-|_[A-Z][a-z]{2}_)\d{4}(-\d{4})?)?)?$
114
+ }x
115
+ ----
116
+
117
+ This RegEx expession covers 99% of the identifiers from the type II bibxml-ieee https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ieee-new/[dataset].
118
+
119
+ == File name generator
120
+
121
+ For type I identifiers file names are generated by replacing symbols `/`, `\`, `,`, `'`, `"`, `(`, `)`, and breakspace with symbol `_`. Sequences of multiple sybols `_` should be squized to one symbol.
122
+
123
+ For type II identifiers it needs to parse PubID elements than join the elements in order:
124
+
125
+ ----
126
+ IEEE.{number1}_{part1}.{subpart11}.{subpart12}-{year1}_{number2}_{part2}.{subpart21}_{number3}_{part3}-{year2}_{correction}-{coryear}
127
+ ----
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ VERSION = "0.1.0"
5
+ end
data/lib/pubid.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pubid/version"
4
+
5
+ module Pubid
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pubid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: Library to generate, parse and manipulate PubIDs.
42
+ email:
43
+ - open.source@ribose.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files:
47
+ - README.adoc
48
+ - LICENSE.txt
49
+ files:
50
+ - LICENSE.txt
51
+ - README.adoc
52
+ - lib/pubid.rb
53
+ - lib/pubid/version.rb
54
+ homepage: https://github.com/metanorma/pubid-ieee
55
+ licenses:
56
+ - BSD-2-Clause
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.5.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.3.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Library to generate, parse and manipulate PubIDs.
77
+ test_files: []