Sha256: 56d5fbb9971299472f1828d54c491a20f8c0b464e5e1002a0699fd6bf1e6e089

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require "bundler"

module Licensed
  module Source
    class Bundler
      def initialize(config)
        @config = config
      end

      def enabled?
        @config.enabled?(type) && File.exist?(lockfile_path)
      end

      def type
        "rubygem"
      end

      def dependencies
        @dependencies ||= definition.specs_for(groups).map do |spec|
          Dependency.new(spec.gem_dir, {
            "type"     => type,
            "name"     => spec.name,
            "version"  => spec.version.to_s,
            "summary"  => spec.summary,
            "homepage" => spec.homepage
          })
        end
      end

      # Build the bundler definition
      def definition
        @definition ||= ::Bundler::Definition.build(gemfile_path, lockfile_path, nil)
      end

      def groups
        definition.groups - [:test, :development]
      end

      def gemfile_path
        @config.pwd.join "Gemfile"
      end

      def lockfile_path
        @config.pwd.join "Gemfile.lock"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensed-0.6.0 lib/licensed/source/bundler.rb