haml-i18n-extractor 0.3.0 → 0.3.2
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 +8 -8
- data/lib/haml-i18n-extractor/version.rb +1 -1
- data/lib/haml-i18n-extractor/yaml_tool.rb +7 -4
- data/test/integration_test.rb +7 -2
- data/test/test_helper.rb +1 -1
- data/test/workflow_test.rb +2 -2
- data/test/yaml_tool_test.rb +16 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzE3Mzc4M2VkYTdhOGViYWE2NjJlMjhhMjMxOGYxN2FiNjc3ZjJkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGFiOWZhODkzODRjNTY4MDVhMzYzY2M1ODE0MWEwNGExNmM1MzMxYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWVhMDM5NzZkMzgwNTRmYzg5Njk2ZTAxYjg5NDI0YTdjZTY2ZDc3YmQyMmRj
|
10
|
+
Mzg4NTcwMThjODA5ZTA0YzMxOWViNjBlMDFmMmJhMjZhMDkxNDYzYmQzNTQw
|
11
|
+
MjE0MjE1NjAwMzQ5ODdlYjg4ODllZDc2YTRiYjk1OWEzZDljNWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWNjYjQwNTEzMWVmNDBmNzk4MzIwMGU3MTFkYzQ3NjY4YzFjMzcwZmY3MGEy
|
14
|
+
YjMzMjFhNWMwNzI2OTZiMWRiZGNiZTZiMjFmMjE3OTkyZjYyNTk0MDJkZDI1
|
15
|
+
Y2ZhZTFlZWRiY2M4NDM1ZGFkMjA5OTdjOTI0YjlhMGQ2Mzg3ZjY=
|
@@ -85,15 +85,18 @@ module Haml
|
|
85
85
|
|
86
86
|
# assuming rails format, app/views/users/index.html.haml return [users]
|
87
87
|
# app/views/admin/users/index.html.haml return [admin, users]
|
88
|
-
# app/views/admin/users/with_namespace/index.html.haml return [admin, users, with_namespace]
|
88
|
+
# app/views/admin/users/with_namespace/index.html.haml return [admin, users, with_namespace, index]
|
89
89
|
# otherwise, just grab the last one.
|
90
90
|
def standardized_viewnames(pth)
|
91
|
-
|
91
|
+
pathname = Pathname.new(pth)
|
92
|
+
array_of_dirs = pathname.dirname.to_s.split("/")
|
93
|
+
view_name = pathname.basename.to_s.gsub(/.html.haml$/,"").gsub(/.haml$/,"")
|
94
|
+
view_name.gsub!(/^_/, "")
|
92
95
|
index = array_of_dirs.index("views")
|
93
96
|
if index
|
94
|
-
array_of_dirs[index+1..-1]
|
97
|
+
array_of_dirs[index+1..-1] << view_name
|
95
98
|
else
|
96
|
-
[array_of_dirs.last]
|
99
|
+
[array_of_dirs.last] << view_name
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
data/test/integration_test.rb
CHANGED
@@ -3,6 +3,7 @@ module Haml
|
|
3
3
|
|
4
4
|
def setup
|
5
5
|
TestHelper.setup_project_directory!
|
6
|
+
@workflow = TestHelper.mock_full_project_user_interaction!
|
6
7
|
end
|
7
8
|
|
8
9
|
def teardown
|
@@ -10,10 +11,14 @@ module Haml
|
|
10
11
|
end
|
11
12
|
|
12
13
|
test "it can handle namespaced views" do
|
13
|
-
|
14
|
-
namespaced_extractor = workflow.extractors.select{|ex| ex.haml_writer.path.match /namespace/ }.last
|
14
|
+
namespaced_extractor = @workflow.extractors.select{|ex| ex.haml_writer.path.match /namespace/ }.last
|
15
15
|
assert namespaced_extractor.yaml_tool.yaml_hash["en"]["namespace"], "namespace key works"
|
16
16
|
end
|
17
17
|
|
18
|
+
test "it can handle partial views" do
|
19
|
+
partial_extractor = @workflow.extractors.select{|ex| ex.haml_writer.path.match /_partial/ }.last
|
20
|
+
assert partial_extractor.yaml_tool.yaml_hash["en"]["view2"]["partial"], "partial filenames in yaml are w/out leading _"
|
21
|
+
end
|
22
|
+
|
18
23
|
end
|
19
24
|
end
|
data/test/test_helper.rb
CHANGED
@@ -126,7 +126,7 @@ module TestHelper
|
|
126
126
|
view3 = File.join(PROJECT_DIR, "app", "views", "namespace", "view3")
|
127
127
|
[ view1, view2, view3 ].map do |dir|
|
128
128
|
FileUtils.mkdir_p(dir)
|
129
|
-
["thing.haml", "thang.haml"].map do |fn|
|
129
|
+
["thing.haml", "thang.haml", "_partial.html.haml"].map do |fn|
|
130
130
|
haml_text=<<EOH
|
131
131
|
%h1 Notifications
|
132
132
|
|
data/test/workflow_test.rb
CHANGED
@@ -23,13 +23,13 @@ module Haml
|
|
23
23
|
end
|
24
24
|
|
25
25
|
test "it_finds_all_haml_files" do
|
26
|
-
assert_equal @workflow.files.size,
|
26
|
+
assert_equal @workflow.files.size, 9
|
27
27
|
end
|
28
28
|
|
29
29
|
test "outputs_stats" do
|
30
30
|
with_highline do
|
31
31
|
@workflow.start_message
|
32
|
-
assert @output.string.match(/Found
|
32
|
+
assert @output.string.match(/Found \d haml files/), "Outputs stats"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/test/yaml_tool_test.rb
CHANGED
@@ -33,27 +33,29 @@ module Haml
|
|
33
33
|
|
34
34
|
def existing_yaml_hash
|
35
35
|
{"en" => {
|
36
|
-
|
37
|
-
|
38
|
-
}
|
36
|
+
"viewname" => {
|
37
|
+
"translate_key" => "Translate Key"
|
39
38
|
}
|
40
39
|
}
|
40
|
+
}
|
41
41
|
end
|
42
42
|
|
43
43
|
def ex1_yaml_hash
|
44
44
|
{"en"=>
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
{"support" =>
|
46
|
+
{"ex1" =>
|
47
|
+
{"some_place"=>"Some place",
|
48
|
+
"admin"=>"Admin",
|
49
|
+
"admin_dashboard"=>"Admin Dashboard",
|
50
|
+
"stacks"=>"Stacks",
|
51
|
+
"alerts"=>"t('.alerts')",
|
52
|
+
"accounts"=>"Accounts",
|
53
|
+
"what_is_supposed_to_be_is_supp"=>
|
54
|
+
"What is@ supposed to be, is supposed to be! ~"
|
55
|
+
}
|
56
56
|
}
|
57
|
+
}
|
58
|
+
}
|
57
59
|
end
|
58
60
|
|
59
61
|
test "defaults for empty init" do
|