Class: Ossy::CLI::Changelogs::Generate
- Inherits:
-
Ossy::CLI::Commands::Core
- Object
- Dry::CLI::Command
- Ossy::CLI::Commands::Core
- Ossy::CLI::Changelogs::Generate
- Defined in:
- lib/ossy/cli/changelogs/generate.rb
Defined Under Namespace
Classes: Context
Instance Method Summary collapse
Instance Method Details
#call(config_path:, output_path:, template_path:, data_path: nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ossy/cli/changelogs/generate.rb', line 34 def call(config_path:, output_path:, template_path:, data_path: nil) puts "Generating #{output_path} from #{config_path} using #{template_path}" ctx_data = YAML.load_file(config_path, permitted_classes: [Date]) template = Tilt.new(template_path) context = Context.new(ctx_data) if data_path key = File.basename(data_path).gsub(".yml", "") data = YAML.load_file(data_path, permitted_classes: [Date]) context.update(key => OpenStruct.new(data)) end output = template.render(context) File.write(output_path, "#{output.strip}\n") end |