Class: Ecogem::Gemfile::Source
- Inherits:
-
Object
- Object
- Ecogem::Gemfile::Source
- Defined in:
- lib/ecogem/gemfile/source.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
Instance Method Summary collapse
- #code ⇒ Object
- #git? ⇒ Boolean
- #git_source ⇒ Object
- #git_uri ⇒ Object
-
#initialize(dependency, data) ⇒ Source
constructor
A new instance of Source.
- #path ⇒ Object
- #path? ⇒ Boolean
- #path_source ⇒ Object
- #ref ⇒ Object
- #relative_path ⇒ Object
- #source ⇒ Object
- #source? ⇒ Boolean
Constructor Details
#initialize(dependency, data) ⇒ Source
Returns a new instance of Source.
9 10 11 12 |
# File 'lib/ecogem/gemfile/source.rb', line 9 def initialize(dependency, data) @dependency = dependency @data = data end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
7 8 9 |
# File 'lib/ecogem/gemfile/source.rb', line 7 def git @git end |
Instance Method Details
#code ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# 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? ⇒ Boolean
14 15 16 |
# File 'lib/ecogem/gemfile/source.rb', line 14 def git? @data && @data..key?('git') end |
#git_source ⇒ Object
46 47 48 |
# File 'lib/ecogem/gemfile/source.rb', line 46 def git_source @git_source ||= ::Ecogem::Git.new(git_uri, ref) end |
#git_uri ⇒ Object
26 27 28 |
# File 'lib/ecogem/gemfile/source.rb', line 26 def git_uri @data.['git'] end |
#path ⇒ Object
30 31 32 |
# File 'lib/ecogem/gemfile/source.rb', line 30 def path @path ||= ::File.(@data.['path'].to_s, @dependency.gemfile.dir) end |
#path? ⇒ Boolean
18 19 20 |
# File 'lib/ecogem/gemfile/source.rb', line 18 def path? @data && @data..key?('path') end |
#path_source ⇒ Object
50 51 52 |
# File 'lib/ecogem/gemfile/source.rb', line 50 def path_source @path_source ||= ::Ecogem::Path.new(path) end |
#ref ⇒ Object
42 43 44 |
# File 'lib/ecogem/gemfile/source.rb', line 42 def ref @data.ref end |
#relative_path ⇒ Object
34 35 36 |
# 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 ⇒ Object
38 39 40 |
# File 'lib/ecogem/gemfile/source.rb', line 38 def source @data.['remotes'][0] end |
#source? ⇒ Boolean
22 23 24 |
# File 'lib/ecogem/gemfile/source.rb', line 22 def source? @data && @data..key?('remotes') end |