host_range 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +65 -6
- data/VERSION +1 -1
- data/examples/hr.yaml +6 -0
- data/host_range.gemspec +61 -0
- data/test/helper.rb +4 -4
- data/test/test_host_range.rb +6 -6
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -7,18 +7,77 @@ Make lists of hosts using ranges like:
|
|
7
7
|
|
8
8
|
== Library Usage
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
Get an array of hostname from a range:
|
11
|
+
|
12
|
+
require 'host_range'
|
13
|
+
HostRange.parse 'foo-[01-03].domain.com'
|
14
|
+
=> ["foo-01.domain.com", "foo-02.domain.com", "foo-03.domain.com"]
|
15
|
+
|
16
|
+
== Patterns
|
17
|
+
|
18
|
+
Ranges are parsed using the ruby '..' operator:
|
19
|
+
|
20
|
+
HostRange.parse 'foo-[a-c]'
|
21
|
+
=> ["foo-a", "foo-b", "foo-c"]
|
22
|
+
|
23
|
+
Multiple atoms and ranges may be separated by commas:
|
24
|
+
|
25
|
+
HostRange.parse 'foo-[1,3-5,9]'
|
26
|
+
=> ["foo-1", "foo-3", "foo-4", "foo-5", "foo-9"]
|
27
|
+
|
28
|
+
With no commas or range operators ('-'), atoms are parsed as single
|
29
|
+
characters:
|
30
|
+
|
31
|
+
HostRange.parse 'foo-[123]'
|
32
|
+
=> ["foo-1", "foo-2", "foo-3"]
|
33
|
+
|
34
|
+
Combined:
|
35
|
+
|
36
|
+
HostRange.parse 'foo-[ab][01-02]'
|
37
|
+
=> ["foo-a01", "foo-a02", "foo-b01", "foo-b02"]
|
12
38
|
|
13
39
|
== Command-line Usage
|
14
40
|
|
15
41
|
Commandline tool lists hosts, or execs commands on them in a loop:
|
16
42
|
|
17
|
-
|
18
|
-
|
19
|
-
|
43
|
+
Get help:
|
44
|
+
|
45
|
+
$ hr -h
|
46
|
+
|
47
|
+
List some hosts:
|
48
|
+
|
49
|
+
$ hr foo-[01-03].domain.com
|
50
|
+
foo-01.domain.com
|
51
|
+
foo-02.domain.com
|
52
|
+
foo-03.domain.com
|
53
|
+
|
54
|
+
Get some IP addresses:
|
55
|
+
|
56
|
+
$ hr foo-[01-03].domain.com -e host
|
57
|
+
foo-01.domain.com has address 172.16.0.1
|
58
|
+
foo-02.domain.com has address 172.16.0.2
|
59
|
+
foo-03.domain.com has address 172.16.0.3
|
60
|
+
|
61
|
+
Run a command, '{}' is replaced with each hostname:
|
62
|
+
|
63
|
+
$ hr foo-[01-03].domain.com -e ssh root@{} uptime
|
64
|
+
|
65
|
+
You can provide a config file (~/.hr.yaml) with predefined patterns with
|
66
|
+
project names:
|
67
|
+
|
68
|
+
web:
|
69
|
+
- webfe-[ab][01-05].newco.com
|
70
|
+
- webfe-c[20-23,27-29].newco.com
|
71
|
+
dev:
|
72
|
+
- dev-[web,db]-[01-02].newco.com
|
73
|
+
|
74
|
+
and then call project by name:
|
20
75
|
|
21
|
-
|
76
|
+
$ hosts dev
|
77
|
+
dev-web-01.newco.com
|
78
|
+
dev-web-02.newco.com
|
79
|
+
dev-db-01.newco.com
|
80
|
+
dev-db-02.newco.com
|
22
81
|
|
23
82
|
== Copyright
|
24
83
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/examples/hr.yaml
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## example config file for the host_range 'hr' command-line tool
|
2
|
+
## install as ~/.hr.yaml
|
3
|
+
##
|
4
|
+
## list pre-defined host patterns for your various projects, then invoke them
|
5
|
+
## by the given name, e.g.:
|
6
|
+
## hr web -e ssh root@{} service httpd restart
|
1
7
|
web:
|
2
8
|
- webfe-[ab][01-05].newco.com
|
3
9
|
- webfe-c[20-23,27-29].newco.com
|
data/host_range.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{host_range}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Richard Lister}]
|
12
|
+
s.date = %q{2011-09-15}
|
13
|
+
s.description = %q{Allows specification of hostname ranges such as foo-[01-09].}
|
14
|
+
s.email = %q{rlister+gh@gmail.com}
|
15
|
+
s.executables = [%q{hr}]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/hr",
|
28
|
+
"examples/hr.yaml",
|
29
|
+
"host_range.gemspec",
|
30
|
+
"lib/host_range.rb",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_host_range.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/rlister/host_range}
|
35
|
+
s.licenses = [%q{MIT}]
|
36
|
+
s.require_paths = [%q{lib}]
|
37
|
+
s.rubygems_version = %q{1.8.5}
|
38
|
+
s.summary = %q{Convert hostname range pattern into array of hostnames.}
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
46
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
47
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
50
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/test/helper.rb
CHANGED
@@ -7,12 +7,12 @@ rescue Bundler::BundlerError => e
|
|
7
7
|
$stderr.puts "Run `bundle install` to install missing gems"
|
8
8
|
exit e.status_code
|
9
9
|
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
10
|
+
# require 'test/unit'
|
11
|
+
# require 'shoulda'
|
12
12
|
|
13
13
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
14
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
15
|
require 'host_range'
|
16
16
|
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
17
|
+
# class Test::Unit::TestCase
|
18
|
+
# end
|
data/test/test_host_range.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'helper'
|
1
|
+
# require 'helper'
|
2
2
|
|
3
|
-
class TestHostRange < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
# class TestHostRange < Test::Unit::TestCase
|
4
|
+
# should "probably rename this file and start testing for real" do
|
5
|
+
# flunk "hey buddy, you should probably rename this file and start testing for real"
|
6
|
+
# end
|
7
|
+
# end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: host_range
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Richard Lister
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- VERSION
|
75
75
|
- bin/hr
|
76
76
|
- examples/hr.yaml
|
77
|
+
- host_range.gemspec
|
77
78
|
- lib/host_range.rb
|
78
79
|
- test/helper.rb
|
79
80
|
- test/test_host_range.rb
|
@@ -90,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
91
|
requirements:
|
91
92
|
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
94
|
+
hash: 1347353560576965439
|
94
95
|
segments:
|
95
96
|
- 0
|
96
97
|
version: "0"
|