localio 0.0.23 → 0.1.0
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 +31 -11
- data/lib/localio/processors/google_drive_processor.rb +41 -7
- data/lib/localio/version.rb +1 -1
- data/localio.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37ebfdfd8bd72c867b84d975ce1f069db365fabf
|
4
|
+
data.tar.gz: d758c6f63079a4e3ff4c7b7e1b29dfdc93932054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebb579abcb7071d11e5daac7df6d00c6ff85773908557067a0abaad63558c6cb8f15247813dc1f60581404a4c8e246ae4fdaeea99ed9e47b2a866f357f1f0ce
|
7
|
+
data.tar.gz: bd43ae7b036b857c47e8965ee4e5b0358d5162d4c3aa558d60d76f1c97a96f95e2260ffcc536621ec04744626391e8f6940901092dfdc987fa7d47aa03cad552
|
data/README.md
CHANGED
@@ -47,10 +47,8 @@ platform :ios
|
|
47
47
|
|
48
48
|
output_path 'out/'
|
49
49
|
|
50
|
-
source :
|
51
|
-
:
|
52
|
-
:login => 'your_email@gmail.com',
|
53
|
-
:password => 'your_password'
|
50
|
+
source :xlsx,
|
51
|
+
:path => 'my_translations.xlsx'
|
54
52
|
|
55
53
|
formatting :smart # This is optional, formatting :smart is used by default.
|
56
54
|
````
|
@@ -113,25 +111,47 @@ You will have to provide some required parameters too. Here is a list of all the
|
|
113
111
|
Option | Description
|
114
112
|
----------------------------|-------------------------------------------------------------------------
|
115
113
|
`:spreadsheet` | (Req.) Title of the spreadsheet you want to use. Can be a partial match.
|
116
|
-
`:login` |
|
117
|
-
`:password` |
|
114
|
+
`:login` | **DEPRECATED** This is deprecated starting version 0.1.0. Please remove it.
|
115
|
+
`:password` | **DEPRECATED** This is deprecated starting version 0.1.0. Please remove it.
|
116
|
+
`:client_id` | (Req.) Your Google CLIENT ID.
|
117
|
+
`:client_secret` | (Req.) Your Google CLIENT SECRET.
|
118
|
+
`: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.
|
119
|
+
|
120
|
+
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.
|
121
|
+
|
122
|
+
Setting it up is a bit of a pain, although it is only required the first time and can be shared by all your projects:
|
123
|
+
|
124
|
+
1. You have to create a new project in Google Developers Console for using Drive API. You can do that [here](https://console.developers.google.com/flows/enableapi?apiid=drive).
|
125
|
+
2. After it is created you will be redirected to the credentials section (if not, just select under APIs and authentication in the sidebar the Credentials section), where you will click in the button labeled **Create new client ID**.
|
126
|
+
3. Select the third option, the one that says something like **Installed Application**.
|
127
|
+
4. Fill the form with whatever you want. For example, you could put Localio as the product name (the only thing required there).
|
128
|
+
5. Select again the third option, **Installed Application**, and in the platform selector select the last one, **Others**.
|
129
|
+
6. You will have all the necessary information in the next screen: Client ID and Client Secret.
|
130
|
+
|
131
|
+
After doing all this, you are ready to add `:client_id` and `:client_secret` fields to your Locfile `source`.
|
132
|
+
|
133
|
+
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.
|
134
|
+
|
135
|
+
After all this is done, you will be given in the `:access_token` in the output. Just add it to the `source` parameters, as you did with the id and secret before, and that's it. Hopefully you won't happen to repeat any of these steps for a long time.
|
118
136
|
|
119
|
-
**NOTE** As it is a very bad practice to put your
|
137
|
+
**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.
|
120
138
|
|
121
139
|
For example, this.
|
122
140
|
|
123
141
|
````ruby
|
124
142
|
source :google_drive,
|
125
143
|
:spreadsheet => '[Localizables] My Project!',
|
126
|
-
:
|
127
|
-
:
|
144
|
+
:client_id => ENV['CLIENT_ID'],
|
145
|
+
:client_secret => ENV['CLIENT_SECRET'],
|
146
|
+
:access_token => ENV['ACCESS_TOKEN']
|
128
147
|
````
|
129
148
|
|
130
149
|
And in your .bashrc (or .bash_profile, .zshrc or whatever), you could export those environment variables like this:
|
131
150
|
|
132
151
|
````ruby
|
133
|
-
export
|
134
|
-
export
|
152
|
+
export CLIENT_ID="your_client_id"
|
153
|
+
export CLIENT_SECRET="your_client_secret"
|
154
|
+
export ACCESS_TOKEN="your_access_token"
|
135
155
|
````
|
136
156
|
|
137
157
|
##### XLS
|
@@ -8,10 +8,23 @@ class GoogleDriveProcessor
|
|
8
8
|
# Parameter validations
|
9
9
|
spreadsheet = options[:spreadsheet]
|
10
10
|
raise ArgumentError, ':spreadsheet required for Google Drive source!' if spreadsheet.nil?
|
11
|
+
|
12
|
+
# Deprecate :login & :password
|
11
13
|
login = options[:login]
|
12
|
-
raise ArgumentError, ':login
|
14
|
+
raise ArgumentError, ':login is deprecated. You should use :client_id and :client_secret for secure OAuth2 authentication.' unless login.nil?
|
13
15
|
password = options[:password]
|
14
|
-
raise ArgumentError, ':password
|
16
|
+
raise ArgumentError, ':password is deprecated. You should use :client_id and :client_secret for secure OAuth2 authentication.' unless password.nil?
|
17
|
+
|
18
|
+
# New authentication way
|
19
|
+
client_id = options[:client_id]
|
20
|
+
client_secret = options[:client_secret]
|
21
|
+
access_token = options[:access_token]
|
22
|
+
|
23
|
+
# We need client_id / client_secret if we dont have an access token
|
24
|
+
if access_token.nil?
|
25
|
+
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?
|
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
|
15
28
|
|
16
29
|
override_default = nil
|
17
30
|
override_default = platform_options[:override_default] unless platform_options.nil? or platform_options[:override_default].nil?
|
@@ -19,9 +32,30 @@ class GoogleDriveProcessor
|
|
19
32
|
# Log in and get spreadsheet
|
20
33
|
puts 'Logging in to Google Drive...'
|
21
34
|
begin
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
if access_token.nil?
|
36
|
+
puts "No :access_token found. Let\'s proceed to get one!".red
|
37
|
+
client = Google::APIClient.new application_name: 'Localio', application_version: Localio::VERSION
|
38
|
+
auth = client.authorization
|
39
|
+
auth.client_id = client_id
|
40
|
+
auth.client_secret = client_secret
|
41
|
+
auth.scope =
|
42
|
+
"https://www.googleapis.com/auth/drive " +
|
43
|
+
"https://spreadsheets.google.com/feeds/"
|
44
|
+
auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
|
45
|
+
puts "1. Open this page in your browser:\n#{auth.authorization_uri}\n\n"
|
46
|
+
puts "2. Enter the authorization code shown in the page: "
|
47
|
+
auth.code = $stdin.gets.chomp
|
48
|
+
auth.fetch_access_token!
|
49
|
+
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
|
+
end
|
54
|
+
# Creates a session
|
55
|
+
session = GoogleDrive.login_with_oauth(access_token)
|
56
|
+
rescue => e
|
57
|
+
puts "Error: #{e.inspect}"
|
58
|
+
raise 'Couldn\'t access Google Drive. Check your values for :client_id and :client_secret, and delete :access_token if present (you might need to refresh its value so please remove it)'
|
25
59
|
end
|
26
60
|
puts 'Logged in!'
|
27
61
|
|
@@ -63,8 +97,8 @@ class GoogleDriveProcessor
|
|
63
97
|
for column in 2..worksheet.max_cols
|
64
98
|
col_all = worksheet[first_valid_row_index, column]
|
65
99
|
col_all.each_line(' ') do |col_text|
|
66
|
-
default_language = col_text.downcase.gsub('*','') if col_text.include? '*'
|
67
|
-
languages.store col_text.downcase.gsub('*',''), column unless col_text.to_s == ''
|
100
|
+
default_language = col_text.downcase.gsub('*', '') if col_text.include? '*'
|
101
|
+
languages.store col_text.downcase.gsub('*', ''), column unless col_text.to_s == ''
|
68
102
|
end
|
69
103
|
end
|
70
104
|
|
data/lib/localio/version.rb
CHANGED
data/localio.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
28
|
spec.add_development_dependency "rake"
|
29
29
|
|
30
|
-
spec.add_dependency "micro-optparse", "~> 1.
|
31
|
-
spec.add_dependency "google_drive", "0.
|
30
|
+
spec.add_dependency "micro-optparse", "~> 1.2"
|
31
|
+
spec.add_dependency "google_drive", "1.0.0"
|
32
32
|
spec.add_dependency "spreadsheet", "~> 1.0"
|
33
33
|
spec.add_dependency "simple_xlsx_reader", "~> 1.0"
|
34
34
|
spec.add_dependency "nokogiri", "~> 1.6"
|
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.0
|
4
|
+
version: 0.1.0
|
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-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: google_drive
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 1.0.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 1.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: spreadsheet
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|