Class: PivotalDoc::Generators::Base
- Inherits:
-
Object
- Object
- PivotalDoc::Generators::Base
- Defined in:
- lib/pivotal_doc/generators/base.rb
Instance Method Summary collapse
- #absolute_path ⇒ Object
-
#initialize(release, 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(release, options = {}) ⇒ Base
Returns a new instance of Base.
4 5 6 7 |
# File 'lib/pivotal_doc/generators/base.rb', line 4 def initialize(release, ={}) @release= release @options= end |
Instance Method Details
#absolute_path ⇒ Object
24 25 26 |
# File 'lib/pivotal_doc/generators/base.rb', line 24 def absolute_path File.dirname(__FILE__) end |
#output_ext ⇒ Object
22 |
# File 'lib/pivotal_doc/generators/base.rb', line 22 def output_ext; '.default' end |
#output_file ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/pivotal_doc/generators/base.rb', line 13 def output_file name= @options['output_file'] unless name name=@release.name || self.object_id.to_s name.gsub!(/\//, '') and name.gsub!(/\s/,'') end File.join(output_path, (name + output_ext)) end |
#output_path ⇒ Object
9 10 11 |
# File 'lib/pivotal_doc/generators/base.rb', line 9 def output_path @options['output_path'] || absolute_path end |
#render_doc(output = '') ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pivotal_doc/generators/base.rb', line 28 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
42 43 44 45 46 |
# File 'lib/pivotal_doc/generators/base.rb', line 42 def template path= File.join(PROJECT_ROOT, 'templates', template_name) raise TemplateNonExistent.new(template_name) unless File.exists?(path) @template ||= File.read(path) end |
#template_name ⇒ Object
48 49 50 |
# File 'lib/pivotal_doc/generators/base.rb', line 48 def template_name raise 'Not Implemented!' end |