locca 0.9.5 → 0.9.6

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: 184b6cefe3ca2452b2c4bdc102fcbd09ea2cad2a
4
- data.tar.gz: e925c505ba4e6fc1ab27606bd611f41eb2fb2386
3
+ metadata.gz: 694c840f5f64001d74c08f0adf3aab810642aa10
4
+ data.tar.gz: 8f8e83e8f901f0e193c1ca60841d6e4847b981c7
5
5
  SHA512:
6
- metadata.gz: b41bbd7d5d909882cd0550d78b336dba9cecd400b0999d32a1718aa5ba34ccafe01ce063cbf4e5b398eed02aac5cf434bbe8ea1d903d8525f5e53fd9bdba4833
7
- data.tar.gz: 08cdcfbac26a8874f2d0a0638eb8ae1e957bcb0f3b318b61ecaff96ea2a2516a5e54e6eb550067acc309cc4bda732f3113a3536290f99a2c9c0b2590592824d8
6
+ metadata.gz: f27ef9dd3d9906a779ab3660181560eb1bee24f70ca859699f84b4514e2cf64ea64ef3614c6e3c7fd6c6301ac88fc6b71e111ff9230ecbcd167b60fb3a810ec5
7
+ data.tar.gz: 666f1f04e6291be5fcc6e130fb8bb1e87c15089664d059ad7a727441fe6dc221f3c2bc511242fb6db96f72fd3ca2ca9136ad96644beca9cf314492cb1a059d13
data/bin/locca CHANGED
@@ -110,7 +110,9 @@ end
110
110
  on_error do |exception|
111
111
  # Error logic here
112
112
  # return false to skip default error handling
113
- puts exception.backtrace
113
+ if ENV["LOCCA_DEBUG"]
114
+ puts exception.backtrace
115
+ end
114
116
  true
115
117
  end
116
118
 
@@ -42,7 +42,7 @@ module Locca
42
42
  langs.each do |lang|
43
43
  collection_path = @project.path_for_collection(generated_collection.name, lang)
44
44
  collection = @collection_builder.collection_at_path(collection_path)
45
- @collection_merger.merge(generated_collection, collection, (CollectionMerger::ACTION_ADD | CollectionMerger::ACTION_DELETE))
45
+ @collection_merger.merge(generated_collection, collection, (CollectionMerger::ACTION_ADD | CollectionMerger::ACTION_DELETE | CollectionMerger::ACTION_UPDATE_COMMENTS))
46
46
  @collection_writer.write_to_path(collection, collection_path)
47
47
  end
48
48
  end
@@ -70,10 +70,26 @@ module Locca
70
70
  @langs.each do |lang|
71
71
  print "[*] merge: code -> #{lang}/#{generated_collection.name}\n"
72
72
 
73
- collection_path = @project.path_for_collection(generated_collection.name, lang)
74
- collection = @collection_builder.collection_at_path(collection_path)
75
- @collection_merger.merge(generated_collection, collection, (CollectionMerger::ACTION_ADD | CollectionMerger::ACTION_DELETE))
76
- @collection_writer.write_to_path(collection, collection_path)
73
+ local_collection_path = @project.path_for_collection(generated_collection.name, lang)
74
+ local_collection = @collection_builder.collection_at_path(local_collection_path)
75
+ @collection_merger.merge(generated_collection, local_collection, (CollectionMerger::ACTION_ADD | CollectionMerger::ACTION_DELETE | CollectionMerger::ACTION_UPDATE_COMMENTS))
76
+
77
+ @collection_writer.write_to_path(local_collection, local_collection_path)
78
+ end
79
+ end
80
+
81
+ if @project.prevent_sync_without_comments?
82
+ lang = @project.base_lang
83
+ @generated_collections.each do |generated_collection|
84
+ print "[*] check: #{lang}/#{generated_collection.name}\n"
85
+
86
+ local_collection_path = @project.path_for_collection(generated_collection.name, lang)
87
+ local_collection = @collection_builder.collection_at_path(local_collection_path)
88
+
89
+ keys = local_collection.keys_without_comments
90
+ if keys.length > 0
91
+ raise "Keys without comments:\n" + keys.join("\n")
92
+ end
77
93
  end
78
94
  end
79
95
 
@@ -56,6 +56,16 @@ module Locca
56
56
  return @items.keys
57
57
  end
58
58
 
59
+ def keys_without_comments
60
+ result = []
61
+ @items.each do |key, item|
62
+ if item.comment == nil || item.comment.strip.length == 0
63
+ result.push(key)
64
+ end
65
+ end
66
+ return result
67
+ end
68
+
59
69
  def translated?
60
70
  @items.each do |key, item|
61
71
  if !item.translated?
@@ -24,9 +24,10 @@
24
24
 
25
25
  module Locca
26
26
  class CollectionMerger
27
- ACTION_ADD = (1 << 0)
28
- ACTION_DELETE = (1 << 1)
29
- ACTION_UPDATE = (1 << 2)
27
+ ACTION_ADD = (1 << 0)
28
+ ACTION_DELETE = (1 << 1)
29
+ ACTION_UPDATE = (1 << 2)
30
+ ACTION_UPDATE_COMMENTS = (1 << 3)
30
31
 
31
32
  def merge(src_collection, dst_collection, actions = (ACTION_ADD | ACTION_DELETE))
32
33
  if not src_collection or not dst_collection
@@ -45,6 +46,9 @@ module Locca
45
46
  dst_collection.add_item(src_item.dup)
46
47
  elsif (actions & ACTION_UPDATE) != 0 && dst_item
47
48
  dst_collection.add_item(src_item.dup)
49
+ elsif (actions & ACTION_UPDATE_COMMENTS) != 0 && dst_item
50
+ item = CollectionItem.new(dst_item.key, dst_item.value, src_item.comment)
51
+ dst_collection.add_item(item)
48
52
  end
49
53
 
50
54
  if dst_keys
@@ -26,6 +26,7 @@ require_relative 'project'
26
26
 
27
27
  module Locca
28
28
  class AndroidProject < Project
29
+ MAIN_COLLECTION_NAME = 'strings'
29
30
 
30
31
  def initialize(dir, config)
31
32
  super(dir, config)
@@ -36,7 +37,9 @@ module Locca
36
37
  result.add(self.base_lang)
37
38
 
38
39
  Dir.glob(File.join(@lang_dir, 'values-*')) do |filepath|
39
- result.add(File.basename(filepath).split('-', 2).last)
40
+ if (File.exist?(File.join(filepath, "#{MAIN_COLLECTION_NAME}.xml")))
41
+ result.add(File.basename(filepath).split('-', 2).last)
42
+ end
40
43
  end
41
44
 
42
45
  return result
@@ -44,7 +47,7 @@ module Locca
44
47
 
45
48
  def collection_names
46
49
  result = Set.new()
47
- result.add('strings');
50
+ result.add(MAIN_COLLECTION_NAME);
48
51
  return result
49
52
  end
50
53
 
@@ -42,6 +42,16 @@ module Locca
42
42
  return @config[key]
43
43
  end
44
44
 
45
+ def prevent_sync_without_comments?
46
+ value = @config['prevent_sync_without_comments']
47
+ if value == true ||
48
+ value == 1
49
+ return true
50
+ else
51
+ return false
52
+ end
53
+ end
54
+
45
55
  def langs
46
56
  # implement in subclass
47
57
  end
@@ -22,5 +22,5 @@
22
22
  # SOFTWARE.
23
23
  #
24
24
  module Locca
25
- VERSION = '0.9.5'
25
+ VERSION = '0.9.6'
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shurakov Evgeny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest