Class: Ecogem::Gemfile
- Inherits:
-
Object
show all
- Defined in:
- lib/ecogem/gemfile.rb,
lib/ecogem/gemfile/source.rb,
lib/ecogem/gemfile/marshal.rb,
lib/ecogem/gemfile/dependency.rb
Defined Under Namespace
Classes: Dependency, Marshal, Source
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Gemfile
Returns a new instance of Gemfile.
8
9
10
|
# File 'lib/ecogem/gemfile.rb', line 8
def initialize(path)
@path = path
end
|
Instance Method Details
#code ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/ecogem/gemfile.rb', line 76
def code
@code ||= begin
a = []
a << 'require "ecogem"'
a << sources.reverse.map{|i| "source #{i.inspect}"}.join("\n")
a << exported_dependencies.map{|i| i.code}.uniq.join("\n")
a.join("\n\n")
end
end
|
#dir ⇒ Object
12
13
14
|
# File 'lib/ecogem/gemfile.rb', line 12
def dir
@dir ||= ::File.dirname(@path)
end
|
#write(dir = nil, name = nil) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/ecogem/gemfile.rb', line 86
def write(dir = nil, name = nil)
dir ||= self.dir
name ||= 'Gemfile'
path = "#{dir}/#{name}"
::File.write "#{dir}/#{name}", code
path
end
|