wheres_my_weekend 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/wheres_my_weekend/version.rb +1 -1
- data/lib/wheres_my_weekend.rb +23 -1
- data/wheres_my_weekend.gemspec +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab666043007754e05f9c54ca291f9b9fd2a68b21
|
4
|
+
data.tar.gz: 8571700e805ab703fb5b0ff85df1bd4c9848c7ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a4aee1778541349678cab13fc8615c692ec547c836c3c482b2fe16c43deb2ae46f44fc6360ec18dae7e1226752433ed5a60252b84c4e0008601d0c332ff36fe
|
7
|
+
data.tar.gz: 614077d55da243a69054af6a1a87351e01f11e705511bbd0d5dabb710d89dbd3f8a2edf841ef3f3f97edf2069a7303821aa38d7d21f54423d88e17a0894b23df
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
# Where's my weekend
|
1
|
+
# Where's my weekend?
|
2
2
|
|
3
3
|
[](https://travis-ci.org/OdineiRibeiro/wheres_my_weekend)
|
4
4
|
|
5
|
+
## About
|
6
|
+
|
7
|
+
This gem detects if a date is a weekend or if on a range of dates exist some weekend. Is perfect to plan your day trip!
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -46,10 +50,17 @@ dates.any_weekend?
|
|
46
50
|
- `weekend_dates` will return a array of weekend days from a array of dates
|
47
51
|
|
48
52
|
```ruby
|
49
|
-
|
53
|
+
[Time.new(2016, 12, 23), Time.new(2016, 12, 24), Time.new(2016, 12, 25)].weekend_dates
|
50
54
|
# => [2016-12-24 00:00:00 -0200, 2016-12-25 00:00:00 -0200]
|
51
55
|
```
|
52
56
|
|
57
|
+
- `next_weekend` will return the next weekend from the given date
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Time.new(2016, 12, 25).next_weekend
|
61
|
+
# => [2016-12-31 00:00:00 -0200, 2017-01-01 00:00:00 -0200]
|
62
|
+
```
|
63
|
+
|
53
64
|
## Development
|
54
65
|
|
55
66
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/wheres_my_weekend.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require 'wheres_my_weekend/version'
|
2
|
+
|
3
|
+
SECONDS_PER_DAY = 86_400
|
2
4
|
|
3
5
|
class Time
|
4
6
|
def weekend_day?
|
5
7
|
saturday? || sunday?
|
6
8
|
end
|
9
|
+
|
10
|
+
def next_weekend
|
11
|
+
[next_saturday, next_saturday + 1.days]
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def last_saturday
|
17
|
+
saturday? ? self - 7.days : self - (wday + 1).days
|
18
|
+
end
|
19
|
+
|
20
|
+
def next_saturday
|
21
|
+
saturday? ? self + 7.days : self + (6 - wday).days
|
22
|
+
end
|
7
23
|
end
|
8
24
|
|
9
25
|
class Array
|
@@ -15,3 +31,9 @@ class Array
|
|
15
31
|
reject { |date| !date.weekend_day? }
|
16
32
|
end
|
17
33
|
end
|
34
|
+
|
35
|
+
class Integer
|
36
|
+
def days
|
37
|
+
self * SECONDS_PER_DAY
|
38
|
+
end
|
39
|
+
end
|
data/wheres_my_weekend.gemspec
CHANGED
@@ -13,12 +13,10 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://github.com/odineiribeiro/wheres_my_weekend"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
|
19
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
17
|
f.match(%r{^(test|spec|features)/})
|
21
18
|
end
|
19
|
+
|
22
20
|
spec.bindir = "exe"
|
23
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
22
|
spec.require_paths = ["lib"]
|