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.



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

def initialize(config)
  @config = config
end

Instance Method Details

#definitionObject

Build the bundler definition



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

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

#dependenciesObject



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

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)


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

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

#gemfile_pathObject



39
40
41
# File 'lib/licensed/source/bundler.rb', line 39

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

#groupsObject



35
36
37
# File 'lib/licensed/source/bundler.rb', line 35

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

#lockfile_pathObject



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

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

#typeObject



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

def type
  "rubygem"
end