election_day 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +7 -0
- data/README.md +3 -0
- data/election_day.gemspec +2 -1
- data/lib/election_day.rb +23 -6
- data/lib/election_day/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aedfe7d53827fe093a8ca037083c62c9291c38b6
|
4
|
+
data.tar.gz: 543856fbafce3365912cd4a2eb9a4f8b66c702ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb8b5be860eea049d66e76be1a7561c76915abde32a831c86900250cee411eb27b74db9e2937d8ac99e8960e81f8d5845091eaa4c3ebd2c95387052c1c4b0a6
|
7
|
+
data.tar.gz: 664047f11d41020cec55745bdaf1af85e870a5212a80b7e2bbdceeda5cab136fbfe2ec5eb16d64fdb7cb4857a99660b8221c324287a9dc95ac2330758f1c5416
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Election Day
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/election_day.svg)](https://badge.fury.io/rb/election_day)
|
3
4
|
[![Build Status](https://travis-ci.org/jcypret/election_day.svg?branch=master)](https://travis-ci.org/jcypret/election_day)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/jcypret/election_day/badges/gpa.svg)](https://codeclimate.com/github/jcypret/election_day)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/jcypret/election_day/badges/coverage.svg)](https://codeclimate.com/github/jcypret/election_day/coverage)
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
data/election_day.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Justin Cypret"]
|
10
10
|
spec.email = ["jcypret@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{A library
|
12
|
+
spec.summary = %q{A library to calculate when U.S. Election Day occurs.}
|
13
13
|
spec.homepage = "https://github.com/jcypret/election_day"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
22
|
spec.add_development_dependency "rspec", "~> 3.0"
|
23
23
|
spec.add_development_dependency "timecop", "~> 0.8.1"
|
24
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
24
25
|
end
|
data/lib/election_day.rb
CHANGED
@@ -1,35 +1,52 @@
|
|
1
1
|
require "election_day/version"
|
2
2
|
|
3
|
+
# A library to calculate when U.S. Election Day occurs.
|
4
|
+
#
|
3
5
|
# "The Tuesday next after the first Monday in the month of November"
|
4
6
|
# -- The 28th Congress (http://memory.loc.gov/ll/llsl/005/0700/07590721.tif)
|
5
7
|
module ElectionDay
|
6
8
|
|
7
|
-
#
|
9
|
+
# Checks whether year is an election year.
|
10
|
+
#
|
11
|
+
# @param year [Integer] the year to check
|
12
|
+
# @return [Boolean] whether year is an election year
|
8
13
|
def self.election_year?(year = Date.today.year)
|
9
14
|
year.even?
|
10
15
|
end
|
11
16
|
|
12
|
-
#
|
17
|
+
# Checks whether year is a midterm election year.
|
18
|
+
#
|
19
|
+
# @param year [Integer] the year to check
|
20
|
+
# @return [Boolean] whether year is a midterm election year
|
13
21
|
def self.midterm_election_year?(year = Date.today.year)
|
14
22
|
(year + 2) % 4 == 0
|
15
23
|
end
|
16
24
|
|
17
|
-
#
|
25
|
+
# Checks whether year is a presidential election year.
|
26
|
+
#
|
27
|
+
# @param year [Integer] the year to check
|
28
|
+
# @return [Boolean] whether year is a presidential election year
|
18
29
|
def self.presidential_election_year?(year = Date.today.year)
|
19
30
|
year % 4 == 0
|
20
31
|
end
|
21
32
|
|
22
|
-
# Returns the
|
33
|
+
# Returns the date of the next election.
|
34
|
+
#
|
35
|
+
# @return [Date] the date of the next election
|
23
36
|
def self.next_election
|
24
37
|
get_next_election(&:election_year?)
|
25
38
|
end
|
26
39
|
|
27
|
-
# Returns the
|
40
|
+
# Returns the date of the next midterm election.
|
41
|
+
#
|
42
|
+
# @return [Date] the date of the next midterm election
|
28
43
|
def self.next_midterm_election
|
29
44
|
get_next_election(&:midterm_election_year?)
|
30
45
|
end
|
31
46
|
|
32
|
-
# Returns the
|
47
|
+
# Returns the date of the next presidential election.
|
48
|
+
#
|
49
|
+
# @return [Date] the date of the next presidential election
|
33
50
|
def self.next_presidential_election
|
34
51
|
get_next_election(&:presidential_election_year?)
|
35
52
|
end
|
data/lib/election_day/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: election_day
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Cypret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.8.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- jcypret@gmail.com
|
@@ -76,6 +90,7 @@ files:
|
|
76
90
|
- ".gitignore"
|
77
91
|
- ".rspec"
|
78
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
79
94
|
- CODE_OF_CONDUCT.md
|
80
95
|
- Gemfile
|
81
96
|
- README.md
|
@@ -107,5 +122,5 @@ rubyforge_project:
|
|
107
122
|
rubygems_version: 2.5.1
|
108
123
|
signing_key:
|
109
124
|
specification_version: 4
|
110
|
-
summary: A library
|
125
|
+
summary: A library to calculate when U.S. Election Day occurs.
|
111
126
|
test_files: []
|