cells 4.0.3 → 4.0.4
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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/cell/escaped.rb +9 -7
- data/lib/cell/version.rb +1 -1
- data/test/property_test.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0deae1307acc8178812fdb8770ef8e42fa1ec62e
|
4
|
+
data.tar.gz: 1ace8b75ed910b9a1e870d9b3c9bececbe81295a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32622f1999e6bebefff207da8c68c367b3e80e958449bd84f5ac5b5712c27358af6b591387c2e9dbeade5fdb50368083aff80bb7be0851813c9a3a6d6f5653b5
|
7
|
+
data.tar.gz: f4604cb8d50ae093e94ef9ce9a2747573945750e68d2d3f2fe4d6936574e546c748023c32b7d2daa9f05bab5617d0818327be2b438d1384ac01d4ee942f2b086
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 4.0.4
|
2
|
+
|
3
|
+
* `Escaped::property` now properly escapes all passed properties. Thanks @xzo and @jlogsdon!
|
4
|
+
|
1
5
|
## 4.0.3
|
2
6
|
|
3
7
|
* `Cell::Partial` now does _append_ the global partial path to its `view_paths` instead of using `unshift` and thereby removing possible custom paths.
|
data/lib/cell/escaped.rb
CHANGED
@@ -4,14 +4,16 @@ module Cell::ViewModel::Escaped
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module Property
|
7
|
-
def property(
|
7
|
+
def property(*names)
|
8
8
|
super.tap do # super defines #title
|
9
9
|
mod = Module.new do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
names.each do |name|
|
11
|
+
define_method(name) do |options={}|
|
12
|
+
value = super() # call the original #title.
|
13
|
+
return value unless value.is_a?(String)
|
14
|
+
return value if options[:escape] == false
|
15
|
+
escape!(value)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
include mod
|
@@ -24,4 +26,4 @@ module Cell::ViewModel::Escaped
|
|
24
26
|
def escape!(string)
|
25
27
|
::ERB::Util.html_escape(string)
|
26
28
|
end
|
27
|
-
end
|
29
|
+
end
|
data/lib/cell/version.rb
CHANGED
data/test/property_test.rb
CHANGED
@@ -20,6 +20,7 @@ class EscapedPropertyTest < MiniTest::Spec
|
|
20
20
|
include Escaped
|
21
21
|
property :title
|
22
22
|
property :artist
|
23
|
+
property :copyright, :lyrics
|
23
24
|
|
24
25
|
def title(*)
|
25
26
|
"#{super}</b>" # super + "</b>" still escapes, but this is Rails.
|
@@ -30,12 +31,18 @@ class EscapedPropertyTest < MiniTest::Spec
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
let (:song)
|
34
|
+
let (:song) do
|
35
|
+
Struct
|
36
|
+
.new(:title, :artist, :copyright, :lyrics)
|
37
|
+
.new("<b>She Sells And Sand Sandwiches", Object, "<a>Copy</a>", "<i>Words</i>")
|
38
|
+
end
|
34
39
|
|
35
40
|
# ::property escapes, everywhere.
|
36
41
|
it { SongCell.(song).title.must_equal "<b>She Sells And Sand Sandwiches</b>" }
|
42
|
+
it { SongCell.(song).copyright.must_equal "<a>Copy</a>" }
|
43
|
+
it { SongCell.(song).lyrics.must_equal "<i>Words</i>" }
|
37
44
|
# no escaping for non-strings.
|
38
45
|
it { SongCell.(song).artist.must_equal Object }
|
39
46
|
# no escaping when escape: false
|
40
47
|
it { SongCell.(song).raw_title.must_equal "<b>She Sells And Sand Sandwiches</b>" }
|
41
|
-
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cells
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|