lib/teuton/project/readme/readme.rb in teuton-2.1.8 vs lib/teuton/project/readme/readme.rb in teuton-2.1.9
- old
+ new
@@ -29,10 +29,14 @@
# Creates README.md file from RB script file
class Readme
attr_reader :result
attr_reader :data
+ ##
+ # Initialize Readme instance
+ # @param script_path (String) Path to main rb file (start.rb)
+ # @param config_path (String) Path to main config file (config.yaml)
def initialize(script_path, config_path)
@path = {}
@path[:script] = script_path
@path[:dirname] = File.dirname(script_path)
@path[:filename] = File.basename(script_path, '.rb')
@@ -74,43 +78,21 @@
show_head
show_content
show_tail
end
- def show_content
- @data[:groups].each do |group|
- next if group[:actions].empty?
-
- puts "\n## #{group[:name]}\n\n"
- group[:readme].each { |line| puts "#{line}\n" }
- previous_host = nil
- group[:actions].each_with_index do |item, index|
- if item[:host].nil? && index.positive?
- item[:host] = group[:actions][0][:host]
- end
- if previous_host.nil? || item[:host] != previous_host
- previous_host = item[:host] || 'null'
- puts format(Lang::get(:goto), previous_host.upcase)
- end
-
- weight = ''
- weight = "(x#{item[:weight]}) " if item[:weight] != 1.0
- puts "* #{weight}#{item[:target]}"
- item[:readme].each { |line| puts " * #{line}\n" }
- end
- end
- end
-
+ ##
+ # Show README head
def show_head
app = Application.instance
puts '```'
puts format(Lang::get(:testname), app.test_name)
puts format(Lang::get(:date), Time.now)
puts format(Lang::get(:version), Application::VERSION)
puts '```'
- puts "\n---\n"
- puts "# README.md\n"
+ puts "\n"
+ puts "# #{app.test_name}\n"
i = 1
unless @required_hosts.empty?
puts Lang::get(:hosts)
puts "\n"
@@ -133,9 +115,38 @@
puts "> * Teuton software must known this information!"
puts "> * Save every ':param: value' into config file."
end
end
+ ##
+ # Show README content
+ def show_content
+ @data[:groups].each do |group|
+ next if group[:actions].empty?
+
+ puts "\n## #{group[:name].capitalize}\n\n"
+ group[:readme].each { |line| puts "#{line}\n" }
+ previous_host = nil
+ group[:actions].each_with_index do |item, index|
+ if item[:host].nil? && index.positive?
+ item[:host] = group[:actions][0][:host]
+ end
+ if previous_host.nil? || item[:host] != previous_host
+ previous_host = item[:host] || 'null'
+ puts format(Lang::get(:goto), previous_host.upcase)
+ end
+
+ weight = ''
+ weight = "(x#{item[:weight]}) " if item[:weight] != 1.0
+ last = (item[:target].end_with?('.') ? '' : '.')
+ puts "* #{weight}#{item[:target]}#{last}"
+ item[:readme].each { |line| puts " * #{line}\n" }
+ end
+ end
+ end
+
+ ##
+ # Show README tail
def show_tail
return if @global_params.empty?
app = Application.instance
puts "\n---"