pubid-ccsds 0.1.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 +7 -0
- data/LICENSE.txt +25 -0
- data/README.adoc +26 -0
- data/lib/pubid/ccsds/identifier/base.rb +55 -0
- data/lib/pubid/ccsds/identifier/corrigendum.rb +22 -0
- data/lib/pubid/ccsds/identifier.rb +12 -0
- data/lib/pubid/ccsds/parser.rb +39 -0
- data/lib/pubid/ccsds/renderer/base.rb +29 -0
- data/lib/pubid/ccsds/renderer/corrigendum.rb +7 -0
- data/lib/pubid/ccsds/version.rb +5 -0
- data/lib/pubid/ccsds.rb +22 -0
- data/lib/pubid-ccsds.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 193f9b9e47d7c18988db0a3443b52cee6dd5afedfeb9977119ef8b8ba02d4b93
|
4
|
+
data.tar.gz: 9776b5d64ff1baf0649038a95f20f61efe3c66c05eabaf6fb7b5d9b012442818
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32de5a456214ee004c4f94c7a803f31d7b5405c1963f1c1cd3a3fa5547e5e9f0484fc3aa7c7c024882dd9a66732e4594b3a4fc397bbd467e5c3c04cd6b88744a
|
7
|
+
data.tar.gz: 7aa1a35efe5c5eac4fb39d1e85f1317cd373fc5ae2e0b78b815579aa94ea1c46fcccf0eb32a9992d71fd2614a5333d4f8d097b57044a4def850a463e45ae4a00
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
BSD 2-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2018, 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,26 @@
|
|
1
|
+
= JIS publication identifiers ("CCSDS PubID")
|
2
|
+
|
3
|
+
== Purpose
|
4
|
+
|
5
|
+
This gem implements a mechanism to parse and utilize CCSDS publication
|
6
|
+
identifiers.
|
7
|
+
|
8
|
+
== Use cases to support
|
9
|
+
|
10
|
+
. generate updated PubID
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
=== Identifier creation
|
15
|
+
|
16
|
+
Basic usage of the pubid-ccsds gem starts with the `Identifier#create` method.
|
17
|
+
|
18
|
+
[source,ruby]
|
19
|
+
----
|
20
|
+
require "pubid-ccsds"
|
21
|
+
|
22
|
+
pubid = Pubid::Ccsds::Identifier.create(number: 1234, part: 1, type: "B", edition: 2)
|
23
|
+
pubid.to_s
|
24
|
+
|
25
|
+
=> "CCSDS 1234.1-B-2"
|
26
|
+
----
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Pubid::Ccsds
|
4
|
+
module Identifier
|
5
|
+
class Base < Pubid::Core::Identifier::Base
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
attr_accessor :series, :retired, :book_color
|
9
|
+
|
10
|
+
def self.type
|
11
|
+
{ key: :ccsds, title: "The Consultative Committee for Space Data Systems" }
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(publisher: "CCSDS", book_color: nil, part: nil,
|
15
|
+
series: nil, retired: nil, **opts)
|
16
|
+
super(**opts.merge(publisher: publisher))
|
17
|
+
@book_color = book_color
|
18
|
+
@part = part || 0
|
19
|
+
@series = series
|
20
|
+
@retired = retired
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def transform_supplements(type, identifier_params)
|
25
|
+
Identifier.create(
|
26
|
+
type: type,
|
27
|
+
base: transform(
|
28
|
+
**identifier_params.dup.tap { |h| h.delete(type) }),
|
29
|
+
**identifier_params[type],
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Use Identifier#create to resolve identifier's type class
|
34
|
+
def transform(params)
|
35
|
+
identifier_params = params.map do |k, v|
|
36
|
+
get_transformer_class.new.apply(k => v)
|
37
|
+
end.inject({}, :merge)
|
38
|
+
|
39
|
+
%i(corrigendum).each do |type|
|
40
|
+
return transform_supplements(type, identifier_params) if identifier_params[type]
|
41
|
+
end
|
42
|
+
Identifier.create(**identifier_params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_parser_class
|
46
|
+
Parser
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_renderer_class
|
50
|
+
Renderer::Base
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Pubid::Ccsds
|
2
|
+
module Identifier
|
3
|
+
class Corrigendum < Base
|
4
|
+
def_delegators 'Pubid::Ccsds::Identifier::Corrigendum', :type
|
5
|
+
|
6
|
+
attr_accessor :base
|
7
|
+
|
8
|
+
def initialize(base: nil, **opts)
|
9
|
+
super(**opts)
|
10
|
+
@base = base
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.type
|
14
|
+
{ key: :corrigendum, title: "Corrigendum" }
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_renderer_class
|
18
|
+
Renderer::Corrigendum
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pubid::Ccsds
|
2
|
+
class Parser < Pubid::Core::Parser
|
3
|
+
|
4
|
+
rule(:book_color) do
|
5
|
+
dash >> match["BGMYO"].as(:book_color)
|
6
|
+
end
|
7
|
+
|
8
|
+
rule(:edition) do
|
9
|
+
dash >> digits.as(:edition)
|
10
|
+
end
|
11
|
+
|
12
|
+
rule(:part) do
|
13
|
+
(dot >> digits.as(:part)).repeat(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
rule(:series) do
|
17
|
+
match["A-Z"].as(:series)
|
18
|
+
end
|
19
|
+
|
20
|
+
rule(:retired) do
|
21
|
+
str("-S").as(:retired)
|
22
|
+
end
|
23
|
+
|
24
|
+
rule(:corrigendum) do
|
25
|
+
space >> str("Cor. ") >> digits.as(:number).as(:corrigendum)
|
26
|
+
end
|
27
|
+
|
28
|
+
rule(:language) do
|
29
|
+
space >> dash >> space >> words.as(:language) >> space >> str("Translated")
|
30
|
+
end
|
31
|
+
|
32
|
+
rule(:identifier) do
|
33
|
+
str("CCSDS") >> space >> series.maybe >> digits.as(:number) >> part >>
|
34
|
+
book_color >> edition >> retired.maybe >> corrigendum.maybe >> language.maybe
|
35
|
+
end
|
36
|
+
|
37
|
+
rule(:root) { identifier }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pubid::Ccsds::Renderer
|
2
|
+
class Base < Pubid::Core::Renderer::Base
|
3
|
+
TYPE = "".freeze
|
4
|
+
|
5
|
+
def render_identifier(params)
|
6
|
+
"%{publisher} %{series}%{number}%{part}%{book_color}%{edition}%{retired}" % params
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_part(part, _opts, _params)
|
10
|
+
".#{part}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def render_book_color(book_color, _opts, _params)
|
14
|
+
"-#{book_color}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def render_edition(edition, _opts, _params)
|
18
|
+
"-#{edition}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def render_retired(retired, _opts, _params)
|
22
|
+
"-S" if retired
|
23
|
+
end
|
24
|
+
|
25
|
+
def render_language(language, opts, _params)
|
26
|
+
" - #{language} Translated"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/pubid/ccsds.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "parslet"
|
4
|
+
|
5
|
+
module Pubid
|
6
|
+
end
|
7
|
+
|
8
|
+
require "pubid-core"
|
9
|
+
|
10
|
+
require_relative "ccsds/identifier/base"
|
11
|
+
require_relative "ccsds/identifier/corrigendum"
|
12
|
+
require_relative "ccsds/renderer/base"
|
13
|
+
require_relative "ccsds/renderer/corrigendum"
|
14
|
+
require_relative "ccsds/parser"
|
15
|
+
require_relative "ccsds/identifier"
|
16
|
+
|
17
|
+
config = Pubid::Core::Configuration.new
|
18
|
+
config.default_type = Pubid::Ccsds::Identifier::Base
|
19
|
+
config.types = [Pubid::Ccsds::Identifier::Base,
|
20
|
+
Pubid::Ccsds::Identifier::Corrigendum]
|
21
|
+
config.type_names = {}.freeze
|
22
|
+
Pubid::Ccsds::Identifier.set_config(config)
|
data/lib/pubid-ccsds.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pubid-ccsds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-19 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: parslet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pubid-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.6
|
69
|
+
description: Library to generate, parse and manipulate CCSDS PubID.
|
70
|
+
email:
|
71
|
+
- open.source@ribose.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- README.adoc
|
76
|
+
- LICENSE.txt
|
77
|
+
files:
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.adoc
|
80
|
+
- lib/pubid-ccsds.rb
|
81
|
+
- lib/pubid/ccsds.rb
|
82
|
+
- lib/pubid/ccsds/identifier.rb
|
83
|
+
- lib/pubid/ccsds/identifier/base.rb
|
84
|
+
- lib/pubid/ccsds/identifier/corrigendum.rb
|
85
|
+
- lib/pubid/ccsds/parser.rb
|
86
|
+
- lib/pubid/ccsds/renderer/base.rb
|
87
|
+
- lib/pubid/ccsds/renderer/corrigendum.rb
|
88
|
+
- lib/pubid/ccsds/version.rb
|
89
|
+
homepage: https://github.com/metanorma/pubid-jis
|
90
|
+
licenses:
|
91
|
+
- BSD-2-Clause
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.5.0
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.3.26
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Library to generate, parse and manipulate CCSDS PubID.
|
112
|
+
test_files: []
|