Class: Laborantin::Commands::Describe
Constant Summary
collapse
- FORMATS =
['default', 'txt', 'html']
- HTML_TPL =
<<ERB
<html>
<head>
</head>
<body>
<h1>Laborantin's description</h1>
<p>Project located at: <%= runner.root_dir %> </p>
<h2>List of environments</h2>
<ul>
<% Environment.all.each do |env| %>
<li><%= env.name %>
(<%= env.description %>)
</li>
<% end %>
</ul>
<h2>List of scenarios</h2>
<ul>
<% Scenario.all.each do |sc| %>
<li><%= sc.name %>
(<%= sc.description %>)
<ul>
<% sc.parameters.each_pair do |name, spec| %>
<li><%= name %></li>
<ul>
<li><%= spec.description %></li>
<li><%= spec.values.inspect %></li>
</ul>
<% end %>
</ul>
</li>
<% end %>
</ul>
<h2>List of analyses</h2>
<ul>
<% Analysis.all.each do |a| %>
<li><%= a.name %>
(<%= a.description %>)
<ul>
<% a.analyses.each do |hash| %>
<li>
<%= hash[:str] %>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>
</body>
</html>
ERB
- TXT_TPL =
<<ERB
Available environments:
<% Environment.all.each do |env| %>
* <%= env.name %> (<%= env.description %>)
<% end %>
Available scenarios:
<% Scenario.all.each do |sc| %>
* <%= sc.name %> (<%= sc.description %>)
<% sc.parameters.each_pair do |name, spec| %>
+ <%= name %> (<%= spec.description %>) | <%= spec.values.inspect %>
<% end %>
<% end %>
Available analyses:
<% Analysis.all.each do |a| %>
* <%= a.name %> (<%= a.description %>)
<% a.analyses.each do |hash| %>
<% if hash[:params][:type] %>
+ <%= hash[:str] %> (<%= hash[:params][:type] %>)
<% else %>
+ <%= hash[:str] %>
<% end %>
<% end %>
<% end %>
ERB
Instance Attribute Summary
#args, #opts, #runner
#completion_block
Instance Method Summary
collapse
describe, each, execute, inherited, #initialize, option, plumbery!, plumbery?, porcelain?, #puts, #run
#complete, #completion_propositions_iterating_on
Instance Method Details
#analyses ⇒ Object
106
107
108
|
# File 'lib/laborantin/runner/commands/describe.rb', line 106
def analyses
Analysis.all
end
|
#close_out ⇒ Object
94
95
96
|
# File 'lib/laborantin/runner/commands/describe.rb', line 94
def close_out
@out.close unless stdout?
end
|
#environments ⇒ Object
98
99
100
|
# File 'lib/laborantin/runner/commands/describe.rb', line 98
def environments
Environment.all
end
|
197
198
199
200
201
202
203
204
|
# File 'lib/laborantin/runner/commands/describe.rb', line 197
def format_str
case opts[:format]
when 'html'
html_format
else
default_format
end
end
|
187
188
189
|
# File 'lib/laborantin/runner/commands/describe.rb', line 187
def html_format
ERB.new(HTML_TPL).result(binding)
end
|
#out ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/laborantin/runner/commands/describe.rb', line 86
def out
@out ||= if stdout?
self else
File.open(opts[:output], 'w')
end
end
|
#scenarii ⇒ Object
102
103
104
|
# File 'lib/laborantin/runner/commands/describe.rb', line 102
def scenarii
Scenario.all
end
|
#stdout? ⇒ Boolean
82
83
84
|
# File 'lib/laborantin/runner/commands/describe.rb', line 82
def stdout?
opts[:output].empty?
end
|
191
192
193
|
# File 'lib/laborantin/runner/commands/describe.rb', line 191
def txt_format
ERB.new(TXT_TPL).result(binding).lines.reject{|l| l =~/^\s*$/}.join
end
|