Sha256: 43534295280da958f122d31bd65ff1dfd980b2dc3cd38fefd4f90a869f144b57

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

module Gemfiler
  class BundlerShim
    attr_accessor :gems, :ruby_version, :sources, :has_gemspec
    attr_reader :cabinet

    def initialize
      @gems         = []
      @sources      = []
      @ruby_version = nil
      @has_gemspec  = false
    end

    def gather(source)
      source = source.gsub /source[\s]+\:([\w_]+)/, 'source(:\\1)'
      instance_eval(source)
    end

    def gemspec?
      @has_gemspec
    end

    def gem(name, *args)
      return unless name.length > 0
      gem = {name: name}

      case args.first
      when String
        gem[:version] = args.first
      when Hash
        gem.merge! args.first
      end

      gem[:groups]    = @groups.map(&:to_s) if @groups
      gem[:platforms] = @platforms.map(&:to_s) if @platforms

      if @git
        gem[:git] = @git
        gem.merge! @git_options
      end

      if gem[:group]
        gem[:groups] ||= []
        gem[:groups] << gem.delete(:group)
      end

      @gems << gem

      gem
    end

    def gemspec
      @has_gemspec = true
    end

    def ruby(version, engine={})
      @ruby_version = {version: version}.merge(engine)
    end

    def source(source)
      @sources << source
    end

    def group(*names, &block)
      @groups = names.uniq
      self.instance_eval(&block)
      @groups = nil
    end

    def platforms(*names, &block)
      @platforms = names.uniq
      self.instance_eval(&block)
      @platforms = nil
    end

    def git(url, options={}, &block)
      @git         = url
      @git_options = options

      self.instance_eval(&block)
      
      @git         = nil
      @git_options = nil
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
gemfiler-0.1.2 lib/Gemfiler/bundler_shim.rb
gemfiler-0.1.1 lib/Gemfiler/bundler_shim.rb
gemfiler-0.1.0 lib/Gemfiler/bundler_shim.rb
gemfiler-0.0.1 lib/Gemfiler/bundler_shim.rb
Gemfiler-0.0.1 lib/Gemfiler/bundler_shim.rb