reserved_subdomain 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b946c00cb63fbfe39ad7f7dd2ad0e7b52a230d7211fda09c7f704c5992e0529
4
- data.tar.gz: 78c931d69d132e534dd0cff37ac714e393f467b6bd4aeab93c3e2a96d6136b75
3
+ metadata.gz: 355678eb8d873df7becf4aaa09ea241d0438a30854e4bb2cec412c9cdc5b784a
4
+ data.tar.gz: a94bb8ac2fdacd693c3253513d91c187d953853cf31cdc2a4a84f328b20f4c60
5
5
  SHA512:
6
- metadata.gz: 6aeb84bdd1db6ad923aa25cb1f7419ca63e958fd7551261a19fef8b3a2f51f7722a0cc415e5f137990422f2b2187c2f4fb118805fdf1cfe0c9f0d382cebd8b21
7
- data.tar.gz: 57412ff3901d113ee036d369665350febdbeed325f8ec3b2c3adbbfe3af6f688330efd4390fbe79d73f1efa67a6ffb0fed4b80d62663449790ae33e862ecf5f3
6
+ metadata.gz: 13432bfe336ff699c89859c353cf08a67febb0ed2c2bba24cf0d11f1bb1c912d69ba4758d7c023946ea74664e88cbe903929fbdd9a97056f00da0ce1b57b684a
7
+ data.tar.gz: c90a5b7730222259e61caabf684b5b028ee2652218dbad90c4292256e8d8eff088e878a86eb1c4fda62e9c524a52695a773918d4e90e29afb169070c981a1e41
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased](https://github.com/dominicsayers/reserved_subdomain/tree/HEAD)
4
+
5
+ **Merged pull requests:**
6
+
7
+ - New build [\#4](https://github.com/dominicsayers/reserved_subdomain/pull/4) ([dominicsayers](https://github.com/dominicsayers))
8
+ - Add Simplecov and report to CodeClimate from Travis [\#3](https://github.com/dominicsayers/reserved_subdomain/pull/3) ([dominicsayers](https://github.com/dominicsayers))
9
+ - Initial commit [\#1](https://github.com/dominicsayers/reserved_subdomain/pull/1) ([dominicsayers](https://github.com/dominicsayers))
10
+
11
+
12
+
13
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
File without changes
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/bin/build_literals CHANGED
@@ -4,42 +4,29 @@
4
4
  lib = File.expand_path('../lib', __dir__)
5
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
 
7
+ require 'csv'
7
8
  require 'open-uri'
8
9
  require 'reserved_subdomain'
9
10
 
10
- def write_file(content, filename)
11
- filepath = File.join(__dir__, '..', 'lib', 'reserved_subdomain', 'literals', filename)
12
- File.open(filepath, 'w') { |f| f.write content.join("\n") }
13
- end
14
-
15
- # Remove existing literals that exist in content
16
- def remove_literals(content)
17
- literals = ReservedSubdomain::Literal.load_literals.dup
18
- literals.select! { |literal| !content.include?(literal) }
19
- write_file literals, 'reserved_subdomains.txt'
20
- end
21
-
22
11
  # TLDs
23
12
  uri = URI.parse('http://data.iana.org/TLD/tlds-alpha-by-domain.txt')
24
- tlds = uri.read.downcase.split("\n")
25
- remove_literals(tlds)
26
-
27
- tlds.select! do |tld|
28
- (tld !~ /^#/) &&
29
- !ReservedSubdomain::Prefix.new(tld).reserved? &&
30
- !ReservedSubdomain::Pattern.new(tld).reserved?
31
- end
32
-
33
- write_file tlds, 'tlds.txt'
13
+ file = ReservedSubdomain::File.new(:tlds)
14
+ file.literals = uri.read.downcase.split("\n")
15
+ content = file.remove_reserved!.save.literals
16
+ ReservedSubdomain::File.new(:miscellaneous).dedupe!(content).save
34
17
 
35
18
  # Country codes
36
- # TODO: Find source of ISO-3166-1 country codes and add them to the list of literals
37
- filepath = File.join(__dir__, '..', 'lib', 'reserved_subdomain', 'literals', 'iso-3166-1.txt')
38
- country_codes = File.read(filepath).split("\n").compact
39
- remove_literals(country_codes)
19
+ uri = URI.parse('https://datahub.io/core/country-list/r/data.csv')
20
+ io = uri.open
21
+ csv = CSV.parse(io, headers: true)
22
+
23
+ file = ReservedSubdomain::File.new(:iso_3166_1)
24
+ file.literals = csv.map { |row| row["Code"].downcase }
25
+ content = file.remove_reserved!.save.literals
26
+ ReservedSubdomain::File.new(:miscellaneous).dedupe!(content).save
40
27
 
41
28
  # Language codes
42
29
  # TODO: Find a source of ISO-639 language codes and add them to the list of literals
43
- filepath = File.join(__dir__, '..', 'lib', 'reserved_subdomain', 'literals', 'iso-639-1.txt')
44
- language_codes = File.read(filepath).split("\n").compact
45
- remove_literals(language_codes)
30
+ file = ReservedSubdomain::File.new(:iso_639_1)
31
+ content = file.remove_reserved!.save.literals
32
+ ReservedSubdomain::File.new(:miscellaneous).dedupe!(content).save
@@ -0,0 +1,48 @@
1
+ class ReservedSubdomain
2
+ class File
3
+ DIRECTORY = ::File.join(__dir__, 'literals')
4
+
5
+ class << self
6
+ def load(fileroot = '*')
7
+ new(fileroot).literals
8
+ end
9
+ end
10
+
11
+ attr_reader :fileroot, :literals
12
+
13
+ def initialize(fileroot = '*')
14
+ @fileroot = fileroot
15
+ @literals = files.map { |filename| ::File.read(filename).split("\n") }.compact.flatten
16
+ end
17
+
18
+ def literals=(list)
19
+ @literals = list.sort.uniq
20
+ end
21
+
22
+ def save
23
+ ::File.open(files.first, 'w') { |f| f.write literals.join("\n") }
24
+ self
25
+ end
26
+
27
+ def dedupe!(content)
28
+ literals.reject! { |literal| content.include?(literal) }
29
+ self
30
+ end
31
+
32
+ def remove_reserved!
33
+ literals.reject! do |literal|
34
+ (literal =~ /^#/) ||
35
+ ReservedSubdomain::Prefix.new(literal).reserved? ||
36
+ ReservedSubdomain::Pattern.new(literal).reserved?
37
+ end
38
+
39
+ self
40
+ end
41
+
42
+ private
43
+
44
+ def files
45
+ Dir.glob(::File.join(DIRECTORY, "#{fileroot}.txt"))
46
+ end
47
+ end
48
+ end
@@ -13,17 +13,7 @@ class ReservedSubdomain
13
13
  end
14
14
 
15
15
  def load_literals
16
- literals_files.map { |filename| File.read(filename).split("\n") }.compact.flatten
17
- end
18
-
19
- private
20
-
21
- def literals_files
22
- Dir.glob(File.join(literals_directory, '*'))
23
- end
24
-
25
- def literals_directory
26
- @literals_directory ||= File.join(__dir__, 'literals')
16
+ ReservedSubdomain::File.load('*')
27
17
  end
28
18
  end
29
19
 
@@ -0,0 +1,248 @@
1
+ ad
2
+ ae
3
+ af
4
+ ag
5
+ ai
6
+ al
7
+ am
8
+ ao
9
+ aq
10
+ ar
11
+ as
12
+ at
13
+ au
14
+ aw
15
+ ax
16
+ az
17
+ ba
18
+ bb
19
+ bd
20
+ be
21
+ bf
22
+ bg
23
+ bh
24
+ bi
25
+ bj
26
+ bl
27
+ bm
28
+ bn
29
+ bo
30
+ bq
31
+ br
32
+ bs
33
+ bt
34
+ bv
35
+ bw
36
+ by
37
+ bz
38
+ ca
39
+ cc
40
+ cd
41
+ cf
42
+ cg
43
+ ch
44
+ ci
45
+ ck
46
+ cl
47
+ cm
48
+ cn
49
+ co
50
+ cr
51
+ cu
52
+ cv
53
+ cw
54
+ cx
55
+ cy
56
+ cz
57
+ de
58
+ dj
59
+ dk
60
+ dm
61
+ do
62
+ dz
63
+ ec
64
+ ee
65
+ eg
66
+ eh
67
+ er
68
+ es
69
+ et
70
+ fi
71
+ fj
72
+ fk
73
+ fm
74
+ fo
75
+ fr
76
+ ga
77
+ gb
78
+ gd
79
+ ge
80
+ gf
81
+ gg
82
+ gh
83
+ gi
84
+ gl
85
+ gm
86
+ gn
87
+ gp
88
+ gq
89
+ gr
90
+ gs
91
+ gt
92
+ gu
93
+ gw
94
+ gy
95
+ hk
96
+ hm
97
+ hn
98
+ hr
99
+ ht
100
+ hu
101
+ id
102
+ ie
103
+ il
104
+ im
105
+ in
106
+ io
107
+ iq
108
+ ir
109
+ is
110
+ it
111
+ je
112
+ jm
113
+ jo
114
+ jp
115
+ ke
116
+ kg
117
+ kh
118
+ ki
119
+ km
120
+ kn
121
+ kp
122
+ kr
123
+ kw
124
+ ky
125
+ kz
126
+ la
127
+ lb
128
+ lc
129
+ li
130
+ lk
131
+ lr
132
+ ls
133
+ lt
134
+ lu
135
+ lv
136
+ ly
137
+ ma
138
+ mc
139
+ md
140
+ me
141
+ mf
142
+ mg
143
+ mh
144
+ mk
145
+ ml
146
+ mm
147
+ mn
148
+ mo
149
+ mp
150
+ mq
151
+ mr
152
+ ms
153
+ mt
154
+ mu
155
+ mv
156
+ mw
157
+ my
158
+ mz
159
+ na
160
+ nc
161
+ ne
162
+ nf
163
+ ng
164
+ ni
165
+ nl
166
+ no
167
+ np
168
+ nr
169
+ nu
170
+ nz
171
+ om
172
+ pa
173
+ pe
174
+ pf
175
+ pg
176
+ ph
177
+ pk
178
+ pl
179
+ pm
180
+ pn
181
+ pr
182
+ ps
183
+ pt
184
+ pw
185
+ py
186
+ qa
187
+ re
188
+ ro
189
+ rs
190
+ ru
191
+ rw
192
+ sa
193
+ sb
194
+ sc
195
+ sd
196
+ se
197
+ sg
198
+ sh
199
+ si
200
+ sj
201
+ sk
202
+ sl
203
+ sm
204
+ sn
205
+ so
206
+ sr
207
+ ss
208
+ st
209
+ sv
210
+ sx
211
+ sy
212
+ sz
213
+ tc
214
+ td
215
+ tf
216
+ tg
217
+ th
218
+ tj
219
+ tk
220
+ tl
221
+ tm
222
+ tn
223
+ to
224
+ tr
225
+ tt
226
+ tv
227
+ tw
228
+ tz
229
+ ua
230
+ ug
231
+ um
232
+ us
233
+ uy
234
+ uz
235
+ va
236
+ vc
237
+ ve
238
+ vg
239
+ vi
240
+ vn
241
+ vu
242
+ wf
243
+ ws
244
+ ye
245
+ yt
246
+ za
247
+ zm
248
+ zw
@@ -139,7 +139,6 @@ ecommerce
139
139
  edit
140
140
  editor
141
141
  edits
142
- eh
143
142
  embed
144
143
  embedded
145
144
  employment
@@ -321,6 +320,7 @@ msn
321
320
  mssql
322
321
  music
323
322
  musicas
323
+ mx
324
324
  mysql
325
325
  nagios
326
326
  named
@@ -447,7 +447,6 @@ spanish
447
447
  speedtest
448
448
  sports
449
449
  sql
450
- ss
451
450
  ssh
452
451
  ssl
453
452
  ssladmin
@@ -611,6 +611,7 @@ imdb
611
611
  immo
612
612
  immobilien
613
613
  in
614
+ inc
614
615
  industries
615
616
  infiniti
616
617
  info
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ReservedSubdomain
4
- VERSION = '0.0.1'.freeze
4
+ VERSION = '0.0.2'.freeze
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'reserved_subdomain/file'
1
2
  require 'reserved_subdomain/literal'
2
3
  require 'reserved_subdomain/pattern'
3
4
  require 'reserved_subdomain/prefix'
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reserved_subdomain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Sayers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -21,6 +21,7 @@ files:
21
21
  - ".rspec"
22
22
  - ".rubocop.yml"
23
23
  - ".travis.yml"
24
+ - CHANGELOG.md
24
25
  - Gemfile
25
26
  - Gemfile.local.example
26
27
  - LICENSE
@@ -31,10 +32,11 @@ files:
31
32
  - bin/rspec
32
33
  - bin/rubocop
33
34
  - lib/reserved_subdomain.rb
35
+ - lib/reserved_subdomain/file.rb
34
36
  - lib/reserved_subdomain/literal.rb
35
- - lib/reserved_subdomain/literals/iso-3166-1.txt
36
- - lib/reserved_subdomain/literals/iso-639-1.txt
37
- - lib/reserved_subdomain/literals/reserved_subdomains.txt
37
+ - lib/reserved_subdomain/literals/iso_3166_1.txt
38
+ - lib/reserved_subdomain/literals/iso_639_1.txt
39
+ - lib/reserved_subdomain/literals/miscellaneous.txt
38
40
  - lib/reserved_subdomain/literals/tlds.txt
39
41
  - lib/reserved_subdomain/pattern.rb
40
42
  - lib/reserved_subdomain/prefix.rb
@@ -1,2 +0,0 @@
1
- gb
2
- us