Sha256: f2f083eec3a0a71d0e974f6d3e23d1b42c89c6964d3f493f1ce5cd7780824ee1

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

# Utility methods.

# The Katapult::Util module is used inside the `katapult` script. It should not
# require any gems in order to prevent version conflicts.
require_relative '../katapult'
require 'bundler'

module Katapult
  module BinaryUtil
    extend self

    def git_commit(message, options = nil)
      message.gsub! /'/, "" # remove single quotes
      system "git add --all; git commit -m '#{ message }' --author='katapult <katapult@makandra.com>' #{ options }"
    end

    def create_rails_app(name)
      run "rails _#{ Katapult::RAILS_VERSION }_ new #{ name } --skip-test-unit --skip-bundle --database postgresql"
    end

    def puts(*args)
      message = "\n> #{ args.join ' ' }"
      Kernel.puts "\e[35m#{ message }\e[0m" # pink
    end

    # With clean Bundler env
    def run(command)
      success = Bundler.with_clean_env { system command }

      if !success
        puts 'x Something went wrong'
        exit(1)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katapult-0.2.0 lib/katapult/binary_util.rb