ghost 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -46,12 +46,21 @@ Command
46
46
  Listing 1 host(s):
47
47
  staging-server.local -> 64.233.167.99
48
48
 
49
+ $ ghost export > some_file
50
+
49
51
  $ ghost empty
50
52
  [Emptying] Done.
51
53
 
52
54
  $ ghost list
53
55
  Listing 0 host(s):
54
56
 
57
+ $ ghost import some_file
58
+ [Adding] staging-server.local -> 64.233.167.99
59
+
60
+ $ ghost list
61
+ Listing 1 host(s):
62
+ staging-server.local -> 64.233.167.99
63
+
55
64
  Library
56
65
  -------
57
66
 
@@ -69,6 +78,7 @@ Contributors
69
78
 
70
79
  * [Bodaniel Jeanes](http://github.com/bjeanes)
71
80
  * [Mitchell V Riley](http://github.com/mitchellvriley)
81
+ * [Courtois Simon](http://github.com/simonc)
72
82
 
73
83
  Legal Stuff
74
84
  ===========
data/bin/ghost CHANGED
@@ -17,6 +17,8 @@ def help_text(exit_code = 0)
17
17
  #{script_name} delete <hostname>
18
18
  #{script_name} list
19
19
  #{script_name} empty
20
+ #{script_name} export
21
+ #{script_name} import <file>
20
22
  """
21
23
  exit(exit_code)
22
24
  end
@@ -25,7 +27,7 @@ if ARGV.size.zero? || ['-h', '--help', 'help'].include?(ARGV.first)
25
27
  help_text
26
28
  else
27
29
  case ARGV[0]
28
- when 'add':
30
+ when 'add'
29
31
  if [2,3].include?(ARGV.size)
30
32
  begin
31
33
  ARGV.shift
@@ -40,7 +42,7 @@ else
40
42
  $stderr.puts "The add subcommand requires at least a hostname.\n\n"
41
43
  help_text 2
42
44
  end
43
- when 'modify':
45
+ when 'modify'
44
46
  if ARGV.size == 3
45
47
  ARGV.shift
46
48
  ARGV << true
@@ -51,7 +53,7 @@ else
51
53
  $stderr.puts "The modify subcommand requires a hostname and an IP.\n\n"
52
54
  help_text 4
53
55
  end
54
- when 'delete', 'del', 'remove', 'rm':
56
+ when 'delete', 'del', 'remove', 'rm'
55
57
  if ARGV.size == 2
56
58
  Host.delete(ARGV[1])
57
59
  puts " [Deleting] #{ARGV[1]}"
@@ -60,7 +62,7 @@ else
60
62
  $stderr.puts "The delete subcommand requires a hostname.\n\n"
61
63
  help_text 2
62
64
  end
63
- when 'list':
65
+ when 'list'
64
66
  hosts = Host.list
65
67
  pad = hosts.max{|a,b| a.to_s.length <=> b.to_s.length }.to_s.length
66
68
 
@@ -70,11 +72,34 @@ else
70
72
  puts "#{host.name.rjust(pad+2)} -> #{host.ip}"
71
73
  end
72
74
  exit 0
73
- when 'empty':
75
+ when 'empty'
74
76
  print " [Emptying] "
75
77
  Host.empty!
76
78
  puts "Done."
77
79
  exit 0
80
+ when 'export':
81
+ hosts = Host.list
82
+ hosts.each do |host|
83
+ puts "#{host.name} #{host.ip}"
84
+ end
85
+ exit 0
86
+ when 'import':
87
+ if ARGV.size == 2
88
+ begin
89
+ File.foreach(ARGV[1]) do |line|
90
+ host_infos = line.strip.split(' ', 2)
91
+ host = Host.add(*host_infos)
92
+ puts " [Adding] #{host.name} -> #{host.ip}"
93
+ end
94
+ exit 0
95
+ rescue
96
+ $stderr.puts "Cannot import. A problem occured while opening the import file."
97
+ exit 5
98
+ end
99
+ else
100
+ $stderr.puts "The import command requires an input file.\n\n"
101
+ help_text 6
102
+ end
78
103
  else
79
104
  $stderr.puts "Invalid option: #{ARGV[0]}"
80
105
  help_text 1
@@ -9,6 +9,7 @@ class Host
9
9
 
10
10
  def list
11
11
  list = `#{ListCmd}`
12
+ list = list.split("\n")
12
13
  list.collect { |host| Host.new(host.chomp) }
13
14
  end
14
15
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  $TESTING=true
2
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'rubygems'
4
+ require 'spec'
3
5
  require 'ghost'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodaniel Jeanes
@@ -9,11 +9,11 @@ autorequire: ghost
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-15 00:00:00 +10:00
12
+ date: 2009-08-30 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Allows you to create, list, and modify local hostnames with ease
16
+ description: Allows you to create, list, and modify .local hostnames in 10.5 with ease
17
17
  email: me@bjeanes.com
18
18
  executables:
19
19
  - ghost
@@ -59,9 +59,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  requirements: []
60
60
 
61
61
  rubyforge_project: ghost
62
- rubygems_version: 1.3.4
62
+ rubygems_version: 1.3.5
63
63
  signing_key:
64
64
  specification_version: 3
65
- summary: Allows you to create, list, and modify local hostnames with ease
65
+ summary: Allows you to create, list, and modify .local hostnames in 10.5 with ease
66
66
  test_files: []
67
67