what_date 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/lib/what_date/client.rb +5 -5
- data/lib/what_date/date_of_month.rb +5 -8
- data/lib/what_date/version.rb +1 -1
- data/what_date.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70384a2d60233a02607c610587d9f06dbab6d192
|
4
|
+
data.tar.gz: b73639d75dc929a4aacb3870cef384a97410a208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad328d807ad87f347e98c1cc9efc8d9a816fba89fdf012e7f8d1d736cf8b4373f2f12503bd62cd273e0c4490175118383ba390160eb9dbbfc2fa081f5a923d5
|
7
|
+
data.tar.gz: 8a8d64597eae2a78d93e5410946539224804d2fcd5c4ebef3b0d6416850db6f291e6cf1be3ac85e4700f90c0c75e9fc3448d13b36a7e02456c2d0c19023d102d
|
data/.travis.yml
CHANGED
data/lib/what_date/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'active_support/core_ext/time/calculations'
|
|
4
4
|
require 'what_date/date_of_month'
|
5
5
|
|
6
6
|
module WhatDate
|
7
|
-
class Client
|
7
|
+
class Client
|
8
8
|
include WhatDate::DateOfMonth
|
9
9
|
|
10
10
|
Date::DAYS_INTO_WEEK.each do |day, inc|
|
@@ -15,19 +15,19 @@ module WhatDate
|
|
15
15
|
end
|
16
16
|
|
17
17
|
Date::DAYS_INTO_WEEK.each do |day, inc|
|
18
|
-
define_method("prev_#{day
|
18
|
+
define_method("prev_#{day}".to_sym) do |ref_date = nil|
|
19
19
|
send(day, ref_date).days_ago(7)
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
22
22
|
|
23
23
|
Date::DAYS_INTO_WEEK.each do |day, inc|
|
24
|
-
define_method("last_#{day
|
24
|
+
define_method("last_#{day}".to_sym) do |ref_date = nil|
|
25
25
|
send("prev_#{day.to_s}".to_sym, ref_date)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
Date::DAYS_INTO_WEEK.each do |day, inc|
|
30
|
-
define_method("next_#{day
|
30
|
+
define_method("next_#{day}".to_sym) do |ref_date = nil|
|
31
31
|
send(day, ref_date).days_since(7)
|
32
32
|
end
|
33
33
|
end
|
@@ -6,7 +6,6 @@ module WhatDate
|
|
6
6
|
WEEKDAYS = 'monday||tuesday||wednesday||thursday||friday||saturday||sunday'.freeze
|
7
7
|
MONTHS = 'january||february||march||april||may||june||july||august||september||october||november||december'.freeze
|
8
8
|
|
9
|
-
|
10
9
|
def date_of_month(order:1, day:, month:, year: Date.today.year)
|
11
10
|
month_int = Date::MONTHNAMES.index(month)
|
12
11
|
first_date = Date.new(year, month_int, 1)
|
@@ -22,11 +21,11 @@ module WhatDate
|
|
22
21
|
rescue ArgumentError
|
23
22
|
nil
|
24
23
|
end
|
25
|
-
end
|
24
|
+
end
|
26
25
|
|
27
26
|
def method_missing(name, *args, &block)
|
28
27
|
methods = missing_method_reg.match(name)
|
29
|
-
if methods
|
28
|
+
if methods
|
30
29
|
order = ORDINALS[methods[1].downcase]
|
31
30
|
day = format_date_string methods[2]
|
32
31
|
month = format_date_string methods[3]
|
@@ -39,11 +38,9 @@ module WhatDate
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def last_date_of_month(month:, year:)
|
42
|
-
|
43
|
-
Date.parse("#{year}-#{month}-1").end_of_month
|
41
|
+
Date.parse("#{year}-#{month}-1").end_of_month
|
44
42
|
rescue ArgumentError
|
45
|
-
|
46
|
-
end
|
43
|
+
nil
|
47
44
|
end
|
48
45
|
|
49
46
|
private
|
@@ -57,7 +54,7 @@ module WhatDate
|
|
57
54
|
end
|
58
55
|
|
59
56
|
def date_of_last_week_day_in_month(lookup_day, month, year)
|
60
|
-
last_date = last_date_of_month(month: month, year: year)
|
57
|
+
last_date = last_date_of_month(month: month, year: year)
|
61
58
|
last_day = last_date.wday
|
62
59
|
lookup = Date::DAYNAMES.index(lookup_day)
|
63
60
|
diff = last_day - lookup
|
data/lib/what_date/version.rb
CHANGED
data/what_date.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
|
-
spec.required_ruby_version = ">=2.
|
23
|
+
spec.required_ruby_version = ">=2.1.0"
|
24
24
|
|
25
25
|
spec.add_dependency "activesupport", ">= 4.2"
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.13"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: what_date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.1.0
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - ">="
|