wca_i18n 0.3.0 → 0.4.0

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: 11d594713ea35a6dbae3e6b8bb530d4d915cd1f2
4
- data.tar.gz: 577a0b309bbf4201056624ff6cf8536540cd46bb
3
+ metadata.gz: d81a519daa516d4bb71890b9805fc929f96225f2
4
+ data.tar.gz: 824d4dd501949c961272a0738fb43ac01f66f0f6
5
5
  SHA512:
6
- metadata.gz: 9d3a9de484bcc71b959fc4ff85c138a458bd50dfd5ba07b85e0212144d791efd2f012bdb3e47274de68398b5d044d823d2a702d5bf63c6bc3001044c136581d9
7
- data.tar.gz: 941199189e253a192cc0535a9831c95d426196582be699075964f4fb0774477a249da4e30943e82cc307da1cb4ed07f9873bca0a107d63eb613a0085d8ab05f2
6
+ metadata.gz: 10acd68e49dbe4cf26474b4558e8a2a3791fa18849c30cfa95b0d2b81549d8c923ec84a0486ecf4cded3299b1d6d2ae7625563784aa788d8f7357423785c51de
7
+ data.tar.gz: a6ae0c401e3ac2c584b4b87dbd8f020b6a8f7c3fc9a2ceb5ea15ef1afdf199312210c306c81f64dcd476b4d1aad9820e222079f8c3e96f3218cafc7cb02b766b
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wca_i18n (0.3.0)
4
+ wca_i18n (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  byebug (9.1.0)
10
+ colorize (0.8.1)
10
11
  diff-lcs (1.3)
11
12
  rake (10.5.0)
12
13
  rspec (3.7.0)
@@ -29,6 +30,7 @@ PLATFORMS
29
30
  DEPENDENCIES
30
31
  bundler (~> 1.16)
31
32
  byebug (~> 9.0)
33
+ colorize (~> 0.8)
32
34
  rake (~> 10.0)
33
35
  rspec (~> 3.0)
34
36
  wca_i18n!
data/exe/wca_i18n CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'wca_i18n'
5
+ require 'colorize'
5
6
 
6
7
  def main
7
8
  verbose = false
@@ -22,7 +23,8 @@ def main
22
23
  base_translation = load_translation(base_translation_file)
23
24
  translations = translation_files.map { |f| load_translation(f) }.reject { |t| t.locale == base_translation.locale }
24
25
 
25
- compare_base_with_translations(base_translation, translations.sort_by!(&:locale), verbose)
26
+ perfect = compare_base_with_translations(base_translation, translations.sort_by!(&:locale), verbose)
27
+ exit (perfect ? 0 : 1)
26
28
  end
27
29
 
28
30
  def load_translation(filename)
@@ -31,26 +33,37 @@ def load_translation(filename)
31
33
  end
32
34
 
33
35
  def compare_base_with_translations(base_translation, translations, verbose)
36
+ total_issue_count = 0
34
37
  translations.each do |translation|
35
38
  diff = translation.compare_to(base_translation)
36
- puts "#{translation.locale}:#{indent(format_diff(diff, verbose), 1)}"
39
+ translation_issue_count = diff.values.map(&:length).sum
40
+ total_issue_count += translation_issue_count
41
+
42
+ prefix = (translation_issue_count == 0 ? "✔".green : "✗".red)
43
+ puts "#{prefix} #{translation.locale}:#{indent(format_diff(diff, verbose), 1)}"
37
44
  end
45
+
46
+ total_issue_count == 0
38
47
  end
39
48
 
40
49
  def format_diff(diff, verbose=false)
41
50
  types = [:missing, :outdated, :unused]
51
+ total = diff.values.map(&:length).sum
42
52
 
43
- pretty_counts = types.map do |type|
44
- contexts = diff[type]
45
- pretty = "#{contexts.length} #{type.to_s}"
46
- pretty += ":\n" + indent(format_contexts(contexts), 1) if verbose
47
- pretty
48
- end
49
-
50
- if verbose
51
- "\n" + pretty_counts.join("\n")
53
+ if total == 0
54
+ "Up to date"
55
+ elsif verbose
56
+ pretty_counts = types.map do |type|
57
+ contexts = diff[type]
58
+ pretty = "• #{contexts.length} #{type.to_s}"
59
+ if contexts.length > 0
60
+ pretty += ":\n#{indent(format_contexts(contexts), 1)}"
61
+ end
62
+ pretty
63
+ end
64
+ "#{total} total\n" + pretty_counts.join("\n")
52
65
  else
53
- total = diff.values.map(&:length).sum
66
+ pretty_counts = types.map { |type| "#{diff[type].length} #{type.to_s}" }
54
67
  "#{total} total = #{pretty_counts.join(" + ")}"
55
68
  end
56
69
  end
@@ -1,3 +1,3 @@
1
1
  module WcaI18n
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/wca_i18n.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
  spec.add_development_dependency "byebug", "~> 9.0"
27
+ spec.add_development_dependency "colorize", "~> 0.8"
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wca_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Fleischman
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '9.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
69
83
  description:
70
84
  email:
71
85
  - software@worldcubeassociation.org