haml-i18n-extractor 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -1
- data/TODO +28 -0
- data/lib/haml-i18n-extractor/exception_finder.rb +37 -0
- data/lib/haml-i18n-extractor/extractor.rb +18 -12
- data/lib/haml-i18n-extractor/haml_parser.rb +46 -0
- data/lib/haml-i18n-extractor/haml_reader.rb +10 -0
- data/lib/haml-i18n-extractor/text_finder.rb +52 -67
- data/lib/haml-i18n-extractor/text_replacer.rb +27 -13
- data/lib/haml-i18n-extractor/version.rb +1 -1
- data/lib/haml-i18n-extractor.rb +9 -1
- data/test/exception_finder_test.rb +46 -0
- data/test/extractor_test.rb +21 -2
- data/test/haml_parser_test.rb +31 -0
- data/test/haml_reader_test.rb +7 -2
- data/test/support/ex1.haml +4 -0
- data/test/support/ex1.output.haml +5 -1
- data/test/support/ex2.haml +31 -0
- data/test/support/ex2.output.haml +31 -0
- data/test/support/ex3.haml +13 -0
- data/test/support/ex3.output.haml +13 -0
- data/test/support/with_filter.haml +22 -0
- data/test/text_finder_test.rb +64 -64
- data/test/text_replacer_test.rb +11 -11
- data/test/yaml_tool_test.rb +1 -15
- metadata +197 -200
@@ -24,5 +24,9 @@
|
|
24
24
|
%li
|
25
25
|
%a{:href => url_for([:admin, :accounts])}
|
26
26
|
%span= t('.accounts')
|
27
|
+
= link_to pending_account_invoices_path(account) do
|
28
|
+
= t('.this_linkez')
|
27
29
|
- if true
|
28
|
-
= t('.what_is_supposed_to_be_is_supp')
|
30
|
+
= t('.what_is_supposed_to_be_is_supp')
|
31
|
+
%td=link_to(t('.details'), admin_usage_import_url(usage_import.usage_report))
|
32
|
+
= t('.random')
|
@@ -0,0 +1,31 @@
|
|
1
|
+
= render :partial => "layouts/adminnav", :locals => {:account => nil }
|
2
|
+
.row
|
3
|
+
.admin.span12
|
4
|
+
%h1
|
5
|
+
Billing Month
|
6
|
+
= @billing_month.display_name
|
7
|
+
|
8
|
+
%h3
|
9
|
+
All Invoices Billable?
|
10
|
+
%span{:style => (@billable_invoices == @active_invoices) ? "color: #090" : "color: #900"}
|
11
|
+
= "#{@billable_invoices} out of #{@active_invoices}"
|
12
|
+
%h3
|
13
|
+
24 hours past end of billing month?
|
14
|
+
%span{:style => (@billing_month.past_cutoff) ? "color: #090" : "color: #900"}
|
15
|
+
= @billing_month.past_cutoff
|
16
|
+
|
17
|
+
- if @billing_month.open?
|
18
|
+
- if @billing_month.past_cutoff && (@billable_invoices == @active_invoices)
|
19
|
+
= form_for @billing_month, :url => close_admin_billing_month_url(@billing_month), :method => "POST" do |f|
|
20
|
+
= f.submit "Close This Month (cannot be undone)", :class => 'btn btn-primary'
|
21
|
+
- else
|
22
|
+
%p
|
23
|
+
Billing Month cannot be closed yet.
|
24
|
+
%p
|
25
|
+
Closing the billing month will mark all the invoices as "Posted".
|
26
|
+
%p
|
27
|
+
After closing you will need to do a payment run to charge all the affected customers for the amounts due in posted invoices.
|
28
|
+
- elsif @billing_month.closing?
|
29
|
+
Month is currently closing (reload to check if it's done)
|
30
|
+
- elsif @billing_month.closed?
|
31
|
+
Month is closed
|
@@ -0,0 +1,31 @@
|
|
1
|
+
= render :partial => "layouts/adminnav", :locals => {:account => nil }
|
2
|
+
.row
|
3
|
+
.admin.span12
|
4
|
+
%h1
|
5
|
+
= t('.billing_month')
|
6
|
+
= @billing_month.display_name
|
7
|
+
|
8
|
+
%h3
|
9
|
+
= t('.all_invoices_billable')
|
10
|
+
%span{:style => (@billable_invoices == @active_invoices) ? "color: #090" : "color: #900"}
|
11
|
+
=t('.billable_invoices_out_of_activ')
|
12
|
+
%h3
|
13
|
+
= t('.24_hours_past_end_of_billing_m')
|
14
|
+
%span{:style => (@billing_month.past_cutoff) ? "color: #090" : "color: #900"}
|
15
|
+
= @billing_month.past_cutoff
|
16
|
+
|
17
|
+
- if @billing_month.open?
|
18
|
+
- if @billing_month.past_cutoff && (@billable_invoices == @active_invoices)
|
19
|
+
= form_for @billing_month, :url => close_admin_billing_month_url(@billing_month), :method => "POST" do |f|
|
20
|
+
= f.submit "Close This Month (cannot be undone)", :class => 'btn btn-primary'
|
21
|
+
- else
|
22
|
+
%p
|
23
|
+
= t('.billing_month_cannot_be_closed')
|
24
|
+
%p
|
25
|
+
= t('.closing_the_billing_month_will')
|
26
|
+
%p
|
27
|
+
= t('.after_closing_you_will_need_to')
|
28
|
+
- elsif @billing_month.closing?
|
29
|
+
= t('.month_is_currently_closing_rel')
|
30
|
+
- elsif @billing_month.closed?
|
31
|
+
= t('.month_is_closed')
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h1
|
2
|
+
= link_to '#', id: 'customer-control-menu', role: 'button', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
|
3
|
+
Here
|
4
|
+
= link_to 'real text here', id: 'customer-control-menu', role: 'button', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
|
5
|
+
There
|
6
|
+
|
7
|
+
%span.creator{:title => "This user is an owner of this account"} owner
|
8
|
+
%span.title&= user.name
|
9
|
+
%strong \#{@account.name}
|
10
|
+
|
11
|
+
%table(style="width:400px")
|
12
|
+
%td (?)
|
13
|
+
%td \#{@account.send(attr) || '(none)'}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h1
|
2
|
+
= link_to t('.link_to_id_customercontrolmenu'), id: 'customer-control-menu', role: 'button', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
|
3
|
+
= t('.here')
|
4
|
+
= link_to t('.real_text_here'), id: 'customer-control-menu', role: 'button', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
|
5
|
+
= t('.there')
|
6
|
+
|
7
|
+
%span.creator{:title= => "This user is an t('.owner') of this account"} t('.owner')
|
8
|
+
%span.title&= user.name
|
9
|
+
%strong \#{@account.name}
|
10
|
+
|
11
|
+
%table(style="width:400px")
|
12
|
+
%td= t('.td')
|
13
|
+
%td \#{@account.send(attr) || '(none)'}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.class This is text
|
2
|
+
- if true
|
3
|
+
:javascript
|
4
|
+
var cheaterButton = $("<a href='#'>Cheat</a>");
|
5
|
+
$('form').prepend(cheaterButton);
|
6
|
+
cheaterButton.click(function(){
|
7
|
+
$('[name="field_creditCardType"]').first().click();
|
8
|
+
$('[name="field_creditCardNumber"]').val("4111111111111111");
|
9
|
+
$('[name="field_creditCardExpirationMonth"]').val("01");
|
10
|
+
$('[name="field_creditCardExpirationYear"]').val("2015");
|
11
|
+
$('[name="field_cardSecurityCode"]').val("111");
|
12
|
+
$('[name="field_creditCardHolderName"]').val("Foo Bar");
|
13
|
+
$('[name="field_creditCardCountry"]').val("USA");
|
14
|
+
$('[name="field_creditCardAddress1"]').val("123 Abc St");
|
15
|
+
$('[name="field_creditCardAddress2"]').val("Apt 456");
|
16
|
+
$('[name="field_creditCardCity"]').val("San Francisco");
|
17
|
+
$('[name="field_creditCardState"]').val("CA");
|
18
|
+
$('[name="field_creditCardPostalCode"]').val("94107");
|
19
|
+
$('[name="field_phone"]').val("1234567890");
|
20
|
+
$('[name="field_email"]').val("foo@example.com");
|
21
|
+
return false;
|
22
|
+
});
|
data/test/text_finder_test.rb
CHANGED
@@ -6,113 +6,113 @@ module Haml
|
|
6
6
|
# empty line
|
7
7
|
test "empty line does not explode" do
|
8
8
|
assert_equal find_text(""), ""
|
9
|
-
assert_equal find_type(""), :
|
9
|
+
assert_equal find_type(""), :plain
|
10
10
|
end
|
11
11
|
|
12
12
|
# regular text mode
|
13
13
|
test "regular text without whitespaces" do
|
14
14
|
assert_equal find_text("iphone"), "iphone"
|
15
|
-
assert_equal find_type("iphone"), :
|
15
|
+
assert_equal find_type("iphone"), :plain
|
16
16
|
end
|
17
17
|
|
18
18
|
test "regular text with whitespaces" do
|
19
|
-
assert_equal find_text("
|
20
|
-
assert_equal find_type("
|
19
|
+
assert_equal find_text("iphone4 "), "iphone4"
|
20
|
+
assert_equal find_type("iphone4 "), :plain
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
assert_equal
|
26
|
-
assert_equal find_type("- 'jessica'"), :silent
|
23
|
+
test "scripts with strings" do
|
24
|
+
assert_equal find_text("= 'jessica'"), " 'jessica'"
|
25
|
+
assert_equal find_type("= 'jessica'"), :script
|
27
26
|
end
|
28
27
|
|
29
|
-
test "
|
30
|
-
assert_equal find_text("
|
31
|
-
assert_equal find_type("
|
28
|
+
test "scripts with no strings" do
|
29
|
+
assert_equal find_text("= true"), ""
|
30
|
+
assert_equal find_type("= true"), :script
|
32
31
|
end
|
33
32
|
|
34
|
-
# html
|
35
|
-
test "%tag Text is an
|
33
|
+
# html tag mode
|
34
|
+
test "%tag Text is an tag" do
|
36
35
|
assert_equal find_text("%span Text to find"), "Text to find"
|
37
|
-
assert_equal find_type("%span Text to find"), :
|
36
|
+
assert_equal find_type("%span Text to find"), :tag
|
38
37
|
end
|
39
38
|
|
40
|
-
test "%tag Text with class is an
|
39
|
+
test "%tag Text with class is an tag" do
|
41
40
|
assert_equal find_text("%span.whatever-with-thing Text to find"), "Text to find"
|
42
|
-
assert_equal find_type("%span.whatever-with-thing Text to find"), :
|
41
|
+
assert_equal find_type("%span.whatever-with-thing Text to find"), :tag
|
43
42
|
end
|
44
43
|
|
45
|
-
test "%tag Text with ruby eval code is a
|
44
|
+
test "%tag Text with ruby eval code is a script script" do
|
46
45
|
assert_equal find_text("%span= ruby_eval_code"), ""
|
47
|
-
assert_equal find_type("%span= ruby_eval_code"), :
|
46
|
+
assert_equal find_type("%span= ruby_eval_code"), :tag
|
48
47
|
end
|
49
48
|
|
50
|
-
test "%tag Text with ruby eval code and class is a
|
49
|
+
test "%tag Text with ruby eval code and class is a script script" do
|
51
50
|
assert_equal find_text( "%span#whatever-with-thing= ruby_eval_code"), ""
|
52
|
-
assert_equal find_type( "%span#whatever-with-thing= ruby_eval_code"), :
|
51
|
+
assert_equal find_type( "%span#whatever-with-thing= ruby_eval_code"), :tag
|
53
52
|
end
|
54
|
-
|
53
|
+
|
55
54
|
test "Ruby style tags %a{'href' => 'http://whatever'} whatever" do
|
56
55
|
assert_equal find_text("%a{'href' => 'http://whatever'} whatever"), "whatever"
|
57
|
-
assert_equal find_type("%a{'href' => 'http://whatever'} whatever"), :
|
56
|
+
assert_equal find_type("%a{'href' => 'http://whatever'} whatever"), :tag
|
58
57
|
end
|
59
|
-
|
60
|
-
#
|
61
|
-
test "
|
62
|
-
assert_equal find_text('= "bob"'), "bob"
|
63
|
-
assert_equal find_text("= 'bob'"), "bob"
|
64
|
-
assert_equal find_type("= 'bob'"), :
|
58
|
+
|
59
|
+
# script scripts / ruby eval mode
|
60
|
+
test "script scripts with strings" do
|
61
|
+
assert_equal find_text('= "bob"'), " \"bob\""
|
62
|
+
assert_equal find_text("= 'bob'"), " 'bob'"
|
63
|
+
assert_equal find_type("= 'bob'"), :script
|
65
64
|
end
|
66
65
|
|
67
|
-
test "
|
68
|
-
assert_equal find_text('= "ruby can #{var}"'), "ruby can \#{var}"
|
69
|
-
assert_equal find_type('= "ruby can #{var}"'), :
|
66
|
+
test "script scripts does not interpolate ruby vars in strings" do
|
67
|
+
assert_equal find_text('= "ruby can #{var}"'), " \"ruby can \#{var}\""
|
68
|
+
assert_equal find_type('= "ruby can #{var}"'), :script
|
70
69
|
end
|
71
|
-
|
72
|
-
# special
|
70
|
+
|
71
|
+
# special script scripts exceptions
|
73
72
|
test "it finds link_to texts as an exception to the rule" do
|
74
73
|
assert_equal find_text('= link_to "This should be found", "/"'), "This should be found"
|
75
|
-
assert_equal find_type('= link_to "This should be found", "/"'), :
|
74
|
+
assert_equal find_type('= link_to "This should be found", "/"'), :script
|
76
75
|
end
|
77
|
-
|
76
|
+
|
78
77
|
test "it finds link_to texts as an exception to the rule and does not interpolate" do
|
79
|
-
assert_equal find_text('= "Statistics for #{@name}"'), "Statistics for \#{@name}"
|
80
|
-
assert_equal find_type('= "Statistics for #{@name}"'), :
|
81
|
-
end
|
82
|
-
|
83
|
-
# html
|
84
|
-
test "html
|
85
|
-
assert_equal find_text('%p= "bob"'), "bob"
|
86
|
-
assert_equal find_text("%p.what= 'bob'"), "bob"
|
87
|
-
assert_equal find_text("%p.what{:attr => :val}= 'bob'"), "bob"
|
88
|
-
assert_equal find_type("%p.what{:attr => :val}= 'bob'"), :
|
89
|
-
end
|
90
|
-
|
91
|
-
test "html
|
92
|
-
assert_equal find_text('%p= "ruby can #{var}"'), "ruby can \#{var}"
|
93
|
-
assert_equal find_text('%p.what= "ruby can #{var}"'), "ruby can \#{var}"
|
94
|
-
assert_equal find_text('%p.what{:attr => :val}= "ruby can #{var}"'), "ruby can \#{var}"
|
95
|
-
assert_equal find_type('%p.what{:attr => :val}= "ruby can #{var}"'), :
|
96
|
-
end
|
97
|
-
|
98
|
-
test "html
|
78
|
+
assert_equal find_text('= "Statistics for #{@name}"'), " \"Statistics for \#{@name}\""
|
79
|
+
assert_equal find_type('= "Statistics for #{@name}"'), :script
|
80
|
+
end
|
81
|
+
|
82
|
+
# html tag mode with ruby evaling
|
83
|
+
test "html tag with ruby eval with strings" do
|
84
|
+
assert_equal find_text('%p= "bob"'), "\"bob\""
|
85
|
+
assert_equal find_text("%p.what= 'bob'"), "'bob'"
|
86
|
+
assert_equal find_text("%p.what{:attr => :val}= 'bob'"), "'bob'"
|
87
|
+
assert_equal find_type("%p.what{:attr => :val}= 'bob'"), :tag
|
88
|
+
end
|
89
|
+
|
90
|
+
test "html tag script scripts does not interpolate ruby vars in strings" do
|
91
|
+
assert_equal find_text('%p= "ruby can #{var}"'), "\"ruby can \#{var}\""
|
92
|
+
assert_equal find_text('%p.what= "ruby can #{var}"'), "\"ruby can \#{var}\""
|
93
|
+
assert_equal find_text('%p.what{:attr => :val}= "ruby can #{var}"'), "\"ruby can \#{var}\""
|
94
|
+
assert_equal find_type('%p.what{:attr => :val}= "ruby can #{var}"'), :tag
|
95
|
+
end
|
96
|
+
|
97
|
+
test "html tag it finds link_to texts as an exception to the rule" do
|
99
98
|
assert_equal find_text('%p= link_to "This should be found", "/"'), "This should be found"
|
100
99
|
assert_equal find_text('%p.what= link_to "This should be found", "/"'), "This should be found"
|
101
100
|
assert_equal find_text('%p.what{:attr => :val}= link_to "This should be found", "/"'), "This should be found"
|
102
|
-
assert_equal find_type('%p.what{:attr => :val}= link_to "This should be found", "/"'), :
|
101
|
+
assert_equal find_type('%p.what{:attr => :val}= link_to "This should be found", "/"'), :tag
|
103
102
|
end
|
104
|
-
|
105
|
-
test "html
|
106
|
-
assert_equal find_text('%p= "Statistics for #{@name}"'), "Statistics for \#{@name}"
|
107
|
-
assert_equal find_text('%p.what= "Statistics for #{@name}"'), "Statistics for \#{@name}"
|
108
|
-
assert_equal find_text('%p.what{:attr => :val}= "Statistics for #{@name}"'), "Statistics for \#{@name}"
|
109
|
-
assert_equal find_type('%p.what{:attr => :val}= "Statistics for #{@name}"'), :
|
103
|
+
|
104
|
+
test "html tag it finds link_to texts as an exception to the rule and does not interpolate" do
|
105
|
+
assert_equal find_text('%p= "Statistics for #{@name}"'), "\"Statistics for \#{@name}\""
|
106
|
+
assert_equal find_text('%p.what= "Statistics for #{@name}"'), "\"Statistics for \#{@name}\""
|
107
|
+
assert_equal find_text('%p.what{:attr => :val}= "Statistics for #{@name}"'), "\"Statistics for \#{@name}\""
|
108
|
+
assert_equal find_type('%p.what{:attr => :val}= "Statistics for #{@name}"'), :tag
|
110
109
|
end
|
111
110
|
|
112
111
|
private
|
113
112
|
|
114
113
|
def process_haml(haml)
|
115
|
-
|
114
|
+
metadata = Haml::I18n::Extractor::HamlParser.new(haml).metadata.first
|
115
|
+
text_finder = Haml::I18n::Extractor::TextFinder.new(haml,metadata)
|
116
116
|
text_finder.process_by_regex
|
117
117
|
end
|
118
118
|
|
@@ -127,4 +127,4 @@ module Haml
|
|
127
127
|
end
|
128
128
|
|
129
129
|
end
|
130
|
-
end
|
130
|
+
end
|
data/test/text_replacer_test.rb
CHANGED
@@ -4,7 +4,7 @@ module Haml
|
|
4
4
|
class TextReplacerTest < MiniTest::Unit::TestCase
|
5
5
|
|
6
6
|
test "it initializes with the line it is going to replace and the match to replace" do
|
7
|
-
Haml::I18n::Extractor::TextReplacer.new("this is whatever", "this is whatever", :
|
7
|
+
Haml::I18n::Extractor::TextReplacer.new("this is whatever", "this is whatever", :plain)
|
8
8
|
end
|
9
9
|
|
10
10
|
test "but it raises if passed a wrong line type" do
|
@@ -18,48 +18,48 @@ module Haml
|
|
18
18
|
|
19
19
|
# some text replacement examples
|
20
20
|
test "it can replace the body of haml with t() characters" do
|
21
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new("this is whatever", "this is whatever", :
|
21
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new("this is whatever", "this is whatever", :plain)
|
22
22
|
assert_equal replacer.replace_hash, { :modified_line => "= t('.this_is_whatever')",
|
23
23
|
:keyname => "t('.this_is_whatever')", :replaced_text => "this is whatever" }
|
24
24
|
end
|
25
25
|
|
26
26
|
test "it can replace the body of haml with t() characters example" do
|
27
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new("%span Admin Dashboard", "Admin Dashboard", :
|
27
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new("%span Admin Dashboard", "Admin Dashboard", :tag)
|
28
28
|
assert_equal replacer.replace_hash, { :modified_line => "%span= t('.admin_dashboard')",
|
29
29
|
:keyname => "t('.admin_dashboard')", :replaced_text => "Admin Dashboard" }
|
30
30
|
end
|
31
31
|
|
32
32
|
test "it won't replace already replaced t() characters if they are not ruby evaled" do
|
33
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new("%span t('.admin_dashboard')", "t('.admin_dashboard')", :
|
33
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new("%span t('.admin_dashboard')", "t('.admin_dashboard')", :tag)
|
34
34
|
assert_equal replacer.replace_hash, { :modified_line => "%span t('.admin_dashboard')",
|
35
35
|
:keyname => "t('.admin_dashboard')", :replaced_text => "t('.admin_dashboard')" }
|
36
36
|
end
|
37
37
|
|
38
38
|
test "it won't replace already replaced t() characters that are ruby evaled" do
|
39
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new("%span= t('.admin_dashboard')", "t('.admin_dashboard')", :
|
39
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new("%span= t('.admin_dashboard')", "t('.admin_dashboard')", :script)
|
40
40
|
assert_equal replacer.replace_hash, { :modified_line => "%span= t('.admin_dashboard')",
|
41
41
|
:keyname => "t('.admin_dashboard')", :replaced_text => "t('.admin_dashboard')" }
|
42
42
|
end
|
43
43
|
|
44
44
|
test "it can replace the body of haml with t() characters example for link_to and removes surrounding quotes as well" do
|
45
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new(%{%p#brand= link_to 'Some Place', '/'}, "Some Place", :
|
45
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new(%{%p#brand= link_to 'Some Place', '/'}, "Some Place", :script)
|
46
46
|
assert_equal replacer.replace_hash, { :modified_line => %{%p#brand= link_to t('.some_place'), '/'} ,
|
47
47
|
:keyname => "t('.some_place')", :replaced_text => "Some Place" }
|
48
48
|
|
49
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new(%{%p#brand= link_to "Some Place", "/"}, "Some Place", :
|
49
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new(%{%p#brand= link_to "Some Place", "/"}, "Some Place", :script)
|
50
50
|
assert_equal replacer.replace_hash, { :modified_line => %{%p#brand= link_to t('.some_place'), "/"} ,
|
51
51
|
:keyname => "t('.some_place')", :replaced_text => "Some Place" }
|
52
52
|
end
|
53
53
|
|
54
54
|
# keyname restrictions
|
55
55
|
test "it limits the characters of the t namespace it provides to LIMIT_KEY_NAME" do
|
56
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new("this is whatever" * 80, "this is whatever" * 80, :
|
56
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new("this is whatever" * 80, "this is whatever" * 80, :plain)
|
57
57
|
assert_equal replacer.replace_hash[:modified_line].size, Haml::I18n::Extractor::TextReplacer::LIMIT_KEY_NAME + 8 # = t('.')
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
test "it does not allow weird characters in the keyname" do
|
61
|
-
weird_line = "
|
62
|
-
replacer = Haml::I18n::Extractor::TextReplacer.new(weird_line, weird_line, :
|
61
|
+
weird_line = "thi:s = (is \"' `ch@racter ~ ma?dne{}ss!"
|
62
|
+
replacer = Haml::I18n::Extractor::TextReplacer.new(weird_line, weird_line, :plain)
|
63
63
|
assert_equal replacer.replace_hash, { :modified_line => "= t('.this_is_chracter_madness')",
|
64
64
|
:keyname => "t('.this_is_chracter_madness')", :replaced_text => weird_line }
|
65
65
|
end
|
data/test/yaml_tool_test.rb
CHANGED
@@ -41,21 +41,7 @@ module Haml
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def ex1_yaml_hash
|
44
|
-
|
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
|
-
}
|
57
|
-
}
|
58
|
-
}
|
44
|
+
YAML.load File.read(file_path("ex1.yml"))
|
59
45
|
end
|
60
46
|
|
61
47
|
test "defaults for empty init" do
|