Class: Caco::Rbenv::Install

Inherits:
Trailblazer::Operation
  • Object
show all
Defined in:
lib/caco/rbenv/install.rb

Constant Summary collapse

CloneRepo =
Class.new(Trailblazer::Activity::Signal)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.repo_exist?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/caco/rbenv/install.rb', line 47

def self.repo_exist?
  File.exist?("/opt/rbenv") ? true : CloneRepo
end

Instance Method Details

#clone_repo(ctx) ⇒ Object



51
52
53
54
# File 'lib/caco/rbenv/install.rb', line 51

def clone_repo(ctx, **)
  result = Caco::Executer.(command: "git clone https://github.com/rbenv/rbenv.git /opt/rbenv")
  result.success?
end

#install_packages!(ctx) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/caco/rbenv/install.rb', line 28

def install_packages!(ctx, **)
  packages = []
  if Caco::Facter.("os", "distro", "codename") == "stretch"
    packages = %w(git autoconf bison libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev)
  elsif Caco::Facter.("os", "distro", "codename") == "buster"
    packages = %w(git autoconf bison libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev)
  end

  packages.each do |package|
    result = Caco::Debian::PackageInstall.(package: package)
    return false if result.failure?
  end
  true
end

#repo_exist?(ctx) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/caco/rbenv/install.rb', line 43

def repo_exist?(ctx, **)
  self.class.repo_exist?
end