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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjljYWNkZjRjNWEyZjAyZmU5MTExNDAwZjRkNTdmOTUzODA4NjA4NQ==
4
+ NDUxZDgxNzQ4M2E0NDAzNzcxMDQyMDU5MzBlMTAyYmU1ZWZlYzQ2NQ==
5
5
  data.tar.gz: !binary |-
6
- ZWFiYjcyYjI3NWQ3OTU1ZjllOWE5ODBmYjZlNTZiYjNhNTRjNjdhNg==
6
+ YzM1NGU3MDgxZWIwZDNhMWIzYmUxMWZhMmJhZjFmZmY2YTM4ZDFmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTk1YTY3ODk4NjNkODEwNzZiODAyZDUwOWIzYmIxZmRmZjcyNzQ0YmNmNTll
10
- OWZkYzEyOWU1MTc2MWU1YjJiMTkzODFiN2U0MWJkNGIwMzM3MDYwZDQxYjFm
11
- YzI1N2FjMzYyNjI3M2Y0OGFkNWYyZmEyZmEwNjc2MDc4YTU5Zjk=
9
+ ZTFlOTM3MTFiMmYwMDJlNDdkNGFmMDJiYjRkMDQxNDU3N2NmMzg4OThmZGZh
10
+ NTAwOGRlMDQ3ODc2NmIzYWQwNGQyMTVmMDIyMTk0ZDRiMGQ0NjQxZWFhZTMz
11
+ MGFjZTkwYzg5MmM0NjE1OTQxNGI1Njg1N2FmZTM4YmJlYzRhNTc=
12
12
  data.tar.gz: !binary |-
13
- ZmVmMGM0ZmFlOGEyZmM0MmZjNTYzOTllYmM1ZWUyM2ZjN2ZhODM2N2I2MTZk
14
- ODNkMmExNjIyYjU5ZGIzYWE5NzMyM2RiODcwMWQ0NjlmZDUyZGVmM2NiODg1
15
- YWYyZjEyMDVkYjc5MGIyMTc5NmIyNTE4MWRjZThjZTY3MDYxMmE=
13
+ OWNjNzc1MTUzYWVkNmJhZDAzMjQxMWI5ODc1OGE5NzkyMTUyOTcyN2JkNTll
14
+ MzFiMGU0OTM1NjY3NTI3NGM5ZWQyN2VlNmFlY2JiNDk1OTNlYjRkMmExZTU5
15
+ MzgyYTk1ZTk2YzZiN2RlMzUzMGJjZjA5NGU2NzM2NzE0MzEwMWM=
@@ -3,5 +3,6 @@ rvm:
3
3
  - 1.9.3
4
4
  - jruby-19mode # JRuby in 1.9 mode
5
5
  - 2.0.0
6
+ - 2.1.0
6
7
  notifications:
7
8
  email: false
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).
@@ -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
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "snippr"
4
- s.version = "0.15.14"
4
+ s.version = "0.15.15"
5
5
  s.date = Time.now
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Daniel Harrington", "Thomas Jachmann", "Frank Schumacher"]
@@ -3,6 +3,6 @@ require "spec_helper"
3
3
 
4
4
  describe "Snippr::SegmentFilter::Base" do
5
5
  it "remembers its subclasses" do
6
- Snippr::SegmentFilter::Base.should have(4).filters
6
+ Snippr::SegmentFilter::Base.should have(5).filters
7
7
  end
8
8
  end
@@ -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.14
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: 2013-09-24 00:00:00.000000000 Z
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.1.4
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