applocale 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d8869b79798773984196bbfc33f3358f9c52e50
4
- data.tar.gz: aaab67885d67212dc783ed7be4560e3549739315
3
+ metadata.gz: ce3e7bff7b22d23d3c66bb199eae555a63229fe4
4
+ data.tar.gz: da64526dc0fa94ad7a270145a339b92e8b2a8195
5
5
  SHA512:
6
- metadata.gz: 0f6ee6f3cde1bcc235fb7cb6eefb042ad54bdb711921212f925e0f7ac978bd6066110d031b5da420ea486438dc173046b66128f3dd8d782b5941a113a93703e7
7
- data.tar.gz: 81d2a69a19d328b2b9568783d9ce436d491eb4bdf25930febebc054795dd4efb7a809736ec20779e2eeda8f273730549ec7871f1dadeae73c9c11707a7dd0cf8
6
+ metadata.gz: 1a72c2970c189ee0ac9784d5a8bb1db62011e2459ae89ca2ef77f1815a9d8e220a465cc2de5067a8fccb047428a28adc76b0f46a61d5c573a01038238a0ce6dd
7
+ data.tar.gz: fbd7a924f29f4b22f18a954557380342f81ac167eebc20fa78f72f2c82bdad0df4b3297b0f0e12e41af43ee9adf943abfe35670a0fd54492871f15a29a8d7b24
@@ -5,6 +5,7 @@ require File.expand_path('../../Core/setting.rb', __FILE__)
5
5
  require File.expand_path('../../Core/init.rb', __FILE__)
6
6
  require File.expand_path('../../Core/ParserStringFile/parse_localized_resource.rb', __FILE__)
7
7
  require File.expand_path('../../version', __FILE__)
8
+ require File.expand_path('../../Core/GoogleHepler/google_helper', __FILE__)
8
9
 
9
10
  require 'thor'
10
11
 
@@ -58,6 +59,10 @@ module Applocale
58
59
  puts Applocale::VERSION
59
60
  end
60
61
 
62
+ desc "google_logout", "logout google account"
63
+ def google_logout()
64
+ GoogleHelper.reset_loginacc
65
+ end
61
66
  end
62
67
  end
63
68
  end
@@ -27,13 +27,20 @@ module Applocale
27
27
  end
28
28
  end
29
29
 
30
+ def self.reset_loginacc
31
+ if File.exist? CREDENTIALS_PATH
32
+ File.delete(CREDENTIALS_PATH)
33
+ end
34
+ puts "Account Reseted!"
35
+ end
36
+
30
37
  def self.download_spreadsheet(spreadsheet_Id, filename)
31
38
  puts "Start download from google, fileId: #{spreadsheet_Id} ...".green
32
39
  service = Google::Apis::DriveV3::DriveService.new
33
40
  service.client_options.application_name = APPLICATION_NAME
34
41
  service.authorization = self.authorize
35
42
  begin
36
- content = service.export_file(spreadsheet_Id,
43
+ service.export_file(spreadsheet_Id,
37
44
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
38
45
  download_dest: filename)
39
46
  if File.exist? filename
@@ -41,12 +48,39 @@ module Applocale
41
48
  else
42
49
  ErrorUtil::DownloadFromGoogleFail.new.raise
43
50
  end
51
+ rescue Google::Apis::AuthorizationError => e
52
+ self.failauth(spreadsheet_Id, filename)
53
+ rescue Google::Apis::ClientError => e
54
+ self.failauth(spreadsheet_Id, filename)
55
+ rescue Google::Apis::ServerError => e
56
+ self.failauth( spreadsheet_Id, filename)
44
57
  rescue
45
58
  ErrorUtil::DownloadFromGoogleFail.new.raise
46
59
  end
47
60
  end
48
61
 
62
+ def self.failauth(spreadsheet_Id, filename)
63
+ ErrorUtil::DownloadFromGoogleFail.new.to_warn
64
+ self.askfor_relogin(true, spreadsheet_Id, filename)
65
+ end
66
+
49
67
  private
68
+ def self.askfor_relogin(is_firsttime, spreadsheet_Id, filename)
69
+ unless is_firsttime
70
+ puts "Invalid Command. Please input [Y/N]".red
71
+ end
72
+ puts "login again? [Y/N]".red
73
+ code = STDIN.gets.chomp.downcase
74
+ if code == 'y'
75
+ self.reset_loginacc
76
+ self.download_spreadsheet(spreadsheet_Id, filename)
77
+ elsif code == 'n'
78
+ exit(0)
79
+ else
80
+ self.askfor_relogin(false, spreadsheet_Id, filename)
81
+ end
82
+ end
83
+
50
84
  def self.authorize
51
85
 
52
86
  FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
@@ -121,7 +121,7 @@ module Applocale
121
121
  if cell_value.nil?
122
122
  return ''
123
123
  else
124
- return ContentUtil.add_escaped_double_quote(cell_value)
124
+ return ContentUtil.from_excel(cell_value)
125
125
  end
126
126
  end
127
127
 
@@ -4,7 +4,7 @@ require File.expand_path('../platform.rb', __FILE__)
4
4
 
5
5
  module Applocale
6
6
  class ValidKey
7
- REGEX_KEYSTR_IOS = /\A[0-9a-zA-Z_]+\z/
7
+ REGEX_KEYSTR_IOS = /\A[0-9a-zA-Z_\/]+\z/
8
8
 
9
9
  def self.is_validkey(platfrom, key)
10
10
  return false if key.nil?
@@ -78,6 +78,16 @@ module Applocale
78
78
  return new_value
79
79
  end
80
80
 
81
+ def self.from_excel(content)
82
+ reg = /(?<!\\)((?:\\{2})+)*\\"/
83
+ new_value = content.gsub(reg) {|match|
84
+ match.slice!(0)
85
+ match
86
+ }
87
+ new_value = new_value.gsub(/\n/, "\\n")
88
+ new_value = new_value.gsub(/\t/, "\\t")
89
+ return new_value
90
+ end
81
91
  end
82
92
  end
83
93
 
@@ -1,3 +1,3 @@
1
1
  module Applocale
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applocale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kennix
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler