localio 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1705276b160a063b9d2ad77227318b21c33aebc4
4
- data.tar.gz: 5c98005eeaec197757a5e351295bfdc52bdd6fbf
3
+ metadata.gz: 7545745288cd1d2a90ab07b92aabeba59481e21b
4
+ data.tar.gz: fa6c825a442d45737232b8095c6d952040456c3f
5
5
  SHA512:
6
- metadata.gz: 5a7d2aab7b576e9837ca82af31eda6cddf68facbe5671a898b9414bb34fa1935927d11144a0a3f997f05740cf2f984a64a2fb4f95a2a1a1eec320a67efb86321
7
- data.tar.gz: d23402ce05638296481d68b4e0013146d486368152ae1d97c8cd30cae57561d66d1cc08657d7e9fbb6e99da68d20acd418394420f1a4e6dbd88aca70c9d2a3c2
6
+ metadata.gz: 36f73ead59451a89bd13b31a677fb5ff92ce410f1379f8c315abb0be6aaa1d8754b98573f27a02aba0915bfb578f580eaa95e60574789a27e36778604b247d3a
7
+ data.tar.gz: bb797d0d11972c9b269443b03bfee43d683e60ffbe78abb68218f2b8c816d73c7028962cc8cbdf9d243ab3affda172c6468cbd881c5af5f004faae4ce4a51e2a
data/README.md CHANGED
@@ -159,27 +159,33 @@ export CLIENT_SECRET="your_client_secret"
159
159
  ##### XLS
160
160
 
161
161
  `source :xls` will use a local XLS file. In the parameter's hash you should specify a `:path`.
162
+ You may specify a `sheet` parameter, otherwise the first sheet will be used.
162
163
 
163
164
  Option | Description
164
165
  ----------------------------|-------------------------------------------------------------------------
165
166
  `:path` | (Req.) Path for your XLS file.
167
+ `:sheet` | (Optional) Index number (starting with 0) or name of the sheet w/ the data
166
168
 
167
169
  ````ruby
168
170
  source :xls,
169
- :path => 'YourExcelFileWithTranslations.xls'
171
+ :path => 'YourExcelFileWithTranslations.xls',
172
+ :sheet => 'Master Translation Data'
170
173
  ````
171
174
 
172
175
  ##### XLSX
173
176
 
174
177
  `source :xlsx` will use a local XLSX file. In the parameter's hash you should specify a `:path`.
178
+ You may specify a `sheet` parameter, otherwise the first sheet will be used.
175
179
 
176
180
  Option | Description
177
181
  ----------------------------|-------------------------------------------------------------------------
178
182
  `:path` | (Req.) Path for your XLSX file.
183
+ `:sheet` | (Optional) Index number (starting with 0) or name of the sheet w/ the data
179
184
 
180
185
  ````ruby
181
186
  source :xlsx,
182
- :path => 'YourExcelFileWithTranslations.xlsx'
187
+ :path => 'YourExcelFileWithTranslations.xlsx',
188
+ :sheet => 'Master Translation Data'
183
189
  ````
184
190
 
185
191
  ##### CSV
@@ -43,7 +43,12 @@ class GoogleDriveProcessor
43
43
 
44
44
  access_token = nil
45
45
 
46
- if config.has? :refresh_token
46
+ if options.has_key?(:client_token)
47
+ puts 'Refreshing auth token...'
48
+ auth.refresh_token = options[:client_token]
49
+ auth.refresh!
50
+ access_token = auth.access_token
51
+ elsif config.has? :refresh_token
47
52
  puts 'Refreshing auth token...'
48
53
  auth.refresh_token = config.get :refresh_token
49
54
  auth.refresh!
@@ -56,9 +61,12 @@ class GoogleDriveProcessor
56
61
  access_token = auth.access_token
57
62
  end
58
63
 
64
+ if !options.has_key?(:client_token)
65
+ puts 'Store auth data...'
59
66
  config.store :refresh_token, auth.refresh_token
60
67
  config.store :access_token, auth.access_token
61
68
  config.persist
69
+ end
62
70
 
63
71
  # Creates a session
64
72
  session = GoogleDrive.login_with_oauth(access_token)
@@ -9,6 +9,8 @@ class XlsProcessor
9
9
  path = options[:path]
10
10
  raise ArgumentError, ':path attribute is missing from the source, and it is required for xls spreadsheets' if path.nil?
11
11
 
12
+ sheet = options[:sheet] || 0
13
+
12
14
  override_default = nil
13
15
  override_default = platform_options[:override_default] unless platform_options.nil? or platform_options[:override_default].nil?
14
16
 
@@ -16,9 +18,8 @@ class XlsProcessor
16
18
 
17
19
  book = Spreadsheet.open path
18
20
 
19
- # TODO we could pass a :page_index in the options hash and get that worksheet instead, defaulting to zero?
20
- worksheet = book.worksheet 0
21
- raise 'Unable to retrieve the first worksheet from the spreadsheet. Are there any pages?' if worksheet.nil?
21
+ worksheet = book.worksheet(sheet)
22
+ raise "Unable to retrieve the specified worksheet from the spreadsheet. Are there any pages?" if worksheet.nil?
22
23
 
23
24
  # At this point we have the worksheet, so we want to store all the key / values
24
25
  first_valid_row_index = nil
@@ -9,14 +9,20 @@ class XlsxProcessor
9
9
  path = options[:path]
10
10
  raise ArgumentError, ':path attribute is missing from the source, and it is required for xlsx spreadsheets' if path.nil?
11
11
 
12
+ sheet = options[:sheet]
13
+
12
14
  override_default = nil
13
15
  override_default = platform_options[:override_default] unless platform_options.nil? or platform_options[:override_default].nil?
14
16
 
15
17
  book = SimpleXlsxReader.open path
16
18
 
17
- # TODO we could pass a :page_index in the options hash and get that worksheet instead, defaulting to zero?
18
- worksheet = book.sheets.first
19
- raise 'Unable to retrieve the first worksheet from the spreadsheet. Are there any pages?' if worksheet.nil?
19
+ worksheet = if sheet.is_a? Integer
20
+ book.sheets[sheet]
21
+ elsif sheet.is_a? String
22
+ book.sheets.detect { |s| s.name == sheet }
23
+ end
24
+
25
+ raise 'Unable to retrieve the specified worksheet from the spreadsheet. Are there any pages?' if worksheet.nil?
20
26
 
21
27
  # At this point we have the worksheet, so we want to store all the key / values
22
28
  first_valid_row_index = nil
@@ -1,3 +1,3 @@
1
1
  module Localio
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
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
4
+ version: 0.1.6
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-09-14 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec