Sha256: ceb11488af5e1579307fc5b83e78ea86cecb2e6aa3e6e421248f046b26cdb532

Contents?: true

Size: 801 Bytes

Versions: 6

Compression:

Stored size: 801 Bytes

Contents

class GlobalizeApp

  attr_reader :request_host

  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? or ENV['GLOBALIZE_USE_PRODUCTION_SERVER'] == 'true' ? "globalize.exvo.com" : "globalize.exvo.co"
  end

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
exvo_globalize-0.5.3 lib/exvo_globalize/globalize_app.rb
exvo_globalize-0.5.2 lib/exvo_globalize/globalize_app.rb
exvo_globalize-0.5.1 lib/exvo_globalize/globalize_app.rb
exvo_globalize-0.5.0 lib/exvo_globalize/globalize_app.rb
exvo_globalize-0.4.0 lib/exvo_globalize/globalize_app.rb
exvo_globalize-0.3.2 lib/exvo_globalize/globalize_app.rb