i15r 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{i15r}
8
- s.version = "0.4.2"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Balint Erdi"]
@@ -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]/, '_').gsub(/[!?.,:"';()]/, '')
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*)([^.#!%\s][[:alpha:][:upper:]\s\d\!\-\.\?]+)$/
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Balint Erdi