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