Class: FontelloRailsConverter::FontelloApi
- Inherits:
-
Object
- Object
- FontelloRailsConverter::FontelloApi
- Defined in:
- lib/fontello_rails_converter/fontello_api.rb
Constant Summary collapse
- FONTELLO_HOST =
"http://fontello.com"
Instance Method Summary collapse
- #download_zip_body ⇒ Object
-
#initialize(options) ⇒ FontelloApi
constructor
A new instance of FontelloApi.
-
#new_session_from_config ⇒ Object
creates a new fontello session from config.json.
- #session_url ⇒ Object
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() @config_file = [:config_file] @session_id = [:fontello_session_id] @fontello_session_id_file = [:fontello_session_id_file] end |
Instance Method Details
#download_zip_body ⇒ Object
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_config ⇒ Object
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_url ⇒ Object
21 22 23 |
# File 'lib/fontello_rails_converter/fontello_api.rb', line 21 def session_url "#{FONTELLO_HOST}/#{session_id}" end |