Sha256: a950846ebae3e95b659e7dcda407533c8d2f6a6bbd5835de7625316c4153060e
Contents?: true
Size: 1.08 KB
Versions: 11
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require "refinements/struct" module Hanamismith module Builders module Rack # Builds project skeleton. class Attack using Refinements::Struct def self.call(...) = new(...).call def initialize configuration, builder: Rubysmith::Builder @configuration = configuration @builder = builder end def call add_configuration add_middleware configuration end private attr_reader :configuration, :builder def add_configuration template_path = "%project_name%/config/initializers/rack_attack.rb.erb" builder.call(configuration.merge(template_path:)).render end def add_middleware builder.call(configuration.merge(template_path: "%project_name%/config/app.rb.erb")) .insert_after(/require/, %(\nrequire_relative "initializers/rack_attack"\n)) .insert_before(/environment/, " config.middleware.use Rack::Attack\n\n") end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems