crowdin-api 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,8 +28,10 @@ Start by creating a connection to Crowdin with your credentials:
28
28
 
29
29
  ```ruby
30
30
  require 'crowdin-api'
31
+ require 'logger'
31
32
 
32
33
  crowdin = Crowdin::API.new(:api_key => API_KEY, :project_id => PROJECT_ID, :account_key => ACCOUNT_KEY)
34
+ crowdin.log = Logger.new $stderr
33
35
  ```
34
36
 
35
37
  Now you can make requests to the api.
data/lib/crowdin-api.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'pp'
2
- require 'logger'
3
2
  require 'json'
4
3
  require 'rest-client'
5
4
 
@@ -7,13 +6,28 @@ require "crowdin-api/errors"
7
6
  require "crowdin-api/methods"
8
7
  require "crowdin-api/version"
9
8
 
10
- #log = Logger.new(STDOUT)
11
- #RestClient.log = log
12
- #log.level = Logger::DEBUG
13
9
 
10
+ # The Crowdin::API library is used for interactions with a crowdin.net website.
11
+ #
12
+ # == Example
13
+ #
14
+ # require 'crowdin-api'
15
+ # require 'logger'
16
+ #
17
+ # crowdin = Crowdin::API.new(:api_key => API_KEY, :project_id => PROJECT_ID)
18
+ # crowdin.log = Logger.new($stderr)
19
+ #
14
20
  module Crowdin
15
21
  class API
16
22
 
23
+ class << self
24
+ # Default logger for all Crowdin::API instances
25
+ #
26
+ # Crowdin::API.log = Logger.new($stderr)
27
+ #
28
+ attr_accessor :log
29
+ end
30
+
17
31
  # Create a new API object using the given parameters.
18
32
  #
19
33
  # @param [String] api_key the authentication API key can be found on the project settings page
@@ -27,6 +41,8 @@ module Crowdin
27
41
  @account_key = options.delete(:account_key)
28
42
  @base_url = options.delete(:base_url) || 'http://api.crowdin.net'
29
43
 
44
+ @log = nil
45
+
30
46
  options = {
31
47
  :headers => {},
32
48
  :params => {},
@@ -65,6 +81,9 @@ module Crowdin
65
81
  }
66
82
  end
67
83
 
84
+ log.debug("args: #{@response.args}") if log
85
+ log.debug("body: #{@response.body}") if log
86
+
68
87
  if @response.headers[:content_disposition]
69
88
  filename = params[:output] || @response.headers[:content_disposition][/attachment; filename="(.+?)"/, 1]
70
89
  body = @response.body
@@ -86,6 +105,18 @@ module Crowdin
86
105
 
87
106
  end
88
107
 
108
+ # The current logger. If no logger has been set Crowdin::API.log is used.
109
+ #
110
+ def log
111
+ @log || Crowdin::API.log
112
+ end
113
+
114
+ # Sets the +logger+ used by this instance of Crowdin::API
115
+ #
116
+ def log= logger
117
+ @log = logger
118
+ end
119
+
89
120
  private
90
121
 
91
122
  end
@@ -1,5 +1,5 @@
1
1
  module Crowdin
2
2
  class API
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client