lingohub 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## lingohub ruby
2
2
 
3
+ ### Documentation
4
+
5
+ #### Retrieving resource files
6
+
7
+ This is a simple example how we retrieve our resource files from lingohub in our _local repository_.
8
+ We use the option `--locale <locale as filter>` for `translation:down` because our resource files are
9
+ stored in a folder per locale:
10
+
11
+ ``` bash
12
+ lingohub translation:down --locale 'en' --directory config/locales/en --project 'lingohub' --all
13
+ lingohub translation:down --locale 'de' --directory config/locales/de --project 'lingohub' --all
14
+ ```
15
+
16
+
3
17
  ### Maintainers
4
18
 
5
19
  * Markus Merzinger (https://github.com/maerzbow)
@@ -59,9 +59,9 @@ module Lingohub::Command
59
59
 
60
60
  group 'Translation Commands' do |group|
61
61
  group.command 'translation:down --all --directory <path> --project <name>', 'download all resource files'
62
+ group.command 'translation:down --locale <iso2_slug> --all --directory <path> --project <name>', 'download all resource files, using the given locale as filter'
62
63
  group.command 'translation:down <file1> <file2> ... --directory <path> --project <name>', 'download specific resource files'
63
- group.command 'translation:down <file> --query <query> --directory <path> --locale <iso2_slug> --project <name>', 'search for translations and download them to file'
64
- group.command 'translation:up <file1> <file2> ... --locale <iso2_slug> --project <name>', 'upload specific resource files'
64
+ group.command 'translation:up <file1> <file2> ... --locale <iso2_slug> --project <name>', 'upload specific resource files, a locale may be specified to tell lingohub the locale of file content'
65
65
  group.space
66
66
  end
67
67
  end
@@ -72,10 +72,12 @@ module Lingohub::Command
72
72
 
73
73
  def pull_resources(directory)
74
74
  files_source = extract_all_from_args ? project.resources.keys : args
75
+ locale_as_filter = extract_locale_from_args
76
+
75
77
  files_source.each do |file_name|
76
78
  begin
77
- project.pull_resource(directory, file_name)
78
- display("#{file_name} downloaded")
79
+ downloaded = project.pull_resource(directory, file_name, locale_as_filter)
80
+ display("#{file_name} downloaded") if downloaded
79
81
  rescue
80
82
  display "Error downloading #{file_name}. Response: #{$!.message || $!.response}"
81
83
  end
@@ -50,7 +50,7 @@ module Lingohub
50
50
  resource_hash = JSON.parse(response)
51
51
  members = resource_hash["members"]
52
52
  members.each do |member|
53
- @resources[member["name"]] = Lingohub::Models::Resource.new(@client, member["links"][0]["href"])
53
+ @resources[member["name"]] = Lingohub::Models::Resource.new(@client, member["project_locale"], member["links"][0]["href"])
54
54
  end
55
55
  end
56
56
  @resources
@@ -74,9 +74,16 @@ module Lingohub
74
74
  @collaborators
75
75
  end
76
76
 
77
- def pull_resource(directory, filename)
77
+ def pull_resource(directory, filename, locale_as_filter = nil)
78
78
  raise "Project does not contain that file." unless self.resources.has_key?(filename)
79
- save_to_file(File.join(directory, filename), self.resources[filename].content)
79
+ resource = self.resources[filename]
80
+
81
+ if locale_as_filter.nil? || resource_has_locale(resource, locale_as_filter)
82
+ save_to_file(File.join(directory, filename), resource.content)
83
+ true
84
+ else
85
+ false
86
+ end
80
87
  end
81
88
 
82
89
  def push_resource(path, locale)
@@ -129,6 +136,9 @@ module Lingohub
129
136
  File.open(path, 'w+') { |f| f.write(content) }
130
137
  end
131
138
 
139
+ def resource_has_locale(resource, locale_as_filter)
140
+ resource.locale == locale_as_filter
141
+ end
132
142
  end
133
143
  end
134
144
  end
@@ -1,8 +1,11 @@
1
1
  module Lingohub
2
2
  module Models
3
3
  class Resource
4
- def initialize(client, link)
4
+ attr_accessor :locale
5
+
6
+ def initialize(client, locale, link)
5
7
  @client = client
8
+ @locale = locale
6
9
  @link = link
7
10
  end
8
11
 
@@ -1,4 +1,4 @@
1
1
  module Lingohub
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  API_VERSION = 'v1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lingohub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-07-05 00:00:00.000000000 Z
12
+ date: 2012-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70361082811120 !ruby/object:Gem::Requirement
16
+ requirement: &70336921195260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70361082811120
24
+ version_requirements: *70336921195260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: launchy
27
- requirement: &70361082810620 !ruby/object:Gem::Requirement
27
+ requirement: &70336921194760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70361082810620
35
+ version_requirements: *70336921194760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: stringex
38
- requirement: &70361082810160 !ruby/object:Gem::Requirement
38
+ requirement: &70336921194300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.3.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70361082810160
46
+ version_requirements: *70336921194300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70361082809700 !ruby/object:Gem::Requirement
49
+ requirement: &70336921193840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70361082809700
57
+ version_requirements: *70336921193840
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70361082809240 !ruby/object:Gem::Requirement
60
+ requirement: &70336921193380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.8.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70361082809240
68
+ version_requirements: *70336921193380
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakefs
71
- requirement: &70361082808780 !ruby/object:Gem::Requirement
71
+ requirement: &70336921192920 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.4.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70361082808780
79
+ version_requirements: *70336921192920
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: taps
82
- requirement: &70361082808320 !ruby/object:Gem::Requirement
82
+ requirement: &70336921192460 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.3.23
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70361082808320
90
+ version_requirements: *70336921192460
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &70361082807860 !ruby/object:Gem::Requirement
93
+ requirement: &70336921192000 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.8.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70361082807860
101
+ version_requirements: *70336921192000
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: i18n
104
- requirement: &70361082807400 !ruby/object:Gem::Requirement
104
+ requirement: &70336921191540 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.6.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70361082807400
112
+ version_requirements: *70336921191540
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: vcr
115
- requirement: &70361082806940 !ruby/object:Gem::Requirement
115
+ requirement: &70336921191080 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: 2.0.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70361082806940
123
+ version_requirements: *70336921191080
124
124
  description: Client library and command-line tool to translate Ruby based apps with
125
125
  lingohub.
126
126
  email:
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: 3497422470760374720
173
+ hash: -3287970018099107805
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
176
  requirements:
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: 3497422470760374720
182
+ hash: -3287970018099107805
183
183
  requirements: []
184
184
  rubyforge_project:
185
185
  rubygems_version: 1.8.17