subdomain_name 0.0.1

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: 639d6fcee57a929329ab90e585129fe37487c554e9c9d855bc15b562b42ee2bf
4
+ data.tar.gz: bedbd7eb0b2ab5c711a493ac977af01fe3f8f2054070ab2d585266957f350d5c
5
+ SHA512:
6
+ metadata.gz: 56d3bbd3e91f4b9cd824960e662aad952a67aaa0b6d0af898f19316aff0399f42c136f7ebce9f2ab53a66738a74bc6a0f22062e159317d81a44542b1f329d3e4
7
+ data.tar.gz: 416f799146fdbdd2a04999886a832229c77b570964e49dc1a8aba440c88b90ce3bac09fd2b413511dc16b92da693e1528f4931da54d4cb358d662fd93ba4f08d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Dominic Sayers
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ require 'subdomain_name/name'
2
+
3
+ module SubdomainName
4
+ module_function
5
+
6
+ def [](name)
7
+ Name.new(name)
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ require 'idn'
2
+ require 'reserved_subdomain'
3
+
4
+ module SubdomainName
5
+ class Name
6
+ include IDN
7
+
8
+ ACE_PREFIX = Idna::ACE_PREFIX
9
+
10
+ def initialize(name)
11
+ @name = name
12
+ end
13
+
14
+ def valid?
15
+ Idna.toASCII @name, IDN::Idna::USE_STD3_ASCII_RULES
16
+ true
17
+ rescue IDN::Idna::IdnaError
18
+ false
19
+ end
20
+
21
+ def reserved?
22
+ @reserved ||= ReservedSubdomain.new(@name).reserved?
23
+ end
24
+
25
+ def idn?
26
+ @idn ||= [to_ascii, to_unicode].any? { |value| value != @name }
27
+ end
28
+
29
+ def to_ascii
30
+ @to_ascii ||= Idna.toASCII @name
31
+ end
32
+
33
+ def to_unicode
34
+ @to_unicode ||= Idna.toUnicode @name
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SubdomainName
4
+ VERSION = '0.0.1'.freeze
5
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subdomain_name
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dominic Sayers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: idn-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: reserved_subdomain
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - dominic@sayers.cc
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - lib/subdomain_name.rb
50
+ - lib/subdomain_name/name.rb
51
+ - lib/subdomain_name/version.rb
52
+ homepage: https://github.com/dominicsayers/subdomain_name
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.7.7
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Manage subdomain names
76
+ test_files: []