Sha256: 214074032d37e2a16b29b1f8c81b54e5771e7f8014bc39d6c3c40c212e8bc96c

Contents?: true

Size: 897 Bytes

Versions: 4

Compression:

Stored size: 897 Bytes

Contents

module Kazan
  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_action_mailer_host(rails_env, host)
      config = "config.action_mailer.default_url_options = { host: #{host} }"
      configure_environment(rails_env, config)
    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

4 entries across 4 versions & 1 rubygems

Version Path
kazan-0.5.0 lib/kazan/actions.rb
kazan-0.4.0 lib/kazan/actions.rb
kazan-0.3.1 lib/kazan/actions.rb
kazan-0.3.0 lib/kazan/actions.rb