Class: FontelloRailsConverter::FontelloApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fontello_rails_converter/fontello_api.rb

Constant Summary collapse

FONTELLO_HOST =
"http://fontello.com"

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FontelloApi

Returns a new instance of FontelloApi.



8
9
10
11
12
# File 'lib/fontello_rails_converter/fontello_api.rb', line 8

def initialize(options)
  @config_file = options[:config_file]
  @session_id = options[:fontello_session_id]
  @fontello_session_id_file = options[:fontello_session_id_file]
end

Instance Method Details

#download_zip_bodyObject



25
26
27
28
# File 'lib/fontello_rails_converter/fontello_api.rb', line 25

def download_zip_body
  response = RestClient.get "#{session_url}/get"
  response.body.force_encoding("UTF-8")
end

#new_session_from_configObject

creates a new fontello session from config.json



15
16
17
18
19
# File 'lib/fontello_rails_converter/fontello_api.rb', line 15

def new_session_from_config
  @session_id = RestClient.post FONTELLO_HOST, config: File.new(@config_file, 'rb')
  persist_session
  @session_id
end

#session_urlObject



21
22
23
# File 'lib/fontello_rails_converter/fontello_api.rb', line 21

def session_url
  "#{FONTELLO_HOST}/#{session_id}"
end