hem 1.0.1.beta1 → 1.0.1.beta2

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: de1021c2b7f5bfe996e119f41ee6c7b2eac65839
4
- data.tar.gz: b79fb7a3564ca815336a89c0a5fc2f7d66d078a3
3
+ metadata.gz: a44495fc9c4a95ad2036264a9fbe126f0db119ca
4
+ data.tar.gz: d52eb3e5b8abdeb52a5db03c3704c1d6e5f4804e
5
5
  SHA512:
6
- metadata.gz: e4bc3b8bf466cb07c699f9f81f04d4419b03a81c4b04d4e3d1b3a8a4f272fa2b8cf07d66f5a5d5f2d3c116d2ec5ae9d735a4821b12711821bd0858f776ba90b3
7
- data.tar.gz: 1b2a337cd6ba8eb3c7a68cfc6b86e43d2595c24690bb9a552c95442276e556ad7129f7d97eb7473fab9763780b263972e3d4d591d7820e22e176b88187a8dcb7
6
+ metadata.gz: b028dd6c290e07aa872660eecd4c8f5091f8e49829bbe8a52b947a03a7db66476cff4ab8bfc18c7ef0ad23b3383f30643280ea797523d0598a883b87618ecb33
7
+ data.tar.gz: eed7903da8c98062cefe33c7a0b5fd21b6eadb37a6cf6e11bdf8d051df56922415d34cfde2c0a9a59c8a309769554bf848e20390b8c5d3e97ead0dbf15db4491
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hem (1.0.0.beta1)
4
+ hem (1.0.1.beta2)
5
5
  aws-sdk (~> 2.0.24)
6
6
  deepstruct (~> 0.0.5)
7
7
  highline (~> 1.6.20)
@@ -22,12 +22,31 @@ module Hem
22
22
  private
23
23
 
24
24
  # Thin wrapper over a hash to provide a means to "register" asset applicators
25
- class AssetApplicatorRegistry < Hash
25
+ class AssetApplicatorRegistry < Array
26
26
  # Register a new asset applicator
27
+ # @param [String] The name of the applicator
27
28
  # @param [Regexp] Pattern to match against asset filename.
28
29
  # @yield The block to be executed when an asset matches the pattern.
29
- def register pattern, &block
30
- self[pattern] = block
30
+ def register name, pattern, &block
31
+ self << AssetApplicator.new(name, pattern, block)
32
+ end
33
+ end
34
+
35
+ class AssetApplicator
36
+ attr_reader :name
37
+
38
+ def initialize(name, pattern, block)
39
+ @name = name
40
+ @pattern = pattern
41
+ @block = block
42
+ end
43
+
44
+ def matches?(file)
45
+ @pattern.match(file)
46
+ end
47
+
48
+ def call(file, opts = {})
49
+ @block.call file, opts
31
50
  end
32
51
  end
33
52
  end
@@ -1,5 +1,5 @@
1
1
  # Built in applicators
2
- Hem.asset_applicators.register /.*\.files\.(tgz|tar\.gz|tar\.bz2)/ do |file|
2
+ Hem.asset_applicators.register 'files', /.*\.files\.(tgz|tar\.gz|tar\.bz2)/ do |file, _|
3
3
  Hem.ui.title "Applying file dump (#{file})"
4
- vm_shell "tar -xvf #{file.shellescape}"
4
+ run_command "tar -xvf #{file.shellescape}"
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # Built in applicators
2
- Hem.asset_applicators.register /.*\.sql\.gz/ do |file|
2
+ Hem.asset_applicators.register 'sqldump', /.*\.sql\.gz/ do |file, opts|
3
3
  matches = file.match(/^([^\.]+).*\.sql\.gz/)
4
4
  db = File.basename(matches[1])
5
5
 
@@ -9,27 +9,27 @@ Hem.asset_applicators.register /.*\.sql\.gz/ do |file|
9
9
  }
10
10
 
11
11
  begin
12
- result = shell(vm_mysql(:db => db).pipe('SHOW TABLES; SELECT FOUND_ROWS();', :on => :vm), :capture => true)
12
+ result = shell(create_mysql_command(:db => db).pipe('SHOW TABLES; SELECT FOUND_ROWS();', :on => :vm), :capture => true)
13
13
  status[:db_exists] = true
14
14
  status[:db_has_tables] = !(result.split("\n").last.strip == '0')
15
15
  rescue Hem::ExternalCommandError
16
16
  # This will fail later with a more useful error message
17
17
  end
18
18
 
19
- if status[:db_exists] && status[:db_has_tables]
20
- Hem.ui.warning "Already applied (#{file})"
19
+ if status[:db_exists] && status[:db_has_tables] && !opts[:force]
20
+ Hem.ui.warning "Already applied (#{file})"
21
21
  next
22
22
  end
23
23
 
24
- if status[:db_exists] && !status[:db_has_tables]
25
- # Db exists but is empty
26
- shell(vm_mysql(:mysql => 'mysqladmin', :append => " --force drop #{db.shellescape}"))
24
+ if status[:db_exists] && (!status[:db_has_tables] || opts[:force])
25
+ # Db exists but is empty, or is being reapplied
26
+ shell(create_mysql_command(:mysql => 'mysqladmin', :append => " --force drop #{db.shellescape}"))
27
27
  end
28
28
 
29
29
  begin
30
30
  Hem.ui.title "Applying mysqldump (#{file})"
31
- shell(vm_mysql(:mysql => 'mysqladmin', :append => " create #{db.shellescape}"))
32
- shell(vm_mysql(:auto_echo => false, :db => db) < "zcat #{file.shellescape}")
31
+ shell(create_mysql_command(:mysql => 'mysqladmin', :append => " create #{db.shellescape}"))
32
+ shell(create_mysql_command(:auto_echo => false, :db => db) < "zcat #{file.shellescape}")
33
33
  rescue Hem::ExternalCommandError => exception
34
34
  Hem.ui.error "Could not apply #{file} due to the following error:\n"
35
35
  Hem.ui.error File.read(exception.output.path).strip
@@ -0,0 +1,48 @@
1
+ module Hem
2
+ module Helper
3
+ def get_run_environment
4
+ [
5
+ ENV['HEM_RUN_ENV'],
6
+ Hem.project_config.run_environment,
7
+ Hem.user_config.run_environment,
8
+ 'vm'
9
+ ].each do |env|
10
+ return env unless env.nil?
11
+ end
12
+ end
13
+
14
+ def run_command command, opts = {}
15
+ create_command(command, opts).run
16
+ end
17
+
18
+ def create_mysql_command opts = {}
19
+ opts = {
20
+ :auto_echo => true,
21
+ :db => "",
22
+ :user => maybe(Hem.project_config.mysql.username) || "",
23
+ :pass => maybe(Hem.project_config.mysql.password) || "",
24
+ :mysql => 'mysql'
25
+ }.merge(opts)
26
+
27
+ opts[:user] = "-u#{opts[:user].shellescape}" unless opts[:user].empty?
28
+ opts[:pass] = "-p#{opts[:pass].shellescape}" unless opts[:pass].empty?
29
+ opts[:db] = opts[:db].shellescape unless opts[:db].empty?
30
+
31
+ create_command "#{opts[:mysql]} #{opts[:user]} #{opts[:pass]} #{opts[:db]}".strip, opts
32
+ end
33
+
34
+ def create_command command = nil, opts = {}
35
+ run_env = opts[:run_environment] || get_run_environment
36
+ case run_env
37
+ when 'vm'
38
+ ::Hem::Lib::Vm::Command.new command, opts
39
+ when 'local'
40
+ ::Hem::Lib::Local::Command.new command, opts
41
+ else
42
+ raise Hem::InvalidCommandOrOpt.new "run_environment #{run_env}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ include Hem::Helper
@@ -1,28 +1,21 @@
1
1
  module Hem
2
2
  module Helper
3
-
4
3
  def vm_shell command, opts = {}
5
- shell ::Hem::Lib::Vm::Command.new(command, opts).to_s, opts
4
+ Hem.ui.warning "Using vm_shell is deprecated and will be removed in a future release. Please use run_command instead"
5
+ opts['run_environment'] = 'vm'
6
+ run_command command, opts
6
7
  end
7
8
 
8
9
  def vm_mysql opts = {}
9
- opts = {
10
- :auto_echo => true,
11
- :db => "",
12
- :user => maybe(Hem.project_config.mysql.username) || "",
13
- :pass => maybe(Hem.project_config.mysql.password) || "",
14
- :mysql => 'mysql'
15
- }.merge(opts)
16
-
17
- opts[:user] = "-u#{opts[:user].shellescape}" unless opts[:user].empty?
18
- opts[:pass] = "-p#{opts[:pass].shellescape}" unless opts[:pass].empty?
19
- opts[:db] = opts[:db].shellescape unless opts[:db].empty?
20
-
21
- ::Hem::Lib::Vm::Command.new "#{opts[:mysql]} #{opts[:user]} #{opts[:pass]} #{opts[:db]}".strip, opts
10
+ Hem.ui.warning "Using vm_mysql is deprecated and will be removed in a future release. Please use create_mysql_command instead"
11
+ opts['run_environment'] = 'vm'
12
+ create_mysql_command opts
22
13
  end
23
14
 
24
15
  def vm_command command = nil, opts = {}
25
- ::Hem::Lib::Vm::Command.new command, opts
16
+ Hem.ui.warning "Using vm_command is deprecated and will be removed in a future release. Please use create_command instead"
17
+ opts['run_environment'] = 'vm'
18
+ create_command command, opts
26
19
  end
27
20
  end
28
21
  end
@@ -4,6 +4,8 @@ module Hem
4
4
  def vagrant_version opts
5
5
  require 'semantic'
6
6
  begin
7
+ return unless get_run_environment == 'vm'
8
+
7
9
  version = shell "vagrant --version", :capture => true
8
10
  version.gsub!(/^Vagrant[^0-9]+/, '')
9
11
  version = ::Semantic::Version.new version.strip
@@ -0,0 +1,62 @@
1
+ module Hem
2
+ module Lib
3
+ module Local
4
+ class Command
5
+ attr_accessor :opts, :command
6
+
7
+ def initialize command, opts = {}
8
+ @command = command
9
+ @opts = {
10
+ :auto_echo => false,
11
+ :pwd => opts[:pwd] || Hem.project_path,
12
+ :append => ''
13
+ }.merge(opts)
14
+ end
15
+
16
+ def pipe cmd, pipe_opts = {}
17
+ pipe_opts = pipe_opts.merge({ :on => :host })
18
+ cmd = "echo #{cmd.shellescape}" if @opts[:auto_echo]
19
+
20
+ case pipe_opts[:on]
21
+ when :host
22
+ @pipe = cmd
23
+ else
24
+ raise "Unknown pipe source: #{pipe_opts[:on]}"
25
+ end
26
+ return self
27
+ end
28
+
29
+ def << cmd
30
+ pipe cmd, :on => :host
31
+ end
32
+
33
+ def < cmd
34
+ pipe cmd, :on => :host
35
+ end
36
+
37
+ def run
38
+ return if @command.nil?
39
+ shell @command, @opts
40
+ end
41
+
42
+ def to_s
43
+ pwd_set_command = "cd #{@opts[:pwd].shellescape} && exec /bin/bash"
44
+
45
+ command = [
46
+ pwd_set_command,
47
+ @command.empty? ? nil : @command.shellescape
48
+ ].compact.join(" -c ") + "#{opts[:append].shellescape}"
49
+
50
+ [
51
+ @pipe,
52
+ "(#{command})"
53
+ ].compact.join(" | ")
54
+ end
55
+
56
+ def to_str
57
+ to_s
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -21,11 +21,11 @@ module Hem
21
21
 
22
22
  def pipe cmd, pipe_opts = {}
23
23
  pipe_opts = pipe_opts.merge({ :on => :vm })
24
- cmd = "echo #{cmd.shellescape.gsub(/(\\+)/, '\\\\\1')}" if @opts[:auto_echo]
24
+ cmd = "echo #{cmd.shellescape}" if @opts[:auto_echo]
25
25
 
26
26
  case pipe_opts[:on]
27
27
  when :vm
28
- @pipe_in_vm = cmd
28
+ @pipe_in_vm = cmd.gsub(/(\\+)/, '\\\\\1')
29
29
  when :host
30
30
  @pipe = cmd
31
31
  else
@@ -72,21 +72,35 @@ namespace :assets do
72
72
  end
73
73
 
74
74
  desc "Apply project assets"
75
+ option "-a=", "--applicator=", "Asset applicator to apply, default all"
75
76
  option "-e=", "--env=", "Environment"
77
+ option "-f", "--force", "Force application of already applied assets"
76
78
  project_only
77
79
  task :apply do |task, args|
78
80
  env = task.opts[:env] || args[:env] || 'development'
79
81
  path = "tools/assets/#{env}"
82
+ opts = {
83
+ force: task.opts[:force] || args[:force] || false
84
+ }
85
+
86
+ applicator_name = task.opts[:applicator] || args[:applicator]
87
+ case applicator_name
88
+ when nil, 'all'
89
+ asset_applicators = Hem.asset_applicators
90
+ else
91
+ asset_applicators = Hem.asset_applicators.select do |applicator|
92
+ applicator.name == applicator_name
93
+ end
94
+ end
80
95
 
81
96
  next unless File.exists? path
82
97
 
83
98
  Dir.new(path).each do |file|
84
99
  file = File.join(path, file)
85
100
  next unless File.file? file
86
- Hem.asset_applicators.each do |matcher, proc|
87
- proc.call(file) if matcher.match(file)
101
+ asset_applicators.each do |applicator|
102
+ applicator.call(file, opts) if applicator.matches?(file)
88
103
  end
89
104
  end
90
-
91
105
  end
92
106
  end
@@ -38,7 +38,7 @@ namespace :deps do
38
38
  end
39
39
 
40
40
  if !complete
41
- vm_shell *args
41
+ run_command *args
42
42
  end
43
43
 
44
44
  Hem.ui.success "Composer dependencies installed"
@@ -2,7 +2,7 @@ namespace :tools do
2
2
  desc "Fetches the n98-magerun utility"
3
3
  task :n98magerun do
4
4
  FileUtils.mkdir_p "bin"
5
- vm_shell '"wget" --no-check-certificate "https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar" -O bin/n98-magerun.phar'
5
+ run_command '"wget" --no-check-certificate "https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar" -O bin/n98-magerun.phar'
6
6
  FileUtils.chmod 0755, "bin/n98-magerun.phar"
7
7
  end
8
8
  end
@@ -46,7 +46,7 @@ namespace :magento do
46
46
  if magento_version_file
47
47
  args = [ "php -r \"require '#{magento_version_file}'; echo Mage::getEdition();\""]
48
48
 
49
- magento_edition = vm_shell(*args, :capture => true).to_s.downcase
49
+ magento_edition = run_command(*args, :capture => true).to_s.downcase
50
50
  end
51
51
 
52
52
  edition_options = ['community', 'enterprise', 'professional', 'go']
@@ -64,7 +64,7 @@ namespace :magento do
64
64
  if magento_version_file
65
65
  args = [ "php -r \"require '#{magento_version_file}'; echo Mage::getVersion();\""]
66
66
 
67
- magento_version = vm_shell(*args, :capture => true)
67
+ magento_version = run_command(*args, :capture => true)
68
68
  end
69
69
 
70
70
  version_regex = /^\d+(\.\d+){3}$/
@@ -95,7 +95,7 @@ namespace :magento do
95
95
  end
96
96
 
97
97
  if use_vm
98
- status = vm_shell(tools_command, :exit_status => true)
98
+ status = run_command(tools_command, :exit_status => true)
99
99
  end
100
100
 
101
101
  if status != 0
@@ -183,7 +183,7 @@ namespace :magento do
183
183
  File.rename file, "#{magento_path}/#{filename}"
184
184
  file = "#{magento_path}/#{filename}"
185
185
  if use_vm
186
- vm_shell "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
186
+ run_command "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
187
187
  else
188
188
  shell "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
189
189
  end
@@ -213,8 +213,8 @@ namespace :magento do
213
213
  desc "Run magento setup scripts"
214
214
  task :run => ['tools:n98magerun'] do
215
215
  Hem.ui.success "Running setup scripts"
216
- vm_shell("bin/n98-magerun.phar cache:clean config", :realtime => true, :indent => 2)
217
- vm_shell("bin/n98-magerun.phar sys:setup:incremental -n", :realtime => true, :indent => 2)
216
+ run_command("bin/n98-magerun.phar cache:clean config", :realtime => true, :indent => 2)
217
+ run_command("bin/n98-magerun.phar sys:setup:incremental -n", :realtime => true, :indent => 2)
218
218
  Hem.ui.separator
219
219
  end
220
220
  end
@@ -224,7 +224,7 @@ namespace :magento do
224
224
  desc "Clear cache"
225
225
  task :clear => ['tools:n98magerun'] do
226
226
  Hem.ui.success "Clearing magento cache"
227
- vm_shell("bin/n98-magerun.phar cache:flush", :realtime => true, :indent => 2)
227
+ run_command("bin/n98-magerun.phar cache:flush", :realtime => true, :indent => 2)
228
228
  Hem.ui.separator
229
229
  end
230
230
  end
@@ -235,8 +235,8 @@ namespace :magento do
235
235
  task :'configure-urls' => ['tools:n98magerun'] do
236
236
  Hem.ui.success "Configuring magento base urls"
237
237
  domain = Hem.project_config.hostname
238
- vm_shell("bin/n98-magerun.phar config:set web/unsecure/base_url 'http://#{domain}/'", :realtime => true, :indent => 2)
239
- vm_shell("bin/n98-magerun.phar config:set web/secure/base_url 'https://#{domain}/'", :realtime => true, :indent => 2)
238
+ run_command("bin/n98-magerun.phar config:set web/unsecure/base_url 'http://#{domain}/'", :realtime => true, :indent => 2)
239
+ run_command("bin/n98-magerun.phar config:set web/secure/base_url 'https://#{domain}/'", :realtime => true, :indent => 2)
240
240
  Hem.ui.separator
241
241
  end
242
242
 
@@ -252,10 +252,10 @@ namespace :magento do
252
252
 
253
253
  desc "Create admin user"
254
254
  task :'create-admin-user' do
255
- initialized = vm_shell("bin/n98-magerun.phar admin:user:list | grep admin", :exit_status => true) == 0
255
+ initialized = run_command("bin/n98-magerun.phar admin:user:list | grep admin", :exit_status => true) == 0
256
256
  unless initialized
257
257
  Hem.ui.success "Creating admin user"
258
- vm_shell("bin/n98-magerun.phar admin:user:create admin '' admin admin admin", :realtime => true, :indent => 2)
258
+ run_command("bin/n98-magerun.phar admin:user:create admin '' admin admin admin", :realtime => true, :indent => 2)
259
259
  Hem.ui.separator
260
260
  end
261
261
  end
@@ -263,7 +263,7 @@ namespace :magento do
263
263
  desc "Enable rewrites"
264
264
  task :'enable-rewrites' do
265
265
  Hem.ui.success "Enabling rewrites"
266
- vm_shell("bin/n98-magerun.phar config:set web/seo/use_rewrites 1", :realtime => true, :indent => 2)
266
+ run_command("bin/n98-magerun.phar config:set web/seo/use_rewrites 1", :realtime => true, :indent => 2)
267
267
  Hem.ui.separator
268
268
  end
269
269
  end
@@ -8,7 +8,7 @@ namespace :tools do
8
8
  unless File.exists?(bin_file)
9
9
  Hem.ui.success "Getting composer"
10
10
  FileUtils.mkdir_p File.dirname(bin_file)
11
- vm_shell "cd bin && php -r \"readfile('https://getcomposer.org/installer');\" | php", :realtime => true, :indent => 2
11
+ run_command "cd bin && php -r \"readfile('https://getcomposer.org/installer');\" | php", :realtime => true, :indent => 2
12
12
  else
13
13
  Hem.ui.success "Composer already available in bin/composer.phar"
14
14
  end
data/lib/hem/tasks/vm.rb CHANGED
@@ -119,7 +119,7 @@ namespace :vm do
119
119
  opts[:db] = task.opts[:db] if task.opts[:db]
120
120
 
121
121
  Hem.ui.success "Determining VM connection details..." if STDOUT.tty?
122
- command = vm_mysql(opts)
122
+ command = create_mysql_command(opts)
123
123
  Hem.logger.debug "vm:mysql: #{command}"
124
124
 
125
125
  Hem.ui.success "Connecting..." if STDOUT.tty?
@@ -131,7 +131,7 @@ namespace :vm do
131
131
  opts = { :psuedo_tty => STDIN.tty? }
132
132
 
133
133
  Hem.ui.success "Determining VM connection details..." if STDOUT.tty?
134
- command = vm_command("redis-cli", opts)
134
+ command = create_command("redis-cli", opts)
135
135
  Hem.logger.debug "vm:redis: #{command}"
136
136
 
137
137
  Hem.ui.success "Connecting..." if STDOUT.tty?
data/lib/hem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hem
2
- VERSION = '1.0.1-beta1'
2
+ VERSION = '1.0.1-beta2'
3
3
  end
data/lib/hem.rb CHANGED
@@ -36,12 +36,15 @@ require 'hem/lib/s3/remote/file'
36
36
  require 'hem/lib/s3/remote/iohandler'
37
37
 
38
38
  # Task helpers
39
+ require 'hem/helper/command'
39
40
  require 'hem/helper/shell'
40
41
  require 'hem/helper/file_locator'
41
42
  require 'hem/helper/github'
42
43
  require 'hem/helper/http_download'
43
44
  require 'hem/helper/vm_command'
44
45
 
46
+ require 'hem/lib/local/command'
47
+
45
48
  require 'hem/lib/vm/inspector'
46
49
  require 'hem/lib/vm/command'
47
50
 
@@ -27,70 +27,57 @@ describe Hem::Helper do
27
27
  end
28
28
  end
29
29
 
30
- describe "vm_command" do
30
+ describe "create_command" do
31
31
  it "should create a new vm command wrapper with specified command" do
32
- vm_command("my_command", :pwd => '/').to_s.should match /-c my_command/
32
+ create_command("my_command", :pwd => '/').to_s.should match /-c my_command/
33
33
  end
34
34
 
35
35
  it "should default to not using a psuedo tty" do
36
- vm_command("my_command", :pwd => '/').to_s.should_not match /\s-t\s/
36
+ create_command("my_command", :pwd => '/').to_s.should_not match /\s-t\s/
37
37
  end
38
38
 
39
39
  it "should default to ssh_config user" do
40
- vm_command("my_command", :pwd => '/').to_s.should match /fakeuser@/
40
+ create_command("my_command", :pwd => '/').to_s.should match /fakeuser@/
41
41
  end
42
42
 
43
43
  it "should default to ssh_config host name" do
44
- vm_command("my_command", :pwd => '/').to_s.should match /@fakehost/
44
+ create_command("my_command", :pwd => '/').to_s.should match /@fakehost/
45
45
  end
46
46
 
47
47
  it "should not wrap piped commands with echo by default" do
48
- c = vm_command("my_command", :pwd => '/')
48
+ c = create_command("my_command", :pwd => '/')
49
49
  c << "test"
50
50
  c.to_s.should_not match /^echo test/
51
51
  end
52
52
  end
53
53
 
54
- describe "vm_mysql" do
54
+ describe "create_mysql_command" do
55
55
  it "should use mysql command by default" do
56
- vm_mysql(:pwd => '/').to_s.should match /-c mysql/
56
+ create_mysql_command(:pwd => '/').to_s.should match /-c mysql/
57
57
  end
58
58
 
59
59
  it "should use project config mysql username & password if set" do
60
- vm_mysql(:pwd => '/').to_s.should match /-c mysql.*-utest_user.*-ptest_pass/
60
+ create_mysql_command(:pwd => '/').to_s.should match /-c mysql.*-utest_user.*-ptest_pass/
61
61
  end
62
62
 
63
63
  it "should not pass user / pass if project config mysql credentials not set" do
64
64
  Hem.project_config = DeepStruct.wrap({})
65
- vm_mysql(:pwd => '/').to_s.should match /-c mysql'/
65
+ create_mysql_command(:pwd => '/').to_s.should match /-c mysql'/
66
66
  end
67
67
 
68
68
  it "should allow specifying the database in options" do
69
- vm_mysql(:pwd => '/', :db => "test_db").to_s.should match /-c mysql.*test_db'/
69
+ create_mysql_command(:pwd => '/', :db => "test_db").to_s.should match /-c mysql.*test_db'/
70
70
  end
71
71
 
72
72
  it "should enable auto echo of piped commands" do
73
- c = vm_mysql(:pwd => '/')
73
+ c = create_mysql_command(:pwd => '/')
74
74
  c << "SELECT 1"
75
- c.to_s.should match /^echo SELECT\\ 1/
75
+ puts c.to_s
76
+ c.to_s.should match /echo\\ SELECT\\\\\\\\\\ 1\\ \\\|/
76
77
  end
77
78
  end
78
79
 
79
- describe "vm_shell" do
80
- it "should execute the command using the shell helper" do
81
- Hem::Helper.class_eval do
82
- alias :old_shell :shell
83
- def shell command, opts
84
- command.to_s.should match /ssh.* -c my_command/
85
- end
86
- end
87
-
88
- vm_shell "my_command", :pwd => '/'
89
-
90
- Hem::Helper.class_eval do
91
- remove_method :shell
92
- alias :shell :old_shell
93
- end
94
- end
80
+ describe "run_command" do
81
+ it "should execute the command using the shell helper when refactored"
95
82
  end
96
83
  end
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.beta1
4
+ version: 1.0.1.beta2
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-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -206,6 +206,7 @@ files:
206
206
  - lib/hem/error_handlers/friendly.rb
207
207
  - lib/hem/errors.rb
208
208
  - lib/hem/help_formatter.rb
209
+ - lib/hem/helper/command.rb
209
210
  - lib/hem/helper/file_locator.rb
210
211
  - lib/hem/helper/github.rb
211
212
  - lib/hem/helper/http_download.rb
@@ -218,6 +219,7 @@ files:
218
219
  - lib/hem/lib/host_check/git.rb
219
220
  - lib/hem/lib/host_check/ruby.rb
220
221
  - lib/hem/lib/host_check/vagrant.rb
222
+ - lib/hem/lib/local/command.rb
221
223
  - lib/hem/lib/s3/local/file.rb
222
224
  - lib/hem/lib/s3/local/iohandler.rb
223
225
  - lib/hem/lib/s3/remote/file.rb
@@ -262,10 +264,10 @@ files:
262
264
  - spec/hem/error_handlers/friendly_spec.rb
263
265
  - spec/hem/error_spec.rb
264
266
  - spec/hem/help_formatter_spec.rb
267
+ - spec/hem/helpers/command_spec.rb
265
268
  - spec/hem/helpers/file_locator_spec.rb
266
269
  - spec/hem/helpers/github_spec.rb
267
270
  - spec/hem/helpers/shell_spec.rb
268
- - spec/hem/helpers/vm_command_spec.rb
269
271
  - spec/hem/lib/github/api_spec.rb
270
272
  - spec/hem/lib/s3/sync_spec.rb
271
273
  - spec/hem/lib/seed/project_spec.rb
@@ -300,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
302
  version: 1.3.1
301
303
  requirements: []
302
304
  rubyforge_project:
303
- rubygems_version: 2.4.5
305
+ rubygems_version: 2.4.5.1
304
306
  signing_key:
305
307
  specification_version: 4
306
308
  summary: Inviqan toolbelt
@@ -320,10 +322,10 @@ test_files:
320
322
  - spec/hem/error_handlers/friendly_spec.rb
321
323
  - spec/hem/error_spec.rb
322
324
  - spec/hem/help_formatter_spec.rb
325
+ - spec/hem/helpers/command_spec.rb
323
326
  - spec/hem/helpers/file_locator_spec.rb
324
327
  - spec/hem/helpers/github_spec.rb
325
328
  - spec/hem/helpers/shell_spec.rb
326
- - spec/hem/helpers/vm_command_spec.rb
327
329
  - spec/hem/lib/github/api_spec.rb
328
330
  - spec/hem/lib/s3/sync_spec.rb
329
331
  - spec/hem/lib/seed/project_spec.rb