tldv-data 1.0.2022101300

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ require "faraday"
5
+
6
+ DATA_MODULE_TEMPLATE = <<~ERB
7
+ # frozen_string_literal: true
8
+
9
+ # This file is generated by `rake update`. Do not add your changes here.
10
+
11
+ require "set"
12
+
13
+ module TLDv
14
+ module Data # rubocop:disable Metrics/ModuleLength
15
+ VERSION = "1.0.<%= iana_version %>"
16
+
17
+ TLDS = Set.new(
18
+ %w[<% tlds.each do |tld| %>
19
+ <%= tld -%>
20
+ <% end %>
21
+ ]
22
+ ).freeze
23
+ end
24
+ end
25
+ ERB
26
+
27
+ task :update do
28
+ puts "* fetching TLD database"
29
+ raw_data = Faraday.get("https://data.iana.org/TLD/tlds-alpha-by-domain.txt").body
30
+
31
+ puts "* updating data.rb"
32
+ tlds = raw_data
33
+ .split("\n")
34
+ .reject { _1.start_with?("#") }
35
+ .map(&:downcase)
36
+ .sort
37
+ matches = raw_data.match(/# version (?<version>\d+)/i)
38
+ iana_version = matches[:version]
39
+
40
+ code = ERB.new(DATA_MODULE_TEMPLATE, trim_mode: "<>-").result_with_hash(
41
+ iana_version:,
42
+ tlds:
43
+ )
44
+ File.open(File.expand_path("../lib/tldv/data.rb", __dir__), "w") do |f|
45
+ f.puts code
46
+ end
47
+ end
data/tldv-data.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/tldv/data"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tldv-data"
7
+ spec.version = TLDv::Data::VERSION
8
+ spec.authors = ["Georg Gadinger"]
9
+ spec.email = ["nilsding@nilsding.org"]
10
+
11
+ spec.summary = "TLD data for TLDv"
12
+ spec.description = "contains TLD data from IANA"
13
+ spec.homepage = "https://github.com/nilsding/tldv-data"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.1.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/nilsding/tldv-data"
19
+ spec.metadata["changelog_uri"] = "https://github.com/nilsding/tldv-data/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "faraday", "~> 2.6"
33
+
34
+ # For more information and examples about making a new gem, check out our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ spec.metadata["rubygems_mfa_required"] = "true"
37
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tldv-data
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2022101300
5
+ platform: ruby
6
+ authors:
7
+ - Georg Gadinger
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ description: contains TLD data from IANA
28
+ email:
29
+ - nilsding@nilsding.org
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - CODE_OF_CONDUCT.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - lib/tldv/data.rb
43
+ - rakelib/update.rake
44
+ - tldv-data.gemspec
45
+ homepage: https://github.com/nilsding/tldv-data
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ homepage_uri: https://github.com/nilsding/tldv-data
50
+ source_code_uri: https://github.com/nilsding/tldv-data
51
+ changelog_uri: https://github.com/nilsding/tldv-data/blob/main/CHANGELOG.md
52
+ rubygems_mfa_required: 'true'
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.3.3
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: TLD data for TLDv
72
+ test_files: []