Class: KnifeCookbookDoc::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- KnifeCookbookDoc::RakeTask
- Defined in:
- lib/knife_cookbook_doc/rake_task.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :knife_cookbook_doc) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(name = :knife_cookbook_doc) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
18 19 20 21 22 23 |
# File 'lib/knife_cookbook_doc/rake_task.rb', line 18 def initialize(name = :knife_cookbook_doc) @name = name @options = {} yield self if block_given? define end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/knife_cookbook_doc/rake_task.rb', line 16 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
16 17 18 |
# File 'lib/knife_cookbook_doc/rake_task.rb', line 16 def @options end |
Instance Method Details
#define ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/knife_cookbook_doc/rake_task.rb', line 25 def define last_description = ::Rake::Version::MAJOR.to_i < 12 ? ::Rake.application.last_comment : ::Rake.application.last_description desc 'Generate cookbook documentation' unless last_description task(name) do = .merge() cookbook_dir = File.realpath([:cookbook_dir]) model = ReadmeModel.new(cookbook_dir, ) template = File.read([:template_file]) eruby = Erubis::Eruby.new(template) result = eruby.result(model.get_binding) File.open("#{cookbook_dir}/#{[:output_file]}", 'wb') do |f| result.each_line do |line| f.write line.gsub(/[ \t\r\n]*$/,'') f.write "\n" end end end end |