web_translate_it 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/history.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Version 2.0.6 / 2012-03-11
2
+
3
+ * Remove dependency on JSON. We use `multi_json` instead so wti should now be easier to install.
4
+ (it previously required a C compiler to install).
5
+
1
6
  ## Version 2.0.5 / 2012-02-22
2
7
 
3
8
  * New: Add ability to pass a file path in `wti push`: `wti push path/to/file`. #90.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  module WebTranslateIt
3
3
  class String
4
- require 'json'
4
+ require 'multi_json'
5
5
 
6
6
  attr_accessor :id, :key, :plural, :type, :dev_comment, :word_count, :status, :category, :labels, :file,
7
7
  :created_at, :updated_at, :translations, :new_record
@@ -254,7 +254,7 @@ module WebTranslateIt
254
254
  hash["translations"].push(translation.to_hash)
255
255
  end
256
256
  end
257
- hash.to_json
257
+ MultiJson.dump(hash)
258
258
  end
259
259
  end
260
260
  end
@@ -2,7 +2,7 @@
2
2
  module WebTranslateIt
3
3
  class Term
4
4
  require 'net/https'
5
- require 'json'
5
+ require 'multi_json'
6
6
 
7
7
  attr_accessor :id, :text, :description, :created_at, :updated_at, :translations, :new_record
8
8
 
@@ -240,7 +240,7 @@ module WebTranslateIt
240
240
  hash["translations"].push(translation.to_hash)
241
241
  end
242
242
  end
243
- hash.to_json
243
+ MultiJson.dump(hash)
244
244
  end
245
245
  end
246
246
  end
@@ -2,7 +2,7 @@
2
2
  module WebTranslateIt
3
3
  class TermTranslation
4
4
  require 'net/https'
5
- require 'json'
5
+ require 'multi_json'
6
6
 
7
7
  attr_accessor :id, :locale, :text, :description, :status, :new_record, :term_id
8
8
 
@@ -49,6 +49,10 @@ module WebTranslateIt
49
49
  "status" => status
50
50
  }
51
51
  end
52
+
53
+ def to_json
54
+ MultiJson.dump(self.to_hash)
55
+ end
52
56
 
53
57
  protected
54
58
 
@@ -58,7 +62,7 @@ module WebTranslateIt
58
62
  request.add_field("X-Client-Version", WebTranslateIt::Util.version)
59
63
  request.add_field("Content-Type", "application/json")
60
64
 
61
- request.body = self.to_hash.to_json
65
+ request.body = self.to_json
62
66
 
63
67
  begin
64
68
  response = YAML.load(Util.handle_response(Connection.http_connection.request(request), true, true))
@@ -79,7 +83,7 @@ module WebTranslateIt
79
83
  request.add_field("X-Client-Version", WebTranslateIt::Util.version)
80
84
  request.add_field("Content-Type", "application/json")
81
85
 
82
- request.body = self.to_hash.to_json
86
+ request.body = self.to_json
83
87
 
84
88
  begin
85
89
  Util.handle_response(Connection.http_connection.request(request), true, true)
@@ -2,7 +2,7 @@
2
2
  module WebTranslateIt
3
3
  class Translation
4
4
  require 'net/https'
5
- require 'json'
5
+ require 'multi_json'
6
6
 
7
7
  attr_accessor :id, :locale, :text, :status, :created_at, :updated_at, :version, :string_id
8
8
 
@@ -46,7 +46,7 @@ module WebTranslateIt
46
46
  request.add_field("X-Client-Name", "web_translate_it")
47
47
  request.add_field("X-Client-Version", WebTranslateIt::Util.version)
48
48
  request.add_field("Content-Type", "application/json")
49
- request.body = self.to_hash.to_json
49
+ request.body = self.to_json
50
50
 
51
51
  begin
52
52
  Util.handle_response(Connection.http_connection.request(request), true, true)
@@ -64,5 +64,9 @@ module WebTranslateIt
64
64
  "status" => status
65
65
  }
66
66
  end
67
+
68
+ def to_json
69
+ MultiJson.dump(self.to_hash)
70
+ end
67
71
  end
68
72
  end
@@ -4,7 +4,7 @@ module WebTranslateIt
4
4
  # A few useful functions
5
5
  class Util
6
6
 
7
- require 'json'
7
+ require 'multi_json'
8
8
 
9
9
  # Return a string representing the gem version
10
10
  # For example "1.8.3"
@@ -20,9 +20,9 @@ module WebTranslateIt
20
20
  def self.handle_response(response, return_response = false, raise_exception = false)
21
21
  if response.code.to_i >= 400 and response.code.to_i < 500
22
22
  if raise_exception
23
- raise "Error: #{JSON.parse(response.body)['error']}"
23
+ raise "Error: #{MultiJson.load(response.body)['error']}"
24
24
  else
25
- StringUtil.failure(JSON.parse(response.body)['error'])
25
+ StringUtil.failure(MultiJson.load(response.body)['error'])
26
26
  end
27
27
  elsif response.code.to_i == 500
28
28
  if raise_exception
data/readme.md CHANGED
@@ -22,8 +22,6 @@ An external library, [web_translate_it_server](https://github.com/AtelierConvivi
22
22
 
23
23
  ## Installation
24
24
 
25
- `wti` requires `json`, a library that needs gcc, so you will need to have a gcc compile. With Linux, `apt-get install build-essential` or `yum install gcc` should do it. On Mac OS X, install Xcode command line tools.
26
-
27
25
  You will also need ruby to run `wti`. On Linux or a Mac, it’s already installed. Install [RubyInstaller](http://rubyinstaller.org/) if you’re using Windows. [See detailed installation instructions for Windows users](https://github.com/AtelierConvivialite/webtranslateit/wiki/Install-wti-on-Windows).
28
26
 
29
27
  ``` bash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_translate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
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: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post
@@ -44,7 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2.0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: json
47
+ name: multi_json
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 1.8.24
156
+ rubygems_version: 1.8.25
157
157
  signing_key:
158
158
  specification_version: 3
159
159
  summary: A CLI to sync locale files with webtranslateit.com.