has_niklas_left_yet 0.0.1

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: 009fb745f130943d39532320d5f4e557b7031a15
4
+ data.tar.gz: 385288274a099384ab3e7684500045a64ca197be
5
+ SHA512:
6
+ metadata.gz: 754af9f8f58eec2c5a3788e187acc35c2fe1a40672475638299af233d45e6e6480978c8f5665196310b56b9b5a8e9fbd75e2ab4a0349084b3a6f2e84b6d70e65
7
+ data.tar.gz: ce8ff041810877b9753ceb944f0c46fdd98774111244524fb9cdb515d9a512011b3a8efe1461cbfd0934e9175840f7f8ca92b89730165ec536c32ba1ff2d0cb1
data/.gitignore ADDED
@@ -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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in has_niklas_left_yet.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
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.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # HasNiklasLeftYet
2
+
3
+ This is a gem designed to help me make friends in my job. Well maybe! It is
4
+ something for me to play around with and continuing to write code.
5
+ In essence it is a very simple countdown timer until Niklas leaves :-(
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'has_niklas_left_yet'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install has_niklas_left_yet
22
+
23
+ ## Usage
24
+
25
+ ````
26
+ $ has_niklas_left_yet
27
+ ````
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it (https://github.com/HatStephens/has_niklas_left_yet/fork)
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'has_niklas_left_yet'
3
+
4
+ niklas = HasNiklasLeftYet.new
5
+
6
+ niklas.answer_to_question
7
+ niklas.link_speech_before_countdown
8
+ niklas.time_difference_spoken
9
+ niklas.link_speech_after_countdown
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'has_niklas_left_yet/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "has_niklas_left_yet"
8
+ spec.version = HasNiklasLeftYet::VERSION
9
+ spec.authors = ["Stephen Giles"]
10
+ spec.email = [""]
11
+ spec.summary = %q{Countdown to Niklas leaving.}
12
+ spec.description = %q{A gem to help me make some friends which
13
+ countdowns how long Niklas has left in the
14
+ office.}
15
+ spec.homepage = ""
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "delorean"
27
+ end
@@ -0,0 +1,84 @@
1
+ require_relative 'has_niklas_left_yet/version'
2
+ require 'time'
3
+
4
+ class HasNiklasLeftYet
5
+
6
+ def current_time
7
+ Time.now
8
+ end
9
+
10
+ def niklas_leaving_time
11
+ Time.new(2015,01,28,18,00,00)
12
+ end
13
+
14
+ def has_niklas_left_yet?
15
+ current_time > niklas_leaving_time
16
+ end
17
+
18
+ def answer_to_question
19
+ has_niklas_left_yet? ? say_something("Yes") : say_something("No")
20
+ end
21
+
22
+ def time_difference
23
+ niklas_leaving_time.to_i - current_time.to_i
24
+ end
25
+
26
+ def time_difference_normal
27
+ "#{days}:#{hours}:#{minutes}"
28
+ end
29
+
30
+ def time_difference_spoken
31
+ say_something("#{days} days, #{hours} hours and #{minutes} minutes")
32
+ end
33
+
34
+ def link_speech_before_countdown
35
+ if has_niklas_left_yet?
36
+ say_something("Niklas has been gone for")
37
+ else
38
+ say_something("Niklas will be with us for another")
39
+ end
40
+ end
41
+
42
+ def link_speech_after_countdown
43
+ if has_niklas_left_yet?
44
+ say_something("Boo hoo hoo. We miss him loads.")
45
+ else
46
+ say_something(random_string)
47
+ end
48
+ end
49
+
50
+
51
+ private
52
+ def say_something(string)
53
+ %x(say "#{string}")
54
+ end
55
+
56
+ def days
57
+ (((time_difference / 60) / 60) / 24)
58
+ end
59
+
60
+ def hours
61
+ (((time_difference - (days_to_seconds)) / 60) / 60)
62
+ end
63
+
64
+ def minutes
65
+ ((time_difference - (days_to_seconds) - (hours_to_seconds)) / 60)
66
+ end
67
+
68
+ def days_to_seconds
69
+ days*60*60*24
70
+ end
71
+
72
+ def hours_to_seconds
73
+ hours*60*60
74
+ end
75
+
76
+ def random_string
77
+ %w(we_must_make_the_most_of_him
78
+ i_cannot_believe_he_is_leaving_us
79
+ he_will_be_greatly_missed i_hope_he_visits_us
80
+ i_wonder_if_he_will_buy_us_all_a_drink_when_he_leaves
81
+ heroku_will_be_a_better_place
82
+ ).sample
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ class HasNiklasLeftYet
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+ require 'has_niklas_left_yet'
3
+
4
+ describe HasNiklasLeftYet do
5
+
6
+ let(:countdown) {HasNiklasLeftYet.new}
7
+
8
+ it 'knows the current time' do
9
+ expect(countdown.current_time.strftime("%H:%M:%s"))
10
+ .to eq(Time.now.strftime("%H:%M:%s"))
11
+ end
12
+
13
+ it 'knows when Niklas is leaving' do
14
+ expect(countdown.niklas_leaving_time).to eq(Time.new(2015,01,28,18,00,00))
15
+ end
16
+
17
+ it 'knows whether Niklas has left yet' do
18
+ Delorean.time_travel_to(Time.utc(2015,01,21,17,30))
19
+ expect(countdown.has_niklas_left_yet?).to eq(false)
20
+ end
21
+
22
+ it 'knows whether Niklas has left yet' do
23
+ Delorean.time_travel_to(Time.utc(2015,02,21,17,30))
24
+ expect(countdown.has_niklas_left_yet?).to eq(true)
25
+ end
26
+
27
+ it 'says that Niklas has not left if he is still here' do
28
+ Delorean.time_travel_to(Time.utc(2015,01,21,17,30))
29
+ expect(countdown).to receive(:`).with('say "No"')
30
+ countdown.answer_to_question
31
+ end
32
+
33
+ it 'says that Niklas has left if he is still here' do
34
+ Delorean.time_travel_to(Time.utc(2015,02,21,17,30))
35
+ expect(countdown).to receive(:`).with('say "Yes"')
36
+ countdown.answer_to_question
37
+ end
38
+
39
+ it 'knows the difference between Niklas leaving and current time' do
40
+ Delorean.time_travel_to(Time.utc(2015,01,21,17,30))
41
+ expect(countdown.time_difference.to_i)
42
+ .to eq(606600)
43
+ end
44
+
45
+ it 'can convert the difference in time into days, hours and minutes' do
46
+ Delorean.time_travel_to(Time.utc(2015,01,21,17,30))
47
+ expect(countdown.time_difference_normal).to eq("7:0:30")
48
+ end
49
+
50
+ it 'can says how long Niklas has left' do
51
+ Delorean.time_travel_to(Time.utc(2015,01,21,17,30))
52
+ expect(countdown).to receive(:`)
53
+ .with('say "7 days, 0 hours and 30 minutes"')
54
+ countdown.time_difference_spoken
55
+ end
56
+
57
+ end
@@ -0,0 +1 @@
1
+ require 'delorean'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,2 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: has_niklas_left_yet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Giles
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-22 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
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: delorean
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ A gem to help me make some friends which
71
+ countdowns how long Niklas has left in the
72
+ office.
73
+ email:
74
+ - ''
75
+ executables:
76
+ - has_niklas_left_yet
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - ".gitignore"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/has_niklas_left_yet
86
+ - has_niklas_left_yet.gemspec
87
+ - lib/has_niklas_left_yet.rb
88
+ - lib/has_niklas_left_yet/version.rb
89
+ - spec/has_niklas_left_yet_spec.rb
90
+ - spec/spec_helper.rb
91
+ - tasks/rspec.rake
92
+ homepage: ''
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.5
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Countdown to Niklas leaving.
116
+ test_files:
117
+ - spec/has_niklas_left_yet_spec.rb
118
+ - spec/spec_helper.rb