shiv 0.1.0

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'chef'
4
+
5
+ group :development do
6
+ gem "shoulda", ">= 0"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.6.4"
9
+ gem "rcov", ">= 0"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bunny (0.7.3)
5
+ chef (0.10.2)
6
+ bunny (>= 0.6.0)
7
+ erubis
8
+ highline
9
+ json (<= 1.5.2, >= 1.4.4)
10
+ mixlib-authentication (>= 1.1.0)
11
+ mixlib-cli (>= 1.1.0)
12
+ mixlib-config (>= 1.1.2)
13
+ mixlib-log (>= 1.3.0)
14
+ moneta
15
+ net-ssh (~> 2.1.3)
16
+ net-ssh-multi (~> 1.0.1)
17
+ ohai (>= 0.6.0)
18
+ rest-client (< 1.7.0, >= 1.0.4)
19
+ treetop (~> 1.4.9)
20
+ uuidtools
21
+ erubis (2.7.0)
22
+ git (1.2.5)
23
+ highline (1.6.2)
24
+ jeweler (1.6.4)
25
+ bundler (~> 1.0)
26
+ git (>= 1.2.5)
27
+ rake
28
+ json (1.5.2)
29
+ mime-types (1.16)
30
+ mixlib-authentication (1.1.4)
31
+ mixlib-log
32
+ mixlib-cli (1.2.0)
33
+ mixlib-config (1.1.2)
34
+ mixlib-log (1.3.0)
35
+ moneta (0.6.0)
36
+ net-ssh (2.1.4)
37
+ net-ssh-gateway (1.1.0)
38
+ net-ssh (>= 1.99.1)
39
+ net-ssh-multi (1.0.1)
40
+ net-ssh (>= 1.99.2)
41
+ net-ssh-gateway (>= 0.99.0)
42
+ ohai (0.6.4)
43
+ mixlib-cli
44
+ mixlib-config
45
+ mixlib-log
46
+ systemu
47
+ yajl-ruby
48
+ polyglot (0.3.2)
49
+ rake (0.9.2)
50
+ rcov (0.9.10)
51
+ rest-client (1.6.3)
52
+ mime-types (>= 1.16)
53
+ shoulda (2.11.3)
54
+ systemu (2.2.0)
55
+ treetop (1.4.10)
56
+ polyglot
57
+ polyglot (>= 0.3.1)
58
+ uuidtools (2.1.2)
59
+ yajl-ruby (0.8.2)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ bundler (~> 1.0.0)
66
+ chef
67
+ jeweler (~> 1.6.4)
68
+ rcov
69
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 vanstee
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ Shiv
2
+ ====
3
+
4
+ Shiv is a quick and dirty hack to use chef node names in place of their hostnames.
5
+
6
+ Examples
7
+ --------
8
+
9
+ Need to ssh to a specific server? Normally you would probably do something like this:
10
+
11
+ ```
12
+ $ knife node show node-name -a ec2.public_hostname
13
+ ec2.public_hostname: ec2-hostname.compute-1.amazonaws.com
14
+
15
+ $ ssh ubuntu@ec2-hostname.compute-1.amazonaws.com
16
+ ```
17
+
18
+ Try this instead:
19
+
20
+ ```
21
+ $ shiv ssh ubuntu@node-name
22
+ ```
23
+
24
+ Works with any other command too:
25
+
26
+ ```
27
+ $ shiv scp ubuntu@node-name:/file .
28
+ ```
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "shiv"
18
+ gem.homepage = "http://github.com/vanstee/shiv"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Shiv is a quick and dirty hack to use chef node names in place of their hostnames.}
21
+ gem.description = %Q{Shiv is a quick and dirty hack to use chef node names in place of their hostnames.}
22
+ gem.email = "vanstee@highgroove.com"
23
+ gem.authors = ["vanstee"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "shiv #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/shiv ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'shiv'
5
+
6
+ command = ARGV.join(' ')
7
+ command = Shiv.edit(command)
8
+ exec(command)
data/lib/shiv.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'chef/node'
2
+ require 'chef/knife'
3
+ require 'chef/config'
4
+
5
+ module Shiv
6
+ def self.edit(command)
7
+ configure
8
+ nodes.each do |node|
9
+ command.gsub!(node, hostname_from(node)) if command.include? node
10
+ end
11
+ command
12
+ end
13
+
14
+ def self.nodes
15
+ Chef::Node.list.keys
16
+ end
17
+
18
+ def self.hostname_from(node)
19
+ Chef::Node.load(node)["ec2"]["public_hostname"]
20
+ end
21
+
22
+ def self.configure
23
+ Chef::Knife.new.configure_chef
24
+ end
25
+ end
26
+
27
+ class Chef
28
+ class Config
29
+ config_attr_writer :log_level do |l|
30
+ configure do |c|
31
+ c[:log_level] = :error
32
+ end
33
+ end
34
+ end
35
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'shiv'
16
+
17
+ class Test::Unit::TestCase
18
+ end
data/test/test_shiv.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestShiv < 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 ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shiv
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - vanstee
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :runtime
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ version_requirements: *id001
32
+ name: chef
33
+ prerelease: false
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ version_requirements: *id002
46
+ name: shoulda
47
+ prerelease: false
48
+ - !ruby/object:Gem::Dependency
49
+ type: :development
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ hash: 23
56
+ segments:
57
+ - 1
58
+ - 0
59
+ - 0
60
+ version: 1.0.0
61
+ version_requirements: *id003
62
+ name: bundler
63
+ prerelease: false
64
+ - !ruby/object:Gem::Dependency
65
+ type: :development
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ hash: 7
72
+ segments:
73
+ - 1
74
+ - 6
75
+ - 4
76
+ version: 1.6.4
77
+ version_requirements: *id004
78
+ name: jeweler
79
+ prerelease: false
80
+ - !ruby/object:Gem::Dependency
81
+ type: :development
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ version_requirements: *id005
92
+ name: rcov
93
+ prerelease: false
94
+ description: Shiv is a quick and dirty hack to use chef node names in place of their hostnames.
95
+ email: vanstee@highgroove.com
96
+ executables:
97
+ - shiv
98
+ extensions: []
99
+
100
+ extra_rdoc_files:
101
+ - LICENSE.txt
102
+ - README.md
103
+ files:
104
+ - .document
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - VERSION
111
+ - bin/shiv
112
+ - lib/shiv.rb
113
+ - test/helper.rb
114
+ - test/test_shiv.rb
115
+ homepage: http://github.com/vanstee/shiv
116
+ licenses:
117
+ - MIT
118
+ post_install_message:
119
+ rdoc_options: []
120
+
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ hash: 3
138
+ segments:
139
+ - 0
140
+ version: "0"
141
+ requirements: []
142
+
143
+ rubyforge_project:
144
+ rubygems_version: 1.8.6
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: Shiv is a quick and dirty hack to use chef node names in place of their hostnames.
148
+ test_files: []
149
+