clavius 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/clavius.rb +0 -2
- data/lib/clavius/configuration.rb +27 -21
- data/lib/clavius/schedule.rb +13 -3
- data/lib/clavius/time.rb +1 -1
- data/lib/clavius/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cddd4a79f948d7a8b39e5fe26e9e06b22c985730
|
4
|
+
data.tar.gz: 62686392677a4ab4063e86e23ac0f52045ed127a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72d84b8e47b0b883e7f361e02e462a3304cabdfb82d8053c9b81277b8464b744abed04e22beec215df1d45c5467ea3c22e57e04ca6aa2123408056b146736ec
|
7
|
+
data.tar.gz: 07d526280f512b32388a84f3b368f4bf5d6f0160e6364ff872f16456dbde30e39164f253d0c20ccd66565deefdf4aa1df76ee45502a77088b271a913d43e72f5
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Clavius
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/clavius.svg)](http://badge.fury.io/rb/clavius)
|
3
4
|
[![Build Status](https://travis-ci.org/craiglittle/clavius.svg?branch=master)](https://travis-ci.org/craiglittle/clavius)
|
4
5
|
[![Code Climate](https://codeclimate.com/github/craiglittle/clavius/badges/gpa.svg)](https://codeclimate.com/github/craiglittle/clavius)
|
5
6
|
[![Test Coverage](https://codeclimate.com/github/craiglittle/clavius/badges/coverage.svg)](https://codeclimate.com/github/craiglittle/clavius)
|
@@ -45,6 +46,6 @@ for commit messages.
|
|
45
46
|
|
46
47
|
## Copyright
|
47
48
|
|
48
|
-
Copyright (c) 2015 Craig Little. See [LICENSE][license] for details.
|
49
|
+
Copyright (c) 2015-2016 Craig Little. See [LICENSE][license] for details.
|
49
50
|
|
50
51
|
[license]: https://github.com/craiglittle/clavius/blob/master/LICENSE
|
data/lib/clavius.rb
CHANGED
@@ -1,46 +1,52 @@
|
|
1
1
|
module Clavius
|
2
2
|
class Configuration
|
3
3
|
|
4
|
-
include Memoizable
|
5
|
-
|
6
4
|
def initialize
|
7
5
|
@raw = Raw.new.tap do |raw| yield raw if block_given? end
|
8
6
|
end
|
9
7
|
|
10
8
|
def weekdays
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
@weekdays ||= begin
|
10
|
+
raw
|
11
|
+
.weekdays
|
12
|
+
.select(&Time::WEEKDAYS.method(:include?))
|
13
|
+
.map(&Time::WEEKDAYS.method(:index))
|
14
|
+
.to_set
|
15
|
+
.freeze
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def included
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
@included ||= begin
|
21
|
+
raw
|
22
|
+
.included
|
23
|
+
.select { |date| date.respond_to?(:to_date) }
|
24
|
+
.map(&:to_date)
|
25
|
+
.to_set
|
26
|
+
.freeze
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
def excluded
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
@excluded ||= begin
|
32
|
+
raw
|
33
|
+
.excluded
|
34
|
+
.select { |date| date.respond_to?(:to_date) }
|
35
|
+
.map(&:to_date)
|
36
|
+
.to_set
|
37
|
+
.freeze
|
38
|
+
end
|
29
39
|
end
|
30
40
|
|
31
41
|
protected
|
32
42
|
|
33
43
|
attr_reader :raw
|
34
44
|
|
35
|
-
memoize :weekdays,
|
36
|
-
:included,
|
37
|
-
:excluded
|
38
|
-
|
39
45
|
Raw = Struct.new(:weekdays, :included, :excluded) do
|
40
46
|
module Default
|
41
|
-
WEEKDAYS = Set.new(%i[mon tue wed thu fri])
|
42
|
-
INCLUDED = Set.new
|
43
|
-
EXCLUDED = Set.new
|
47
|
+
WEEKDAYS = Set.new(%i[mon tue wed thu fri]).freeze
|
48
|
+
INCLUDED = Set.new.freeze
|
49
|
+
EXCLUDED = Set.new.freeze
|
44
50
|
end
|
45
51
|
|
46
52
|
def initialize(*)
|
data/lib/clavius/schedule.rb
CHANGED
@@ -14,12 +14,20 @@ module Clavius
|
|
14
14
|
] => :configuration
|
15
15
|
|
16
16
|
def before(date)
|
17
|
-
date
|
17
|
+
date
|
18
|
+
.to_date
|
19
|
+
.prev_day
|
20
|
+
.downto(Time::BIG_BANG)
|
21
|
+
.lazy
|
18
22
|
.select(&method(:active?))
|
19
23
|
end
|
20
24
|
|
21
25
|
def after(date)
|
22
|
-
date
|
26
|
+
date
|
27
|
+
.to_date
|
28
|
+
.next_day
|
29
|
+
.upto(Time::HEAT_DEATH)
|
30
|
+
.lazy
|
23
31
|
.select(&method(:active?))
|
24
32
|
end
|
25
33
|
|
@@ -35,7 +43,9 @@ module Clavius
|
|
35
43
|
end
|
36
44
|
|
37
45
|
def between(start_date, end_date)
|
38
|
-
start_date
|
46
|
+
start_date
|
47
|
+
.to_date
|
48
|
+
.upto(end_date.to_date.prev_day)
|
39
49
|
.select(&method(:active?))
|
40
50
|
end
|
41
51
|
|
data/lib/clavius/time.rb
CHANGED
data/lib/clavius/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clavius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Little
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: memoizable
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.4.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.4.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
73
|
version: '0'
|
88
74
|
requirements: []
|
89
75
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.4.5
|
76
|
+
rubygems_version: 2.4.5.1
|
91
77
|
signing_key:
|
92
78
|
specification_version: 4
|
93
79
|
summary: Date calculations
|