web_translate_it 1.9.4 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/history.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 1.9.5 / 2012-02-06
2
+
3
+ * Include classes to connect to [TermBase](http://docs.webtranslateit.com/api/term_base/) and [TermBase Translation](http://docs.webtranslateit.com/api/term_base_translation/) APIs.
4
+
1
5
  ## Version 1.9.4 / 2012-01-10
2
6
 
3
7
  * Bug fix: Prevent `wti` from crashing when pulling from a project having no files.
@@ -0,0 +1,99 @@
1
+ # encoding: utf-8
2
+ module WebTranslateIt
3
+ class Term
4
+ require 'net/https'
5
+
6
+ attr_accessor :id, :api_key
7
+
8
+ def initialize(id, api_key)
9
+ self.id = id
10
+ self.api_key = api_key
11
+ end
12
+
13
+ def self.list(http_connection, api_key, params = {}, options = {})
14
+ options.reverse_merge!(:format => 'yaml')
15
+
16
+ url = "/api/projects/#{api_key}/terms.#{options[:format]}"
17
+ url += '?' + HashUtil.to_param(params) unless params.blank?
18
+
19
+ request = Net::HTTP::Get.new(url)
20
+ request.add_field("X-Client-Name", "web_translate_it")
21
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
22
+
23
+ begin
24
+ Util.handle_response(http_connection.request(request), true)
25
+ rescue Timeout::Error
26
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
27
+ sleep(5)
28
+ retry
29
+ end
30
+ end
31
+
32
+ def show(http_connection, options = {})
33
+ options.reverse_merge!(:format => 'yaml')
34
+
35
+ request = Net::HTTP::Get.new("/api/projects/#{self.api_key}/terms/#{self.id}.#{options[:format]}")
36
+ request.add_field("X-Client-Name", "web_translate_it")
37
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
38
+
39
+ begin
40
+ Util.handle_response(http_connection.request(request), true)
41
+ rescue Timeout::Error
42
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
43
+ sleep(5)
44
+ retry
45
+ end
46
+ end
47
+
48
+ def update(http_connection, params = {}, options = {})
49
+ options.reverse_merge!(:format => 'yaml')
50
+
51
+ request = Net::HTTP::Put.new("/api/projects/#{self.api_key}/terms/#{self.id}.#{options[:format]}")
52
+ request.add_field("X-Client-Name", "web_translate_it")
53
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
54
+ request.add_field("Content-Type", "application/json")
55
+
56
+ request.body = params.to_json
57
+
58
+ begin
59
+ Util.handle_response(http_connection.request(request), true)
60
+ rescue Timeout::Error
61
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
62
+ sleep(5)
63
+ retry
64
+ end
65
+ end
66
+
67
+ def self.create(http_connection, api_key, params = {})
68
+ request = Net::HTTP::Post.new("/api/projects/#{api_key}/terms")
69
+ request.add_field("X-Client-Name", "web_translate_it")
70
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
71
+ request.add_field("Content-Type", "application/json")
72
+
73
+ request.body = params.to_json
74
+
75
+ begin
76
+ Util.handle_response(http_connection.request(request), true)
77
+ rescue Timeout::Error
78
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
79
+ sleep(5)
80
+ retry
81
+ end
82
+ end
83
+
84
+ def delete(http_connection)
85
+ request = Net::HTTP::Delete.new("/api/projects/#{self.api_key}/terms/#{self.id}")
86
+ request.add_field("X-Client-Name", "web_translate_it")
87
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
88
+
89
+ begin
90
+ Util.handle_response(http_connection.request(request), true)
91
+ rescue Timeout::Error
92
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
93
+ sleep(5)
94
+ retry
95
+ end
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ module WebTranslateIt
3
+ class TermTranslation
4
+ require 'net/https'
5
+
6
+ attr_accessor :id, :locale, :api_key
7
+
8
+ def initialize(id, locale, api_key)
9
+ self.id = id
10
+ self.locale = locale
11
+ self.api_key = api_key
12
+ end
13
+
14
+ def show(http_connection, options = {})
15
+ options.reverse_merge!(:format => 'yaml')
16
+
17
+ request = Net::HTTP::Get.new("/api/projects/#{self.api_key}/terms/#{self.id}/locales/#{self.locale}/translations.#{options[:format]}")
18
+ request.add_field("X-Client-Name", "web_translate_it")
19
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
20
+
21
+ begin
22
+ Util.handle_response(http_connection.request(request), true)
23
+ rescue Timeout::Error
24
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
25
+ sleep(5)
26
+ retry
27
+ end
28
+ end
29
+
30
+ def create(http_connection, params = {})
31
+ request = Net::HTTP::Post.new("/api/projects/#{self.api_key}/terms/#{self.id}/locales/#{self.locale}/translations")
32
+ request.add_field("X-Client-Name", "web_translate_it")
33
+ request.add_field("X-Client-Version", WebTranslateIt::Util.version)
34
+ request.add_field("Content-Type", "application/json")
35
+
36
+ request.body = params.to_json
37
+
38
+ begin
39
+ Util.handle_response(http_connection.request(request), true)
40
+ rescue Timeout::Error
41
+ puts "The request timed out. The service may be overloaded. We will retry in 5 seconds."
42
+ sleep(5)
43
+ retry
44
+ end
45
+ end
46
+
47
+ end
48
+ end
data/readme.md CHANGED
@@ -20,7 +20,7 @@ This gem provides:
20
20
  Installation
21
21
  ------------
22
22
 
23
- You will need ruby to run wti. On Linux or a Mac, it’s already installed. Install [RubyInstaller](http://rubyinstaller.org/) if you’re using Windows.
23
+ You will 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).
24
24
 
25
25
  gem install web_translate_it
26
26
 
data/version.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  :major: 1
2
2
  :minor: 9
3
- :patch: 4
3
+ :patch: 5
4
4
 
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: 1.9.4
4
+ version: 1.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-10 00:00:00.000000000 Z
12
+ date: 2012-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post
16
- requirement: &70272624123660 !ruby/object:Gem::Requirement
16
+ requirement: &70301933466100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70272624123660
24
+ version_requirements: *70301933466100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: trollop
27
- requirement: &70272624123040 !ruby/object:Gem::Requirement
27
+ requirement: &70301933464240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.16.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70272624123040
35
+ version_requirements: *70301933464240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70272624122420 !ruby/object:Gem::Requirement
38
+ requirement: &70301933477500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70272624122420
46
+ version_requirements: *70301933477500
47
47
  description:
48
48
  email: edouard@atelierconvivialite.com
49
49
  executables:
@@ -64,6 +64,8 @@ files:
64
64
  - lib/web_translate_it/configuration.rb
65
65
  - lib/web_translate_it/project.rb
66
66
  - lib/web_translate_it/string.rb
67
+ - lib/web_translate_it/term.rb
68
+ - lib/web_translate_it/term_translation.rb
67
69
  - lib/web_translate_it/translation.rb
68
70
  - lib/web_translate_it/translation_file.rb
69
71
  - lib/web_translate_it/util/array_util.rb
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 1.8.10
111
+ rubygems_version: 1.8.15
110
112
  signing_key:
111
113
  specification_version: 3
112
114
  summary: A CLI to sync locale files with webtranslateit.com.