Sha256: 0f97619c3aef12c657f8a12f9a328c04c1f4adfc4eb7609dee5bc0745f9f2de4

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true

module Hoboken
  # Custom actions.
  #
  module Actions
    def gem(name, opts={})
      verbose = opts.key?(:verbose) ? opts.delete(:verbose) : true
      version = opts.key?(:version) ? opts.delete(:version) : nil

      parts = ["'#{name}'"]
      parts << "'~> #{version}'" unless version.nil? || version.empty?
      opts.each { |k, v| parts << "#{k}: #{v.inspect}" }
      append_file('Gemfile', "gem #{parts.join(', ')}\n", verbose: verbose)
    end

    def indent(text, num_spaces)
      text.gsub(/^/, 1.upto(num_spaces).map { |_| ' ' }.join)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hoboken-0.10.0 lib/hoboken/actions.rb
hoboken-0.9.0 lib/hoboken/actions.rb