quotejar 1.0.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: fb901b26ff34eb8df53ba06afb502fbd964fdbc2
4
+ data.tar.gz: 151b0603da06223be10b5d713a1f91df139dad5b
5
+ SHA512:
6
+ metadata.gz: 6c80b609a7048023a2ec21a83ee9f3e366fb5c8530445a32ecbda0512ea00158fe42b0587f62e123f4dcf0bde95f784987e464a0377737b5d5760e0c94c8d9c1
7
+ data.tar.gz: f591c412c1777eabc4c6a4bff0a2c37df52e38dbfead481e07f60f0a657f3a04935425ec62161e591e1f4b71e9248254e2ec35779628f01f550010393db4a054
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.yaml/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quotejar.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jen Trudell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # QuoteJar
2
+
3
+ QuoteJar let's you easily store the cute things your kids say (or the awful things your enemies say),
4
+ including the date quoted and the age the child (or enemy) was when quoted.
5
+
6
+ ## Usage
7
+
8
+ To install from the command line: gem install 'quotejar'
9
+
10
+ Once installed, in IRB enter "require 'quotejar'", and then enter "start".
11
+ You will be prompted to enter a child's name. If you have entered information
12
+ for this childed previously, you will be prompted to enter a new quote or list
13
+ all quotes saved for that child. If the child has not been stored previously,
14
+ you will be prompted to save the child by entering the child's birthday, and
15
+ then will be able to enter new quotes.
16
+
17
+ Creating a new child will create a .yaml file to start that child's name, birthday and quotes.
18
+ Creating new entries for an existing child will update that child's .yaml file.
19
+
20
+ If you get booted out of the program during an IRB session, typing 'start' will begin QuoteJar again.
21
+
22
+ ## Features To Come
23
+
24
+ - Ability to search quotes by date or age
25
+ - Better tests
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/quotejar/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib/quotejar'
8
+ t.test_files = FileList['test/lib/quotejar/*_test.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
data/Sally.yaml ADDED
@@ -0,0 +1,10 @@
1
+ --- !ruby/object:Kids
2
+ name: Sally
3
+ birth_date: 2015-06-08 16:00:28.742821000 -05:00
4
+ quotes:
5
+ 2015-06-08 16:02:19.402014000 -05:00:
6
+ - This is my first gem
7
+ - 3.5065782252135778e-06
8
+ 2003-05-13 00:00:00.000000000 -05:00:
9
+ - I said this before I was even born!
10
+ - -12.073010265128557
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "quotejar"
5
+
6
+ require "irb"
7
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
@@ -0,0 +1,46 @@
1
+ module Age
2
+ require 'time'
3
+
4
+ def prompt
5
+ print ">> "
6
+ end
7
+
8
+ def kid_birthday(name)
9
+ puts "What is #{name}'s birthday?"
10
+ puts "Enter the year:"
11
+ prompt
12
+ year = gets.chomp
13
+ puts "Enter the month as a two digit number:"
14
+ prompt
15
+ month = gets.chomp
16
+ puts "Enter the day as a two digit number:"
17
+ prompt
18
+ day = gets.chomp
19
+ Time.new(year, month, day)
20
+ end
21
+
22
+ def quote_date
23
+ puts "What's the date? If you want to enter a day, enter 'Y'. Enter 'N' for today's date."
24
+ prompt
25
+ answer = gets.chomp.downcase
26
+ if answer == 'y'
27
+ puts "Enter the year:"
28
+ prompt
29
+ year = gets.chomp
30
+ puts "Enter the month as a two digit number:"
31
+ prompt
32
+ month = gets.chomp
33
+ puts "Enter the day as a two digit number:"
34
+ prompt
35
+ day = gets.chomp
36
+ Time.new(year, month, day)
37
+ else
38
+ Time.new
39
+ end
40
+ end
41
+
42
+ def quote_age(date, birth_date)
43
+ (date - birth_date) / 31557600 # divided by seconds in a year to get age
44
+ end
45
+
46
+ end
@@ -0,0 +1,66 @@
1
+ class Kids
2
+ include Age
3
+ attr_reader :name, :birth_date
4
+ attr_accessor :quotes
5
+
6
+ def initialize(name, birth_date)
7
+ @name = name
8
+ @birth_date = birth_date
9
+ @quotes ||= Hash.new
10
+ end
11
+
12
+ def prompt
13
+ print ">> "
14
+ end
15
+
16
+ def save_kid # creates kid.file if the kid is new, or saves to the existing file if the kid exists
17
+ File.open("./#{@name}.yaml", 'w+') do |file|
18
+ file.puts YAML::dump(self)
19
+ end
20
+ end
21
+
22
+ def new_entry
23
+ puts "What did #{@name} say?"
24
+ prompt
25
+ quote = gets.chomp
26
+ date = quote_date # retrieves quote_date from Age module, to get date from user
27
+ age = quote_age(date, @birth_date) # calculates age of kid when quoted
28
+ entry_hash = {date => [quote, age]}
29
+ @quotes.merge!(entry_hash)
30
+ save_kid
31
+ options
32
+ end
33
+
34
+ def retrieve_entries
35
+ if @quotes.empty?
36
+ puts "Sorry, no quotes yet for this child."
37
+ else
38
+ @quotes.each_pair do |date, quote|
39
+ date_shorten = date.strftime("%m/%d/%y")
40
+ puts "On #{date_shorten} when #{@name} was #{quote[1].to_i} years-old, #{@name} said: #{quote[0]}"
41
+ end
42
+ end
43
+ options
44
+ end
45
+
46
+ def options
47
+ puts "Do you want to enter a new quote, or see a list of all quotes for #{@name}?"
48
+ puts "Type 'N' for new entry, 'L' for a list of all quotes, or 'Q' to quit."
49
+ prompt
50
+ answer = gets.chomp.downcase
51
+ if answer == 'n'
52
+ new_entry
53
+ elsif answer == 'l'
54
+ retrieve_entries
55
+ elsif answer == 'q'
56
+ good_bye
57
+ else
58
+ puts "Sorry, that wasn't an option."
59
+ options
60
+ end
61
+ end
62
+
63
+ def good_bye
64
+ puts "See you soon!"
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module Quotejar
2
+ VERSION = "1.0.0"
3
+ end
data/lib/quotejar.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'yaml'
2
+ require './lib/quotejar/age'
3
+ require './lib/quotejar/kids'
4
+
5
+ def load_kid(name) # loads kid object from .yaml file
6
+ File.open("./#{name}.yaml", 'r') do |file|
7
+ YAML::load(file.read)
8
+ end
9
+ end
10
+
11
+ def create_kid(name)
12
+ include Age
13
+ puts "A file for this child doesn't exist. Do you want to add the child?"
14
+ puts "Type 'Y' for yes or 'N' for no, which will return you to the beginning."
15
+ prompt
16
+ answer = gets.chomp.downcase
17
+ if answer == 'y'
18
+ birthday = kid_birthday(name) # retieves kid_birthday from Age module, to get user to input birthday
19
+ kid = Kids.new(name, birthday)
20
+ kid.save_kid
21
+ puts "We've created a file for #{name}. Now what would you like to do?"
22
+ kid.options
23
+ else
24
+ start
25
+ end
26
+ end
27
+
28
+ def start
29
+ puts "Welcome! Please enter a child's name:"
30
+ print ">> "
31
+ name = gets.chomp
32
+ if File.exists?("./#{name}.yaml")
33
+ load_kid(name).options
34
+ else
35
+ create_kid(name)
36
+ end
37
+ end
data/quotejar.gemspec ADDED
@@ -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 'quotejar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "quotejar"
8
+ spec.version = Quotejar::VERSION
9
+ spec.authors = ["Jen Trudell"]
10
+ spec.email = ["jtrudell@gmail.com"]
11
+
12
+ spec.summary = %q{Saves quotes from your kids. Also saves paper.}
13
+ spec.description = %q{Saves quotes from your kids (or anyone) and includes the age of the kid when quoted.}
14
+ spec.homepage = "https://github.com/jtrudell/quotejar"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quotejar
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jen Trudell
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-08 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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
+ description: Saves quotes from your kids (or anyone) and includes the age of the kid
42
+ when quoted.
43
+ email:
44
+ - jtrudell@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - Sally.yaml
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/quotejar.rb
59
+ - lib/quotejar/age.rb
60
+ - lib/quotejar/kids.rb
61
+ - lib/quotejar/version.rb
62
+ - quotejar.gemspec
63
+ homepage: https://github.com/jtrudell/quotejar
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.5
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Saves quotes from your kids. Also saves paper.
87
+ test_files: []