simonmenke-hosts 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/hosts +15 -1
- data/config/hoe.rb +7 -6
- data/lib/hosts.rb +7 -3
- data/lib/hosts/version.rb +1 -1
- metadata +22 -5
data/bin/hosts
CHANGED
@@ -23,6 +23,10 @@ class HostsCLI < Thor
|
|
23
23
|
desc "add HOSTNAME [ADDRESS]", "Add a hostname"
|
24
24
|
def add(hostname, address="127.0.0.1")
|
25
25
|
Hosts.read
|
26
|
+
if Hosts.exists?(hostname, address)
|
27
|
+
puts "There already is an entry for this hostname and address!"
|
28
|
+
exit(0)
|
29
|
+
end
|
26
30
|
if Hosts.editable?(hostname, address)
|
27
31
|
Hosts.add(hostname, address)
|
28
32
|
Hosts.write
|
@@ -33,8 +37,18 @@ class HostsCLI < Thor
|
|
33
37
|
end
|
34
38
|
|
35
39
|
desc "remove HOSTNAME [ADDRESS]", "Remove a hostname"
|
36
|
-
def remove(hostname, address=
|
40
|
+
def remove(hostname, address=nil)
|
37
41
|
Hosts.read
|
42
|
+
if Hosts.hostname(hostname).size > 1 and address.nil?
|
43
|
+
puts "Please specify an address!"
|
44
|
+
list(hostname)
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
address ||= "127.0.0.1"
|
48
|
+
unless Hosts.exists?(hostname, address)
|
49
|
+
puts "There is no entry for this hostname and address!"
|
50
|
+
exit(0)
|
51
|
+
end
|
38
52
|
if Hosts.editable?(hostname, address)
|
39
53
|
Hosts.remove(hostname, address)
|
40
54
|
Hosts.write
|
data/config/hoe.rb
CHANGED
@@ -5,10 +5,11 @@ EMAIL = "simon@5xm.org"
|
|
5
5
|
DESCRIPTION = "A simple tool to manage your hosts file"
|
6
6
|
GEM_NAME = 'hosts' # what ppl will type to install your gem
|
7
7
|
RUBYFORGE_PROJECT = 'hosts' # The unix name for your project
|
8
|
-
HOMEPATH = "http
|
9
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
8
|
+
HOMEPATH = "http://github.com/simonmenke/hosts/tree/master"
|
9
|
+
# DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
10
|
EXTRA_DEPENDENCIES = [
|
11
|
-
['thor', '>= 0.9.2']
|
11
|
+
['thor', '>= 0.9.2'],
|
12
|
+
['need', '>= 1.1.0']
|
12
13
|
# ['activesupport', '>= 1.3.1']
|
13
14
|
] # An array of rubygem dependencies [name, version]
|
14
15
|
|
@@ -56,13 +57,13 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
56
57
|
p.description = DESCRIPTION
|
57
58
|
p.summary = DESCRIPTION
|
58
59
|
p.url = HOMEPATH
|
59
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
60
|
+
p.rubyforge_name = nil #RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
60
61
|
p.test_globs = ["test/**/test_*.rb"]
|
61
62
|
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
62
|
-
|
63
|
+
|
63
64
|
# == Optional
|
64
65
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
65
|
-
|
66
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
66
67
|
|
67
68
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
68
69
|
end
|
data/lib/hosts.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "need"
|
2
|
+
require "hosts/version"
|
3
3
|
|
4
4
|
module Hosts
|
5
5
|
|
@@ -44,8 +44,12 @@ module Hosts
|
|
44
44
|
addresses[address] ||= {}
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.exists?(hostname, address)
|
48
|
+
hostname(hostname) != nil and hostname(hostname)[address] != nil
|
49
|
+
end
|
50
|
+
|
47
51
|
def self.editable?(hostname, address)
|
48
|
-
return true
|
52
|
+
return true unless exists?(hostname, address)
|
49
53
|
return hostname(hostname)[address]
|
50
54
|
end
|
51
55
|
|
data/lib/hosts/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonmenke-hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -11,8 +11,25 @@ cert_chain: []
|
|
11
11
|
|
12
12
|
date: 2008-05-26 00:00:00 -07:00
|
13
13
|
default_executable: hosts
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thor
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.2
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: need
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.1.0
|
32
|
+
version:
|
16
33
|
description: A simple tool to manage your hosts file
|
17
34
|
email:
|
18
35
|
- simon@5xm.org
|
@@ -55,7 +72,7 @@ files:
|
|
55
72
|
- website/stylesheets/screen.css
|
56
73
|
- website/template.html.erb
|
57
74
|
has_rdoc: true
|
58
|
-
homepage: http://hosts
|
75
|
+
homepage: http://github.com/simonmenke/hosts/tree/master
|
59
76
|
post_install_message: ""
|
60
77
|
rdoc_options:
|
61
78
|
- --main
|
@@ -76,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
93
|
version:
|
77
94
|
requirements: []
|
78
95
|
|
79
|
-
rubyforge_project:
|
96
|
+
rubyforge_project:
|
80
97
|
rubygems_version: 1.0.1
|
81
98
|
signing_key:
|
82
99
|
specification_version: 2
|