Sha256: 099781a5b66167cee40bff09de328d612360f26e6a33e6fc996ac510d053351d

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

require 'pathname'
require 'securerandom'
require 'highline'

require 'librarian'
require 'librarian/action/install'
require 'librarian/chef'

module Librarian
  module Chef

    class Environment
      def install_path
        @install_path ||= begin
          has_home = ENV["HOME"] && File.directory?(ENV["HOME"])
          tmp_dir = Pathname.new(has_home ? "~/.librarian/tmp" : "/tmp/librarian").expand_path
          enclosing = tmp_dir.join("chef/integration/knife/install")
          enclosing.mkpath unless enclosing.exist?
          dir = enclosing.join(SecureRandom.hex(16))
          dir.mkpath
          at_exit { dir.rmtree }
          dir
        end
      end
    end

    def environment
      @environment ||= environment_class.new
    end

    def install_path
      environment.install_path
    end

    hl = HighLine.new

    begin
      Action::Install.new(environment).run
    rescue Error => e
      message = hl.color(e.message, HighLine::RED)
      hl.say(message)
      Process.exit!(1)
    end

  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
librarian-chef-0.0.4 lib/librarian/chef/integration/knife.rb
librarian-chef-0.0.3 lib/librarian/chef/integration/knife.rb
librarian-chef-0.0.2 lib/librarian/chef/integration/knife.rb
librarian-chef-0.0.1 lib/librarian/chef/integration/knife.rb
librarian-chef-0.0.1.beta.2 lib/librarian/chef/integration/knife.rb
librarian-chef-0.0.1.beta.1 lib/librarian/chef/integration/knife.rb
librarian-puppet-lmco-0.9.8.2 vendor/librarian/lib/librarian/chef/integration/knife.rb
librarian-0.0.26 lib/librarian/chef/integration/knife.rb
librarian-0.0.25 lib/librarian/chef/integration/knife.rb