semantic_date_time_tags 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +19 -22
- data/lib/semantic_date_time_tags/tag/date_range.rb +6 -0
- data/lib/semantic_date_time_tags/version.rb +1 -1
- data/test/semantic_date_time_tags/view_helpers_test.rb +27 -24
- 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: fe726c652f793a8dd9fe4544b1ce97c490f8e886
|
4
|
+
data.tar.gz: 0e7ea49f7fb2c6099f34f300b148d6c3131d38d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710ddafcf1f2284cb34c1a8505ddca911dce078d28468e1b0c9849707ece8e879c62691d3d97a63fba1daca55043ba5fd672ea423074160cfd58614c6b3a3f6d
|
7
|
+
data.tar.gz: 37b06c8ec419ebef9a7742b4cd05646b00ea2cc28b0e15d582cb329fb28f1380adc56dfecd093ee321c00987e21df86ddf57a0e699df67989c6c5ea0df200981
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
semantic_date_time_tags (0.0.
|
4
|
+
semantic_date_time_tags (0.0.10)
|
5
5
|
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -44,26 +44,24 @@ GEM
|
|
44
44
|
tzinfo (~> 1.1)
|
45
45
|
arel (6.0.3)
|
46
46
|
builder (3.2.2)
|
47
|
-
celluloid (0.16.0)
|
48
|
-
timers (~> 4.0.0)
|
49
47
|
coderay (1.1.0)
|
50
|
-
coveralls (0.8.
|
48
|
+
coveralls (0.8.3)
|
51
49
|
json (~> 1.8)
|
52
50
|
rest-client (>= 1.6.8, < 2)
|
53
51
|
simplecov (~> 0.10.0)
|
54
52
|
term-ansicolor (~> 1.3)
|
55
53
|
thor (~> 0.19.1)
|
56
54
|
docile (1.1.5)
|
57
|
-
domain_name (0.5.
|
55
|
+
domain_name (0.5.25)
|
58
56
|
unf (>= 0.0.5, < 1.0.0)
|
59
57
|
erubis (2.7.0)
|
60
|
-
ffi (1.9.
|
58
|
+
ffi (1.9.10)
|
61
59
|
formatador (0.2.5)
|
62
60
|
globalid (0.3.6)
|
63
61
|
activesupport (>= 4.1.0)
|
64
|
-
guard (2.
|
62
|
+
guard (2.13.0)
|
65
63
|
formatador (>= 0.2.4)
|
66
|
-
listen (
|
64
|
+
listen (>= 2.7, <= 4.0)
|
67
65
|
lumberjack (~> 1.0)
|
68
66
|
nenv (~> 0.1)
|
69
67
|
notiffany (~> 0.0)
|
@@ -74,13 +72,11 @@ GEM
|
|
74
72
|
guard-minitest (2.4.4)
|
75
73
|
guard-compat (~> 1.2)
|
76
74
|
minitest (>= 3.0)
|
77
|
-
hitimes (1.2.2)
|
78
75
|
http-cookie (1.0.2)
|
79
76
|
domain_name (~> 0.5)
|
80
77
|
i18n (0.7.0)
|
81
78
|
json (1.8.3)
|
82
|
-
listen (
|
83
|
-
celluloid (~> 0.16.0)
|
79
|
+
listen (3.0.3)
|
84
80
|
rb-fsevent (>= 0.9.3)
|
85
81
|
rb-inotify (>= 0.9)
|
86
82
|
loofah (2.0.3)
|
@@ -89,17 +85,17 @@ GEM
|
|
89
85
|
mail (2.6.3)
|
90
86
|
mime-types (>= 1.16, < 3)
|
91
87
|
method_source (0.8.2)
|
92
|
-
mime-types (2.6.
|
88
|
+
mime-types (2.6.2)
|
93
89
|
mini_portile (0.6.2)
|
94
|
-
minitest (5.
|
90
|
+
minitest (5.8.2)
|
95
91
|
nenv (0.2.0)
|
96
|
-
netrc (0.
|
92
|
+
netrc (0.11.0)
|
97
93
|
nokogiri (1.6.6.2)
|
98
94
|
mini_portile (~> 0.6.0)
|
99
|
-
notiffany (0.0.
|
95
|
+
notiffany (0.0.8)
|
100
96
|
nenv (~> 0.1)
|
101
97
|
shellany (~> 0.0)
|
102
|
-
pry (0.10.
|
98
|
+
pry (0.10.3)
|
103
99
|
coderay (~> 1.1.0)
|
104
100
|
method_source (~> 0.8.1)
|
105
101
|
slop (~> 3.4)
|
@@ -131,7 +127,7 @@ GEM
|
|
131
127
|
rake (>= 0.8.7)
|
132
128
|
thor (>= 0.18.1, < 2.0)
|
133
129
|
rake (10.4.2)
|
134
|
-
rb-fsevent (0.9.
|
130
|
+
rb-fsevent (0.9.6)
|
135
131
|
rb-inotify (0.9.5)
|
136
132
|
ffi (>= 0.5.0)
|
137
133
|
rest-client (1.8.0)
|
@@ -145,8 +141,8 @@ GEM
|
|
145
141
|
simplecov-html (~> 0.10.0)
|
146
142
|
simplecov-html (0.10.0)
|
147
143
|
slop (3.6.0)
|
148
|
-
sprockets (3.
|
149
|
-
rack (
|
144
|
+
sprockets (3.4.0)
|
145
|
+
rack (> 1, < 3)
|
150
146
|
sprockets-rails (2.3.3)
|
151
147
|
actionpack (>= 3.0)
|
152
148
|
activesupport (>= 3.0)
|
@@ -155,9 +151,7 @@ GEM
|
|
155
151
|
tins (~> 1.0)
|
156
152
|
thor (0.19.1)
|
157
153
|
thread_safe (0.3.5)
|
158
|
-
|
159
|
-
hitimes
|
160
|
-
tins (1.5.4)
|
154
|
+
tins (1.6.0)
|
161
155
|
tzinfo (1.2.2)
|
162
156
|
thread_safe (~> 0.1)
|
163
157
|
unf (0.1.4)
|
@@ -175,3 +169,6 @@ DEPENDENCIES
|
|
175
169
|
minitest
|
176
170
|
rake
|
177
171
|
semantic_date_time_tags!
|
172
|
+
|
173
|
+
BUNDLED WITH
|
174
|
+
1.10.6
|
@@ -27,12 +27,18 @@ module SemanticDateTimeTags
|
|
27
27
|
@date_from == @date_to
|
28
28
|
end
|
29
29
|
|
30
|
+
def both_in_current_year?
|
31
|
+
return false if spans_years?
|
32
|
+
@date_from.year == ::Date.today.year
|
33
|
+
end
|
34
|
+
|
30
35
|
# ---------------------------------------------------------------------
|
31
36
|
|
32
37
|
def dom_classes
|
33
38
|
res = []
|
34
39
|
res << 'date_range'
|
35
40
|
res << 'same_year' unless spans_years?
|
41
|
+
res << 'current_year' if both_in_current_year?
|
36
42
|
res << 'same_month' unless spans_months?
|
37
43
|
res << 'more_than_a_week' unless within_a_week?
|
38
44
|
res << 'same_day' if one_day?
|
@@ -4,10 +4,10 @@ require 'semantic_date_time_tags/view_helpers'
|
|
4
4
|
describe SemanticDateTimeTags::ViewHelpers do
|
5
5
|
include SemanticDateTimeTags::ViewHelpers
|
6
6
|
|
7
|
-
let(:time_object) { Time.
|
8
|
-
let(:date_object) { Date.
|
9
|
-
let(:date_tomorrow_object) { Date.
|
10
|
-
let(:date_time_object) { DateTime.
|
7
|
+
let(:time_object) { Time.parse('31/10/2015') }
|
8
|
+
let(:date_object) { Date.parse('31/10/2015') }
|
9
|
+
let(:date_tomorrow_object) { Date.parse('31/10/2015')+1.day }
|
10
|
+
let(:date_time_object) { DateTime.parse('31/10/2015') }
|
11
11
|
|
12
12
|
# ---------------------------------------------------------------------
|
13
13
|
|
@@ -22,27 +22,27 @@ describe SemanticDateTimeTags::ViewHelpers do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'returns hours wrapped in a span tag' do
|
25
|
-
semantic_time_tag(time_object).must_match Regexp.new("
|
25
|
+
semantic_time_tag(time_object).must_match Regexp.new("<span.+?hours.+?H.+?>#{time_object_hours}</span>")
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'returns minutes wrapped in a span tag' do
|
29
|
-
semantic_time_tag(time_object).must_match Regexp.new("
|
29
|
+
semantic_time_tag(time_object).must_match Regexp.new("<span.+?minutes.+?M.+?>#{time_object_minutes}</span>")
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'wraps the whole thing in a time tag by default' do
|
33
|
-
semantic_time_tag(time_object).must_match
|
33
|
+
semantic_time_tag(time_object).must_match /\A<time.+?<\/time>\z/
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'wraps the whole thing in a span tag if passed as argument' do
|
37
|
-
semantic_time_tag(time_object, :span).must_match
|
37
|
+
semantic_time_tag(time_object, :span).must_match /\A<span.+?<\/span>\z/
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'adds whole_hour class if time is whole hour' do
|
41
|
-
semantic_time_tag(time_object_whole_hour).must_match
|
41
|
+
semantic_time_tag(time_object_whole_hour).must_match /\A<time.+?whole_hour.+?<\/time>\z/
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'adds whole_minute class if time is whole minute' do
|
45
|
-
semantic_time_tag(time_object_whole_minute).must_match
|
45
|
+
semantic_time_tag(time_object_whole_minute).must_match /\A<time.+?whole_minute.+?<\/time>\z/
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'allows to pass :format' do
|
@@ -56,39 +56,37 @@ describe SemanticDateTimeTags::ViewHelpers do
|
|
56
56
|
let(:date_object_day) { date_object.strftime('%-d') }
|
57
57
|
let(:date_object_month) { date_object.strftime('%-m') }
|
58
58
|
let(:date_object_year) { date_object.year }
|
59
|
-
let(:date_object_yesterday) { Date.yesterday }
|
60
|
-
let(:date_object_last_year) { Date.civil( date_object.year-1, date_object.month, date_object.day ) }
|
61
59
|
|
62
60
|
it 'should only work with a date or datetime object' do
|
63
61
|
proc { semantic_date_tag(time_object) }.must_raise RuntimeError
|
64
62
|
end
|
65
63
|
|
66
64
|
it 'wraps everything in a time tag by default' do
|
67
|
-
semantic_date_tag(date_object).must_match
|
65
|
+
semantic_date_tag(date_object).must_match /\A<time.+?<\/time>\z/
|
68
66
|
end
|
69
67
|
|
70
68
|
it 'wraps everything in a span tag if passed as argument' do
|
71
|
-
semantic_date_tag(date_object, :span).must_match
|
69
|
+
semantic_date_tag(date_object, :span).must_match /\A<span.+?<\/span>\z/
|
72
70
|
end
|
73
71
|
|
74
72
|
it 'returns year, month and day wrapped in a span tags' do
|
75
|
-
semantic_date_tag(date_object).must_match Regexp.new("
|
76
|
-
semantic_date_tag(date_object).must_match Regexp.new("
|
77
|
-
semantic_date_tag(date_object).must_match Regexp.new("
|
73
|
+
semantic_date_tag(date_object).must_match Regexp.new("<span.+?year.+?>#{date_object_year}</span>")
|
74
|
+
semantic_date_tag(date_object).must_match Regexp.new("<span.+?month.+?>#{date_object_month}</span>")
|
75
|
+
semantic_date_tag(date_object).must_match Regexp.new("<span.+?day.+?>#{date_object_day}</span>")
|
78
76
|
end
|
79
77
|
|
80
78
|
it 'adds current_date class if date is today' do
|
81
|
-
semantic_date_tag(
|
82
|
-
semantic_date_tag(
|
79
|
+
semantic_date_tag(Date.today).must_include "current_date"
|
80
|
+
semantic_date_tag(Date.today-1.day).wont_include "current_date"
|
83
81
|
end
|
84
82
|
|
85
83
|
it 'adds current class to year span if date is this year' do
|
86
|
-
semantic_date_tag(
|
87
|
-
semantic_date_tag(
|
84
|
+
semantic_date_tag(Date.today).must_include "current_year"
|
85
|
+
semantic_date_tag(Date.today-1.year).wont_include "current_year"
|
88
86
|
end
|
89
87
|
|
90
88
|
it 'allows to pass :format' do
|
91
|
-
semantic_date_tag(
|
89
|
+
semantic_date_tag(Date.today, :time, format: :test).must_include '~'
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
@@ -100,7 +98,7 @@ describe SemanticDateTimeTags::ViewHelpers do
|
|
100
98
|
end
|
101
99
|
|
102
100
|
it 'wraps the whole thing in a time tag' do
|
103
|
-
semantic_date_time_tag(date_time_object).must_match
|
101
|
+
semantic_date_time_tag(date_time_object).must_match /\A<time.+?<\/time>\z/
|
104
102
|
end
|
105
103
|
|
106
104
|
it 'allows to pass :format' do
|
@@ -112,7 +110,12 @@ describe SemanticDateTimeTags::ViewHelpers do
|
|
112
110
|
|
113
111
|
describe '#semantic_date_range_tag' do
|
114
112
|
it 'returns the from date wrapped correctly' do
|
115
|
-
semantic_date_range_tag(date_object, date_tomorrow_object).must_match
|
113
|
+
semantic_date_range_tag(date_object, date_tomorrow_object).must_match /<time.+?semantic.+?date.+?from.+?>/
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'adds same_year and current_year class to wrapping span' do
|
117
|
+
semantic_date_range_tag(date_object, date_tomorrow_object).must_match /<time.+?date_range.+?current_year.+?>/
|
116
118
|
end
|
117
119
|
end
|
120
|
+
|
118
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantic_date_time_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|