class Ecogem::Gemfile::Source

Attributes

git[R]

Public Class Methods

new(dependency, data) click to toggle source
# File lib/ecogem/gemfile/source.rb, line 9
def initialize(dependency, data)
  @dependency = dependency
  @data = data
end

Public Instance Methods

code() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 54
def code
  @code ||= begin
    if git?
      "path: Ecogem.git_path(#{git_source.key.inspect})"
    elsif path?
      "path: #{relative_path.inspect}"
    elsif source?
      "source: #{source.inspect}"
    end
  end
end
git?() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 14
def git?
  @data && @data.options.key?('git')
end
git_source() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 46
def git_source
  @git_source ||= ::Ecogem::Git.new(git_uri, ref)
end
git_uri() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 26
def git_uri
  @data.options['git']
end
path() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 30
def path
  @path ||= ::File.expand_path(@data.options['path'].to_s, @dependency.gemfile.dir)
end
path?() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 18
def path?
  @data && @data.options.key?('path')
end
path_source() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 50
def path_source
  @path_source ||= ::Ecogem::Path.new(path)
end
ref() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 42
def ref
  @data.ref
end
relative_path() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 34
def relative_path
  @relative_path ||= ::Pathname.new(path).relative_path_from(::Pathname.new(@dependency.gemfile.dir)).to_s
end
source() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 38
def source
  @data.options['remotes'][0]
end
source?() click to toggle source
# File lib/ecogem/gemfile/source.rb, line 22
def source?
  @data && @data.options.key?('remotes')
end