Class: Staticky::Generator
- Inherits:
-
Object
- Object
- Staticky::Generator
- Defined in:
- lib/staticky/generator.rb
Defined Under Namespace
Classes: ViewContext
Instance Method Summary collapse
- #call(output_dir) ⇒ Object
-
#initialize(**kwargs) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(**kwargs) ⇒ Generator
Returns a new instance of Generator.
20 21 22 23 |
# File 'lib/staticky/generator.rb', line 20 def initialize(**kwargs) super @path = GEM_ROOT.join("site_template") end |
Instance Method Details
#call(output_dir) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/staticky/generator.rb', line 25 def call(output_dir, **) view_context = ViewContext.new(**) output_dir = Pathname(output_dir). Pathname.glob(@path.join("**/*"), File::FNM_DOTMATCH).each do |input_path| relative_path = input_path.relative_path_from(@path) output_path = output_dir.join(relative_path) build_file(input_path:, output_path:, view_context:) end end |