Class: Licensed::Source::Bundler

Inherits:
Object
  • Object
show all
Defined in:
lib/licensed/source/bundler.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Bundler

Returns a new instance of Bundler.



7
8
9
# File 'lib/licensed/source/bundler.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#definitionObject

Build the bundler definition



32
33
34
# File 'lib/licensed/source/bundler.rb', line 32

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

#dependenciesObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/licensed/source/bundler.rb', line 19

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

#enabled?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/licensed/source/bundler.rb', line 11

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

#gemfile_pathObject

Returns the expected path to the Bundler Gemfile



42
43
44
# File 'lib/licensed/source/bundler.rb', line 42

def gemfile_path
  @config.pwd.join ::Bundler.default_gemfile.basename.to_s
end

#groupsObject

Returns the bundle definition groups, excluding test and development



37
38
39
# File 'lib/licensed/source/bundler.rb', line 37

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

#lockfile_pathObject

Returns the expected path to the Bundler Gemfile.lock



47
48
49
# File 'lib/licensed/source/bundler.rb', line 47

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

#typeObject



15
16
17
# File 'lib/licensed/source/bundler.rb', line 15

def type
  "rubygem"
end