Sha256: 53485517dfa690de8d5b9c090fd9f1311755dde71e538145c6789561a0fb7186

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

class GlobalizeApp

  def initialize(request_host)
    @request_host = request_host
  end

  def updated_translations_available?
    # TODO fetch_translations and sha1 compare them with database stored sha1 of previously fetched translations
    true
  end

  # returns a Hash with translations: { "en" => { "intro" => "Introduction" } }
  def fetch_translations
    resp = HTTParty.get(translations_uri)
    if resp.response.is_a?(Net::HTTPOK)
      resp.parsed_response
    else
      {}
    end
  end

  private

  def globalize_host
    Rails.env.production? ? "globalize.exvo.com" : "globalize.exvo.co"
  end

  def translations_uri
    "http://#{globalize_host}/translations.json?host=#{@request_host}"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exvo_globalize-0.1.0 lib/exvo_globalize/globalize_app.rb