chef-extensions 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use --create ree@chef-extensions
1
+ rvm use --create 1.8.7@chef-extensions
@@ -7,7 +7,6 @@ Gem::Specification.new do |s|
7
7
  s.version = Chef::Extensions::VERSION
8
8
  s.authors = ["Gerhard Lazu"]
9
9
  s.email = ["gerhard@lazu.co.uk"]
10
- s.homepage = "http://gchef.github.com/chef-extensions"
11
10
  s.summary = %q{Chef extensions, can be used stand-alone}
12
11
  s.description = %q{Commands useful for checking internet connectivity, VM presence etc.}
13
12
 
@@ -18,11 +17,10 @@ Gem::Specification.new do |s|
18
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
18
  s.require_paths = ["lib"]
20
19
 
21
- s.add_development_dependency "chef"
20
+ s.add_development_dependency 'chef'
22
21
  s.add_development_dependency 'guard-minitest'
23
22
  s.add_development_dependency 'minitest'
24
23
  s.add_development_dependency 'pry'
25
- s.add_development_dependency "rdiscount"
24
+ s.add_development_dependency 'rdiscount'
26
25
  s.add_development_dependency "rocco"
27
- s.add_development_dependency 'turn'
28
26
  end
@@ -1,7 +1,8 @@
1
+ require 'securerandom'
2
+
1
3
  require 'chef-extensions/version'
2
4
  require 'chef-extensions/ec2'
3
5
  require 'chef-extensions/ip'
4
- require 'securerandom'
5
6
 
6
7
  class Chef
7
8
  module Extensions
@@ -6,8 +6,14 @@ class Chef
6
6
  # **Get the instance ID from AWS's metadata service** <br />
7
7
  # If we don't hear back within 1 second, time out.
8
8
  def instance_id
9
- `curl --connect-timeout 1 http://169.254.169.254/2011-01-01/meta-data/instance-id 2>&1`.chomp
9
+ `curl --connect-timeout 1 #{aws_url} 2>&1`.chomp
10
10
  end
11
+
12
+ protected
13
+
14
+ def aws_url
15
+ "http://169.254.169.254/2011-01-01/meta-data/instance-id"
16
+ end
11
17
  end
12
18
  end
13
19
  end
@@ -11,7 +11,7 @@ class Chef
11
11
  # **Get all public IPv4 addresses** <br />
12
12
  # Some of them might be local to the host, but it's not easy to say which
13
13
  # is which without expensive queries and a complicated logic. <br />
14
- # It excludes localhost.
14
+ # This method excludes localhost.
15
15
  def public_ipv4
16
16
  local_ipv4 - localhost_ipv4
17
17
  end
@@ -27,7 +27,7 @@ class Chef
27
27
  end
28
28
 
29
29
  # **Runs ifconfig shell utility** <br />
30
- # Caching was not necessary, but it helps with tests.
30
+ # Caching was not necessary, but it helps when testing.
31
31
  def ifconfig
32
32
  @ifconfig ||= `ifconfig`
33
33
  end
@@ -45,7 +45,7 @@ class Chef
45
45
  end
46
46
  end
47
47
 
48
- # Linux's ifconfig returns a slightly different version that OS X
48
+ # Linux's ifconfig returns a slightly different version than OS X's.
49
49
  def linux_filter
50
50
  "#{awk} { print $4 }'"
51
51
  end
@@ -14,6 +14,30 @@ class Chef
14
14
  def linux?
15
15
  RUBY_PLATFORM.index('linux')
16
16
  end
17
+
18
+ # Returns true if architecture is 64bit!
19
+ #
20
+ def amd64?
21
+ !! architecture.index("x86_64")
22
+ end
23
+
24
+ # Returns true if architecture is 32bit!
25
+ #
26
+ def i386?
27
+ ! amd64?
28
+ end
29
+
30
+ # Package friendly architecture string
31
+ #
32
+ def arch
33
+ amd64? ? "amd64" : "i386"
34
+ end
35
+
36
+ # Retrieves and caches the architecture type
37
+ #
38
+ def architecture
39
+ @architecture ||= `uname -m`
40
+ end
17
41
  end
18
42
  end
19
43
  end
@@ -1,5 +1,5 @@
1
1
  class Chef
2
2
  module Extensions
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require 'chef-extensions/platform'
3
+
4
+ class Chef
5
+ module Extensions
6
+ describe Platform do
7
+ describe "32bit architectures" do
8
+ before do
9
+ Platform.instance_variable_set(:@architecture, "i686")
10
+ end
11
+
12
+ it "amd64?" do
13
+ Platform.amd64?.must_equal false
14
+ end
15
+
16
+ it "i386?" do
17
+ Platform.i386?.must_equal true
18
+ end
19
+
20
+ it "arch" do
21
+ Platform.arch.must_equal "i386"
22
+ end
23
+ end
24
+
25
+ describe "64bit architectures" do
26
+ before do
27
+ Platform.instance_variable_set(:@architecture, "x86_64")
28
+ end
29
+
30
+ it "amd64?" do
31
+ Platform.amd64?.must_equal true
32
+ end
33
+
34
+ it "i386?" do
35
+ Platform.i386?.must_equal false
36
+ end
37
+
38
+ it "arch" do
39
+ Platform.arch.must_equal "amd64"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,8 +2,7 @@ require 'rubygems'
2
2
  require 'bundler'
3
3
  Bundler.setup
4
4
 
5
- require 'turn/autorun'
6
- Turn.config.format = :pretty
5
+ require 'minitest/autorun'
7
6
 
8
7
  require 'pry'
9
8
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-extensions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerhard Lazu
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-16 00:00:00 Z
18
+ date: 2012-03-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: chef
@@ -101,20 +101,6 @@ dependencies:
101
101
  version: "0"
102
102
  type: :development
103
103
  version_requirements: *id006
104
- - !ruby/object:Gem::Dependency
105
- name: turn
106
- prerelease: false
107
- requirement: &id007 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
116
- type: :development
117
- version_requirements: *id007
118
104
  description: Commands useful for checking internet connectivity, VM presence etc.
119
105
  email:
120
106
  - gerhard@lazu.co.uk
@@ -140,10 +126,11 @@ files:
140
126
  - lib/chef-extensions/platform.rb
141
127
  - lib/chef-extensions/version.rb
142
128
  - test/chef-extensions/ip_test.rb
129
+ - test/chef-extensions/platform_test.rb
143
130
  - test/fixtures/osx.ifconfig
144
131
  - test/fixtures/ubuntu.ifconfig
145
132
  - test/test_helper.rb
146
- homepage: http://gchef.github.com/chef-extensions
133
+ homepage:
147
134
  licenses: []
148
135
 
149
136
  post_install_message:
@@ -172,12 +159,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
159
  requirements: []
173
160
 
174
161
  rubyforge_project: chef-extensions
175
- rubygems_version: 1.8.10
162
+ rubygems_version: 1.8.17
176
163
  signing_key:
177
164
  specification_version: 3
178
165
  summary: Chef extensions, can be used stand-alone
179
166
  test_files:
180
167
  - test/chef-extensions/ip_test.rb
168
+ - test/chef-extensions/platform_test.rb
181
169
  - test/fixtures/osx.ifconfig
182
170
  - test/fixtures/ubuntu.ifconfig
183
171
  - test/test_helper.rb