i18n_checker 0.8.8 → 0.9.0

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: 5ca10520e2e9b4dbef4c40d56b4346a3e84bc8ea
4
- data.tar.gz: 3054cf04f9e2530023c0386cc4fc039d20468e54
3
+ metadata.gz: 6381881dcce23ddcd7ae1fcd17027c73378679ef
4
+ data.tar.gz: 92fcc55e66abf40bed1e891af5b7f0213cc10f55
5
5
  SHA512:
6
- metadata.gz: 54a710a2defe97fd32a5d81d978bfaab0896f1957793cbb7fef9191c60cebe01028125351deeaaa227636b78320db97dd203eb7d2ce3694d04ee06b7af2b9ea9
7
- data.tar.gz: 671d7cedb198e4a2077648ac24aba96b816e2878e7127480df0eb27e98545879be09b1316f65c8bb51352240cb9e6e34ce23ba120158d26be749824303da896c
6
+ metadata.gz: 6e1c10e5d706a9f3051c7dd1a4a25c7731e3e8d163d3cb02aab9fb71ebd465c4b0748dabcf95654e76e536d48040693bc9996d97265cb4f11be9fa13808d0a80
7
+ data.tar.gz: 9165ccefc2e594085fed1c37ee5caef4ab06df00f55640828cf5d651cec190c7c4eb802ace376a59a8edc91ca092421642625aa271acce3c9304de557e21d3c3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n_checker (0.8.8)
4
+ i18n_checker (0.9.0)
5
5
  colorator (~> 1.1.0)
6
6
  haml_parser (~> 0.4)
7
7
  parser
data/README.md CHANGED
@@ -20,12 +20,12 @@ Add the following tasks to your **Rakefile**.
20
20
  ```ruby
21
21
  require 'i18n_checker/rake_task'
22
22
 
23
- I18nChecker::RakeTask::Check.new do |task|
23
+ I18nChecker::RakeTask::ReferenceCheck.new do |task|
24
24
  task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
25
25
  task.locale_file_paths = FileList['config/locales/*'] # locale file paths
26
26
  end
27
27
 
28
- I18nChecker::RakeTask::Clean do |task|
28
+ I18nChecker::RakeTask::UnusedCheck do |task|
29
29
  task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
30
30
  task.locale_file_paths = FileList['config/locales/*'] # locale file paths
31
31
  end
@@ -34,8 +34,8 @@ end
34
34
  After that we just execute the task.
35
35
 
36
36
  ```shell
37
- bundle exec rake locale_check
38
- bundle exec rake locale_clean
37
+ bundle exec rake locale_reference_check
38
+ bundle exec rake locale_unused_check
39
39
  ```
40
40
 
41
41
  ## Check translation of translated text
@@ -46,7 +46,7 @@ It is useful for detecting text that is not in the translation file of a particu
46
46
  ```ruby
47
47
  require 'i18n_checker/rake_task'
48
48
 
49
- I18nChecker::RakeTask::Check.new do |task|
49
+ I18nChecker::RakeTask::ReferenceCheck.new do |task|
50
50
  task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
51
51
  task.locale_file_paths = FileList['config/locales/*'] # locale file paths
52
52
  end
@@ -55,7 +55,7 @@ end
55
55
  After that we just execute the task.
56
56
 
57
57
  ```shell
58
- bundle exec rake locale_check
58
+ bundle exec rake locale_reference_check
59
59
  ```
60
60
 
61
61
  ## Delete unused translated text
@@ -66,7 +66,7 @@ Since you can delete translated text that you do not use safely, you can reduce
66
66
  ```ruby
67
67
  require 'i18n_checker/rake_task'
68
68
 
69
- I18nChecker::RakeTask::Clean do |task|
69
+ I18nChecker::RakeTask::UnusedClean do |task|
70
70
  task.source_paths = FileList['app/models/*', 'app/views/*'] # haml templates, ruby sources
71
71
  task.locale_file_paths = FileList['config/locales/*'] # locale file paths
72
72
  end
@@ -75,7 +75,7 @@ end
75
75
  After that we just execute the task.
76
76
 
77
77
  ```shell
78
- bundle exec rake locale_clean
78
+ bundle exec rake locale_unused_clean
79
79
  ```
80
80
 
81
81
  ## Run the test
data/Rakefile CHANGED
@@ -5,12 +5,17 @@ require 'i18n_checker/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- I18nChecker::RakeTask::Check.new do |task|
8
+ I18nChecker::RakeTask::ReferenceCheck.new do |task|
9
9
  task.source_paths = FileList['spec/fixtures/haml/*', 'spec/fixtures/ruby/*']
10
10
  task.locale_file_paths = FileList['spec/fixtures/locales/**']
11
11
  end
12
12
 
13
- I18nChecker::RakeTask::Clean.new do |task|
13
+ I18nChecker::RakeTask::UnusedCheck.new do |task|
14
+ task.source_paths = FileList['examples/unused/**']
15
+ task.locale_file_paths = FileList['examples/unused/locales/**']
16
+ end
17
+
18
+ I18nChecker::RakeTask::UnusedClean.new do |task|
14
19
  task.source_paths = FileList['examples/unused/**']
15
20
  task.locale_file_paths = FileList['examples/unused/locales/**']
16
21
  end
@@ -4,7 +4,7 @@ require 'i18n_checker/not_found/result'
4
4
 
5
5
  module I18nChecker
6
6
  module Command
7
- class Check
7
+ class ReferenceCheck
8
8
  def initialize(locale_file_paths: [], source_paths: [], reporter:)
9
9
  @reporter = reporter
10
10
  @locale_texts = I18nChecker::Locale.texts_of(source_paths)
@@ -0,0 +1,20 @@
1
+ require 'i18n_checker/unused/detector'
2
+
3
+ module I18nChecker
4
+ module Command
5
+ class UnusedCheck
6
+ def initialize(locale_file_paths: [], source_paths: [], reporter:)
7
+ @reporter = reporter
8
+ @locale_texts = I18nChecker::Locale.texts_of(source_paths)
9
+ @locale_files = I18nChecker::Locale.load_of(locale_file_paths)
10
+ @unused_detector = I18nChecker::Unused::Detector.new(@locale_files)
11
+ end
12
+
13
+ def run
14
+ unused_result = @locale_texts.detect(@unused_detector)
15
+ @reporter.report unused_result
16
+ yield unused_result if block_given?
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,7 +2,7 @@ require 'i18n_checker/unused/detector'
2
2
 
3
3
  module I18nChecker
4
4
  module Command
5
- class Clean
5
+ class UnusedClean
6
6
  def initialize(locale_file_paths: [], source_paths: [], reporter:)
7
7
  @reporter = reporter
8
8
  @locale_texts = I18nChecker::Locale.texts_of(source_paths)
@@ -1,2 +1,3 @@
1
- require 'i18n_checker/rake_task/check'
2
- require 'i18n_checker/rake_task/clean'
1
+ require 'i18n_checker/rake_task/reference_check'
2
+ require 'i18n_checker/rake_task/unused_check'
3
+ require 'i18n_checker/rake_task/unused_clean'
@@ -4,18 +4,18 @@ require 'i18n_checker/cache'
4
4
  require 'i18n_checker/locale'
5
5
  require 'i18n_checker/not_found/reporter/base'
6
6
  require 'i18n_checker/not_found/reporter/default'
7
- require 'i18n_checker/command/check'
7
+ require 'i18n_checker/command/reference_check'
8
8
 
9
9
  module I18nChecker
10
10
  module RakeTask
11
- class Check < ::Rake::TaskLib
11
+ class ReferenceCheck < ::Rake::TaskLib
12
12
  attr_accessor :name
13
13
  attr_accessor :reporter
14
14
  attr_accessor :source_paths
15
15
  attr_accessor :locale_file_paths
16
16
  attr_accessor :logger
17
17
 
18
- def initialize(name = :locale_check)
18
+ def initialize(name = :locale_reference_check)
19
19
  @name = name
20
20
  @source_paths = FileList['app/views/*', 'app/controllers/*', 'app/jobs/*', 'app/models/*', 'app/helpers/*']
21
21
  @locale_file_paths = FileList['config/locales/*']
@@ -36,7 +36,7 @@ module I18nChecker
36
36
  end
37
37
 
38
38
  def run_task
39
- commmand = I18nChecker::Command::Check.new(
39
+ commmand = I18nChecker::Command::ReferenceCheck.new(
40
40
  reporter: reporter,
41
41
  source_paths: source_paths,
42
42
  locale_file_paths: locale_file_paths,
@@ -0,0 +1,50 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'i18n_checker/cache'
4
+ require 'i18n_checker/locale'
5
+ require 'i18n_checker/unused/detector'
6
+ require 'i18n_checker/unused/reporter/default'
7
+ require 'i18n_checker/command/unused_check'
8
+
9
+ module I18nChecker
10
+ module RakeTask
11
+ class UnusedCheck < ::Rake::TaskLib
12
+ attr_accessor :name
13
+ attr_accessor :reporter
14
+ attr_accessor :source_paths
15
+ attr_accessor :locale_file_paths
16
+ attr_accessor :logger
17
+
18
+ def initialize(name = :locale_unused_check)
19
+ @name = name
20
+ @source_paths = FileList['app/views/*', 'app/controllers/*', 'app/jobs/*', 'app/models/*', 'app/helpers/*']
21
+ @locale_file_paths = FileList['config/locales/*']
22
+ @logger = Logger.new(STDOUT)
23
+ @logger.formatter = proc { |_severity, _datetime, _progname, message|
24
+ "#{message}\n"
25
+ }
26
+ @reporter = I18nChecker::Unused::Reporter::Default.new(logger: logger)
27
+ yield self if block_given?
28
+ define
29
+ end
30
+
31
+ private
32
+
33
+ def define
34
+ desc 'Display unused translation text.'
35
+ task(name) { run_task }
36
+ end
37
+
38
+ def run_task
39
+ command = I18nChecker::Command::UnusedCheck.new(
40
+ reporter: reporter,
41
+ source_paths: source_paths,
42
+ locale_file_paths: locale_file_paths,
43
+ )
44
+ command.run do |result|
45
+ exit 1 unless result.empty?
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -4,18 +4,18 @@ require 'i18n_checker/cache'
4
4
  require 'i18n_checker/locale'
5
5
  require 'i18n_checker/unused/detector'
6
6
  require 'i18n_checker/unused/reporter/default'
7
- require 'i18n_checker/command/clean'
7
+ require 'i18n_checker/command/unused_clean'
8
8
 
9
9
  module I18nChecker
10
10
  module RakeTask
11
- class Clean < ::Rake::TaskLib
11
+ class UnusedClean < ::Rake::TaskLib
12
12
  attr_accessor :name
13
13
  attr_accessor :reporter
14
14
  attr_accessor :source_paths
15
15
  attr_accessor :locale_file_paths
16
16
  attr_accessor :logger
17
17
 
18
- def initialize(name = :locale_clean)
18
+ def initialize(name = :locale_unused_clean)
19
19
  @name = name
20
20
  @source_paths = FileList['app/views/*', 'app/controllers/*', 'app/jobs/*', 'app/models/*', 'app/helpers/*']
21
21
  @locale_file_paths = FileList['config/locales/*']
@@ -36,7 +36,7 @@ module I18nChecker
36
36
  end
37
37
 
38
38
  def run_task
39
- command = I18nChecker::Command::Clean.new(
39
+ command = I18nChecker::Command::UnusedClean.new(
40
40
  reporter: reporter,
41
41
  source_paths: source_paths,
42
42
  locale_file_paths: locale_file_paths,
@@ -1,3 +1,3 @@
1
1
  module I18nChecker
2
- VERSION = '0.8.8'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - holyshared
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml_parser
@@ -204,8 +204,9 @@ files:
204
204
  - lib/i18n_checker.rb
205
205
  - lib/i18n_checker/cache.rb
206
206
  - lib/i18n_checker/collectible.rb
207
- - lib/i18n_checker/command/check.rb
208
- - lib/i18n_checker/command/clean.rb
207
+ - lib/i18n_checker/command/reference_check.rb
208
+ - lib/i18n_checker/command/unused_check.rb
209
+ - lib/i18n_checker/command/unused_clean.rb
209
210
  - lib/i18n_checker/locale.rb
210
211
  - lib/i18n_checker/locale/collector.rb
211
212
  - lib/i18n_checker/locale/collector/haml.rb
@@ -224,8 +225,9 @@ files:
224
225
  - lib/i18n_checker/not_found/result.rb
225
226
  - lib/i18n_checker/not_found/text.rb
226
227
  - lib/i18n_checker/rake_task.rb
227
- - lib/i18n_checker/rake_task/check.rb
228
- - lib/i18n_checker/rake_task/clean.rb
228
+ - lib/i18n_checker/rake_task/reference_check.rb
229
+ - lib/i18n_checker/rake_task/unused_check.rb
230
+ - lib/i18n_checker/rake_task/unused_clean.rb
229
231
  - lib/i18n_checker/unused/detector.rb
230
232
  - lib/i18n_checker/unused/reporter.rb
231
233
  - lib/i18n_checker/unused/reporter/base.rb