reverse 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -10
  3. data/lib/reverse.rb +20 -12
  4. data/lib/reverse/version.rb +1 -1
  5. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f5f74b0916109e0355a5ae9028b2b2c90836bec
4
- data.tar.gz: 20d4d392003cf215113677491725cc173bb7de8b
3
+ metadata.gz: d4aaeca93b8dc60ada1a354e9f859d663b0f4068
4
+ data.tar.gz: c9c63f5ee17c81b752219ba0907449349a15ac7e
5
5
  SHA512:
6
- metadata.gz: 0640b89cd424ee99bcc2ccfe59b0ba469882fa0d92c6715f1e78461d3af66fd1d6e88fbec69d06683d58dd48d1e87da3fb28608ab6d403ca8684921c5f36e0c7
7
- data.tar.gz: 4082911693f12174f0f7c69ae78ed9e5dd8f7d1501a8c0c1442719ff4a0dbee8a31fe4f5db883f056f97ea4b7c062c64f31e2b122637e37eed49c76645b202d6
6
+ metadata.gz: 450c244f6da36ef92f6fb66b67f0b6cd8b008b6c400982d6ad1adf9cd5eabbdad0b3aef82858285788e068ebfaeccb898c2d536776b8742d0648fba3dd8d7023
7
+ data.tar.gz: bcb8f3a9c5df489402309699e6ed0600d8aca911bfbcc8b4571b3b185b5ae0f7617e4b08a00f52cd673ecce2ae0295a2756928dabe06de2dc24bee7d4c53f2e1
data/README.md CHANGED
@@ -4,16 +4,6 @@ reverse DNS lookup CLU for standard output
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'reverse'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
7
  $ gem install reverse
18
8
 
19
9
  ## Usage
data/lib/reverse.rb CHANGED
@@ -7,28 +7,36 @@ class Reverse
7
7
 
8
8
  def initialize
9
9
  @list = {}
10
+ Signal.trap(:INT){ exit(0) }
10
11
  end
11
12
 
12
13
  def exec
13
14
  while line = gets
14
- if line =~ ADDR_REG_EXP
15
- res = line.gsub(ADDR_REG_EXP) do |addr|
16
- name = nil
17
- if @list[addr]
18
- name = @list[addr]
19
- else
20
- name = get_name(addr)
21
- @list[addr] = name
22
- end
23
- name
15
+ output =
16
+ if line =~ ADDR_REG_EXP
17
+ replace_addr(line)
18
+ else
19
+ line
24
20
  end
25
- print res
26
- end
21
+ print output
27
22
  end
28
23
  end
29
24
 
30
25
  private
31
26
 
27
+ def replace_addr(line)
28
+ line.gsub(ADDR_REG_EXP) do |addr|
29
+ name = nil
30
+ if @list[addr]
31
+ name = @list[addr]
32
+ else
33
+ name = get_name(addr)
34
+ @list[addr] = name
35
+ end
36
+ name
37
+ end
38
+ end
39
+
32
40
  def get_name(addr)
33
41
  info = Socket.getnameinfo(Socket.sockaddr_in('80', addr))
34
42
  info[0]
@@ -1,3 +1,3 @@
1
1
  class Reverse
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse
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
  - Hitoshi Kurokawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2014-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: reverse DNS lookup CLU for standard output
@@ -46,7 +46,7 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - LICENSE.txt
52
52
  - README.md
@@ -65,17 +65,17 @@ require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.0.14
78
+ rubygems_version: 2.2.0
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: reverse DNS lookup CLU for standard output