Sha256: e45f3a95391f1dc7da6497850b8dc12dbbcc48c7e6f2558d59b40c26564e7765

Contents?: true

Size: 826 Bytes

Versions: 6

Compression:

Stored size: 826 Bytes

Contents

require 'dply/helper'
require 'fileutils'
require 'yaml'

module Dply
  class Bundle

    include Helper

    def install
      return if not gemfile_exists?
      write_config
      return if check
      cmd "bundle install -j5 --deployment"
    end

    def clean
      return if not gemfile_exists?
      write_config
      cmd "bundle clean"
    end

    private

    def write_config
      @write_config ||= begin
        h = {
          "BUNDLE_PATH" => "vendor/bundle",
          "BUNDLE_FROZEN" => "1",
          "BUNDLE_DISABLE_SHARED_GEMS" => "1"
        }
        FileUtils.mkdir_p ".bundle"
        File.open(".bundle/config", "w") { |f| f.write(YAML.dump h) }
      end
    end

    def check
      system "bundle check > /dev/null"
    end

    def gemfile_exists?
      File.exist? "Gemfile"
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dply-0.3.5 lib/dply/bundle.rb
dply-0.3.4 lib/dply/bundle.rb
dply-0.3.3 lib/dply/bundle.rb
dply-0.3.2 lib/dply/bundle.rb
dply-0.3.1 lib/dply/bundle.rb
dply-0.3.0 lib/dply/bundle.rb