relaton-iana 1.9.2

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: 48562c586397e7ff65110da5246d59bd6ccd55361b93a2c5b001cecb927c46fb
4
+ data.tar.gz: f81db7823ad57e5c7f98558a9438be25f4c852b9f046494d537dae8115a95483
5
+ SHA512:
6
+ metadata.gz: cbe4bdd3aade6812da19e2663d8103164e65195802b01e26d1f34f8c5f8f0538650efad5923f0b5c46eb73f9899e17bfb6182c2aaafaa77798b6cfc5c604b058
7
+ data.tar.gz: 12bb78460fc68bc845df6db1644d7fb7eb8575a472aa2e2dc865e930ba4dc8c05d1e996741fadfef55d1c58fed2e337580a1b0f571a0892d66ace34e2cff4d06
@@ -0,0 +1,36 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ with:
25
+ submodules: true
26
+
27
+ # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
+ - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
+ run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
+
31
+ - uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+
36
+ - run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
13
+ .vscode/
14
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # This project follows the Ribose OSS style guide.
2
+ # https://github.com/riboseinc/oss-guides
3
+ # All project-specific additions and overrides should be specified in this file.
4
+
5
+ inherit_from:
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
+ AllCops:
8
+ TargetRubyVersion: 2.5
9
+ Rails:
10
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in relaton_iana.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Andrei Kislichenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,141 @@
1
+ = RelatonIana
2
+
3
+ RelatonIana is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
4
+
5
+ You can use it to retrieve metadata of W3C Standards from https://w3.org, and access such metadata through the `BibliographicItem` object.
6
+
7
+ == Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ [source,ruby]
12
+ ----
13
+ gem 'relaton-iana'
14
+ ----
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install relaton-iana
23
+
24
+ == Usage
25
+
26
+ === Search for a standard using keywords
27
+
28
+ [source,ruby]
29
+ ----
30
+ require 'relaton_iana'
31
+ => true
32
+
33
+ item = RelatonIana::IanaBibliography.get "IANA service-names-port-numbers"
34
+ [relaton-iana] ("IANA service-names-port-numbers") fetching...
35
+ [relaton-iana] ("IANA service-names-port-numbers") found IANA service-names-port-numbers
36
+ => #<RelatonBib::BibliographicItem:0x00007f7c6cc024d0
37
+ ...
38
+ ----
39
+
40
+ === XML serialization
41
+
42
+ [source,ruby]
43
+ ----
44
+ item.to_xml
45
+ => "<bibitem id="IANAservice-names-port-numbers" type="standard">
46
+ <fetched>2021-11-24</fetched>
47
+ <title format="text/plain">Service Name and Transport Protocol Port Number Registry</title>
48
+ <uri type="src">http://www.iana.org/assignments/service-names-port-numbers</uri>
49
+ <docidentifier type="IANA">IANA service-names-port-numbers</docidentifier>
50
+ <docnumber>service-names-port-numbers</docnumber>
51
+ <date type="updated">
52
+ <on>2021-11-12</on>
53
+ </date>
54
+ <contributor>
55
+ <role type="publisher"/>
56
+ <organization>
57
+ <name>Internet Assigned Numbers Authority</name>
58
+ <abbreviation>IANA</abbreviation>
59
+ </organization>
60
+ </contributor>
61
+ <language>en</language>
62
+ <script>Latn</script>
63
+ </bibitem>"
64
+ ----
65
+
66
+ === Typed links
67
+
68
+ Each IANA document has `src` type link.
69
+
70
+ [source,ruby]
71
+ ----
72
+ item.link.first.type
73
+ => "src"
74
+
75
+ item.link.first.content
76
+ => #<Addressable::URI:0x9ec URI:http://www.iana.org/assignments/service-names-port-numbers>
77
+ ----
78
+
79
+ === Create bibliographic item from XML
80
+ [source,ruby]
81
+ ----
82
+ RelatonBib::XMLParser.from_xml File.read('spec/fixtures/service-names-port-numbers.xml')
83
+ => #<RelatonBib::BibliographicItem:0x00007f7c6b837248
84
+ ...
85
+ ----
86
+
87
+ === Create bibliographic item from YAML
88
+ [source,ruby]
89
+ ----
90
+ hash = YAML.load_file 'spec/fixtures/service-names-port-numbers.yaml'
91
+ => {"id"=>"IANAservice-names-port-numbers",
92
+ "title"=>{"content"=>"Service Name and Transport Protocol Port Number Registry", "format"=>"text/plain"},
93
+ ...
94
+
95
+ bib_hash = RelatonIana::HashConverter.hash_to_bib hash
96
+ => {:id=>"IANAservice-names-port-numbers",
97
+ :title=>{:content=>"Service Name and Transport Protocol Port Number Registry", :format=>"text/plain"},
98
+ ...
99
+
100
+ RelatonBib::BibliographicItem.new **bib_hash
101
+ => #<RelatonBib::BibliographicItem:0x007f9381ec6a00
102
+ ...
103
+ ----
104
+
105
+ === Fetch data
106
+
107
+ There is a IANA dataset https://github.com/ietf-ribose/iana-registries which can be converted into RelatonXML/BibXML/BibYAML formats.
108
+
109
+ The method `RelatonIana::DataFetcher.fetch(output: "data", format: "yaml")` converts all the documents from the dataset and save them to the `./data` folder in YAML format.
110
+ Arguments:
111
+
112
+ - `output` - folder to save documents (default './data').
113
+ - `format` - format in which the documents are saved. Possimle formats are: `yaml`, `xml`, `bibxml` (default `yaml`).
114
+
115
+ [source,ruby]
116
+ ----
117
+ RelatonIana::DataFetcher.fetch
118
+ Started at: 2021-11-19 13:32:05 +0100
119
+ Stopped at: 2021-11-19 13:34:40 +0100
120
+ Done in: 155 sec.
121
+ => nil
122
+ ----
123
+
124
+ This method uses GitHub search API to fetch the documents. The search API has a https://docs.github.com/en/rest/reference/search#rate-limit[rate limitaion] of 30 requests per minute for authenticated users and 10 requests per minute for unauthenticated users. Usually, the rate limit is not reached because the search API is used only for the files list fetching. But if you run the method multiple times in a short period, it is possible that the rate limit will be reached. In this case, the method will wait until the rate limit is reset.
125
+
126
+ You can use pesonal access token to increase the rate limit. To do this, add your pesonal access token to the `GITHUB_TOKEN` environment variable.
127
+
128
+ == Development
129
+
130
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
131
+
132
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
133
+
134
+ == Contributing
135
+
136
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton_w3c.
137
+
138
+
139
+ == License
140
+
141
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "relaton_iana"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here