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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 589b27a457943401b0029d5896071f4fd44678ca
4
- data.tar.gz: c51e60d504a9e233eb9ebb506d5668b5a72b49c0
3
+ metadata.gz: 70384a2d60233a02607c610587d9f06dbab6d192
4
+ data.tar.gz: b73639d75dc929a4aacb3870cef384a97410a208
5
5
  SHA512:
6
- metadata.gz: 1357c088824ba1e953f5d5ae676a13c04a0df97f7305e476421baccab89c78f6526a53fc0eb87e8728bd801f745b59ef876c37b34a0271c6fd097e87285181b4
7
- data.tar.gz: aa9827cbac19ebbd6042fcb82f9d7a3d04700ac7b06a163a3a2865105df5d82871227aa5d6bd7e55a873d6f467c1eba7fb856baffec60346bd1ab1008d4f1ee9
6
+ metadata.gz: 9ad328d807ad87f347e98c1cc9efc8d9a816fba89fdf012e7f8d1d736cf8b4373f2f12503bd62cd273e0c4490175118383ba390160eb9dbbfc2fa081f5a923d5
7
+ data.tar.gz: 8a8d64597eae2a78d93e5410946539224804d2fcd5c4ebef3b0d6416850db6f291e6cf1be3ac85e4700f90c0c75e9fc3448d13b36a7e02456c2d0c19023d102d
@@ -1,5 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.0
4
+ - 2.1.0
5
+ - 2.2.0
6
+ - 2.4.0
7
+ - 2.5.0
5
8
  before_install: gem install bundler -v 1.13.1
@@ -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.to_s}".to_sym) do |ref_date = nil|
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.to_s}".to_sym) do |ref_date = nil|
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.to_s}".to_sym) do |ref_date = nil|
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
- begin
43
- Date.parse("#{year}-#{month}-1").end_of_month
41
+ Date.parse("#{year}-#{month}-1").end_of_month
44
42
  rescue ArgumentError
45
- nil
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
@@ -1,3 +1,3 @@
1
1
  module WhatDate
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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.3.0"
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.3
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.3.0
117
+ version: 2.1.0
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="