r2 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5001cd455fb9de572960b0f6ab968888198a5e88
4
- data.tar.gz: 3508a64c9e2df1edf3a5656094860f3afd66242c
3
+ metadata.gz: 993216b45cc4bad2255bc31184ca50bbd73dc8bf
4
+ data.tar.gz: 8f13aebd5b0081c7f08e796654a67c54cb6ecb14
5
5
  SHA512:
6
- metadata.gz: eaf0fa605bd6b6f03a9181997949618a2567a18bc170e0db71d250b2a7a658ea2e6b613a3d9c050d5da1248bce08f8bd520d36c9e04424e512f30ead4b818c0b
7
- data.tar.gz: 2db705161e9d78c836c7e19ce1c9942ecb0e388b19821edc40bce355eee226c5ee4f2f9d8d006277de6f2e9688a21ac7e75875c94aea5c3a8132f51fa261b985
6
+ metadata.gz: 553d29ee6461fb312f7e93cfee40a8707eefd96db4744041a4073e8d50be25781aea42c332313246c66ec1b23696ddf545965c9959ff88eb53d84a15b919ccaf
7
+ data.tar.gz: 0638da0e1140f27b7b330575d038603007c15f865309b538d5543b8572e6bb610e2f747c7248fc058645c5c45e17255b4b6914920fb8a498733604911a39b643
@@ -2,8 +2,4 @@
2
2
  language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
- - jruby-18mode # JRuby in 1.8 mode
6
5
  - jruby-19mode # JRuby in 1.9 mode
7
- - rbx-18mode
8
- - rbx-19mode
9
- - 1.8.7
data/README.md CHANGED
@@ -23,6 +23,9 @@ Report bugs in the github project at http://github.com/mzsanford/r2rb
23
23
 
24
24
  ## Change Log
25
25
 
26
+ * v0.2.3 - Handle `url()` properties better
27
+ * [BUG] - Handle `url()` with embedded semi-colons (like escaped SVG)
28
+ * [CHANGE] - Remove Travis tests for Ruby 1.8 because Travis adds a `celluloid` dependency that does not work before Ruby 1.9.3
26
29
  * v0.2.2 – CSS3 `box-shadow` fix continues
27
30
  * [BUG] Correctly handle `box-shadow` declarations that define multiple shadows (fix from [@wazeHQ](https://github.com/wazeHQ))
28
31
  * [FEATURE] Make the `r2` command line tool convert CSS provided via `stdin` or a file (previously it was a no-op)
data/lib/r2.rb CHANGED
@@ -70,14 +70,32 @@ module R2
70
70
  css = minimize(original_css)
71
71
 
72
72
  result = css.gsub(/([^\{\}]+[^\}]|[\}])+?/) do |rule|
73
+ # +rule+ can represent a selector (".foo {"), the closing "}" for a selector, or the complete
74
+ # body of a a selector
73
75
  if rule.match(/[\{\}]/)
74
- #it is a selector with "{" or a closing "}", insert as it is
76
+ # it is a selector with "{" or a closing "}", insert as it is. This is
77
+ # things like ".foo {" and its matching "}"
75
78
  rule_str = rule
76
79
  else
77
- #It is a decleration
80
+ # It is a declaration body, like "padding-left:4px;margin-left:5px;"
78
81
  rule_str = ""
79
- rule.split(/;(?!base64)/).each do |decl|
80
- rule_str << declaration_swap(decl)
82
+ # Split up the individual rules in the body and process each swap. To handle the
83
+ # possible ";" in the url() definitions, like
84
+ # url("data;base64") and url("data:image/svg+xml;charset=...")
85
+ # a state machine is constructed.
86
+ url_rule = nil
87
+ rule.split(/;/).each do |part|
88
+ if part.match(/url\(/)
89
+ url_rule = part
90
+ elsif url_rule != nil
91
+ url_rule << ";" + part
92
+ if part.match(/\)$/)
93
+ rule_str << declaration_swap(url_rule)
94
+ url_rule = nil
95
+ end
96
+ else
97
+ rule_str << declaration_swap(part)
98
+ end
81
99
  end
82
100
  end
83
101
  rule_str
@@ -1,3 +1,3 @@
1
1
  module R2
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/r2.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Matt Sanford"]
10
10
  s.email = ["matt@twitter.com"]
11
- s.homepage = ""
11
+ s.homepage = "https://github.com/mzsanford/R2rb"
12
12
  s.summary = %q{CSS flipper for right-to-left processing}
13
13
  s.description = %q{CSS flipper for right-to-left processing. A Ruby port of https://github.com/ded/r2}
14
14
 
@@ -39,6 +39,23 @@ describe R2::Swapper do
39
39
 
40
40
  flipped_css.should == expected_result
41
41
  end
42
+
43
+ it "handles SVG background-image declarations" do
44
+ escaped_xml = "%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20%20width%3D%2214px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2014%2014%22%20style%3D%22enable-background%3Anew%200%200%2014%2014%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpath%20style%3D%22fill%3A%23FFFFFF%3B%22%20d%3D%22M9%2C5v3l5-4L9%2C0v3c0%2C0-5%2C0-5%2C7C6%2C5%2C9%2C5%2C9%2C5z%20M11%2C12H2V5h1l2-2H0v11h13V7l-2%2C2V12z%22%2F%3E%3C%2Fsvg%3E"
45
+ css = <<-EOS
46
+ .ui-icon-action:after {
47
+ display: block;
48
+ background-image: url("data:image/svg+xml;charset=ISO-8859-1,#{escaped_xml}");
49
+ text-align: left;
50
+ }
51
+ EOS
52
+
53
+ expected_result = ".ui-icon-action:after{display:block;background-image:url(\"data:image/svg+xml;charset=ISO-8859-1,#{escaped_xml}\");text-align:right;}"
54
+
55
+ flipped_css = r2.r2(css)
56
+
57
+ flipped_css.should == expected_result
58
+ end
42
59
  end
43
60
 
44
61
  describe "#declaration_swap" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Sanford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,7 +59,7 @@ files:
59
59
  - lib/r2/version.rb
60
60
  - r2.gemspec
61
61
  - spec/r2_spec.rb
62
- homepage: ''
62
+ homepage: https://github.com/mzsanford/R2rb
63
63
  licenses: []
64
64
  metadata: {}
65
65
  post_install_message: