hem 1.0.1.beta5 → 1.0.1.beta6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50ba9467abdcbc5240b09e934016f1195be6c165
4
- data.tar.gz: ec8fcd39f9172bb05e5a0174647de1574dc1d5e8
3
+ metadata.gz: 464afc8e551b0a00daad552544ab7d939d0fb0f0
4
+ data.tar.gz: c36788f90cb8a124df6fd45efb8f2872ef05093d
5
5
  SHA512:
6
- metadata.gz: cc2a7ffdd94f60db5ec456c85caffeea69ea85d1a589fc0ebf5335f0bc31d039122a8236d567e83ed8f3fdf5548862e8fff801b84aa3866cf36ddea4e3b7b19d
7
- data.tar.gz: 0de71d01152dbc13e9ca27b9b5deb3bb4c0d1aa783c95bd73e6af72572353fd904dd9826193ad9086ba852317c400acab9bb5ac535ccec6b4d087db3ccd3dc05
6
+ metadata.gz: 5126f005b480789a700e71c442aca4f9443ee45bec148abb7bacd2abdb81b3dd6396381384af602127c410cce5aebdc7231932e3dfd5a100db64b86034b12d91
7
+ data.tar.gz: ad45a6aba07525e19a4d2c5a6c3de35a0eb3932e826e8d8b8ec5f04d3a87fa04a0b42b3cfd8ba21589300ff96125b72bf84b6639d50e57ac4c1648a4ce29693f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hem (1.0.1.beta5)
4
+ hem (1.0.1.beta6)
5
5
  aws-sdk (~> 2.0.24)
6
6
  deepstruct (~> 0.0.5)
7
7
  highline (~> 1.6.20)
@@ -53,38 +53,36 @@ module Hem
53
53
  # https://gist.github.com/jedi4ever/5657094
54
54
 
55
55
  def to_s
56
- opts = @@vm_inspector.ssh_config.merge(@opts)
56
+ require 'tempfile'
57
+ config = ::Tempfile.new 'hem_ssh_config'
58
+ config.write @@vm_inspector.ssh_config
59
+ config.close
57
60
 
58
- psuedo_tty = opts[:psuedo_tty] ? "-t" : ""
61
+ psuedo_tty = opts[:psuedo_tty] ? '-t' : ''
59
62
 
60
63
  ssh_command = [
61
- "ssh",
62
- "-o 'UserKnownHostsFile /dev/null'",
63
- "-o 'StrictHostKeyChecking no'",
64
- "-o 'ForwardAgent yes'",
65
- "-o 'LogLevel FATAL'",
66
- "-p #{opts[:ssh_port]}",
67
- "-i #{opts[:ssh_identity].shellescape}",
64
+ 'ssh',
65
+ "-F #{config.path.shellescape}",
68
66
  psuedo_tty,
69
- "#{opts[:ssh_user].shellescape}@#{opts[:ssh_host].shellescape}"
70
- ].join(" ")
67
+ 'default'
68
+ ].join(' ')
71
69
 
72
70
  pwd_set_command = " -- \"cd #{@opts[:pwd].shellescape}; exec /bin/bash"
73
71
 
74
72
  vm_command = [
75
73
  @pipe_in_vm.nil? ? nil : @pipe_in_vm.gsub(/(\\+)/, '\\\\\1'),
76
74
  @command
77
- ].compact.join(" | ")
75
+ ].compact.join(' | ')
78
76
 
79
77
  command = [
80
78
  ssh_command + pwd_set_command,
81
79
  vm_command.empty? ? nil : vm_command.shellescape
82
- ].compact.join(" -c ") + "#{opts[:append].shellescape}\""
80
+ ].compact.join(' -c ') + "#{@opts[:append].shellescape}\""
83
81
 
84
82
  [
85
83
  @pipe,
86
84
  command
87
- ].compact.join(" | ")
85
+ ].compact.join(' | ')
88
86
  end
89
87
 
90
88
  def to_str
@@ -51,21 +51,7 @@ module Hem
51
51
 
52
52
  raise Exception.new "Could not retrieve VM ssh configuration" unless config
53
53
 
54
- patterns = {
55
- :ssh_user => /^\s*User (.*)$/,
56
- :ssh_identity => /^\s*IdentityFile (.*)$/,
57
- :ssh_host => /^\s*HostName (.*)$/,
58
- :ssh_port => /^\s*Port (\d+)/
59
- }
60
-
61
- output = {}
62
-
63
- patterns.each do |k, pattern|
64
- match = config.match(pattern)
65
- output[k] = match[1] if match
66
- end
67
-
68
- return @ssh_config = output
54
+ return config
69
55
  end
70
56
  end
71
57
  end
data/lib/hem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hem
2
- VERSION = '1.0.1-beta5'
2
+ VERSION = '1.0.1-beta6'
3
3
  end
@@ -12,15 +12,24 @@ describe Hem::Helper do
12
12
  }
13
13
  })
14
14
 
15
+ Hem.user_config = DeepStruct.wrap({})
16
+
15
17
  Hem.ui = Hem::Ui.new
16
18
 
17
19
  vmi_double = double(Hem::Lib::Vm::Inspector).as_null_object
18
- vmi_double.should_receive(:ssh_config).and_return({
19
- :ssh_host => 'fakehost',
20
- :ssh_user => 'fakeuser',
21
- :ssh_port => '999',
22
- :ssh_identity => 'fakeidentity'
23
- })
20
+ vmi_double.should_receive(:ssh_config).and_return <<-eos
21
+ Host default
22
+ HostName 127.0.0.1
23
+ User vagrant
24
+ Port 2222
25
+ UserKnownHostsFile /dev/null
26
+ StrictHostKeyChecking no
27
+ PasswordAuthentication no
28
+ IdentityFile "/path/to/project/tools/vagrant/.vagrant/machines/default/virtualbox/private_key"
29
+ IdentitiesOnly yes
30
+ LogLevel FATAL
31
+ ForwardAgent yes
32
+ eos
24
33
 
25
34
  Hem::Lib::Vm::Command.class_eval do
26
35
  class_variable_set '@@vm_inspector', vmi_double
@@ -36,12 +45,12 @@ describe Hem::Helper do
36
45
  create_command("my_command", :pwd => '/').to_s.should_not match /\s-t\s/
37
46
  end
38
47
 
39
- it "should default to ssh_config user" do
40
- create_command("my_command", :pwd => '/').to_s.should match /fakeuser@/
48
+ it "should use injected config" do
49
+ create_command("my_command", :pwd => '/').to_s.should match /-F [^-][^ ]*/
41
50
  end
42
51
 
43
- it "should default to ssh_config host name" do
44
- create_command("my_command", :pwd => '/').to_s.should match /@fakehost/
52
+ it "should use default host" do
53
+ create_command("my_command", :pwd => '/').to_s.should match /\ default/
45
54
  end
46
55
 
47
56
  it "should not wrap piped commands with echo by default" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1.beta5
4
+ version: 1.0.1.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Simons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop