Class: Behaviors::ReportTask
- Inherits:
-
TaskLib
- Object
- TaskLib
- Behaviors::ReportTask
- Defined in:
- lib/bloggit/tasks/specs.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#html_dir ⇒ Object
Returns the value of attribute html_dir.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#src_dir ⇒ Object
Returns the value of attribute src_dir.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :behaviors) {|_self| ... } ⇒ ReportTask
constructor
A new instance of ReportTask.
Constructor Details
#initialize(name = :behaviors) {|_self| ... } ⇒ ReportTask
Returns a new instance of ReportTask.
12 13 14 15 16 17 18 |
# File 'lib/bloggit/tasks/specs.rb', line 12 def initialize(name=:behaviors) @name = name @html_dir = 'doc' @src_dir = 'doc' yield self if block_given? define end |
Instance Attribute Details
#html_dir ⇒ Object
Returns the value of attribute html_dir.
9 10 11 |
# File 'lib/bloggit/tasks/specs.rb', line 9 def html_dir @html_dir end |
#pattern ⇒ Object
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/bloggit/tasks/specs.rb', line 8 def pattern @pattern end |
#src_dir ⇒ Object
Returns the value of attribute src_dir.
10 11 12 |
# File 'lib/bloggit/tasks/specs.rb', line 10 def src_dir @src_dir end |
Instance Method Details
#define ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/bloggit/tasks/specs.rb', line 20 def define desc "List behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)" task @name do specifications.each do |spec| puts "#{spec.name} should:\n" spec.requirements.each do |req| puts " - #{req}" end end end desc "Generate html report of behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)" task "#{@name}_html" do require 'erb' txt =<<-EOS <html><head> <style> div.title { width: 600px; font: bold 14pt trebuchet ms; } div.specification { font: bold 12pt trebuchet ms; border: solid 1px black; width: 600px; padding: 5px; margin: 5px; } ul.requirements { font: normal 11pt verdana; padding-left: 0; margin-left: 0; border-bottom: 1px solid gray; width: 600px; } ul.requirements li { list-style: none; margin: 0; padding: 0.25em; border-top: 1px solid gray; } </style> </head> <body> <div class="title">Specifications</div> <% specifications.each do |spec| %> <div class="specification"> <%= spec.name %> should: <ul class="requirements"> <% spec.requirements.each do |req| %> <li><%= req %></li> <% end %> </ul> </div> <% end %> </body> </html> EOS output_dir = File.(@html_dir) mkdir_p output_dir output_filename = output_dir + "/behaviors.html" File.open(output_filename,"w") do |f| f.write ERB.new(txt).result(binding) end puts "(Wrote #{output_filename})" end task "#{@name}_src" do require 'erb' txt =<<-EOS <% specifications.each do |spec| %> ## <%= spec.name %> should: <% spec.requirements.each do |req| %> * <%= req %><% end %> <% end %> EOS output_dir = File.(@src_dir) mkdir_p output_dir output_filename = output_dir + "/specifications.markdown" File.open(output_filename,"w") do |f| f.write ERB.new(txt).result(binding) end puts "(Wrote #{output_filename})" end end |