Sha256: 898ee18f76f07d2590fdcc0ca78458c1bc91233175e9d7985cc86142b77ed89b

Contents?: true

Size: 966 Bytes

Versions: 2

Compression:

Stored size: 966 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 to 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.3.1 lib/indexer/conversion/gemfile.rb
indexer-0.3.0 lib/indexer/conversion/gemfile.rb