Sha256: 19987d4746f13510d0ce6651f3bce4c104340130bfbfea2159b3f9c553d40278

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

module Indexer

  module Conversion

    #
    # Update Spec with a Gemfile.
    #
    # @param [nil,String,::Bundler::DSL,::Bundler::Definition]
    #   Gemfile path, Bundler::Dsl or Bundler::Definition instance.
    #
    def import_gemfile(file=nil)
      require 'bundler'

      case file
      when String
        # FIXME: Is this the correct way fot load a gemfile?
        bundle = ::Bundler::Dsl.new
        bundle.eval_gemfile(file)
      when NilClass
        bundle = ::Bundler.definition
      end

      begin
        merge!(bundle.metadata.to_h)
      rescue
      end

      bundle.dependencies.each do |d|
        add_requirement(d.name,
          :version     => d.requirement.to_s,  # may need to parse this
          :groups      => d.groups,
          :development => (d.type == :development)
          #:engines    => d.platforms ?
          #:platforms  => ?
        )
      end
    end

    alias_method :gemfile, :import_gemfile

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
indexer-0.2.0 lib/indexer/conversion/gemfile.rb
indexer-0.1.0 lib/indexer/conversion/gemfile.rb