lingohub 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lingohub/client.rb +4 -4
- data/lib/lingohub/commands/help.rb +11 -1
- data/lib/lingohub/commands/resource.rb +27 -8
- data/lib/lingohub/models/project.rb +3 -2
- data/lib/lingohub/models/resource.rb +0 -5
- data/lib/lingohub/version.rb +1 -1
- metadata +78 -55
- checksums.yaml +0 -7
data/lib/lingohub/client.rb
CHANGED
@@ -74,12 +74,12 @@ class Lingohub::Client
|
|
74
74
|
args = [method, payload, headers].compact
|
75
75
|
|
76
76
|
if credentials[:password] == nil || credentials[:password].empty?
|
77
|
-
uri = uri + "
|
77
|
+
uri = uri + ((uri.include?('?')) ? "&" : "?")
|
78
|
+
uri = uri + "auth_token=#{credentials[:username]}"
|
78
79
|
end
|
79
80
|
|
80
81
|
#puts "---- URI --- #{uri} - #{args}"
|
81
82
|
response = resource(uri, credentials).send(*args)
|
82
|
-
#puts response
|
83
83
|
|
84
84
|
response
|
85
85
|
end
|
@@ -89,9 +89,9 @@ class Lingohub::Client
|
|
89
89
|
if uri =~ /^https?/
|
90
90
|
RestClient::Resource.new(uri, :user => credentials[:username], :password => credentials[:password])
|
91
91
|
else
|
92
|
-
host_uri = host =~ /^https?/ ? "#{host}/#{api_uri_part}" : "
|
92
|
+
host_uri = host =~ /^https?/ ? "#{host}/#{api_uri_part}" : "http://#{host}/#{api_uri_part}"
|
93
93
|
|
94
|
-
|
94
|
+
#puts host_uri + "/" + uri
|
95
95
|
RestClient::Resource.new(host_uri, :user => credentials[:username], :password => credentials[:password])[uri]
|
96
96
|
end
|
97
97
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'lingohub/commands/resource'
|
2
|
+
|
1
3
|
module Lingohub::Command
|
2
4
|
class Help < Base
|
3
5
|
class HelpGroup < Array
|
@@ -62,7 +64,15 @@ module Lingohub::Command
|
|
62
64
|
group.command 'resource:down --all --directory <path> --project <name>', 'download all resource files'
|
63
65
|
group.command 'resource:down --locale <iso2_code> --all --directory <path> --project <name>', 'download all resource files, using the given locale as filter'
|
64
66
|
group.command 'resource:down <file1> <file2> ... --directory <path> --project <name>', 'download specific resource files'
|
65
|
-
|
67
|
+
|
68
|
+
up_command = 'resource:up <file1> <file2> ... --locale <iso2_code> --project <name>'
|
69
|
+
|
70
|
+
strategy_desc = ""
|
71
|
+
Lingohub::Command::Resource::EXPECTED_STRATEGY_PARAMETERS.each do |parameter|
|
72
|
+
strategy_desc << " --#{parameter} true|false"
|
73
|
+
end
|
74
|
+
|
75
|
+
group.command "resource:up <file1> <file2> ... --locale <iso2_code> --project <name> [#{strategy_desc}]", "upload specific resource files, a locale may be specified to tell lingohub the locale of file content"
|
66
76
|
group.space
|
67
77
|
end
|
68
78
|
end
|
@@ -1,5 +1,14 @@
|
|
1
1
|
module Lingohub::Command
|
2
2
|
class Resource < Base
|
3
|
+
EXPECTED_STRATEGY_PARAMETERS = [
|
4
|
+
'source:createNew',
|
5
|
+
'source:updateExisting',
|
6
|
+
'source:deactivateMissing',
|
7
|
+
'target:createNew',
|
8
|
+
'target:updateExisting',
|
9
|
+
'target:deactivateMissing',
|
10
|
+
]
|
11
|
+
|
3
12
|
def down
|
4
13
|
project #project validation
|
5
14
|
|
@@ -43,13 +52,17 @@ module Lingohub::Command
|
|
43
52
|
@locale
|
44
53
|
end
|
45
54
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
def extract_strategy_parameters
|
56
|
+
result = {}
|
57
|
+
|
58
|
+
EXPECTED_STRATEGY_PARAMETERS.each do |parameter|
|
59
|
+
value = extract_option("--#{parameter}", nil)
|
60
|
+
if value
|
61
|
+
bool_value = to_bool(value, parameter)
|
62
|
+
result.merge!({ parameter => value })
|
63
|
+
end
|
64
|
+
end
|
65
|
+
result
|
53
66
|
end
|
54
67
|
|
55
68
|
def extract_all_from_args
|
@@ -97,12 +110,18 @@ module Lingohub::Command
|
|
97
110
|
resources.each do |file_name|
|
98
111
|
begin
|
99
112
|
path = File.expand_path(file_name, Dir.pwd)
|
100
|
-
project.upload_resource(path, extract_locale_from_args,
|
113
|
+
project.upload_resource(path, extract_locale_from_args, extract_strategy_parameters)
|
101
114
|
display("#{file_name} uploaded")
|
102
115
|
rescue
|
103
116
|
display "Error uploading #{file_name}. Response: #{$!.message || $!.response}"
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
120
|
+
|
121
|
+
def to_bool(value, setting)
|
122
|
+
return true if value == true || value =~ (/(true|t|yes|y|1)$/i)
|
123
|
+
return false if value == false || value =~ (/(false|f|no|n|0)$/i)
|
124
|
+
raise ArgumentError.new("boolean value expected for setting #{setting}, but was: \"#{value}\"")
|
125
|
+
end
|
107
126
|
end
|
108
127
|
end
|
@@ -94,10 +94,11 @@ module Lingohub
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def upload_resource(path, locale,
|
97
|
+
def upload_resource(path, locale, strategy_parameters = {})
|
98
98
|
raise "Path #{path} does not exists" unless File.exists?(path)
|
99
99
|
request = { :file => File.new(path, "rb") }
|
100
|
-
request.merge!({ :iso2_slug => locale
|
100
|
+
request.merge!({ :iso2_slug => locale }) if locale
|
101
|
+
request.merge!(strategy_parameters)
|
101
102
|
@client.post(self.resources_url, request)
|
102
103
|
end
|
103
104
|
|
@@ -3,11 +3,6 @@ module Lingohub
|
|
3
3
|
class Resource
|
4
4
|
attr_accessor :locale
|
5
5
|
|
6
|
-
STRATEGY_UPDATE_AND_CREATE = 'update_and_create'
|
7
|
-
STRATEGY_MASTER_LOCALE_STRUCTURE = 'master_locale_structure'
|
8
|
-
STRATEGY_OVERRIDE ='override'
|
9
|
-
STRATEGIES = [STRATEGY_MASTER_LOCALE_STRUCTURE, STRATEGY_UPDATE_AND_CREATE, STRATEGY_OVERRIDE]
|
10
|
-
|
11
6
|
def initialize(client, locale, link)
|
12
7
|
@client = client
|
13
8
|
@locale = locale
|
data/lib/lingohub/version.rb
CHANGED
metadata
CHANGED
@@ -1,156 +1,178 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lingohub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- lingohub GmbH
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rest-client
|
15
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 1.6.7
|
20
|
-
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
21
26
|
requirements:
|
22
27
|
- - ~>
|
23
28
|
- !ruby/object:Gem::Version
|
24
29
|
version: 1.6.7
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: launchy
|
29
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 2.0.5
|
34
|
-
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
35
42
|
requirements:
|
36
43
|
- - ~>
|
37
44
|
- !ruby/object:Gem::Version
|
38
45
|
version: 2.0.5
|
39
|
-
prerelease: false
|
40
|
-
type: :runtime
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: stringex
|
43
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 1.3.2
|
48
|
-
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
49
58
|
requirements:
|
50
59
|
- - ~>
|
51
60
|
- !ruby/object:Gem::Version
|
52
61
|
version: 1.3.2
|
53
|
-
prerelease: false
|
54
|
-
type: :runtime
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rake
|
57
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: 0.9.2
|
62
|
-
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
63
74
|
requirements:
|
64
75
|
- - ~>
|
65
76
|
- !ruby/object:Gem::Version
|
66
77
|
version: 0.9.2
|
67
|
-
prerelease: false
|
68
|
-
type: :development
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rspec
|
71
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: 2.8.0
|
76
|
-
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
77
90
|
requirements:
|
78
91
|
- - ~>
|
79
92
|
- !ruby/object:Gem::Version
|
80
93
|
version: 2.8.0
|
81
|
-
prerelease: false
|
82
|
-
type: :development
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: fakefs
|
85
|
-
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ~>
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: 0.4.0
|
90
|
-
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
91
106
|
requirements:
|
92
107
|
- - ~>
|
93
108
|
- !ruby/object:Gem::Version
|
94
109
|
version: 0.4.0
|
95
|
-
prerelease: false
|
96
|
-
type: :development
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: taps
|
99
|
-
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ~>
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: 0.3.23
|
104
|
-
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
105
122
|
requirements:
|
106
123
|
- - ~>
|
107
124
|
- !ruby/object:Gem::Version
|
108
125
|
version: 0.3.23
|
109
|
-
prerelease: false
|
110
|
-
type: :development
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: webmock
|
113
|
-
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
117
133
|
version: 1.8.0
|
118
|
-
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
119
138
|
requirements:
|
120
139
|
- - ~>
|
121
140
|
- !ruby/object:Gem::Version
|
122
141
|
version: 1.8.0
|
123
|
-
prerelease: false
|
124
|
-
type: :development
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: i18n
|
127
|
-
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ~>
|
130
148
|
- !ruby/object:Gem::Version
|
131
149
|
version: 0.6.0
|
132
|
-
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
133
154
|
requirements:
|
134
155
|
- - ~>
|
135
156
|
- !ruby/object:Gem::Version
|
136
157
|
version: 0.6.0
|
137
|
-
prerelease: false
|
138
|
-
type: :development
|
139
158
|
- !ruby/object:Gem::Dependency
|
140
159
|
name: vcr
|
141
|
-
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
142
162
|
requirements:
|
143
163
|
- - ~>
|
144
164
|
- !ruby/object:Gem::Version
|
145
165
|
version: 2.0.0
|
146
|
-
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
147
170
|
requirements:
|
148
171
|
- - ~>
|
149
172
|
- !ruby/object:Gem::Version
|
150
173
|
version: 2.0.0
|
151
|
-
|
152
|
-
|
153
|
-
description: Client library and command-line tool to translate Ruby based apps with lingohub.
|
174
|
+
description: Client library and command-line tool to translate Ruby based apps with
|
175
|
+
lingohub.
|
154
176
|
email:
|
155
177
|
- team@lingohub.com
|
156
178
|
executables:
|
@@ -158,11 +180,8 @@ executables:
|
|
158
180
|
extensions: []
|
159
181
|
extra_rdoc_files: []
|
160
182
|
files:
|
161
|
-
- lib/lingohub.rb
|
162
183
|
- lib/lingohub/client.rb
|
163
184
|
- lib/lingohub/command.rb
|
164
|
-
- lib/lingohub/helpers.rb
|
165
|
-
- lib/lingohub/version.rb
|
166
185
|
- lib/lingohub/commands/auth.rb
|
167
186
|
- lib/lingohub/commands/base.rb
|
168
187
|
- lib/lingohub/commands/collaborator.rb
|
@@ -170,12 +189,15 @@ files:
|
|
170
189
|
- lib/lingohub/commands/project.rb
|
171
190
|
- lib/lingohub/commands/resource.rb
|
172
191
|
- lib/lingohub/commands/version.rb
|
192
|
+
- lib/lingohub/helpers.rb
|
173
193
|
- lib/lingohub/models/collaborator.rb
|
174
194
|
- lib/lingohub/models/project.rb
|
175
195
|
- lib/lingohub/models/projects.rb
|
176
196
|
- lib/lingohub/models/resource.rb
|
177
197
|
- lib/lingohub/models/user.rb
|
178
198
|
- lib/lingohub/rails3/railtie.rb
|
199
|
+
- lib/lingohub/version.rb
|
200
|
+
- lib/lingohub.rb
|
179
201
|
- lib/patches/rails3/i18n/i18n.rb
|
180
202
|
- lib/vendor/okjson.rb
|
181
203
|
- bin/lingohub
|
@@ -186,25 +208,26 @@ files:
|
|
186
208
|
- ROADMAP.md
|
187
209
|
homepage: https://lingohub.com
|
188
210
|
licenses: []
|
189
|
-
|
190
|
-
post_install_message:
|
211
|
+
post_install_message:
|
191
212
|
rdoc_options: []
|
192
213
|
require_paths:
|
193
214
|
- lib
|
194
215
|
required_ruby_version: !ruby/object:Gem::Requirement
|
216
|
+
none: false
|
195
217
|
requirements:
|
196
|
-
- - '>='
|
218
|
+
- - ! '>='
|
197
219
|
- !ruby/object:Gem::Version
|
198
220
|
version: '0'
|
199
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
|
+
none: false
|
200
223
|
requirements:
|
201
|
-
- - '>='
|
224
|
+
- - ! '>='
|
202
225
|
- !ruby/object:Gem::Version
|
203
226
|
version: '0'
|
204
227
|
requirements: []
|
205
|
-
rubyforge_project:
|
206
|
-
rubygems_version:
|
207
|
-
signing_key:
|
208
|
-
specification_version:
|
228
|
+
rubyforge_project:
|
229
|
+
rubygems_version: 1.8.25
|
230
|
+
signing_key:
|
231
|
+
specification_version: 3
|
209
232
|
summary: Client library and command-line tool to translate Ruby based apps with lingohub.
|
210
233
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: e24ca3dad15ab7144f747c81d47a0b96a6c0fb19
|
4
|
-
data.tar.gz: ea0f67d8c8fa418042819c5b2c78ac41e79682cc
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 8e26bc6d7d31446ccfe1b79cf44ca64640c4b4fd7edc31a011878822c870dd6b10d50dceeb9a79a87a07cc5dd7be1e13ca752940e6fcadfc714be504c4c0a6d9
|
7
|
-
data.tar.gz: 6ada2e5290e2f675e0c7b91e688fabac84e44549017cba919aedf61ecb0613399711f5ec1af46335ff4efa4415cea4015348133d361364d5d2150ea5d4ddcb2d
|