i18n_tools 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/i18n_tools/scanner.rb +25 -2
- data/tasks/i18n_tools.rake +8 -3
- metadata +17 -9
data/lib/i18n_tools/scanner.rb
CHANGED
@@ -10,6 +10,22 @@ module I18nTools
|
|
10
10
|
@@file_types = val
|
11
11
|
end
|
12
12
|
self.file_types = ['controllers', 'helpers', 'models']
|
13
|
+
|
14
|
+
def self.code_paths
|
15
|
+
@@code_paths
|
16
|
+
end
|
17
|
+
def self.code_paths=(val)
|
18
|
+
@@code_paths = val
|
19
|
+
end
|
20
|
+
self.code_paths = ["app/**/*.rb", "lib/**/*.rb"]
|
21
|
+
|
22
|
+
def self.view_paths
|
23
|
+
@@view_paths
|
24
|
+
end
|
25
|
+
def self.view_paths=(val)
|
26
|
+
@@view_paths = val
|
27
|
+
end
|
28
|
+
self.view_paths = ['app/views/**/*.erb', 'app/views/**/*.rhtml']
|
13
29
|
|
14
30
|
protected
|
15
31
|
def scan(&block)
|
@@ -18,8 +34,15 @@ module I18nTools
|
|
18
34
|
end
|
19
35
|
|
20
36
|
private
|
37
|
+
def code_paths
|
38
|
+
[
|
39
|
+
self.class.file_types.collect { |t| "app/#{t}/**/*.rb" },
|
40
|
+
self.class.code_paths
|
41
|
+
].flatten
|
42
|
+
end
|
43
|
+
|
21
44
|
def scan_views(&block)
|
22
|
-
Dir[
|
45
|
+
Dir[*self.class.view_paths].uniq.each do |filename|
|
23
46
|
next if ignores.any? { |r| filename =~ r }
|
24
47
|
|
25
48
|
content = File.read(filename)
|
@@ -38,7 +61,7 @@ module I18nTools
|
|
38
61
|
end
|
39
62
|
|
40
63
|
def scan_code(&block)
|
41
|
-
Dir[
|
64
|
+
Dir[*code_paths].uniq.each do |filename|
|
42
65
|
next if ignores.any? { |r| filename =~ r }
|
43
66
|
|
44
67
|
content = File.read(filename)
|
data/tasks/i18n_tools.rake
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
namespace :translations do
|
2
|
-
task :
|
2
|
+
task :clear do
|
3
|
+
require 'i18n'
|
4
|
+
I18n.load_path.clear
|
5
|
+
end
|
6
|
+
|
7
|
+
task :load do
|
3
8
|
if Rake::Task.task_defined?("environment")
|
4
9
|
Rake::Task["environment"].invoke
|
5
10
|
else
|
@@ -15,7 +20,7 @@ namespace :translations do
|
|
15
20
|
end
|
16
21
|
|
17
22
|
desc 'Detect missing translations'
|
18
|
-
task :missing => :
|
23
|
+
task :missing => :load do
|
19
24
|
require 'ya2yaml'
|
20
25
|
|
21
26
|
results = I18nTools::MissingScanner.new(@locale).results
|
@@ -23,7 +28,7 @@ namespace :translations do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
desc 'Detect translations that are not used in code'
|
26
|
-
task :unused => :
|
31
|
+
task :unused => [:clear, :load] do
|
27
32
|
unused = I18nTools::UnusedScanner.new(@locale).results
|
28
33
|
puts unused
|
29
34
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Thomas Kadauke
|
@@ -10,19 +15,22 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2013-05-
|
18
|
+
date: 2013-05-18 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
18
22
|
none: false
|
19
23
|
requirements:
|
20
24
|
- - ">="
|
21
25
|
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
22
29
|
version: "0"
|
23
|
-
type: :runtime
|
24
30
|
prerelease: false
|
25
|
-
|
31
|
+
type: :runtime
|
32
|
+
name: ya2yaml
|
33
|
+
requirement: *id001
|
26
34
|
description:
|
27
35
|
email: thomas.kadauke@googlemail.com
|
28
36
|
executables: []
|
@@ -52,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
60
|
requirements:
|
53
61
|
- - ">="
|
54
62
|
- !ruby/object:Gem::Version
|
55
|
-
hash:
|
63
|
+
hash: 3
|
56
64
|
segments:
|
57
65
|
- 0
|
58
66
|
version: "0"
|
@@ -61,14 +69,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
69
|
requirements:
|
62
70
|
- - ">="
|
63
71
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
72
|
+
hash: 3
|
65
73
|
segments:
|
66
74
|
- 0
|
67
75
|
version: "0"
|
68
76
|
requirements: []
|
69
77
|
|
70
78
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.24
|
72
80
|
signing_key:
|
73
81
|
specification_version: 3
|
74
82
|
summary: Tasks for extracting missing and unused translations from Rails projects
|