Sha256: c2276fba0d8c822ea42955741e892644331fe347ef66c60da3aa22143103ada4

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

module Code42Template
  module Actions
    def replace_in_file(relative_path, find, replace)
      path = File.join(destination_root, relative_path)
      contents = IO.read(path)
      unless contents.gsub!(find, replace)
        raise "#{find.inspect} not found in #{relative_path}"
      end
      File.open(path, "w") { |file| file.write(contents) }
    end

    def configure_application_file(config)
      inject_into_file(
        "config/application.rb",
        "\n\n    #{config}",
        before: "\n  end"
      )
    end

    def configure_environment(rails_env, config)
      inject_into_file(
        "config/environments/#{rails_env}.rb",
        "\n\n  #{config}",
        before: "\nend"
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
code42template-2.1.0 lib/code42template/actions.rb
code42template-2.0.0 lib/code42template/actions.rb