Class: Envandle::Elements::Gemfile
Defined Under Namespace
Classes: Dsl
Constant Summary
collapse
- DUMP =
ENV["ENVANDLE_DUMP"].to_s
Instance Method Summary
collapse
Methods included from AsContext
extended
#<<, #children, #children_by_type, #dsl, #groups_or_default, #history_argsets, #parse_string_option, #parse_string_value, #send_to_bundler, #send_to_history
Constructor Details
#initialize(file, binding, config_dir = nil) ⇒ Gemfile
Returns a new instance of Gemfile.
18
19
20
21
22
|
# File 'lib/envandle/elements/gemfile.rb', line 18
def initialize(file, binding, config_dir = nil)
super Location.new(file, 1), nil
@bundler_binding = dumps? ? History.new : binding
@config_dir = config_dir
end
|
Instance Method Details
#bundler_receiver ⇒ Object
24
25
26
|
# File 'lib/envandle/elements/gemfile.rb', line 24
def bundler_receiver
@bundler_binding.receiver
end
|
#config_dir ⇒ Object
74
75
76
|
# File 'lib/envandle/elements/gemfile.rb', line 74
def config_dir
@config_dir ||= File.join(dir, ".envandle")
end
|
#dir ⇒ Object
70
71
72
|
# File 'lib/envandle/elements/gemfile.rb', line 70
def dir
@dir ||= File.dirname(@loc.file)
end
|
#draw(&block) ⇒ Object
32
33
34
35
36
|
# File 'lib/envandle/elements/gemfile.rb', line 32
def draw(&block)
super
exec
dump if dumps?
end
|
#dump ⇒ Object
42
43
44
45
46
|
# File 'lib/envandle/elements/gemfile.rb', line 42
def dump
dump_file do |f|
f << JSON.pretty_generate(history.argsets)
end
end
|
#dump_file(&block) ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/envandle/elements/gemfile.rb', line 48
def dump_file(&block)
case DUMP
when "1"
yield $stdout
when "2"
yield $stderr
else
File.open DUMP, "w", &block
end
end
|
#dumps? ⇒ Boolean
38
39
40
|
# File 'lib/envandle/elements/gemfile.rb', line 38
def dumps?
!DUMP.empty?
end
|
#exec ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/envandle/elements/gemfile.rb', line 59
def exec
receiver = bundler_receiver
children.each do |child|
child.send_to_bundler receiver
child.send_to_history history
end
references.left.each do |k, v|
v.to_executable_argset(Argset.new(nil)).send_to receiver
end
end
|
#gem_keys ⇒ Object
86
87
88
|
# File 'lib/envandle/elements/gemfile.rb', line 86
def gem_keys
@gem_keys ||= {}
end
|
#gemfile ⇒ Object
78
79
80
|
# File 'lib/envandle/elements/gemfile.rb', line 78
def gemfile
self
end
|
#gemspecs ⇒ Object
90
91
92
|
# File 'lib/envandle/elements/gemfile.rb', line 90
def gemspecs
@gemspecs ||= GemspecCache.new(File.join(config_dir, "cache", "gemspecs"))
end
|
#groups ⇒ Object
102
103
104
|
# File 'lib/envandle/elements/gemfile.rb', line 102
def groups
[]
end
|
#history ⇒ Object
28
29
30
|
# File 'lib/envandle/elements/gemfile.rb', line 28
def history
@history ||= History.new
end
|
#references ⇒ Object
82
83
84
|
# File 'lib/envandle/elements/gemfile.rb', line 82
def references
@references ||= ReferenceCache.new(self)
end
|
#source_urls ⇒ Object
98
99
100
|
# File 'lib/envandle/elements/gemfile.rb', line 98
def source_urls
sources.map{|i| i.url}
end
|
#sources ⇒ Object
94
95
96
|
# File 'lib/envandle/elements/gemfile.rb', line 94
def sources
children_by_type(:source)
end
|