Module: Hem::Lib::HostCheck
- Extended by:
- HostCheck
- Included in:
- HostCheck
- Defined in:
- lib/hem/lib/host_check.rb,
lib/hem/lib/host_check/git.rb,
lib/hem/lib/host_check/deps.rb,
lib/hem/lib/host_check/vagrant.rb
Class Method Summary collapse
Instance Method Summary collapse
- #git_autocrlf_disabled(opts) ⇒ Object
- #git_config_email_set(opts) ⇒ Object
- #git_config_name_set(opts) ⇒ Object
- #git_present(opts) ⇒ Object
- #php_present(opts) ⇒ Object
- #ssh_present(opts) ⇒ Object
- #vagrant_version(opts) ⇒ Object
Class Method Details
.check(opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hem/lib/host_check.rb', line 6 def check opts = {} opts = { :filter => nil, :raise => false }.merge(opts) results = {} methods = Hem::Lib::HostCheck.public_instance_methods(false) methods.each do |method| next if opts[:filter] && !method.match(opts[:filter]) if opts[:raise] self.send method, opts else begin self.send method, opts results[method] = :ok rescue Hem::Error => error results[method] = error end end end return results end |
Instance Method Details
#git_autocrlf_disabled(opts) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/hem/lib/host_check/git.rb', line 48 def git_autocrlf_disabled opts return unless Hem.windows? advice = <<-EOF You're using git with the core.autocrlf option enabled. 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. You can disable autocrlf globally with the following command: git config --global core.autocrlf false Disabling this setting will cause git to see all line endings as changed in a repository that was cloned with it enabled. As such, you must either enable it just for those repositories or delete and re-clone them with the setting disabled. You can enable the setting on a per-clone basis by ensuring that you are in the project directory and executing the following command: git config core-autocrlf true EOF begin value = Hem::Helper.shell "git config core.autocrlf", :capture => true if value != "false" raise Hem::HostCheckError.new("Git config has autocrlf enabled", advice) end rescue Hem::ExternalCommandError # NOP end end |
#git_config_email_set(opts) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hem/lib/host_check/git.rb', line 33 def git_config_email_set opts advice = <<-EOF You have not set your email in git config! Please do so with the following command: git config --global user.email <your email here> EOF begin Hem::Helper.shell "git config user.email" rescue Hem::ExternalCommandError raise Hem::HostCheckError.new("Git config is incomplete (Email)", advice) end end |
#git_config_name_set(opts) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hem/lib/host_check/git.rb', line 19 def git_config_name_set opts advice = <<-EOF You have not set your name in git config! Please do so with the following command: git config --global user.name <your name here> EOF begin Hem::Helper.shell "git config user.name" rescue Hem::ExternalCommandError raise Hem::HostCheckError.new("Git config is incomplete (Full name)", advice) end end |
#git_present(opts) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/hem/lib/host_check/git.rb', line 4 def git_present opts advice = "The Git command could not be detected on your system.\n\n" if Hem.windows? advice += "Please install it from http://git-scm.com/downloads ensuring you select the 'Use git and unix tools everywhere' option." else advice += "Please install it using your package manager." end begin Hem::Helper.shell "git --version" rescue Errno::ENOENT raise Hem::HostCheckError.new("Git is missing", advice) end end |
#php_present(opts) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hem/lib/host_check/deps.rb', line 20 def php_present opts advice = <<-EOF The PHP command could not be located on your system. This is an optional command that can speed up composer dependency installs. Please install it from your package manager ensuring that the following command does not produce any errors: php -r "readfile('https://getcomposer.org/installer');" | php EOF begin Hem::Helper.shell "php --version" rescue Errno::ENOENT raise Hem::HostCheckError.new("PHP is missing", advice) end end |
#ssh_present(opts) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hem/lib/host_check/deps.rb', line 4 def ssh_present opts advice = "The SSH command could not be located on your system.\n\n" if Hem.windows? 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." else advice += "Please install openssh using your package manager." end begin Hem::Helper.shell "ssh -V" rescue Errno::ENOENT raise Hem::HostCheckError.new("SSH is missing", advice) end end |
#vagrant_version(opts) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hem/lib/host_check/vagrant.rb', line 4 def vagrant_version opts begin return unless Hem::Helper.get_run_environment == 'vm' version = Hem::Helper.shell "vagrant --version", :capture => true version.gsub!(/^Vagrant[^0-9]+/, '') version = Gem::Version.new(version.strip) minimum_version = Gem::Version.new("1.3.5") advice = <<-EOF The version of vagrant which you are using (#{version}) is less than the minimum required (#{minimum_version}). Please go to http://www.vagrantup.com/downloads.html and download the latest version for your platform. EOF raise Hem::HostCheckError.new("Vagrant is too old!", advice) if version < minimum_version rescue Errno::ENOENT advice = <<-EOF Vagrant could not be detected on the path! Please go to http://www.vagrantup.com/downloads.html and download the latest version for your platform. EOF raise Hem::HostCheckError.new("Vagrant is not on the path", advice) rescue Hem::ExternalCommandError => error advice = <<-EOF Vagrant produced an error while checking its presence. This is usually caused by using the vagrant gem which is no longer supported. Uninstall any gem version of vagrant with the following command selecting "yes" to any prompt: gem uninstall vagrant You can then download and install the latest version from http://www.vagrantup.com/downloads.html 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. Please seek assistance from #devops if this is the case. EOF raise Hem::HostCheckError.new("Vagrant produced an error while checking presence", advice) end end |