Sha256: 2b4de9d18f635d084594473959acd50e48052eb8b95cf5a5fe0448803f931116

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

module Armadura
  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 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

3 entries across 3 versions & 1 rubygems

Version Path
armadura-0.1.2 lib/armadura/actions.rb
armadura-0.1.1 lib/armadura/actions.rb
armadura-0.1.0 lib/armadura/actions.rb