Class: Tap::Generator::Generators::Env
- Inherits:
-
Base
- Object
- Task
- Base
- Tap::Generator::Generators::Env
show all
- Defined in:
- lib/tap/generator/generators/env.rb
Overview
:startdoc::generator generate a tapenv file
Instance Attribute Summary
Attributes inherited from Base
#prompt_in, #prompt_out
Attributes included from Helpers
#helper_registry
Instance Method Summary
collapse
Methods inherited from Base
#action, build, convert_to_spec, #directories, #directory, #file, #initialize, #iterate, #log_relative, #on, parse_as, #path, #process, #template, #template_files
Methods included from Helpers
#cache_helpers, #helpers
Instance Method Details
#gem_options ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/tap/generator/generators/env.rb', line 48
def gem_options
specs = []
gems.each do |gem_name|
gem_name =~ /\A(.*?)([\s<>=~].+)?\z/
dependency = Gem::Dependency.new($1, $2)
collect_specs(dependency, specs)
end
most_recent_specs = {}
specs.sort_by do |spec|
spec.version
end.reverse_each do |spec|
most_recent_specs[spec.name] ||= spec
end
most_recent_specs.values.collect do |spec|
pathfile = File.join(spec.full_gem_path, 'tap.yml')
map = Tap::Env::Path.load(pathfile)
map.merge!('lib' => spec.require_paths)
{
:dir => spec.full_gem_path,
:lib => 'lib',
:map => map,
:set => File.exists?(pathfile)
}
end
end
|
#manifest(m, *paths) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tap/generator/generators/env.rb', line 23
def manifest(m, *paths)
lines = []
paths.each do |path|
lines.concat Tap::Env.generate(options(path))
end
gem_options.each do |options|
lines.concat Tap::Env.generate(options)
end
lines.uniq!
if use_organize
lines = organize(lines)
end
m.file(tapenv) do |io|
lines.each {|line| io.puts line }
end
end
|
#options(path) ⇒ Object
44
45
46
|
# File 'lib/tap/generator/generators/env.rb', line 44
def options(path)
config.to_hash.merge(:dir => path)
end
|
#organize(lines) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/tap/generator/generators/env.rb', line 77
def organize(lines)
sets, everything_else = lines.partition {|line| line.index('set ') == 0 }
sets.collect! {|set| set.split(' ', 4) }
cmax = sets.collect {|set| set[1].length }.max
rmax = sets.collect {|set| set[2].length }.max
format = "%s %-#{cmax}s %-#{rmax}s %s"
sets.collect! {|set| format % set }
lines = everything_else + sets
lines.sort!
lines
end
|