Sha256: e7a2ac33ab7b99653d586d7fda8a85b575034d6d57ddc626cf79bbfc1fad866b
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true # The Crowdin::Client library is used for interactions with a crowdin.com website. # # == Example # # require 'crowdin-api' # # crowdin = Crowdin::Client.new do |config| # config.api_token = 'YOUR_API_TOKEN' # end # module Crowdin class Client # A wrapper and interface to the Crowdin api. Please visit the Crowdin developers # site for a full explanation of what each of the Crowdin api methods # expect and perform. # # https://support.crowdin.com/api/v2/ # include ApiResources::Languages include ApiResources::Projects include ApiResources::SourceFiles include ApiResources::Storages include ApiResources::TranslationStatus include ApiResources::Translations attr_reader :config attr_reader :options attr_reader :connection def initialize raise ArgumentError, 'block with configurations not given' unless block_given? @config = Crowdin::Configuration.new yield config check_logger set_rest_client_proxy! build_options build_connection end def log!(message) return true unless config.logger_enabled? logger.debug(message) end def logger=(logger) @logger = logger config.enable_logger = true end protected def build_options @options = config.options options[:headers] = config.headers end def build_connection @connection = ::RestClient::Resource.new(config.base_url, options) end private def set_rest_client_proxy! ENV['http_proxy'] ? ::RestClient.proxy = ENV['http_proxy'] : false end def check_logger config.enable_logger ||= false end def logger @logger ||= Logger.new($stderr) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crowdin-api-1.0.0 | lib/crowdin-api/client/client.rb |