snippr 0.15.14 → 0.15.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -0
- data/README.md +4 -0
- data/lib/snippr.rb +1 -0
- data/lib/snippr/segment_filter/valid_between.rb +27 -0
- data/snippr.gemspec +1 -1
- data/spec/snippr/segment_filter/base_spec.rb +1 -1
- data/spec/snippr/segment_filter/valid_between_spec.rb +20 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDUxZDgxNzQ4M2E0NDAzNzcxMDQyMDU5MzBlMTAyYmU1ZWZlYzQ2NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzM1NGU3MDgxZWIwZDNhMWIzYmUxMWZhMmJhZjFmZmY2YTM4ZDFmZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTFlOTM3MTFiMmYwMDJlNDdkNGFmMDJiYjRkMDQxNDU3N2NmMzg4OThmZGZh
|
10
|
+
NTAwOGRlMDQ3ODc2NmIzYWQwNGQyMTVmMDIyMTk0ZDRiMGQ0NjQxZWFhZTMz
|
11
|
+
MGFjZTkwYzg5MmM0NjE1OTQxNGI1Njg1N2FmZTM4YmJlYzRhNTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWNjNzc1MTUzYWVkNmJhZDAzMjQxMWI5ODc1OGE5NzkyMTUyOTcyN2JkNTll
|
14
|
+
MzFiMGU0OTM1NjY3NTI3NGM5ZWQyN2VlNmFlY2JiNDk1OTNlYjRkMmExZTU5
|
15
|
+
MzgyYTk1ZTk2YzZiN2RlMzUzMGJjZjA5NGU2NzM2NzE0MzEwMWM=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -151,6 +151,10 @@ Here the second segment would be the content on and after 2013-05-17 13:15:00.
|
|
151
151
|
`valid_until: YYYY-MM-DD HH:MM:SS` :
|
152
152
|
Same as `valid_from` only the other way round
|
153
153
|
|
154
|
+
#### valid_between
|
155
|
+
`valid_between: YYYY-MM-DD HH:MM:SS - YYYY-MM-DD HH:MM::SS` :
|
156
|
+
Combines `valid_from` and `valid_until` segment filters
|
157
|
+
|
154
158
|
#### on_rails_env
|
155
159
|
`on_rails_env: production`:
|
156
160
|
Shows the snippet only in the given environment(s).
|
data/lib/snippr.rb
CHANGED
@@ -18,6 +18,7 @@ require 'snippr/segment_parser'
|
|
18
18
|
require 'snippr/segment_filter/base'
|
19
19
|
require 'snippr/segment_filter/valid_from'
|
20
20
|
require 'snippr/segment_filter/valid_until'
|
21
|
+
require 'snippr/segment_filter/valid_between'
|
21
22
|
require 'snippr/segment_filter/on_host'
|
22
23
|
require 'snippr/segment_filter/on_rails_env' if defined?(Rails)
|
23
24
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Snippr
|
3
|
+
module SegmentFilter
|
4
|
+
class ValidBetween < Base
|
5
|
+
def active?
|
6
|
+
Snippr::Clock.now.to_s >= valid_from && Snippr::Clock.now.to_s <= valid_until
|
7
|
+
rescue ArgumentError
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def valid_from
|
14
|
+
@valid_from ||= DateTime.strptime(@filter_value, "%Y-%m-%d %H:%M").to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid_until
|
18
|
+
@valid_until ||= begin
|
19
|
+
date_until = @filter_value.match(/([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}(?::[0-9]{2})?)$/)
|
20
|
+
raise ArgumentError.new("valid_until date not parsable. Full filter value was: '#{@filter_value}'") if date_until.nil?
|
21
|
+
DateTime.strptime(date_until[1], "%Y-%m-%d %H:%M").to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/snippr.gemspec
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe "Snippr::SegmentFilter::ValidBetween" do
|
5
|
+
it "returns true if 'now' is between the filter dates" do
|
6
|
+
Snippr::SegmentFilter::ValidBetween.new("1976-03-10 09:00:00 - 9999-09-01 23:59:59").should be_active
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns false if 'now' is outside the filter dates" do
|
10
|
+
Snippr::SegmentFilter::ValidBetween.new("1976-03-10 09:00:00 - 1977-09-01 23:59:59").should_not be_active
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns false if the from date is not parsable" do
|
14
|
+
Snippr::SegmentFilter::ValidBetween.new("xxxx-03-10 09:00:00 - 1977-09-01 23:59:59").should_not be_active
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns false if the until date is not parsable" do
|
18
|
+
Snippr::SegmentFilter::ValidBetween.new("1976-03-10 09:00:00 - xxxx-09-01 23:59:59").should_not be_active
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snippr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: i18n
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/snippr/segment_filter/base.rb
|
139
139
|
- lib/snippr/segment_filter/on_host.rb
|
140
140
|
- lib/snippr/segment_filter/on_rails_env.rb
|
141
|
+
- lib/snippr/segment_filter/valid_between.rb
|
141
142
|
- lib/snippr/segment_filter/valid_from.rb
|
142
143
|
- lib/snippr/segment_filter/valid_until.rb
|
143
144
|
- lib/snippr/segment_parser.rb
|
@@ -178,6 +179,7 @@ files:
|
|
178
179
|
- spec/snippr/segment_filter/base_spec.rb
|
179
180
|
- spec/snippr/segment_filter/on_host_spec.rb
|
180
181
|
- spec/snippr/segment_filter/on_rails_env_spec.rb
|
182
|
+
- spec/snippr/segment_filter/valid_between_spec.rb
|
181
183
|
- spec/snippr/segment_filter/valid_from_spec.rb
|
182
184
|
- spec/snippr/segment_filter/valid_until_spec.rb
|
183
185
|
- spec/snippr/segment_parser_spec.rb
|
@@ -206,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
208
|
version: '0'
|
207
209
|
requirements: []
|
208
210
|
rubyforge_project: snippr
|
209
|
-
rubygems_version: 2.
|
211
|
+
rubygems_version: 2.2.0
|
210
212
|
signing_key:
|
211
213
|
specification_version: 4
|
212
214
|
summary: File based content management
|
@@ -243,6 +245,7 @@ test_files:
|
|
243
245
|
- spec/snippr/segment_filter/base_spec.rb
|
244
246
|
- spec/snippr/segment_filter/on_host_spec.rb
|
245
247
|
- spec/snippr/segment_filter/on_rails_env_spec.rb
|
248
|
+
- spec/snippr/segment_filter/valid_between_spec.rb
|
246
249
|
- spec/snippr/segment_filter/valid_from_spec.rb
|
247
250
|
- spec/snippr/segment_filter/valid_until_spec.rb
|
248
251
|
- spec/snippr/segment_parser_spec.rb
|