Class: CukePages::Site
- Inherits:
-
Object
- Object
- CukePages::Site
- Defined in:
- lib/cukepages/site.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(output_dir_path, features = []) ⇒ Site
constructor
A new instance of Site.
Constructor Details
#initialize(output_dir_path, features = []) ⇒ Site
Returns a new instance of Site.
10 11 12 13 |
# File 'lib/cukepages/site.rb', line 10 def initialize(output_dir_path, features = []) @site_dir_path = File.join(output_dir_path, "cukepages-site") @features = features end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
8 9 10 |
# File 'lib/cukepages/site.rb', line 8 def features @features end |
Instance Method Details
#generate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cukepages/site.rb', line 15 def generate copy_resources index_template_path = File.join(TEMPLATES_DIR, "index.erb") feature_template_path = File.join(TEMPLATES_DIR, "feature.erb") index_file_path = File.join(@site_dir_path, "index.html") File.open(index_file_path, "w") { |f| content = ERB.new(File.read(index_template_path)).result(binding) f.syswrite(content) } @features.each { |feature| feature_file_path = File.join(@site_dir_path, "#{feature.ref}.html") File.open(feature_file_path, "w") { |f| content = ERB.new(File.read(feature_template_path)).result(binding) f.syswrite(content) } } end |