Sha256: a4c40bbdc46ec2bf2d9dcb79ddac9eb8d5649e14bf38f31bb4cf9efe0f5b8e77

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module Pah
  module Templates
    class Gem < Pah::Template
      def call
        copy_static_file 'Gemfile'

        gsub_file 'Gemfile', /RUBY_VERSION/, ::Pah::RUBY_VERSION
        gsub_file 'Gemfile', /RAILS_VERSION/, ::Pah::RAILS_VERSION

        begin
          require 'bundler'
        rescue LoadError
          # Install bundler if needed
          unless run 'gem install bundler --no-ri --no-rdoc'
            puts 'Error installing bundler, will attempt to continue'.red
          end
          require 'bundler'
        end

        # Install all other gems needed from Gemfile
        status, output = bundle_install_with_progress
        if status != 0
          puts output
          puts 'Error installing gems, aborting'.red
          exit 1
        end

        git add: 'Gemfile*'
        git_commit 'Add Gemfile and Gemfile.lock.'
      end

      def bundle_install_with_progress
        require 'open3'
        output = ""
        status = 0
        Open3.popen3(ENV, "bundle install --jobs=4") do |stdin, stdout, stderr, wait_thr|
          while line = stdout.gets
            output += line
            print ".".green
          end
          status = wait_thr.value.to_i
        end
        puts ""
        [status, output]
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pah-0.0.28 lib/pah/templates/gems.rb
pah-0.0.27 lib/pah/templates/gems.rb
pah-0.0.26 lib/pah/templates/gems.rb
pah-0.0.25 lib/pah/templates/gems.rb
pah-0.0.24 lib/pah/templates/gems.rb
pah-0.0.23 lib/pah/templates/gems.rb
pah-0.0.22 lib/pah/templates/gems.rb
pah-0.0.21 lib/pah/templates/gems.rb