time-predicates 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b35f7e179e68b0e05c3f527aac98db3ca5448e01
4
+ data.tar.gz: cd1dfb5af99bbab1d088dce639bcf589c7d7aff1
5
+ SHA512:
6
+ metadata.gz: fb9ba6d05836993a0456233deecae0c11e39f6926b74d82449d87a1c807ce5ae5fb23c2c0fc31ce1c872cd24c32555043a2712099d28972664c4c4350a4db1b9
7
+ data.tar.gz: 51c5da1bceb976158283d888317f31ac91b3f98dc274818b3206ed192d40811c4a2908c8d74a3a5068110bc516b1415aa96794e985d3c185924dc9a6d92fe96c
data/.codeclimate.yml ADDED
@@ -0,0 +1,24 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ fixme:
9
+ enabled: true
10
+ rubocop:
11
+ enabled: true
12
+ reek:
13
+ enabled: true
14
+ ratings:
15
+ paths:
16
+ - "**.inc"
17
+ - "**.js"
18
+ - "**.jsx"
19
+ - "**.module"
20
+ - "**.php"
21
+ - "**.py"
22
+ - "**.rb"
23
+ exclude_paths:
24
+ - spec/
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ /.bundle
2
+ /.yardoc/
3
+ /Gemfile.lock
4
+ /doc/
5
+ /pkg/
6
+ /vendor/cache/*.gem
7
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format Fuubar
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'bin/*'
4
+ - 'db/**/*'
5
+ - 'config/**/*'
6
+ - 'script/**/*'
7
+ - 'Guardfile'
8
+ - 'Rakefile'
9
+ Documentation:
10
+ Enabled: false
11
+ Metrics/ClassLength:
12
+ Max: 150
13
+ Metrics/LineLength:
14
+ Enabled: true
15
+ Max: 100
16
+ Rails/ActionFilter:
17
+ Enabled: false
18
+ SignalException:
19
+ Enabled: false
20
+ Style/StringLiterals:
21
+ EnforcedStyle: double_quotes
22
+ Style/TrailingCommaInLiteral:
23
+ EnforcedStyleForMultiline: comma
24
+ Enabled: true
25
+ TrailingCommaInArguments:
26
+ Enabled: false
27
+ Style/DotPosition:
28
+ EnforcedStyle: leading
29
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 1.9
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3.0
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "time-predicates Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,7 @@
1
+ ### 0.1.0 / 2016-03-04
2
+
3
+ * Initial release - added the following methods:
4
+ * `future_date.after?(past_date)`
5
+ * `future_date.after_or_equal?(past_date)`
6
+ * `past_date.before?(future_date)`
7
+ * `past_date.before_or_equal?(future_date)`
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "kramdown"
7
+ gem "fuubar"
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Szymon Szeliga
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Time Predicates
2
+
3
+ [![Build Status](https://secure.travis-ci.org/Szeliga/time-predicates.svg?branch=master)](https://travis-ci.org/Szeliga/time-predicates)
4
+ [![Code Climate GPA](https://codeclimate.com/github/Szeliga/time-predicates/badges/gpa.svg)](https://codeclimate.com/github/Szeliga/time-predicates)
5
+
6
+ ## Description
7
+
8
+ TODO: Description
9
+
10
+ ## Features
11
+
12
+ ## Examples
13
+
14
+ require 'time-predicates'
15
+
16
+ ## Requirements
17
+
18
+ ## Install
19
+
20
+ $ gem install time-predicates
21
+
22
+ or add to your `Gemfile`
23
+
24
+ gem "time-predicates"
25
+
26
+ ## Copyright
27
+
28
+ Copyright (c) 2016 Szymon Szeliga
29
+
30
+ See {file:LICENSE.txt} for details.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+
5
+ begin
6
+ require "bundler/setup"
7
+ rescue LoadError => e
8
+ abort e.message
9
+ end
10
+
11
+ require "rake"
12
+
13
+ require "rubygems/tasks"
14
+ Gem::Tasks.new
15
+
16
+ require "rspec/core/rake_task"
17
+ RSpec::Core::RakeTask.new
18
+
19
+ task test: :spec
20
+ task default: :spec
21
+
22
+ require "yard"
23
+ YARD::Rake::YardocTask.new
24
+ task doc: :yard
@@ -0,0 +1,3 @@
1
+ module TimePredicates
2
+ VERSION = "0.2.0".freeze
3
+ end
@@ -0,0 +1,22 @@
1
+ require "time_predicates/version"
2
+
3
+ module TimePredicates
4
+ def after?(moment)
5
+ self > moment
6
+ end
7
+
8
+ def before?(moment)
9
+ self < moment
10
+ end
11
+
12
+ def after_or_equal?(moment)
13
+ self >= moment
14
+ end
15
+
16
+ def before_or_equal?(moment)
17
+ self <= moment
18
+ end
19
+ end
20
+
21
+ Date.send(:include, TimePredicates)
22
+ Time.send(:include, TimePredicates)
@@ -0,0 +1,16 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+ require "rspec"
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |expectations|
7
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
8
+ end
9
+
10
+ config.mock_with :rspec do |mocks|
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+
14
+ config.order = :random
15
+ Kernel.srand config.seed
16
+ end
@@ -0,0 +1,120 @@
1
+ require "spec_helper"
2
+ require "time_predicates"
3
+
4
+ describe TimePredicates do
5
+ describe "#after?" do
6
+ subject(:predicate) { future.after?(past) }
7
+
8
+ context "for Date" do
9
+ let(:future) { Date.parse("2016-03-13") }
10
+ let(:past) { Date.parse("2016-03-04") }
11
+
12
+ it "is true if the provided date is in the past" do
13
+ expect(predicate).to be_truthy
14
+ end
15
+ end
16
+
17
+ context "for Time" do
18
+ let(:future) { Time.parse("2016-03-04 21:00:30") }
19
+ let(:past) { Time.parse("2016-03-04 21:00:00") }
20
+
21
+ it "is true if the provided time is in the past" do
22
+ expect(predicate).to be_truthy
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#before?" do
28
+ subject(:predicate) { past.before?(future) }
29
+
30
+ context "for Date" do
31
+ let(:future) { Date.parse("2016-03-13") }
32
+ let(:past) { Date.parse("2016-03-04") }
33
+
34
+ it "is true if the provided date is in the future" do
35
+ expect(predicate).to be_truthy
36
+ end
37
+ end
38
+
39
+ context "for Time" do
40
+ let(:future) { Time.parse("2016-03-04 21:00:30") }
41
+ let(:past) { Time.parse("2016-03-04 21:00:00") }
42
+
43
+ it "is true if the provided time is in the future" do
44
+ expect(predicate).to be_truthy
45
+ end
46
+ end
47
+ end
48
+
49
+ describe "#after_or_equal?" do
50
+ subject(:predicate) { future.after_or_equal?(past) }
51
+
52
+ context "for Date" do
53
+ let(:past) { Date.parse("2016-03-04") }
54
+
55
+ context "when provided date is in the past" do
56
+ let(:future) { Date.parse("2016-03-13") }
57
+
58
+ it { is_expected.to be_truthy }
59
+ end
60
+
61
+ context "when provided date is equal" do
62
+ let(:future) { Date.parse("2016-03-04") }
63
+
64
+ it { is_expected.to be_truthy }
65
+ end
66
+ end
67
+
68
+ context "for Time" do
69
+ let(:past) { Time.parse("2016-03-04 21:00:00") }
70
+
71
+ context "when provided time is in the past" do
72
+ let(:future) { Time.parse("2016-03-04 21:00:30") }
73
+
74
+ it { is_expected.to be_truthy }
75
+ end
76
+
77
+ context "when provided time is equal" do
78
+ let(:future) { Time.parse("2016-03-04 21:00:00") }
79
+
80
+ it { is_expected.to be_truthy }
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "#before_or_equal?" do
86
+ subject(:predicate) { past.before_or_equal?(future) }
87
+
88
+ context "for Date" do
89
+ let(:past) { Date.parse("2016-03-04") }
90
+
91
+ context "when provided date is in the future" do
92
+ let(:future) { Date.parse("2016-03-13") }
93
+
94
+ it { is_expected.to be_truthy }
95
+ end
96
+
97
+ context "when provided date is equal" do
98
+ let(:future) { Date.parse("2016-03-04") }
99
+
100
+ it { is_expected.to be_truthy }
101
+ end
102
+ end
103
+
104
+ context "for Time" do
105
+ let(:past) { Time.parse("2016-03-04 21:00:00") }
106
+
107
+ context "when provided time is in the future" do
108
+ let(:future) { Time.parse("2016-03-04 21:00:30") }
109
+
110
+ it { is_expected.to be_truthy }
111
+ end
112
+
113
+ context "when provided time is equal" do
114
+ let(:future) { Time.parse("2016-03-04 21:00:00") }
115
+
116
+ it { is_expected.to be_truthy }
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "time_predicates/version"
6
+ require "English"
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = "time-predicates"
10
+ gem.version = TimePredicates::VERSION
11
+ gem.summary = "Simple library for date comparisons"
12
+ gem.description = "Having trouble figuring out which date is in the future looking at > or < ?"
13
+ gem.license = "MIT"
14
+ gem.authors = ["Szymon Szeliga"]
15
+ gem.email = "szeliga.szymon@gmail.com"
16
+ gem.homepage = "https://github.com/szeliga/time-predicates"
17
+
18
+ gem.files = `git ls-files`.split($RS)
19
+
20
+ `git submodule --quiet foreach --recursive pwd`.split($RS).each do |submodule|
21
+ submodule.sub!("#{Dir.pwd}/", "")
22
+
23
+ Dir.chdir(submodule) do
24
+ `git ls-files`.split($RS).map do |subpath|
25
+ gem.files << File.join(submodule, subpath)
26
+ end
27
+ end
28
+ end
29
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
30
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
31
+ gem.require_paths = ["lib"]
32
+
33
+ gem.add_development_dependency "codeclimate-test-reporter", "~> 0.1"
34
+ gem.add_development_dependency "rake", "~> 10.0"
35
+ gem.add_development_dependency "rspec", "~> 3.0"
36
+ gem.add_development_dependency "rubygems-tasks", "~> 0.2"
37
+ gem.add_development_dependency "yard", "~> 0.8"
38
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: time-predicates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Szymon Szeliga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: codeclimate-test-reporter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubygems-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
83
+ description: Having trouble figuring out which date is in the future looking at >
84
+ or < ?
85
+ email: szeliga.szymon@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".codeclimate.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - ".travis.yml"
95
+ - ".yardopts"
96
+ - ChangeLog.md
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - lib/time_predicates.rb
102
+ - lib/time_predicates/version.rb
103
+ - spec/spec_helper.rb
104
+ - spec/time_predicates_spec.rb
105
+ - time-predicates.gemspec
106
+ homepage: https://github.com/szeliga/time-predicates
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.5.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Simple library for date comparisons
130
+ test_files:
131
+ - spec/spec_helper.rb
132
+ - spec/time_predicates_spec.rb