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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf92e745a22e1d84e3f2ea63569dda12b0350822
4
- data.tar.gz: e2cb31560dea9fbb6c939366eb09755a156d4c67
3
+ metadata.gz: cddd4a79f948d7a8b39e5fe26e9e06b22c985730
4
+ data.tar.gz: 62686392677a4ab4063e86e23ac0f52045ed127a
5
5
  SHA512:
6
- metadata.gz: 97b8e9cf887d6b105ae2a9900d7fe681141306d8b5d038cfd68edd9b70976d551357a39188fa6ac90f4279a0c328bfde6115303338da5570a8072ca7b7c507b2
7
- data.tar.gz: 6537165af0d78afcf86fbd1f13531d1eccc903cbedffeee9e6c58d3d329588e3bb114432bee0f572433f35979cc4ae84766e909f472209e37ad9c0a90cf596b8
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
@@ -2,8 +2,6 @@ require 'date'
2
2
  require 'forwardable'
3
3
  require 'set'
4
4
 
5
- require 'memoizable'
6
-
7
5
  module Clavius
8
6
  class << self
9
7
 
@@ -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
- raw.weekdays
12
- .select(&Time::WEEKDAYS.method(:include?))
13
- .map(&Time::WEEKDAYS.method(:index))
14
- .to_set
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
- raw.included
19
- .select { |date| date.respond_to?(:to_date) }
20
- .map(&:to_date)
21
- .to_set
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
- raw.excluded
26
- .select { |date| date.respond_to?(:to_date) }
27
- .map(&:to_date)
28
- .to_set
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(*)
@@ -14,12 +14,20 @@ module Clavius
14
14
  ] => :configuration
15
15
 
16
16
  def before(date)
17
- date.to_date.prev_day.downto(Time::BIG_BANG).lazy
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.to_date.next_day.upto(Time::HEAT_DEATH).lazy
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.to_date.upto(end_date.to_date.prev_day)
46
+ start_date
47
+ .to_date
48
+ .upto(end_date.to_date.prev_day)
39
49
  .select(&method(:active?))
40
50
  end
41
51
 
@@ -1,6 +1,6 @@
1
1
  module Clavius
2
2
  module Time
3
- WEEKDAYS = %i[sun mon tue wed thu fri sat]
3
+ WEEKDAYS = %i[sun mon tue wed thu fri sat].freeze
4
4
  BIG_BANG = Date.new(-10**100)
5
5
  HEAT_DEATH = Date.new(10**100)
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Clavius
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'.freeze
3
3
  end
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.1
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: 2015-07-09 00:00:00.000000000 Z
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