locraft 1.3.0 → 1.3.1

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: 7cf55e11bdceb1841fb6634cdb0a7c542a007e84
4
- data.tar.gz: 77890f235af48f9363d4f4137bf96b39ade76f6d
3
+ metadata.gz: 49c54082e2fd1485e1bec98037de840be8de3eb2
4
+ data.tar.gz: 62d2f02ca95fddc96130a1b6a74d9c377c749ce0
5
5
  SHA512:
6
- metadata.gz: 7eeb6f98a5128a0e1c841121e71ea079b8f8b0d839bb563ed22e455f1296770a0afa7c7233304c7508ec13fbeb16ddc218fba7c72bbc52b8b788abc83a47706e
7
- data.tar.gz: 7e696aee22acb23c0327c507bb046c0d910f2f4ef5b4d549e9107a6d7e795cbddae27d2acf5eff4544e510a9ea7f8affec39a8aab34663f9290fe56a94f82e61
6
+ metadata.gz: 6e7f7844b14497ce39f7132306a13e2248362ffea1beb8e314938524f8c3eec97f3f63947891784e6e75cfabfaa41f01f637b176412527245e7853822e48878e
7
+ data.tar.gz: 12b1a3b2c288748ef26dfe81ef94f6cf9f9177b1f1097ba6b58f9faf7e890ef88a9d8ec7807a31db4f915752f1f28dc75544fb1e4882417cd20a283dc816f4ca
@@ -55,6 +55,10 @@ module Locraft
55
55
  end
56
56
  end
57
57
 
58
+ def from_folder
59
+ File.dirname(from_file)
60
+ end
61
+
58
62
  def relative_strings_destination
59
63
  File.expand_path('../' + strings_destination, from_file)
60
64
  end
@@ -57,14 +57,17 @@ module Locraft
57
57
  end
58
58
 
59
59
  def constants_keys
60
- @localizations.select { |l| l.valid? }.map do |l|
60
+ @localizations.select(&:valid?).map do |l|
61
61
  { key: l.key, const: constant_from(l.key) }
62
62
  end
63
63
  end
64
64
 
65
65
  def constant_from(key)
66
- inside = key.split(/\W/).map(&:capitalize).join
67
- "k#{@config.dev_prefix}#{inside}Localized"
66
+ parts = key.split(/\W/).select { |p| !p.empty? }.map do |p|
67
+ p[0] = p[0].capitalize
68
+ p
69
+ end
70
+ "k#{@config.dev_prefix}#{parts.join}Localized"
68
71
  end
69
72
  end
70
73
  end
@@ -14,8 +14,7 @@ module Locraft
14
14
  end
15
15
 
16
16
  def authenticate
17
- mkdir_p @config.relative_strings_destination unless Dir.exist?(@config.relative_strings_destination)
18
- token_file = File.join(@config.relative_strings_destination, SESSION_TOKEN_FILE)
17
+ token_file = File.join(@config.from_folder, SESSION_TOKEN_FILE)
19
18
  @session = GoogleDrive.saved_session(token_file)
20
19
  end
21
20
 
@@ -26,11 +25,12 @@ module Locraft
26
25
 
27
26
  # return worksheet
28
27
  def export_worksheet
29
- worksheets = doc_named(@config.gdoc_file).worksheets
28
+ worksheets = doc_named(@config.gdoc_file)&.worksheets
30
29
  if worksheets.count > @config.gdoc_sheet
31
30
  worksheets[@config.gdoc_sheet]
32
31
  else
33
- warn 'gdrive_wrapper worksheet export error: sheet number in config out of bounds!'
32
+ warn 'gdrive_wrapper worksheet export error:
33
+ You have no access to google_doc or sheet number in config out of bounds!'
34
34
  end
35
35
  end
36
36
 
@@ -1,6 +1,7 @@
1
1
  module Locraft
2
2
 
3
- SAMPLE_CONFIG_FILE = './locraft.config'
3
+ SAMPLE_CONFIG_DIR = 'locraft'
4
+ SAMPLE_CONFIG_FILE = 'locraft.config'
4
5
 
5
6
  class Initializer
6
7
  def self.init
@@ -8,8 +9,14 @@ module Locraft
8
9
  if File.file? SAMPLE_CONFIG_FILE
9
10
  warn 'ERROR: Initialization failed. There is already exists some locraft.config.'
10
11
  else
12
+ Dir.mkdir(SAMPLE_CONFIG_DIR) unless Dir.exist?(SAMPLE_CONFIG_DIR)
11
13
  File.write(SAMPLE_CONFIG_FILE, config)
12
14
  end
13
15
  end
16
+
17
+ def self.initialized_config
18
+ return SAMPLE_CONFIG_FILE if File.exist?(SAMPLE_CONFIG_FILE)
19
+ File.join(SAMPLE_CONFIG_DIR, SAMPLE_CONFIG_FILE)
20
+ end
14
21
  end
15
22
  end
@@ -10,7 +10,7 @@ module Locraft
10
10
  end
11
11
 
12
12
  desc 'extract', 'extract strings from google drive and parse them into {.strings, .plist} files. Then create constants'
13
- option :config, default: SAMPLE_CONFIG_FILE, aliases: '-c', type: :string, desc: 'configuration file'
13
+ option :config, default: Initializer.initialized_config, aliases: '-c', type: :string, desc: 'configuration file'
14
14
  def extract
15
15
  config_file = options[:config]
16
16
  if File.file? config_file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sroik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google_drive
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.6.8
125
+ rubygems_version: 2.6.10
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: locraft