wheres_my_weekend 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 508ae0d6ed5c16fa4b1038ba5bbbadb84d07f40c
4
- data.tar.gz: 809ec24cef3e661c195d7ab4315657c34d748a2e
3
+ metadata.gz: 24065b0c7776dcfb648bdacadd27d1ace44c371f
4
+ data.tar.gz: 3279d8979b9fa01d560223474c3ccd54bedb6d88
5
5
  SHA512:
6
- metadata.gz: 20edc05b461ef52d7e78eccc1519eb1d32d1348721ec9f083ea947e7b46a423d912a4a76f2f04a3ef6ec23d9ca05a915e679dd4b9ca75f5ff66f0a2fbf6a1875
7
- data.tar.gz: 6b121cf382878d9a0b99a1d264fa4af0ea9107b2cee6e5eb6d46680e89c12270bfb3baf466eef60894c1acd1679ea3bdfe3cb52e4b260351c23eb7ee971ad02a
6
+ metadata.gz: da824d51ab65037a417a60ecdbb216fb8b8f9cedc663ccd2e798509cb6d7960a749f41aa6d7f3d85531c9965367c368881dcd1b51a9fc9cd076aee2e567d72ba
7
+ data.tar.gz: 8d685d6f109ae0eceb5e4154493683b5882a5be3850c107074cfbb04e549a7ae600a079dd9dbdf51606b1808f49d724bf58188eeb9a516444a166b1020fefb1a
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/LineLength:
4
+ Max: 110
5
+
6
+ Metrics/BlockLength:
7
+ Max: 100
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,25 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-01-09 18:17:31 -0200 using RuboCop version 0.46.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
12
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
13
+ Style/HashSyntax:
14
+ Exclude:
15
+ - 'Rakefile'
16
+
17
+ # Offense count: 19
18
+ # Cop supports --auto-correct.
19
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
20
+ # SupportedStyles: single_quotes, double_quotes
21
+ Style/StringLiterals:
22
+ Exclude:
23
+ - 'Rakefile'
24
+ - 'bin/console'
25
+ - 'wheres_my_weekend.gemspec'
data/.travis.yml CHANGED
@@ -3,4 +3,6 @@ language: ruby
3
3
  rvm:
4
4
  - 2.4.0
5
5
  before_install: gem install bundler -v 1.13.7
6
- script: bundle exec rspec spec
6
+ script:
7
+ - bundle exec rspec spec
8
+ - rubocop
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in wheres_my_weekend.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'rubocop', require: false
7
+
6
8
  group :development, :test do
7
9
  gem 'pry'
8
10
  end
@@ -1,24 +1,50 @@
1
1
  require 'wheres_my_weekend/version'
2
+ require 'date'
2
3
 
3
4
  SECONDS_PER_DAY = 86_400
4
5
 
5
- class Time
6
+ # rubocop:disable Style/Documentation
7
+ module WeekendCheck
6
8
  def weekend?
7
9
  saturday? || sunday?
8
10
  end
9
11
 
10
12
  def next_weekend
11
- [next_saturday, next_saturday + 1.days]
13
+ [next_saturday, next_saturday.add_days(1)]
12
14
  end
13
15
 
14
16
  protected
15
17
 
16
18
  def last_saturday
17
- saturday? ? self - 7.days : self - (wday + 1).days
19
+ saturday? ? sub_days(7) : sub_days(wday + 1)
18
20
  end
19
21
 
20
22
  def next_saturday
21
- saturday? ? self + 7.days : self + (6 - wday).days
23
+ saturday? ? add_days(7) : add_days(6 - wday)
24
+ end
25
+ end
26
+
27
+ class Time
28
+ include WeekendCheck
29
+
30
+ def add_days(n)
31
+ self + n.days
32
+ end
33
+
34
+ def sub_days(n)
35
+ self - n.days
36
+ end
37
+ end
38
+
39
+ class DateTime
40
+ include WeekendCheck
41
+
42
+ def add_days(n)
43
+ self + n
44
+ end
45
+
46
+ def sub_days(n)
47
+ self - n
22
48
  end
23
49
  end
24
50
 
@@ -1,3 +1,3 @@
1
1
  module WheresMyWeekend
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
-
19
+
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheres_my_weekend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Odinei Rocha
@@ -61,6 +61,8 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".rubocop_todo.yml"
64
66
  - ".travis.yml"
65
67
  - Gemfile
66
68
  - LICENSE.txt