Sha256: cceb2154d6bd83a8ca23f5bb11eb6cf813a7a5316d351cec46cefd39e44bfad1

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 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 ::Bundler.default_gemfile.basename.to_s
      end

      def lockfile_path
        @config.pwd.join ::Bundler.default_lockfile.basename.to_s
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
licensed-0.11.1 lib/licensed/source/bundler.rb
licensed-0.11.0 lib/licensed/source/bundler.rb
licensed-0.10.0 lib/licensed/source/bundler.rb