i15r 0.4.2 → 0.4.3
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.
- data/VERSION +1 -1
- data/i15r.gemspec +1 -1
- data/lib/i15r/base.rb +1 -1
- data/lib/i15r/pattern_matchers/haml/tag_content_matcher.rb +1 -1
- data/spec/haml/tag_content_matcher_spec.rb +16 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/i15r.gemspec
CHANGED
data/lib/i15r/base.rb
CHANGED
@@ -10,7 +10,7 @@ module I15R
|
|
10
10
|
def self.get_i18n_message_string(text, prefix)
|
11
11
|
#TODO: downcase does not work properly for accented chars, like 'Ú'
|
12
12
|
#TODO: [:punct:] would be nice but it includes _ which we don't want to remove
|
13
|
-
key = text.strip.downcase.gsub(/[\s]
|
13
|
+
key = text.strip.downcase.gsub(/[\s\/]+/, '_').gsub(/[!?.,:"';()]/, '')
|
14
14
|
indent = ""
|
15
15
|
(0..prefix.split(".").size).each { |i| indent = " " + indent }
|
16
16
|
# silenced_if_testing do
|
@@ -34,7 +34,7 @@ module I15R
|
|
34
34
|
register_matcher :match_haml_explicit_tag_content
|
35
35
|
|
36
36
|
def self.match_haml_tag_content_just_text_on_line
|
37
|
-
patt = /^(\s*)([
|
37
|
+
patt = /^(\s*)([^.#!%=\/\s][[:alpha:][:upper:]\s\d\!\-\.\?\/]+)$/
|
38
38
|
matches(:haml) do |text, prefix|
|
39
39
|
if m = patt.match(text)
|
40
40
|
i18n_string = I15R::Base.get_i18n_message_string(m[2], prefix)
|
@@ -21,6 +21,12 @@ describe I15R::PatternMatchers::Haml::TagContentMatcher do
|
|
21
21
|
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == i18ned
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should replace /-s with an _" do
|
25
|
+
plain = %(%p Do not close/reload while loading)
|
26
|
+
i18ned = %(%p= I18n.t("users.new.do_not_close_reload_while_loading"))
|
27
|
+
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == i18ned
|
28
|
+
end
|
29
|
+
|
24
30
|
it "should not replace an implict div with an assigned class" do
|
25
31
|
plain = %( .field)
|
26
32
|
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == plain
|
@@ -43,6 +49,16 @@ describe I15R::PatternMatchers::Haml::TagContentMatcher do
|
|
43
49
|
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == i18ned
|
44
50
|
end
|
45
51
|
|
52
|
+
it "should not convert Ruby code to be evaluated" do
|
53
|
+
plain = "= yield"
|
54
|
+
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == plain
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not convert comments" do
|
58
|
+
plain = "/ Do not remove the next line"
|
59
|
+
I15R::PatternMatchers::Haml::TagContentMatcher.run(plain, "users.new").should == plain
|
60
|
+
end
|
61
|
+
|
46
62
|
describe "when text has non-english characters" do
|
47
63
|
it "should replace a tag's content where the tag is an implicit div" do
|
48
64
|
plain = %(#form_head Türkçe)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i15r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Balint Erdi
|