xkcd_calendar_facts 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fb6dd90790cf2b84205b52683fcea656fee71fa4b9b0c626af39002dd0be87b3
4
+ data.tar.gz: 503a34a6d5a44a3b9df906daedd750a2b95c5d81d086ab825a3dfb737f3dfbff
5
+ SHA512:
6
+ metadata.gz: 5fe6622dbe935f889743e471f38c29f876bdf4aa1883112dfc718ddd9d4d6f34ca30cb72b0a28be100b427e392a340e84ac5497009bedb2cfd53c61f12d1e6d5
7
+ data.tar.gz: 47a726b1ceda32e22c5aa7b1a20cb7942a4dfc3cc9623981c142555f1d13d0cdad92a16a7ab9f9e0f80cdf9e5266bf7676f729318a0c5cc58a6d2f29aa5cfc22
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in xkcd_calendar_facts.gemspec
6
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xkcd_calendar_facts (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.16)
16
+ rake (~> 10.0)
17
+ xkcd_calendar_facts!
18
+
19
+ BUNDLED WITH
20
+ 1.16.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Travis Petersen
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.
@@ -0,0 +1,44 @@
1
+ # XkcdCalendarFacts
2
+
3
+ This Ruby Gem prints randomly generated calendar facts based on XKCD #1930
4
+ by Randall Munroe. The original comic can be found at: https://xkcd.com/1930/
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'xkcd_calendar_facts'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install xkcd_calendar_facts
21
+
22
+ ## Usage
23
+
24
+ Type the below and follow the on-screen prompts:
25
+
26
+ $ xkcd_calendar_facts
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xkcd_calendar_facts.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the JplMissions project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'tpetersen0308'/jpl_missions/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #require 'xkcd_calendar_facts'
3
+ #require_relative '../lib/xkcd_calendar_facts.rb'
4
+ require_relative '../config/environment.rb'
5
+
6
+
7
+ CLI.call
@@ -0,0 +1,5 @@
1
+ require_relative '../lib/xkcd_calendar_facts/calendar-facts.rb'
2
+ require_relative '../lib/xkcd_calendar_facts/CLI.rb'
3
+ require_relative '../lib/xkcd_calendar_facts/fact-generator.rb'
4
+ require_relative '../lib/xkcd_calendar_facts/version.rb'
5
+ require_relative '../lib/xkcd_calendar_facts.rb'
@@ -0,0 +1,5 @@
1
+ require_relative "../lib/xkcd_calendar_facts/version"
2
+ require_relative '../config/environment.rb'
3
+
4
+ #module XKCDCalendarFacts
5
+ #end
@@ -0,0 +1,35 @@
1
+ class CLI
2
+
3
+ def self.call
4
+ puts ""
5
+ puts "------------------XKCD CALENDAR FACTS-------------------"
6
+ self.start
7
+ end
8
+
9
+ def self.start
10
+ puts "--------------------------------------------------------"
11
+ puts "--Press <ENTER> to learn an interesting calendar fact!--"
12
+ puts "--Enter anything else to exit..."
13
+
14
+ input = gets
15
+
16
+ self.menu(input)
17
+ end
18
+
19
+ def self.menu(input)
20
+ case input
21
+ when "\n"
22
+ FactGenerator.new.print_fact(FACTS)
23
+ puts ""
24
+ puts "--Press <ENTER> to learn another interesting calendar fact!"
25
+ puts "--Enter anything else to exit..."
26
+ puts ""
27
+ input = gets
28
+ self.menu(input)
29
+ else
30
+ puts "--Visit xkcd.com for more!"
31
+ puts "--Goodbye!"
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,41 @@
1
+ FACTS =
2
+ [
3
+ 'Did you know that ',
4
+ [
5
+ ['the ', ['Fall ', 'Spring '], 'Equinox '],
6
+ ['the ', ['Winter ', 'Summer '], ['Solstice ', 'Olympics ']],
7
+ ['the ', ['earliest ', 'latest '], ['sunrise ', 'sunset ']],
8
+ ['Daylight ', ['Saving ', 'Savings '], 'Time '],
9
+ ['Leap ', ['Day ', 'Year ']],
10
+ 'Easter ',
11
+ ['the ', ['harvest ', 'super ', 'blood '], 'moon '],
12
+ 'Toyota Truck Month ',
13
+ 'Shark Week '
14
+ ],
15
+
16
+ [
17
+ ['happens ', ['earlier ', 'later ', 'at the wrong time '], 'every year '],
18
+ ['drifts out of sync with the ', ['sun ', 'moon ', 'Zodiac ', 'atomic clock in Colorado ', [['Gregorian ', 'Mayan ', 'Lunar ', 'iPhone '], 'calendar ']]],
19
+ ['might ', ['not happen ', 'happen twice '], 'this year ']
20
+ ],
21
+ 'because of ',
22
+ [
23
+ ['time zone legislation in ', ['Indiana', 'Arizona', 'Russia']],
24
+ 'a decree by the Pope in the 1500\'s',
25
+ [['precession ', 'libration ', 'nutation ', 'libation ', 'eccentricity ', 'obliquity '], 'of the ', ['Moon', 'Sun', 'Earth\'s axis', 'Equator', 'Prime Meridian', [['International Date ', 'Mason-Dixon '], 'Line']]],
26
+ 'magnetic field reversal',
27
+ ['an arbitrary decision by ', ['Benjamin Franklin', 'Isaac Newton', 'FDR']],
28
+ ],
29
+ "?\nApparently, ",
30
+ [
31
+ 'it causes a predictable increase in car accidents.',
32
+ 'that\'s why we have leap seconds.',
33
+ 'scientists are really worried.',
34
+ ['it was even more extreme during the ', ['Bronze Age.', 'Ice Age.', 'Cretaceous.', '1990\'s']],
35
+ ['there\'s a proposal to fix it, but it ', ['will never happen.', 'actually makes things worse.', 'is stalled in Congress.', 'might be unconstitutional.']],
36
+ 'it is getting worse and no one knows why.'
37
+ ],
38
+ "\nWhile it may seem like trivia, it ",
39
+ ['causes huge headaches for software developers.', 'is taken advantage of by high-speed traders.', 'triggered the 2003 Northeast Blackout.',
40
+ 'has to be corrected for by GPS satellites.', 'is now recognized as a major cause of World War I.']
41
+ ]
@@ -0,0 +1,26 @@
1
+ class FactGenerator
2
+ attr_accessor :fact
3
+
4
+ def initialize
5
+ @fact = String.new
6
+ end
7
+
8
+ def generate_fact(arr)
9
+ arr.each do |el|
10
+ if el.class == String
11
+ @fact += el
12
+ elsif el.flatten.length != el.length
13
+ unknown = el.sample
14
+ generate_fact(unknown) if unknown.class == Array
15
+ @fact += unknown if unknown.class == String
16
+ else
17
+ @fact += el.sample
18
+ end
19
+ end
20
+ end
21
+
22
+ def print_fact(arr)
23
+ self.generate_fact(arr)
24
+ puts self.fact
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module XKCDCalendarFacts
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "xkcd_calendar_facts/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xkcd_calendar_facts"
8
+ spec.version = XKCDCalendarFacts::VERSION
9
+ spec.authors = ["Travis Petersen"]
10
+ spec.email = ["travis.e.petersen@gmail.com"]
11
+
12
+ spec.summary = %q{XKCD Calendar Facts}
13
+ spec.description = %q{This Ruby Gem generates random calendar facts from Randall Munroe\'s XKCD #1930 \'Calendar Facts\''}
14
+ spec.homepage = "https://rubygems.org/gems/xkcd_calendar_facts"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.executables = ["xkcd_calendar_facts"]
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xkcd_calendar_facts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Travis Petersen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-21 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: 'This Ruby Gem generates random calendar facts from Randall Munroe\''s
42
+ XKCD #1930 \''Calendar Facts\'''''
43
+ email:
44
+ - travis.e.petersen@gmail.com
45
+ executables:
46
+ - xkcd_calendar_facts
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/setup
57
+ - bin/xkcd_calendar_facts
58
+ - config/environment.rb
59
+ - lib/xkcd_calendar_facts.rb
60
+ - lib/xkcd_calendar_facts/CLI.rb
61
+ - lib/xkcd_calendar_facts/calendar-facts.rb
62
+ - lib/xkcd_calendar_facts/fact-generator.rb
63
+ - lib/xkcd_calendar_facts/version.rb
64
+ - xkcd_calendar_facts.gemspec
65
+ homepage: https://rubygems.org/gems/xkcd_calendar_facts
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.7.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: XKCD Calendar Facts
89
+ test_files: []