double_or_nothing 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 518e30a9488702bd0a8031540c1d24a859d42e23
4
+ data.tar.gz: df5e2a8fdb7f7f76ef8acfca79dc4a43c2b66849
5
+ SHA512:
6
+ metadata.gz: 838c0115537b84b44d4f1f329521910e64c619af6fb6630f65a2269e10589c1d2fc04bd827150ad6f654ae912b7daf0b6208c81d6c70132c7cebe2e9cb3d22e8
7
+ data.tar.gz: 78625e77690b999f01e10c10a3a10d9d12d518afc519b78d00cc76088823e0bf12bb60a00416c6110b9d3bac31ca91fd8a91baff2e387a41157845f86032e55b
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.irbrc ADDED
@@ -0,0 +1,2 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'double_or_nothing'
data/.pryrc ADDED
@@ -0,0 +1,2 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'double_or_nothing'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in double-or-nothing.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Philip Arndt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # Double Or Nothing
2
+
3
+ Figure out the exact date when somebody will be twice your age.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'double_or_nothing'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install double_or_nothing
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'double_or_nothing'
25
+
26
+ alice = DoubleOrNothing::Person.new("2000-01-01")
27
+ bob = DoubleOrNothing::Person.new("1985-01-01")
28
+
29
+ DoubleOrNothing::Calculator.new(alice, bob).call
30
+ #=> #<Date: 2014-12-31 ((2457023j,0s,0n),+0s,2299161j)>
31
+
32
+ DoubleOrNothing::Calculator.new(alice, bob).difference
33
+ #=> (5478/1)
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/parndt/double_or_nothing/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'double_or_nothing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "double_or_nothing"
8
+ spec.version = DoubleOrNothing::VERSION
9
+ spec.authors = ["Philip Arndt"]
10
+ spec.email = ["p@arndt.io"]
11
+ spec.summary = %q{Calculate when someone is twice your age.}
12
+ spec.description = %q{Figure out the exact date that somebody is twice your age.}
13
+ spec.homepage = "http://p.arndt.io"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = %w(lib)
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec-core", "~> 3.1"
24
+ end
@@ -0,0 +1,6 @@
1
+ require "double_or_nothing/version"
2
+ require "double_or_nothing/person"
3
+ require "double_or_nothing/calculator"
4
+
5
+ module DoubleOrNothing
6
+ end
@@ -0,0 +1,18 @@
1
+ module DoubleOrNothing
2
+ class Calculator
3
+ def initialize(person_one, person_two)
4
+ @elder, @younger = [person_one.birthday, person_two.birthday].sort
5
+ end
6
+
7
+ def difference
8
+ younger - elder
9
+ end
10
+
11
+ def call
12
+ younger + difference
13
+ end
14
+
15
+ private
16
+ attr_reader :elder, :younger
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ require 'date'
2
+
3
+ module DoubleOrNothing
4
+ class Person
5
+ attr_reader :birthday
6
+
7
+ def initialize(birthday)
8
+ birthday = Date.parse(birthday) unless birthday.is_a?(Date)
9
+ @birthday = birthday
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module DoubleOrNothing
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+ require "date"
3
+ require "double_or_nothing"
4
+
5
+ RSpec.describe DoubleOrNothing do
6
+ context DoubleOrNothing::Calculator do
7
+ context "as documented in the README"
8
+ let(:alice) { double(birthday: Date.parse("2000-01-01")) }
9
+ let(:bob) { double(birthday: Date.parse("1985-01-01")) }
10
+ subject { DoubleOrNothing::Calculator.new(alice, bob) }
11
+
12
+ it "calculates the correct date" do
13
+ expect(subject.call).to eq(Date.parse("2014-12-31"))
14
+ end
15
+
16
+ it "shows difference" do
17
+ expect(subject.difference).to eq(Rational(5478, 1))
18
+ end
19
+ end
20
+
21
+ context DoubleOrNothing::Person do
22
+ subject { DoubleOrNothing::Person.new("2000-01-01") }
23
+
24
+ it "has a birthday" do
25
+ expect(subject.birthday).to eq(Date.parse("2000-01-01"))
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ $:.push File.expand_path("../../../lib", __FILE__)
2
+
3
+ RSpec.configure do |config|
4
+ config.order = :random
5
+ config.disable_monkey_patching!
6
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: double_or_nothing
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Philip Arndt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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-core
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: Figure out the exact date that somebody is twice your age.
56
+ email:
57
+ - p@arndt.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".irbrc"
64
+ - ".pryrc"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - double_or_nothing.gemspec
70
+ - lib/double_or_nothing.rb
71
+ - lib/double_or_nothing/calculator.rb
72
+ - lib/double_or_nothing/person.rb
73
+ - lib/double_or_nothing/version.rb
74
+ - spec/lib/double_or_nothing/calculator_spec.rb
75
+ - spec/spec_helper.rb
76
+ homepage: http://p.arndt.io
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.2.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Calculate when someone is twice your age.
100
+ test_files:
101
+ - spec/lib/double_or_nothing/calculator_spec.rb
102
+ - spec/spec_helper.rb
103
+ has_rdoc: