specinfra 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d32927ff79287a07faec63345c70dd4996627b8c
4
- data.tar.gz: e6a138505994cd813599d380d8c5b665fbc33b0a
3
+ metadata.gz: 36a703933ea44bd71de0b88b0932315f8e5ec819
4
+ data.tar.gz: 8d6c7246f7598d31516cf86e000bc968f341b5d5
5
5
  SHA512:
6
- metadata.gz: 7344c9b16ec7731961271b5e4299dff63f67d8467d62474bfa88b1055f9c43bd00b0fc63544f7f3bd0a36f884e349fe7cf61c28470d85950b345c312d2af6168
7
- data.tar.gz: f7cdbe6fd68be9fd20cb29ab6dd65dcca9b32dddf54032e9a957c95f49b206d8b1db6302c2148972f164e2c222e7bf6eb83cea1facb952eb1d68bf7a73887437
6
+ metadata.gz: 941ef8ee1a35f4395ca16b0cee9152a078b31dfd3c178cffcb93b004b2eb872888efc2f83fce78afa0cc92fb6143aefb7998dbbdea71424f2178579818234796
7
+ data.tar.gz: 89e1728fe2ce6418282f441032a557505114088597ce1353dc45fd2ee158de140683590aa649850a4abaf385a44be473604e601936a4078edc3fc322a7aa81d9
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.3
6
+ - 2.0.0
7
+
8
+ before_install:
9
+ - gem update bundler
10
+
11
+ script:
12
+ - bundle exec rake spec
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: 2.0.0
17
+
@@ -33,7 +33,7 @@ module SpecInfra
33
33
  end
34
34
 
35
35
  def build_command(cmd)
36
- path = SpecInfra.configuration.path || RSpec.configuration.path
36
+ path = SpecInfra.configuration.path
37
37
  if path
38
38
  cmd = "env PATH=#{path}:$PATH #{cmd}"
39
39
  cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1env PATH=#{path}:$PATH ")
@@ -43,7 +43,7 @@ module SpecInfra
43
43
  end
44
44
 
45
45
  def add_pre_command(cmd)
46
- path = SpecInfra.configuration.path || RSpec.configuration.path
46
+ path = SpecInfra.configuration.path
47
47
  if SpecInfra.configuration.pre_command
48
48
  cmd = "#{SpecInfra.configuration.pre_command} && #{cmd}"
49
49
  cmd = "env PATH=#{path}:$PATH #{cmd}" if path
@@ -178,7 +178,7 @@ module SpecInfra
178
178
  end
179
179
 
180
180
  def check_os
181
- return RSpec.configuration.os if RSpec.configuration.os
181
+ return SpecInfra.configuration.os if SpecInfra.configuration.os
182
182
  if run_command('ls /etc/redhat-release')[:exit_status] == 0
183
183
  line = run_command('cat /etc/redhat-release')[:stdout]
184
184
  if line =~ /release (\d[\d.]*)/
@@ -5,7 +5,7 @@ module SpecInfra
5
5
  module PowerShell
6
6
  module ScriptHelper
7
7
  def build_command(cmd)
8
- path = SpecInfra.configuration.path || RSpec.configuration.path
8
+ path = SpecInfra.configuration.path
9
9
  if path
10
10
  cmd.strip!
11
11
  cmd =
@@ -18,7 +18,7 @@ EOF
18
18
  end
19
19
 
20
20
  def add_pre_command(cmd)
21
- path = SpecInfra.configuration.path || RSpec.configuration.path
21
+ path = SpecInfra.configuration.path
22
22
  if SpecInfra.configuration.pre_command
23
23
  cmd.strip!
24
24
  cmd =
@@ -20,7 +20,7 @@ module SpecInfra
20
20
 
21
21
  def build_command(cmd)
22
22
  cmd = super(cmd)
23
- if RSpec.configuration.ssh.options[:user] != 'root'
23
+ if SpecInfra.configuration.ssh.options[:user] != 'root'
24
24
  cmd = "#{sudo} #{cmd}"
25
25
  cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1#{sudo} ")
26
26
  cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1#{sudo} ")
@@ -30,7 +30,7 @@ module SpecInfra
30
30
 
31
31
  def add_pre_command(cmd)
32
32
  cmd = super(cmd)
33
- user = RSpec.configuration.ssh.options[:user]
33
+ user = SpecInfra.configuration.ssh.options[:user]
34
34
  pre_command = SpecInfra.configuration.pre_command
35
35
  if pre_command && user != 'root'
36
36
  cmd = "#{sudo} #{cmd}"
@@ -44,9 +44,9 @@ module SpecInfra
44
44
  stderr_data = ''
45
45
  exit_status = nil
46
46
  exit_signal = nil
47
- pass_prompt = RSpec.configuration.pass_prompt || /^\[sudo\] password for/
47
+ pass_prompt = SpecInfra.configuration.pass_prompt || /^\[sudo\] password for/
48
48
 
49
- ssh = RSpec.configuration.ssh
49
+ ssh = SpecInfra.configuration.ssh
50
50
  ssh.open_channel do |channel|
51
51
  channel.request_pty do |ch, success|
52
52
  abort "Could not obtain pty " if !success
@@ -55,8 +55,8 @@ module SpecInfra
55
55
  abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
56
56
  channel.on_data do |ch, data|
57
57
  if data.match pass_prompt
58
- abort "Please set sudo password by using SUDO_PASSWORD or ASK_SUDO_PASSWORD environment variable" if RSpec.configuration.sudo_password.nil?
59
- channel.send_data "#{RSpec.configuration.sudo_password}\n"
58
+ abort "Please set sudo password by using SUDO_PASSWORD or ASK_SUDO_PASSWORD environment variable" if SpecInfra.configuration.sudo_password.nil?
59
+ channel.send_data "#{SpecInfra.configuration.sudo_password}\n"
60
60
  else
61
61
  stdout_data += data
62
62
  end
@@ -80,7 +80,7 @@ module SpecInfra
80
80
  end
81
81
 
82
82
  def sudo
83
- sudo_path = SpecInfra.configuration.sudo_path || RSpec.configuration.sudo_path
83
+ sudo_path = SpecInfra.configuration.sudo_path
84
84
  if sudo_path
85
85
  "#{sudo_path}/sudo"
86
86
  else
@@ -5,7 +5,7 @@ module SpecInfra
5
5
 
6
6
  def run_command(cmd, opts={})
7
7
  script = create_script(cmd)
8
- winrm = RSpec.configuration.winrm
8
+ winrm = SpecInfra.configuration.winrm
9
9
 
10
10
  result = winrm.powershell(script)
11
11
  stdout, stderr = [:stdout, :stderr].map do |s|
@@ -2,11 +2,25 @@ module SpecInfra
2
2
  module Configuration
3
3
  class << self
4
4
  VALID_OPTIONS_KEYS = [:path, :pre_command, :stdout, :stderr, :sudo_path, :pass_prompt].freeze
5
- attr_accessor(*VALID_OPTIONS_KEYS)
6
-
5
+
7
6
  def defaults
8
7
  VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
9
8
  end
9
+
10
+ def method_missing(meth, val=nil)
11
+ key = meth.to_s
12
+ key.gsub!(/=$/, '')
13
+ if val
14
+ instance_variable_set("@#{key}", val)
15
+ RSpec.configuration.send(:"#{key}=", val) if defined?(RSpec)
16
+ end
17
+
18
+ ret = instance_variable_get("@#{key}")
19
+ if ret.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(key)
20
+ ret = RSpec.configuration.send(key)
21
+ end
22
+ ret
23
+ end
10
24
  end
11
25
  end
12
26
  end
@@ -27,9 +27,12 @@ module SpecInfra
27
27
  # end
28
28
  def build_configurations
29
29
  SpecInfra::Configuration.defaults.keys.each do |c|
30
- value = self.respond_to?(c.to_sym) ?
31
- self.send(c) : RSpec.configuration.send(c)
32
- SpecInfra::Configuration.send(:"#{c}=", value)
30
+ if self.respond_to?(c.to_sym)
31
+ value = self.send(c)
32
+ else
33
+ value = RSpec.configuration.send(c) if defined?(RSpec)
34
+ end
35
+ SpecInfra::Configuration.instance_variable_set("@#{c}", value)
33
36
  end
34
37
  end
35
38
  end
@@ -3,7 +3,7 @@ module SpecInfra
3
3
  module DetectOS
4
4
  def commands
5
5
  property[:os_by_host] = {} if ! property[:os_by_host]
6
- host = RSpec.configuration.ssh ? RSpec.configuration.ssh.host : 'localhost'
6
+ host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
7
7
 
8
8
  if property[:os_by_host][host]
9
9
  os = property[:os_by_host][host]
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/specinfra.rb CHANGED
@@ -13,15 +13,17 @@ module SpecInfra
13
13
  end
14
14
  end
15
15
 
16
- RSpec.configure do |c|
17
- c.include(SpecInfra::Helper::Configuration)
18
- c.add_setting :os, :default => nil
19
- c.add_setting :host, :default => nil
20
- c.add_setting :ssh, :default => nil
21
- c.add_setting :sudo_password, :default => nil
22
- c.add_setting :winrm, :default => nil
23
- SpecInfra.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
24
- c.before :each do
25
- backend.set_example(example) if defined?(SPEC_TYPE)
16
+ if defined?(RSpec)
17
+ RSpec.configure do |c|
18
+ c.include(SpecInfra::Helper::Configuration)
19
+ c.add_setting :os, :default => nil
20
+ c.add_setting :host, :default => nil
21
+ c.add_setting :ssh, :default => nil
22
+ c.add_setting :sudo_password, :default => nil
23
+ c.add_setting :winrm, :default => nil
24
+ SpecInfra.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
25
+ c.before :each do
26
+ backend.set_example(example) if defined?(SPEC_TYPE)
27
+ end
26
28
  end
27
29
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.configure do |c|
4
+ c.path = 'foo'
5
+ end
6
+
7
+ describe RSpec.configuration.path do
8
+ it { should eq SpecInfra.configuration.path }
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-30 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
+ - .travis.yml
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md
@@ -77,6 +78,7 @@ files:
77
78
  - lib/specinfra/helper/properties.rb
78
79
  - lib/specinfra/properties.rb
79
80
  - lib/specinfra/version.rb
81
+ - spec/configurtaion_spec.rb
80
82
  - spec/helpers/properties_spec.rb
81
83
  - spec/spec_helper.rb
82
84
  - specinfra.gemspec
@@ -105,5 +107,6 @@ signing_key:
105
107
  specification_version: 4
106
108
  summary: Common layer for serverspec and configspec
107
109
  test_files:
110
+ - spec/configurtaion_spec.rb
108
111
  - spec/helpers/properties_spec.rb
109
112
  - spec/spec_helper.rb