localio 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -16
- data/lib/localio/config_store.rb +37 -0
- data/lib/localio/processors/google_drive_processor.rb +30 -21
- data/lib/localio/version.rb +1 -1
- data/localio.gemspec +13 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d642ee7edb710d0bc09402f50e601c6853d4f1d4
|
4
|
+
data.tar.gz: 242d3eccac6d02fab44194c4d541d33311fe4a41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e4d633dd7957e90545d80afe7dd0d6fe8a02e5a0d06df30ee75148a097e0786dba303e6a8dab2600b8b7b1ed1af6732f29ff17382030086949c8b43df4cafe4
|
7
|
+
data.tar.gz: 976cfba61f9a1475f9b2cc647cf478908f5cbec5c5fe0fdae44b6df04db085a997865d82bdd0f09e94d7828e936aadb15024da7db147f56b9e50af768aa605fb
|
data/README.md
CHANGED
@@ -113,7 +113,6 @@ Option | Description
|
|
113
113
|
`:password` | **DEPRECATED** This is deprecated starting version 0.1.0. Please remove it.
|
114
114
|
`:client_id` | (Req.) Your Google CLIENT ID.
|
115
115
|
`:client_secret` | (Req.) Your Google CLIENT SECRET.
|
116
|
-
`:access_token` | Your generated access token. You will get it the first time you log in and give permissions to your generated Google Developer Console application.
|
117
116
|
|
118
117
|
Please take into account that from version 0.1.0 of Localio onwards we are using **Google OAuth2 authentication**, as the previous one with login/password has been deprecated by Google and cannot be access anymore starting April 20th 2015.
|
119
118
|
|
@@ -137,19 +136,9 @@ source :google_drive,
|
|
137
136
|
|
138
137
|
Then, the first time you run it, you will be prompted to follow some instructions. You will be asked to open a website, where you will be prompted for permission to use the Drive API. After you allow it, you will be given an authorization code, which you will have to paste in your terminal screen when prompted.
|
139
138
|
|
140
|
-
|
139
|
+
**NOTE** A hidden file, called .localio.yml, will be created in your Locfile directory. You should **add that file to your ignored resources** in your repository, aka the **.gitignore** file.
|
141
140
|
|
142
|
-
|
143
|
-
source :google_drive,
|
144
|
-
:spreadsheet => '[Localizables] My Project',
|
145
|
-
:client_id => 'XXXXXXXXX-XXXXXXXX.apps.googleusercontent.com',
|
146
|
-
:client_secret => 'asdFFGGhjKlzxcvbnm',
|
147
|
-
:access_token => 'ya29.RAEXXxxxxsadsadajsdhasuidhakjsdhkajhsduiahsduiasd89a8912'
|
148
|
-
```
|
149
|
-
|
150
|
-
When the Locfile contains the `:access_token`, all the login in process for generating localizables will be automatic and won't require your attention. The parameters for `:client_id` and `:client_secret` are not really needed anymore, although you could leave them there if you want.
|
151
|
-
|
152
|
-
**NOTE** As it is a very bad practice to put your sensitive information in a plain file, specially when you would want to upload your project to some repository, it is **VERY RECOMMENDED** that you use environment variables in here. Ruby syntax is accepted so you can use `ENV['CLIENT_SECRET']`, `ENV['CLIENT_ID']` and `ENV['ACCESS_TOKEN']` in here.
|
141
|
+
**NOTE** As it is a very bad practice to put your sensitive information in a plain file, specially when you would want to upload your project to some repository, it is **VERY RECOMMENDED** that you use environment variables in here. Ruby syntax is accepted so you can use `ENV['CLIENT_SECRET']` and `ENV['CLIENT_ID']` in here.
|
153
142
|
|
154
143
|
For example, this.
|
155
144
|
|
@@ -157,8 +146,7 @@ For example, this.
|
|
157
146
|
source :google_drive,
|
158
147
|
:spreadsheet => '[Localizables] My Project!',
|
159
148
|
:client_id => ENV['CLIENT_ID'],
|
160
|
-
:client_secret => ENV['CLIENT_SECRET']
|
161
|
-
:access_token => ENV['ACCESS_TOKEN']
|
149
|
+
:client_secret => ENV['CLIENT_SECRET']
|
162
150
|
````
|
163
151
|
|
164
152
|
And in your .bashrc (or .bash_profile, .zshrc or whatever), you could export those environment variables like this:
|
@@ -166,7 +154,6 @@ And in your .bashrc (or .bash_profile, .zshrc or whatever), you could export tho
|
|
166
154
|
````ruby
|
167
155
|
export CLIENT_ID="your_client_id"
|
168
156
|
export CLIENT_SECRET="your_client_secret"
|
169
|
-
export ACCESS_TOKEN="your_access_token"
|
170
157
|
````
|
171
158
|
|
172
159
|
##### XLS
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class ConfigStore
|
2
|
+
CONFIG_FILE = '.localio.yml'
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
if File.exist? CONFIG_FILE
|
6
|
+
@config = YAML.load_file(CONFIG_FILE)
|
7
|
+
end
|
8
|
+
@config ||= Hash.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def has?(key)
|
12
|
+
@config.has_key?(clean_param key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(key)
|
16
|
+
@config[clean_param key]
|
17
|
+
end
|
18
|
+
|
19
|
+
def store(key, data)
|
20
|
+
@config[clean_param key] = data
|
21
|
+
end
|
22
|
+
|
23
|
+
def persist
|
24
|
+
File.open(CONFIG_FILE, 'w') do |h|
|
25
|
+
h.write @config.to_yaml
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def clean_param(param)
|
31
|
+
if param.is_a?(Symbol)
|
32
|
+
param.to_s
|
33
|
+
else
|
34
|
+
param
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'google_drive'
|
2
2
|
require 'localio/term'
|
3
|
+
require 'localio/config_store'
|
3
4
|
|
4
5
|
class GoogleDriveProcessor
|
5
6
|
|
6
7
|
def self.load_localizables(platform_options, options)
|
7
|
-
|
8
8
|
# Parameter validations
|
9
9
|
spreadsheet = options[:spreadsheet]
|
10
10
|
raise ArgumentError, ':spreadsheet required for Google Drive source!' if spreadsheet.nil?
|
@@ -18,13 +18,10 @@ class GoogleDriveProcessor
|
|
18
18
|
# New authentication way
|
19
19
|
client_id = options[:client_id]
|
20
20
|
client_secret = options[:client_secret]
|
21
|
-
access_token = options[:access_token]
|
22
21
|
|
23
|
-
# We need client_id / client_secret
|
24
|
-
if
|
25
|
-
|
26
|
-
raise ArgumentError, ':client_secret required for Google Drive. Check how to get it here: https://developers.google.com/drive/web/auth/web-server' if client_secret.nil?
|
27
|
-
end
|
22
|
+
# We need client_id / client_secret
|
23
|
+
raise ArgumentError, ':client_id required for Google Drive. Check how to get it here: https://developers.google.com/drive/web/auth/web-server' if client_id.nil?
|
24
|
+
raise ArgumentError, ':client_secret required for Google Drive. Check how to get it here: https://developers.google.com/drive/web/auth/web-server' if client_secret.nil?
|
28
25
|
|
29
26
|
override_default = nil
|
30
27
|
override_default = platform_options[:override_default] unless platform_options.nil? or platform_options[:override_default].nil?
|
@@ -32,25 +29,37 @@ class GoogleDriveProcessor
|
|
32
29
|
# Log in and get spreadsheet
|
33
30
|
puts 'Logging in to Google Drive...'
|
34
31
|
begin
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
client = Google::APIClient.new application_name: 'Localio', application_version: Localio::VERSION
|
33
|
+
auth = client.authorization
|
34
|
+
auth.client_id = client_id
|
35
|
+
auth.client_secret = client_secret
|
36
|
+
auth.scope =
|
37
|
+
"https://docs.google.com/feeds/" +
|
38
|
+
"https://www.googleapis.com/auth/drive " +
|
39
|
+
"https://spreadsheets.google.com/feeds/"
|
40
|
+
auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
|
41
|
+
|
42
|
+
config = ConfigStore.new
|
43
|
+
|
44
|
+
access_token = nil
|
45
|
+
|
46
|
+
if config.has? :refresh_token
|
47
|
+
puts 'Refreshing auth token...'
|
48
|
+
auth.refresh_token = config.get :refresh_token
|
49
|
+
auth.refresh!
|
50
|
+
access_token = auth.access_token
|
51
|
+
else
|
45
52
|
puts "1. Open this page in your browser:\n#{auth.authorization_uri}\n\n"
|
46
53
|
puts "2. Enter the authorization code shown in the page: "
|
47
54
|
auth.code = $stdin.gets.chomp
|
48
55
|
auth.fetch_access_token!
|
49
56
|
access_token = auth.access_token
|
50
|
-
puts '\n**IMPORTANT** You can store your access_token in the Locfile :source parameter for avoiding this step in the future:\n'
|
51
|
-
puts ":access_token => '#{access_token}'".yellow
|
52
|
-
puts '\n\n'
|
53
57
|
end
|
58
|
+
|
59
|
+
config.store :refresh_token, auth.refresh_token
|
60
|
+
config.store :access_token, auth.access_token
|
61
|
+
config.persist
|
62
|
+
|
54
63
|
# Creates a session
|
55
64
|
session = GoogleDrive.login_with_oauth(access_token)
|
56
65
|
rescue => e
|
@@ -70,7 +79,7 @@ class GoogleDriveProcessor
|
|
70
79
|
when 0
|
71
80
|
abort "Unable to find any spreadsheet matching your criteria: #{spreadsheet}"
|
72
81
|
else
|
73
|
-
abort
|
82
|
+
abort "More than one match found (#{matching_spreadsheets.join ', '}). You have to be more specific!"
|
74
83
|
end
|
75
84
|
|
76
85
|
|
data/lib/localio/version.rb
CHANGED
data/localio.gemspec
CHANGED
@@ -4,20 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'localio/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.description
|
12
|
-
spec.summary
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
7
|
+
spec.name = "localio"
|
8
|
+
spec.version = Localio::VERSION
|
9
|
+
spec.authors = ["Nacho Lopez"]
|
10
|
+
spec.email = ["nacho@nlopez.io"]
|
11
|
+
spec.description = %q{Automatic Localizable file generation for multiple platforms (Rails YAML, Android, Java Properties, iOS, JSON, .NET ResX)}
|
12
|
+
spec.summary = %q{Automatic Localizable file generation for multiple type of files, like Android string.xml, Xcode Localizable.strings, JSON files, Rails YAML files, Java properties, etc. reading from Google Drive and Excel spreadsheets as base.}
|
13
|
+
spec.homepage = "http://github.com/mrmans0n/localio"
|
14
|
+
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
21
|
spec.executables << "localize"
|
22
22
|
|
23
23
|
spec.add_development_dependency "rspec"
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
28
|
spec.add_development_dependency "rake"
|
29
|
-
|
29
|
+
|
30
30
|
spec.add_dependency "micro-optparse", "~> 1.2"
|
31
31
|
spec.add_dependency "google_drive", "1.0.0"
|
32
32
|
spec.add_dependency "spreadsheet", "~> 1.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nacho Lopez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- Rakefile
|
140
140
|
- bin/localize
|
141
141
|
- lib/localio.rb
|
142
|
+
- lib/localio/config_store.rb
|
142
143
|
- lib/localio/filter.rb
|
143
144
|
- lib/localio/formatter.rb
|
144
145
|
- lib/localio/localizable_writer.rb
|