reversed 0.1.0

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
+ SHA1:
3
+ metadata.gz: 0153a5578c5b4d7fffd13c7e8aaccb1f85fb13b2
4
+ data.tar.gz: 4e7b4dbbe5e52bfac9578d4c797130d74169d881
5
+ SHA512:
6
+ metadata.gz: 81994bac9fa7ea8961b0d01130c422804c6902ba4e9c02bef8df5369ea9d112acefac35c8965dfbc657099c04aff26866d51a28c8801c50b82f60ed616b6b70f
7
+ data.tar.gz: 7eaa377e5f884d2f50d9f2245c47524bf5f27bf3a91b1bc94188bbd161fdca45f8e563cb76da9b9ef44a2505271b21978f7aa85f1ec72e15f4a20a7a2c6df858
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0
2
+
3
+ - First release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in reversed.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Reversed
2
+
3
+ :earth_americas: Reverse DNS / IP Lookup for Ruby
4
+
5
+ ```ruby
6
+ Reversed.lookup("8.8.4.4")
7
+ # => {:domain=>"google.com", :hostname=>"google-public-dns-b.google.com"}
8
+ ```
9
+
10
+ Works with IPv4 and IPv6
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application’s Gemfile:
15
+
16
+ ```ruby
17
+ gem 'reversed'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```sh
23
+ bundle
24
+ ```
25
+
26
+ ## History
27
+
28
+ View the [changelog](https://github.com/ankane/reversed/blob/master/CHANGELOG.md)
29
+
30
+ ## Contributing
31
+
32
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
33
+
34
+ - [Report bugs](https://github.com/ankane/reversed/issues)
35
+ - Fix bugs and [submit pull requests](https://github.com/ankane/reversed/pulls)
36
+ - Write, clarify, or fix documentation
37
+ - Suggest or add new features
38
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
data/lib/reversed.rb ADDED
@@ -0,0 +1,20 @@
1
+ require "reversed/version"
2
+ require "net/dns"
3
+ require "public_suffix"
4
+
5
+ module Reversed
6
+ def self.lookup(ip)
7
+ ip = ip.to_s
8
+ unless ip.empty?
9
+ resolver = Net::DNS::Resolver.new(nameservers: ["8.8.8.8", "8.8.4.4"], retry: 3).search(ip)
10
+ answer = resolver.answer.first || resolver.authority.first
11
+ if answer
12
+ hostname = answer.value.split(" ").first[0..-2]
13
+ {
14
+ domain: PublicSuffix.domain(hostname, ignore_private: true),
15
+ hostname: hostname
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Reversed
2
+ VERSION = "0.1.0"
3
+ end
data/reversed.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "reversed/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "reversed"
7
+ spec.version = Reversed::VERSION
8
+ spec.authors = ["Andrew Kane"]
9
+ spec.email = ["andrew@chartkick.com"]
10
+
11
+ spec.summary = "Reverse DNS / IP Lookup for Ruby"
12
+ spec.homepage = "https://github.com/ankane/reversed"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.bindir = "exe"
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "net-dns"
20
+ spec.add_dependency "public_suffix"
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
25
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reversed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kane
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-dns
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: public_suffix
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
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - andrew@chartkick.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CHANGELOG.md
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - lib/reversed.rb
96
+ - lib/reversed/version.rb
97
+ - reversed.gemspec
98
+ homepage: https://github.com/ankane/reversed
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.5.1
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Reverse DNS / IP Lookup for Ruby
121
+ test_files: []