condensation 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +35 -0
- data/Rakefile +6 -6
- data/condensation.gemspec +18 -16
- data/lib/condensation.rb +9 -7
- data/lib/condensation/extensions.rb +7 -5
- data/lib/condensation/filters.rb +15 -13
- data/lib/condensation/filters/advance_date_to_next.rb +13 -9
- data/lib/condensation/filters/at_midnight.rb +12 -8
- data/lib/condensation/filters/days_since.rb +10 -6
- data/lib/condensation/filters/days_until.rb +10 -6
- data/lib/condensation/filters/default.rb +2 -2
- data/lib/condensation/filters/hmac_sha256.rb +12 -0
- data/lib/condensation/filters/hyperlink.rb +1 -1
- data/lib/condensation/filters/in_time_zone.rb +6 -6
- data/lib/condensation/filters/md5.rb +12 -0
- data/lib/condensation/filters/replace_inner_html.rb +4 -4
- data/lib/condensation/filters/strip_commas.rb +2 -2
- data/lib/condensation/filters/url_encode.rb +4 -2
- data/lib/condensation/filters/weeks_since.rb +10 -6
- data/lib/condensation/filters/weeks_until.rb +10 -6
- data/lib/condensation/sanitizer.rb +4 -2
- data/lib/condensation/version.rb +1 -1
- data/spec/condensation/filters/advance_date_to_next_spec.rb +39 -39
- data/spec/condensation/filters/at_midnight_spec.rb +29 -29
- data/spec/condensation/filters/days_since_spec.rb +34 -34
- data/spec/condensation/filters/days_until_spec.rb +39 -39
- data/spec/condensation/filters/default_spec.rb +19 -19
- data/spec/condensation/filters/hmac_sha256_spec.rb +21 -0
- data/spec/condensation/filters/hyperlink_spec.rb +23 -23
- data/spec/condensation/filters/in_time_zone_spec.rb +10 -10
- data/spec/condensation/filters/md5_spec.rb +21 -0
- data/spec/condensation/filters/replace_inner_html_spec.rb +10 -10
- data/spec/condensation/filters/strip_commas_spec.rb +10 -10
- data/spec/condensation/filters/timestamp_spec.rb +34 -34
- data/spec/condensation/filters/url_encode_spec.rb +10 -10
- data/spec/condensation/filters/weeks_since_spec.rb +34 -34
- data/spec/condensation/filters/weeks_until_spec.rb +39 -39
- data/spec/condensation/sanitizer_spec.rb +4 -4
- data/spec/condensation_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- metadata +25 -3
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::WeeksUntil do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::WeeksUntil])
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:now) do
|
@@ -17,59 +17,59 @@ describe Condensation::Filters::WeeksUntil do
|
|
17
17
|
Timecop.return
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
created_at =
|
22
|
-
template = Liquid::Template.parse(
|
23
|
-
result = render_with_filter(template,
|
24
|
-
result.must_equal
|
20
|
+
it 'should handle UTC ISO 8601 dates' do
|
21
|
+
created_at = '2014-05-30T10:00:00Z'
|
22
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
23
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
24
|
+
result.must_equal '2'
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
created_at =
|
29
|
-
template = Liquid::Template.parse(
|
30
|
-
result = render_with_filter(template,
|
31
|
-
result.must_equal
|
27
|
+
it 'should handle non-UTC ISO 8601 dates' do
|
28
|
+
created_at = '2014-05-30T20:00:00-07:00'
|
29
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
30
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
31
|
+
result.must_equal '2'
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
created_at =
|
36
|
-
template = Liquid::Template.parse(
|
37
|
-
result = render_with_filter(template,
|
38
|
-
result.must_equal
|
34
|
+
it 'should handle YMD formatted dates' do
|
35
|
+
created_at = '2014-05-30'
|
36
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
37
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
38
|
+
result.must_equal '2'
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it 'should handle Time input' do
|
42
42
|
created_at = Time.utc(2014, 6, 15, 0, 0, 0)
|
43
|
-
template = Liquid::Template.parse(
|
44
|
-
result = render_with_filter(template,
|
45
|
-
result.must_equal
|
43
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
44
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
45
|
+
result.must_equal '4'
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
created_at =
|
50
|
-
template = Liquid::Template.parse(
|
51
|
-
result = render_with_filter(template,
|
52
|
-
result.must_equal
|
48
|
+
it 'should handle malformed dates' do
|
49
|
+
created_at = 'foo'
|
50
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
51
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
52
|
+
result.must_equal ''
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
created_at =
|
57
|
-
template = Liquid::Template.parse(
|
58
|
-
result = render_with_filter(template,
|
59
|
-
result.must_equal
|
55
|
+
it 'should be zero for days in the past' do
|
56
|
+
created_at = '2014-05-01T20:00:00Z'
|
57
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
58
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
59
|
+
result.must_equal '0'
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
created_at =
|
64
|
-
template = Liquid::Template.parse(
|
65
|
-
result = render_with_filter(template,
|
66
|
-
result.must_equal
|
62
|
+
it 'should handle empty string input' do
|
63
|
+
created_at = ''
|
64
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
65
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
66
|
+
result.must_equal ''
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it 'should handle nil input' do
|
70
70
|
created_at = nil
|
71
|
-
template = Liquid::Template.parse(
|
72
|
-
result = render_with_filter(template,
|
73
|
-
result.must_equal
|
71
|
+
template = Liquid::Template.parse('{{ created_at | weeks_until }}')
|
72
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
73
|
+
result.must_equal ''
|
74
74
|
end
|
75
75
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
describe Condensation::Sanitizer do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe '#escape_html' do
|
5
|
+
it 'should escape HTML entities' do
|
6
6
|
html = "<div><a href='http://foo.bar/?x=r%20b&y=z'>Baz</a></div>"
|
7
|
-
escaped =
|
7
|
+
escaped = '<div><a href='http://foo.bar/?x=r%20b&y=z'>Baz</a></div>'
|
8
8
|
Condensation::Sanitizer.new(html).escape_html.must_equal(escaped)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
data/spec/condensation_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: condensation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: liquid
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,8 @@ extensions: []
|
|
108
122
|
extra_rdoc_files: []
|
109
123
|
files:
|
110
124
|
- ".gitignore"
|
125
|
+
- ".rubocop.yml"
|
126
|
+
- ".rubocop_todo.yml"
|
111
127
|
- Gemfile
|
112
128
|
- LICENSE.txt
|
113
129
|
- README.md
|
@@ -121,8 +137,10 @@ files:
|
|
121
137
|
- lib/condensation/filters/days_since.rb
|
122
138
|
- lib/condensation/filters/days_until.rb
|
123
139
|
- lib/condensation/filters/default.rb
|
140
|
+
- lib/condensation/filters/hmac_sha256.rb
|
124
141
|
- lib/condensation/filters/hyperlink.rb
|
125
142
|
- lib/condensation/filters/in_time_zone.rb
|
143
|
+
- lib/condensation/filters/md5.rb
|
126
144
|
- lib/condensation/filters/replace_inner_html.rb
|
127
145
|
- lib/condensation/filters/strip_commas.rb
|
128
146
|
- lib/condensation/filters/timestamp.rb
|
@@ -136,8 +154,10 @@ files:
|
|
136
154
|
- spec/condensation/filters/days_since_spec.rb
|
137
155
|
- spec/condensation/filters/days_until_spec.rb
|
138
156
|
- spec/condensation/filters/default_spec.rb
|
157
|
+
- spec/condensation/filters/hmac_sha256_spec.rb
|
139
158
|
- spec/condensation/filters/hyperlink_spec.rb
|
140
159
|
- spec/condensation/filters/in_time_zone_spec.rb
|
160
|
+
- spec/condensation/filters/md5_spec.rb
|
141
161
|
- spec/condensation/filters/replace_inner_html_spec.rb
|
142
162
|
- spec/condensation/filters/strip_commas_spec.rb
|
143
163
|
- spec/condensation/filters/timestamp_spec.rb
|
@@ -167,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
187
|
version: '0'
|
168
188
|
requirements: []
|
169
189
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.5.1
|
171
191
|
signing_key:
|
172
192
|
specification_version: 4
|
173
193
|
summary: Condensation is a collection of handy extensions to the Liquid templating
|
@@ -178,8 +198,10 @@ test_files:
|
|
178
198
|
- spec/condensation/filters/days_since_spec.rb
|
179
199
|
- spec/condensation/filters/days_until_spec.rb
|
180
200
|
- spec/condensation/filters/default_spec.rb
|
201
|
+
- spec/condensation/filters/hmac_sha256_spec.rb
|
181
202
|
- spec/condensation/filters/hyperlink_spec.rb
|
182
203
|
- spec/condensation/filters/in_time_zone_spec.rb
|
204
|
+
- spec/condensation/filters/md5_spec.rb
|
183
205
|
- spec/condensation/filters/replace_inner_html_spec.rb
|
184
206
|
- spec/condensation/filters/strip_commas_spec.rb
|
185
207
|
- spec/condensation/filters/timestamp_spec.rb
|