-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.rb
57 lines (45 loc) · 813 Bytes
/
index.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'json'
require 'mustache'
require 'net/http'
class Index < Mustache
def timestamp
json['updated']
end
def domain_names
domains.map(&:name)
end
def domains
json['domains'].to_a.map do |domain|
Domain.new(domain)
end
end
def count
domains.count
end
private
def uri
URI("https://raw.githubusercontent.com/codeandclay/goodi.sh-names/main/available_sh_domains.json")
end
def json
@json ||= JSON.parse(Net::HTTP.get_response(uri).body)
end
end
class Domain
attr_reader :name
def initialize(name)
@name = name
end
def dictionary_word
name.delete('.')
end
def buy_url
"https://google.com/#{name}"
end
def to_h
{
dictionary_word: dictionary_word,
buy_url: buy_url,
name: name
}
end
end