Class: Chisel::Wrapper
- Inherits:
-
Object
- Object
- Chisel::Wrapper
- Defined in:
- lib/chisel/wrapper.rb
Instance Attribute Summary collapse
-
#site_dir ⇒ Object
Returns the value of attribute site_dir.
Instance Method Summary collapse
-
#initialize(site_dir) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #run(dir = @site_dir) ⇒ Object
Constructor Details
#initialize(site_dir) ⇒ Wrapper
Returns a new instance of Wrapper.
17 18 19 20 |
# File 'lib/chisel/wrapper.rb', line 17 def initialize(site_dir) @site_dir = SiteDirectory.new(site_dir) require_rb(@site_dir.resource_dir) end |
Instance Attribute Details
#site_dir ⇒ Object
Returns the value of attribute site_dir.
15 16 17 |
# File 'lib/chisel/wrapper.rb', line 15 def site_dir @site_dir end |
Instance Method Details
#run(dir = @site_dir) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chisel/wrapper.rb', line 22 def run(dir = @site_dir) @site_dir.clear_output_dir # Get all views in the root site directory as well # as any subdirectories (recursive). Don't include # any files or folders beginning with an underscore. view_paths = Pathname.glob(@site_dir.join('[^_]*.*')) view_paths += Pathname.glob(@site_dir.join('[^_]**/**/*.*')) view_paths.each do |view_path| if view_path.extname == '.erb' view = View.fetch(:path => view_path, :site_dir => @site_dir) view.run else output_path = @site_dir.output_dir.join(view_path) output_path.dirname.mkpath FileUtils.cp(view_path, output_path) end end end |