Class: PivotalDoc::Generators::Base
- Inherits:
-
Object
- Object
- PivotalDoc::Generators::Base
- Defined in:
- lib/pivotal_doc/generators/base.rb
Constant Summary collapse
- TEMPLATE_PATH =
"#{PROJECT_ROOT}/templates"
Instance Method Summary collapse
- #absolute_path ⇒ Object
-
#initialize(sprint, options = {}) ⇒ Base
constructor
A new instance of Base.
- #output_ext ⇒ Object
- #output_file ⇒ Object
- #output_path ⇒ Object
- #render_doc(output = '') ⇒ Object
- #template ⇒ Object
- #template_name ⇒ Object
Constructor Details
#initialize(sprint, options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 |
# File 'lib/pivotal_doc/generators/base.rb', line 6 def initialize(sprint, ={}) @sprint= sprint @options= end |
Instance Method Details
#absolute_path ⇒ Object
26 27 28 |
# File 'lib/pivotal_doc/generators/base.rb', line 26 def absolute_path File.dirname(__FILE__) end |
#output_ext ⇒ Object
24 |
# File 'lib/pivotal_doc/generators/base.rb', line 24 def output_ext; '.default' end |
#output_file ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/pivotal_doc/generators/base.rb', line 15 def output_file name= @options['output_file'] unless name name=@sprint.release_name || @sprint.project_name || self.object_id.to_s name.gsub!(/\//, '') and name.gsub!(/\s/,'') end File.join(output_path, (name + output_ext)) end |
#output_path ⇒ Object
11 12 13 |
# File 'lib/pivotal_doc/generators/base.rb', line 11 def output_path @options['output_path'] || absolute_path end |
#render_doc(output = '') ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pivotal_doc/generators/base.rb', line 30 def render_doc(output='') begin # No permissions throw exception about output_path FileUtils.mkdir_p(output_path) f= File.open(self.output_file, 'w+') f.write(output) rescue Exception=>e $stdout.print(e.) $stdout.flush ensure f.close if f end end |
#template ⇒ Object
44 45 46 47 48 |
# File 'lib/pivotal_doc/generators/base.rb', line 44 def template path= File.join(TEMPLATE_PATH, template_name) raise TemplateNonExistent.new(template_name) unless File.exists?(path) @template ||= File.read(path) end |
#template_name ⇒ Object
50 51 52 |
# File 'lib/pivotal_doc/generators/base.rb', line 50 def template_name raise 'Not Implemented!' end |