Skip to content

Commit

Permalink
chore: remove openstruct references (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaglock authored Oct 11, 2024
1 parent 9d38c83 commit a6561b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js_from_routes/lib/js_from_routes/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ def initialize(root)
end
end

class TemplateConfig
attr_reader :cache_key, :filename, :helpers

def initialize(cache_key:, filename:, helpers: nil)
@cache_key = cache_key
@filename = filename
@helpers = helpers
end
end

class << self
# Public: Configuration of the code generator.
def config
Expand Down Expand Up @@ -187,12 +197,12 @@ def generate_file_for_all(routes)
preferred_extension = File.extname(config.file_suffix)
index_file = (config.all_helpers_file == true) ? "index#{preferred_extension}" : config.all_helpers_file

Template.new(config.template_all_path).write_if_changed OpenStruct.new(
Template.new(config.template_all_path).write_if_changed TemplateConfig.new(
cache_key: routes.map(&:import_filename).join + File.read(config.template_all_path),
filename: config.output_folder.join("all#{preferred_extension}"),
helpers: routes,
)
Template.new(config.template_index_path).write_if_changed OpenStruct.new(
Template.new(config.template_index_path).write_if_changed TemplateConfig.new(
cache_key: File.read(config.template_index_path),
filename: config.output_folder.join(index_file),
)
Expand Down

0 comments on commit a6561b2

Please sign in to comment.