hobo-inviqa 0.0.7.pre.rc3 → 0.0.7

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.
Files changed (56) hide show
  1. data/Gemfile.lock +4 -19
  2. data/Guardfile +2 -2
  3. data/Hobofile +1 -5
  4. data/bin/hobo +18 -12
  5. data/hobo.gemspec +0 -3
  6. data/lib/hobo.rb +1 -8
  7. data/lib/hobo/cli.rb +3 -14
  8. data/lib/hobo/error_handlers/debug.rb +2 -5
  9. data/lib/hobo/error_handlers/friendly.rb +8 -8
  10. data/lib/hobo/errors.rb +1 -11
  11. data/lib/hobo/helper/shell.rb +2 -3
  12. data/lib/hobo/helper/vm_command.rb +14 -164
  13. data/lib/hobo/lib/host_check.rb +6 -20
  14. data/lib/hobo/lib/host_check/deps.rb +4 -22
  15. data/lib/hobo/lib/host_check/git.rb +17 -41
  16. data/lib/hobo/lib/host_check/ruby.rb +20 -30
  17. data/lib/hobo/lib/host_check/vagrant.rb +6 -37
  18. data/lib/hobo/lib/s3sync.rb +44 -22
  19. data/lib/hobo/lib/seed/project.rb +4 -8
  20. data/lib/hobo/patches/slop.rb +2 -21
  21. data/lib/hobo/tasks/assets.rb +15 -12
  22. data/lib/hobo/tasks/deps.rb +6 -40
  23. data/lib/hobo/tasks/host.rb +19 -0
  24. data/lib/hobo/tasks/tools.rb +6 -10
  25. data/lib/hobo/tasks/vm.rb +11 -64
  26. data/lib/hobo/ui.rb +10 -27
  27. data/lib/hobo/util.rb +2 -36
  28. data/lib/hobo/version.rb +2 -2
  29. data/spec/hobo/asset_applicator_spec.rb +2 -2
  30. data/spec/hobo/cli_spec.rb +24 -35
  31. data/spec/hobo/config/file_spec.rb +3 -1
  32. data/spec/hobo/error_handlers/debug_spec.rb +5 -39
  33. data/spec/hobo/error_handlers/friendly_spec.rb +21 -38
  34. data/spec/hobo/help_formatter_spec.rb +3 -3
  35. data/spec/hobo/helpers/file_locator_spec.rb +2 -2
  36. data/spec/hobo/helpers/shell_spec.rb +2 -2
  37. data/spec/hobo/helpers/vm_command_spec.rb +24 -36
  38. data/spec/hobo/lib/s3sync_spec.rb +3 -6
  39. data/spec/hobo/lib/seed/project_spec.rb +3 -2
  40. data/spec/hobo/lib/seed/replacer_spec.rb +2 -1
  41. data/spec/hobo/lib/seed/seed_spec.rb +3 -2
  42. data/spec/hobo/logging_spec.rb +2 -2
  43. data/spec/hobo/metadata_spec.rb +2 -2
  44. data/spec/hobo/null_spec.rb +2 -2
  45. data/spec/hobo/paths_spec.rb +2 -1
  46. data/spec/hobo/ui_spec.rb +20 -104
  47. data/spec/spec_helper.rb +0 -1
  48. metadata +48 -57
  49. checksums.yaml +0 -15
  50. data/.editorconfig +0 -10
  51. data/lib/hobo/error_handlers/exit_code_map.rb +0 -16
  52. data/lib/hobo/helper/http_download.rb +0 -41
  53. data/lib/hobo/tasks/config.rb +0 -15
  54. data/lib/hobo/tasks/system.rb +0 -15
  55. data/lib/hobo/tasks/system/completions.rb +0 -76
  56. data/spec/hobo/util_spec.rb +0 -75
@@ -4,34 +4,20 @@ module Hobo
4
4
  class << self
5
5
  include Hobo::Lib::HostCheck
6
6
 
7
- def check opts = {}
8
- opts = {
9
- :filter => nil,
10
- :raise => false
11
- }.merge(opts)
12
-
13
- results = {}
7
+ def check silent = true
14
8
  methods = Hobo::Lib::HostCheck.public_instance_methods(false)
15
9
  methods.each do |method|
16
- next if opts[:filter] && !method.match(opts[:filter])
17
-
18
10
  name = method.to_s.gsub('_', ' ')
19
11
  name[0] = name[0].upcase
20
- if opts[:raise]
12
+ begin
21
13
  self.send method
22
- else
23
- begin
24
- self.send method
25
- results[name] = :ok
26
- rescue Hobo::Error => error
27
- results[name] = error
28
- end
14
+ Hobo.ui.success "#{name}: OK" unless silent
15
+ rescue
16
+ Hobo.ui.error "#{name}: FAILED" unless silent
29
17
  end
30
18
  end
31
-
32
- return results
33
19
  end
34
20
  end
35
21
  end
36
22
  end
37
- end
23
+ end
@@ -2,38 +2,20 @@ module Hobo
2
2
  module Lib
3
3
  module HostCheck
4
4
  def ssh_present
5
- advice = "The SSH command could not be located on your system.\n\n"
6
-
7
- if OS.windows?
8
- advice += "To make SSH available you must re-install git using the installer from http://git-scm.com/downloads ensuring you select the 'Use git and unix tools everywhere' option."
9
- else
10
- advice += "Please install openssh using your package manager."
11
- end
12
-
13
5
  begin
14
6
  shell "ssh -V"
15
7
  rescue Errno::ENOENT
16
- raise Hobo::HostCheckError.new("SSH is missing", advice)
8
+ raise Hobo::MissingDependency.new("ssh")
17
9
  end
18
10
  end
19
11
 
20
12
  def php_present
21
- advice = <<-EOF
22
- The PHP command could not be located on your system.
23
-
24
- This is an optional command that can speed up composer dependency installs.
25
-
26
- Please install it from your package manager ensuring that the following command does not produce any errors:
27
-
28
- php -r "readfile('https://getcomposer.org/installer');" | php
29
- EOF
30
-
31
13
  begin
32
- shell "php --version"
14
+ shell "php -v"
33
15
  rescue Errno::ENOENT
34
- raise Hobo::HostCheckError.new("PHP is missing", advice)
16
+ raise Hobo::MissingDependency.new("php")
35
17
  end
36
18
  end
37
19
  end
38
20
  end
39
- end
21
+ end
@@ -2,70 +2,46 @@ module Hobo
2
2
  module Lib
3
3
  module HostCheck
4
4
  def git_present
5
- advice = "The Git command could not be detected on your system.\n\n"
6
- if OS.windows?
7
- advice += "Please install it from http://git-scm.com/downloads ensuring you select the 'Use git and unix tools everywhere' option."
8
- else
9
- advice += "Please install it using your package manager."
10
- end
11
-
12
5
  begin
13
6
  shell "git --version"
14
7
  rescue Errno::ENOENT
15
- raise Hobo::HostCheckError.new("Git is missing", advice)
8
+ raise Hobo::MissingDependency.new("ssh")
16
9
  end
17
10
  end
18
11
 
19
12
  def git_config_name_set
20
- advice = <<-EOF
21
- You have not set your name in git config!
22
-
23
- Please do so with the following command:
24
- git config --global user.name <your name here>
25
- EOF
26
13
  begin
27
14
  shell "git config user.name"
28
15
  rescue Hobo::ExternalCommandError
29
- raise Hobo::HostCheckError.new("Git config is incomplete (Full name)", advice)
16
+ Hobo.ui.error "You must provide git with your full name"
17
+ name = Hobo.ui.ask "Full name"
18
+ shell "git config --global user.name #{name.shellescape}"
30
19
  end
31
20
  end
32
21
 
33
22
  def git_config_email_set
34
- advice = <<-EOF
35
- You have not set your email in git config!
36
-
37
- Please do so with the following command:
38
- git config --global user.email <your email here>
39
- EOF
40
-
41
23
  begin
42
24
  shell "git config user.email"
43
25
  rescue Hobo::ExternalCommandError
44
- raise Hobo::HostCheckError.new("Git config is incomplete (Email)", advice)
26
+ email = Hobo.ui.ask "Email address"
27
+ shell "git config --global user.email #{email.shellescape}"
45
28
  end
46
29
  end
47
30
 
48
31
  def git_autocrlf_disabled
49
- return unless OS.windows?
50
-
51
- advice = <<-EOF
52
- You're using git with the core.autocrlf option enabled.
53
-
54
- This setting can often cause problems when you clone a repository on windows but need to execute the contents of that repository within a linux VM.
55
-
56
- You can disable autocrlf globally with the following command:
57
- git config --global core.autocrlf false
58
-
59
- Disabling this setting will cause git to see all line endings as changed in a repository that was cloned with it enabled.
60
- As such, you must either enable it just for those repositories or delete and re-clone them with the setting disabled.
61
-
62
- You can enable the setting on a per-clone basis by ensuring that you are in the project directory and executing the following command:
63
- git config core-autocrlf true
64
- EOF
32
+ return true
65
33
  begin
66
34
  value = shell "git config core.autocrlf", :capture => true
67
35
  if value != "false"
68
- raise Hobo::HostCheckError.new("Git config has autocrlf enabled", advice)
36
+ Hobo.ui.error "You're using git with autocrlf!"
37
+ Hobo.ui.error "This setting can cause problems executing scripts within VMs."
38
+ Hobo.ui.error "If you've had it enabled for a while, you'll need to check out all of your repositories again if you change it."
39
+ disable = Hobo.ui.ask "Would you like to disable this setting?", :default => true
40
+ if disable
41
+ shell "git config --global core.autocrlf false"
42
+ Hobo.ui.success "Disabled autocrlf\nYou can re-enable it by executing `git config --global core.autocrlf true"
43
+ end
44
+
69
45
  end
70
46
  rescue Hobo::ExternalCommandError
71
47
  # NOP
@@ -73,4 +49,4 @@ EOF
73
49
  end
74
50
  end
75
51
  end
76
- end
52
+ end
@@ -2,51 +2,41 @@ module Hobo
2
2
  module Lib
3
3
  module HostCheck
4
4
  def not_using_system_ruby
5
- return if OS.windows?
6
- advice = <<-EOF
7
- You're using a system ruby install which can cause issues with installing Gems and running some older projects.
8
-
9
- rbenv is HIGHLY recommended.
10
-
11
- You can install it with the following command:
12
- curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
13
-
14
- Once installed, run the following to set it as the default ruby and re-install hobo-inviqa:
15
- rbenv install 1.9.3-p448 && rbenv global 1.9.3-448 && gem install hobo-inviqa
16
- EOF
5
+ return if Gem.win_platform?
17
6
  which = shell "which ruby", :capture => true
18
- unless which =~ /\.rbenv|\.rvm/
19
- raise Hobo::HostCheckError.new("Hobo is running under a system ruby", advice)
7
+ unless which =~ /\.rbenc|\.rvm/
8
+ Hobo.ui.error "You're using a system ruby install! rbenv is HIGHLY recommended"
9
+ Hobo.ui.error "You can install it with the following command:\n"
10
+ Hobo.ui.error " curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash\n"
11
+ Hobo.ui.error "Once installed, run the following:\n"
12
+ Hobo.ui.error " rbenv install 1.9.3-p448 && rbenv global 1.9.3-448 && gem install hobo-inviqa"
13
+ raise "System ruby in use"
20
14
  end
21
15
  end
22
16
 
23
17
  def system_paths_for_ruby
24
- return if OS.windows?
25
-
26
- advice = <<-EOF
27
- The ordering of your system paths may cause a problem with Gems.
28
-
29
- Unfortunately we can't automatically fix this for you at this time.
30
-
31
- Please seek assistance.
32
-
33
- Your paths were detected as:
34
-
35
- #{ENV['PATH'].split(':').join("\n")}
36
- EOF
37
-
18
+ return if Gem.win_platform?
38
19
  paths = ENV['PATH'].split(':')
39
20
  system_path_found = false
40
21
  ruby_path_found = false
41
22
  paths.each do |path|
42
23
  system_before_ruby = system_path_found && !ruby_path_found
43
24
  ruby_after_system = path =~ /\.rbenv|\.rvm/ && system_path_found
44
- raise Hobo::HostCheckError.new("System paths appear to be mis-ordered", advice) if system_before_ruby or ruby_after_system
25
+ raise "Bad system paths" if system_before_ruby or ruby_after_system
45
26
 
46
27
  ruby_path_found = true if path =~ /\.rbenv|\.rvm/
47
28
  system_path_found = true if path =~ /\/usr\/bin|\/usr\/local\/bin/
48
29
  end
49
30
  end
31
+
32
+ def ruby_include_paths
33
+ paths = $:
34
+ bad_paths = paths.reject do |path|
35
+ path.match /\.rbenv|\.rvm/
36
+ end.compact.length > 0
37
+
38
+ raise "Bad gem paths" if bad_paths
39
+ end
50
40
  end
51
41
  end
52
- end
42
+ end
@@ -4,43 +4,12 @@ module Hobo
4
4
  module Lib
5
5
  module HostCheck
6
6
  def vagrant_version
7
- begin
8
- version = shell "vagrant --version", :capture => true
9
- version.gsub!(/^Vagrant /, '')
10
- version = ::Semantic::Version.new version
11
- minimum_version = ::Semantic::Version.new "1.3.5"
12
-
13
- advice = <<-EOF
14
- The version of vagrant which you are using (#{version}) is less than the minimum required (#{minimum_version}).
15
-
16
- Please go to http://www.vagrantup.com/downloads.html and download the latest version for your platform.
17
- EOF
18
- raise Hobo::HostCheckError.new("Vagrant is too old!", advice) if version < minimum_version
19
- rescue Errno::ENOENT
20
- advice = <<-EOF
21
- Vagrant could not be detected on the path!
22
-
23
- Please go to http://www.vagrantup.com/downloads.html and download the latest version for your platform.
24
- EOF
25
- raise Hobo::HostCheckError.new("Vagrant is not on the path", advice)
26
- rescue Hobo::ExternalCommandError => error
27
- advice = <<-EOF
28
- Vagrant produced an error while checking its presence.
29
-
30
- This is usually caused by using the vagrant gem which is no longer supported.
31
-
32
- Uninstall any gem version of vagrant with the following command selecting "yes" to any prompt:
33
- gem uninstall vagrant
34
-
35
- You can then download and install the latest version from http://www.vagrantup.com/downloads.html
36
-
37
- If you do not have any vagrant gems installed it may be possible that a gem such as vagrant-wrapper is installed and is failing.
38
-
39
- Please seek assistance from #devops if this is the case.
40
- EOF
41
- raise Hobo::HostCheckError.new("Vagrant produced an error while checking presence", advice)
42
- end
7
+ version = shell "vagrant --version", :capture => true
8
+ version.gsub!(/^Vagrant /, '')
9
+ version = ::Semantic::Version.new version
10
+ minimum_version = ::Semantic::Version.new "1.3.5"
11
+ raise "Vagrant too old" if version < minimum_version
43
12
  end
44
13
  end
45
14
  end
46
- end
15
+ end
@@ -1,5 +1,6 @@
1
1
  require 'aws-sdk'
2
2
  require 'fileutils'
3
+ require 'ruby-progressbar'
3
4
 
4
5
  module Hobo
5
6
  module Lib
@@ -10,8 +11,7 @@ module Hobo
10
11
  opts = {
11
12
  :access_key_id => key_id,
12
13
  :secret_access_key => secret,
13
- :verify_response_body_content_length => false,
14
- :max_retries => 15
14
+ :verify_response_body_content_length => false
15
15
  }
16
16
 
17
17
  logger.debug("s3sync: Options #{opts}")
@@ -19,8 +19,26 @@ module Hobo
19
19
  @s3 = AWS::S3.new opts
20
20
  end
21
21
 
22
+ def delta source, dest
23
+ to_add = (source.sort - dest.sort).map(&:first)
24
+ to_remove = (dest.sort - source.sort).map(&:first)
25
+ to_remove = to_remove - to_add
26
+
27
+ {
28
+ :add => to_add,
29
+ :remove => to_remove
30
+ }
31
+ end
32
+
33
+ def io_handler uri
34
+ parsed = URI.parse(uri)
35
+ parsed.scheme == 's3' ?
36
+ Remote.new(@s3, parsed.host, parsed.path) :
37
+ Local.new(uri)
38
+ end
39
+
22
40
  def sync source, dest, opts = {}
23
- opts = { :progress => Hobo.method(:progress) }.merge(opts)
41
+ opts = { :progress => method(:progress) }.merge(opts)
24
42
 
25
43
  source_io = io_handler(source)
26
44
  destination_io = io_handler(dest)
@@ -44,17 +62,19 @@ module Hobo
44
62
 
45
63
  source_file.buffer
46
64
 
65
+ written = 0
47
66
  size = source_file.size
48
67
  destination_file.write({ :size => source_file.size }) do |buffer, bytes|
49
68
  chunk = source_file.read(bytes)
50
69
  buffer.write(chunk)
51
- opts[:progress].call(file, chunk.length, size, :update)
70
+ written += chunk.length
71
+ opts[:progress].call(file, written, size, :update)
52
72
  end
53
73
 
54
74
  destination_file.close
55
75
  source_file.close
56
76
 
57
- opts[:progress].call(file, 0, size, :finish)
77
+ opts[:progress].call(file, written, size, :finish)
58
78
  end
59
79
 
60
80
  delta[:remove].each do |file|
@@ -65,26 +85,28 @@ module Hobo
65
85
  return delta
66
86
  end
67
87
 
68
- private
88
+ def progress file, written, total, type
89
+ opts = {
90
+ :title => file,
91
+ :total => total,
92
+ :format => "%t [%B] %p%% %e"
93
+ }
69
94
 
70
- def delta source, dest
71
- to_add = (source.sort - dest.sort).map(&:first)
72
- to_remove = (dest.sort - source.sort).map(&:first)
73
- to_remove = to_remove - to_add
95
+ # Hack to stop newline spam on windows
96
+ opts[:length] = 79 if Gem::win_platform?
74
97
 
75
- {
76
- :add => to_add,
77
- :remove => to_remove
78
- }
79
- end
98
+ @progress ||= {}
99
+ @progress[file] ||= ProgressBar.create(opts)
80
100
 
81
- def io_handler uri
82
- parsed = URI.parse(uri)
83
- parsed.scheme == 's3' ?
84
- Remote.new(@s3, parsed.host, parsed.path) :
85
- Local.new(uri)
101
+ case type
102
+ when :update
103
+ @progress[file].progress = written
104
+ when :finished
105
+ @progress[file].finish
106
+ end
86
107
  end
87
108
 
109
+
88
110
  class Local
89
111
  include Hobo::Logging
90
112
 
@@ -110,7 +132,7 @@ module Hobo
110
132
  end
111
133
 
112
134
  def rm file
113
- File.unlink File.join(@path, file)
135
+ File.unlink file
114
136
  end
115
137
  end
116
138
 
@@ -213,4 +235,4 @@ module Hobo
213
235
  end
214
236
  end
215
237
  end
216
- end
238
+ end
@@ -16,6 +16,9 @@ module Hobo
16
16
  config[:seed][:version] = seed.version
17
17
  config[:hostname] = "#{config[:name]}.development.local"
18
18
  config[:asset_bucket] = "inviqa-assets-#{config[:name]}"
19
+ config[:mysql] = {
20
+ :password => "984C42CF342f7j6" # Packer default password
21
+ }
19
22
 
20
23
  @opts[:replacer].replace(config[:project_path], config)
21
24
  load_seed_init(config)
@@ -41,17 +44,10 @@ module Hobo
41
44
  def initialize_git path, git_url
42
45
  Dir.chdir path do
43
46
  Hobo::Helper.shell 'git', 'init'
47
+ Hobo::Helper.shell 'git', 'remote', 'add', 'origin', git_url
44
48
  Hobo::Helper.shell 'git', 'add', '--all'
45
49
  Hobo::Helper.shell 'git', 'commit', '-m', "'Initial hobo project'"
46
50
  Hobo::Helper.shell 'git', 'checkout', '-b', 'develop'
47
-
48
- # Github for windows gets clever adding origin / upstream remotes in system level gitconfig
49
- # :facepalm:
50
- begin
51
- Hobo::Helper.shell 'git', 'remote', 'add', 'origin', git_url
52
- rescue Hobo::ExternalCommandError
53
- Hobo::Helper.shell 'git', 'remote', 'set-url', 'origin', git_url
54
- end
55
51
  end
56
52
  end
57
53
  end