dans_didactic_clock 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@dans_didactic_clock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dans_didactic_clock.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ This repository is purposly left empty. It will be used by students as
2
+ a starting point for their Learn Ruby The Hard Way exercises.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ require 'sinatra'
4
+ require 'dans_didactic_clock/time_keeper'
5
+
6
+ # otherwise sinatra won't always automagically launch its embedded
7
+ # http server when this script is executed
8
+ set :run, true
9
+
10
+ get '/' do
11
+ time_keeper = DidacticClock::TimeKeeper.new
12
+ return time_keeper.verbose_time
13
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "dans_didactic_clock/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "dans_didactic_clock"
7
+ s.version = DansDidacticClock::VERSION
8
+ s.authors = ["Dan Schmidt"]
9
+ s.email = ["daniel.adam.schmidt@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Didactic Clock Web App }
12
+ s.description = %q{Simple app that displays the didactic system time.}
13
+
14
+ s.rubyforge_project = "dans_didactic_clock"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ s.add_dependency "sinatra"
25
+ end
@@ -0,0 +1,197 @@
1
+ def prompt()
2
+ print "> "
3
+ end
4
+
5
+ def death()
6
+ quips = ["You died. You kinda suck at this.",
7
+ "Nice job, you died ...jackass.",
8
+ "Such a luser",
9
+ "I have a small puppy that's better at this."]
10
+ puts quips[rand(quips.length())]
11
+ Process.exit(1)
12
+ end
13
+
14
+ attr_reader :number
15
+
16
+ def central_corridor()
17
+ @text = <<-TEXT
18
+ The Gothons of Planet Percal #25 have invaded your ship and destroyed
19
+ you entire crew. You are the last surviving memeber and your last
20
+ mission is to get the neutron destruct bomb from the Weapons Armory,
21
+ put it in the bridge, and blow the ship up after getting into an
22
+ escape pod.
23
+ \n
24
+ You're running down the central corridor to the Weapons Armory when
25
+ a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume
26
+ flowing around his hate filled body. He's blocking the door to the
27
+ Armory and about to pull a weapon to blast you.
28
+ TEXT
29
+
30
+ prompt()
31
+ action = gets.chomp()
32
+
33
+ if action == "shoot!"
34
+ puts <<-TEXT
35
+ Quick on the draw you yank out your blaster and fire it at the Gothon.
36
+ His clown costume is flowing and moving around his body, which throws
37
+ off your aim. Your laser hits his costume but misses him entirely. This
38
+ completely ruins his brand new costume which his mother bought him, which
39
+ makes him fly into an insane rage and blast you repeatedly in the face until
40
+ you are dead. Then he eats you.
41
+ TEXT
42
+ return :death
43
+
44
+ elsif action == "dodge!"
45
+ puts <<-TEXT
46
+ Like a world class boxer you dodge, weave, slip and slide right
47
+ as the Gothon's blaster cranks a laser past your head.
48
+ In the middle of your artful dodge your foot slips and you
49
+ bang your head on the metal wall and pass out.
50
+ You wake up shorty after only to die as the Gothon stomps on
51
+ your head and eats you.
52
+ TEXT
53
+
54
+ return :death
55
+
56
+ elsif action == "tell a joke"
57
+ puts <<-TEXT
58
+ Lucky for you they made you learn Gothon insults at the academy.
59
+ You tell the one Gothon joke you know:
60
+ Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubfhr, fur fvgf nebhaq gur ubhfr.
61
+ The Gothon stops, tries not to laugh, the bursts out laughing and can't move.
62
+ While he's laughing you run up and shoot him square in the head
63
+ putting him down, then jump through the Weapon Armory door.
64
+ TEXT
65
+
66
+ return :laser_weapon_armory
67
+
68
+ else
69
+ puts "DOES NOT COMPUTE"
70
+ return central_corridor
71
+ end
72
+ end
73
+
74
+ def laser_weapon_armory()
75
+ puts "You do a dive roll into the Weapon Armory, crouch and scan the room"
76
+ puts "for more Gothons that might be hiding. It's dead quiet, too quiet."
77
+ puts "You stand up and run to the far side of the room and find the"
78
+ puts "neutron bomb in it container. There's a keypad lock on the box"
79
+ puts "and you need the code to get the bomb out. If you get the code"
80
+ puts "wrong 10 times then the lock closes forever and you can't"
81
+ puts "get the bomb. The is 3 digits."
82
+ code = "%s%s%s" % [rand(9)+1, rand(9)+1, rand(9)+1]
83
+ print "[keypad]> "
84
+ guess = gets.chomp()
85
+ guesses = 0
86
+
87
+ while guess != code and guesses < 10
88
+ if guess == "boom"
89
+ guess = nil
90
+ puts code
91
+ else
92
+ puts "BZZZZZZZD!"
93
+ guesses += 1
94
+ print "[keypad]> "
95
+ guess = gets.chomp()
96
+ end
97
+ end
98
+
99
+ if guess == code
100
+ puts "The container clicks open and the seal breaks, letting gas out."
101
+ puts "You grab the neutron bomb and run as fast as you can to the"
102
+ puts "bridge where you must place it in the right spot."
103
+ return :the_bridge
104
+ else
105
+ puts "The lock buzzes one last time and then you hear a sickening"
106
+ puts "melting sound as the mechanism is forced together."
107
+ puts "You decide to sit there, and finally the Gothons blow up the"
108
+ puts "ship from their ship and you die."
109
+ return :death
110
+ end
111
+ end
112
+
113
+ def the_bridge()
114
+ puts "You burst onto the Bridge with the neutron destruct bomb"
115
+ puts "under your arm and surprise 5 Gothons who are trying to"
116
+ puts "take control of the ship. Each of them has an even uglier"
117
+ puts "clown costume than the last. They haven't pulled their"
118
+ puts "weapons out yet, as they see the active bomb under your"
119
+ puts "arm and don't want to set if off."
120
+
121
+ prompt()
122
+ action = gets.chomp()
123
+
124
+ if action == "throw the bomb"
125
+ puts "In a panic you throw the bomb at the group of Gothons"
126
+ puts "and make a leap for the door. Right as you drop it a"
127
+ puts "Gothon shoots you right in the back killing you."
128
+ puts "As you die you see another Gothon frantically try to disarm"
129
+ puts "the bomb. You die knowing they will probably blow up when"
130
+ puts "it goes off."
131
+
132
+ elsif action == "slowly place the bomb"
133
+ puts "You point the blaster at the bomb under your arm"
134
+ puts "and the Gothons put their hands up and start to sweat."
135
+ puts "You inch backward to the door, open it, and the carefully"
136
+ puts "place the bomb on the floor, pointing your blaster at it."
137
+ puts "You then jump back through the door, punch the close button"
138
+ puts "and blast the lock so the Gothons can't get out."
139
+ puts "Now that the bomb is placed you run to the escape pod to"
140
+ puts "get off this tin can."
141
+ return :escape_pod
142
+ else
143
+ puts "DOES NOT COMPUTE!"
144
+ return :the_bridge
145
+ end
146
+ end
147
+
148
+ def escape_pod()
149
+ puts "You rush through the ship desperately trying to make it to"
150
+ puts "the escape pod before the whole ship explodes. It seem like"
151
+ puts "hardly any Gothons are on the ship, so your run is clear of"
152
+ puts "interference. You get to he chamber with the escape pods, and"
153
+ puts "now need to pick one to take. Some of them could be damaged"
154
+ puts "but you don't have time to look. There's 5 pods, which one"
155
+ puts "do you take?"
156
+
157
+ good_pod = rand(5)+1
158
+ print "[pod #]> "
159
+ guess = gets.chomp()
160
+
161
+ if guess.to_i != good_pod
162
+ puts "You jump into pod %s and hit the eject button." % guess
163
+ puts "The pod escapes out into the void of space, then"
164
+ puts "implodes as the hull ruptures, crushing your body"
165
+ puts "into jam jelly."
166
+ return :death
167
+ else
168
+ puts "You jump into pod %s and hit the eject button." % guess
169
+ puts "The pod easily slides out itno space heading to"
170
+ puts "the planet below. As it flies to the planet, you look"
171
+ puts "back and see your ship implode then explode like a"
172
+ puts "bright star, taking out the Gothon ship at the same"
173
+ puts "time. You won!"
174
+ Process.exit(0)
175
+ end
176
+ end
177
+
178
+ ROOMS = {
179
+ :death => method(:death),
180
+ :central_corridor => method(:central_corridor),
181
+ :laser_weapon_armory => method(:laser_weapon_armory),
182
+ :the_bridge => method(:the_bridge),
183
+ :escape_pod => method(:escape_pod)
184
+ }
185
+
186
+ def runner(map, start)
187
+ next_one = start
188
+
189
+ while true
190
+ room = map[next_one]
191
+ puts "\n--------->"
192
+ puts room.text
193
+ # next_one = room.call()
194
+ end
195
+ end
196
+
197
+ runner(ROOMS, :central_corridor)
@@ -0,0 +1,15 @@
1
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- openssl (LoadError)
2
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
3
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/https.rb:92:in `<top (required)>'
4
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
5
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
6
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:316:in `connection_for'
7
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:368:in `request'
8
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/gemcutter_utilities.rb:56:in `rubygems_api_request'
9
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/commands/push_command.rb:49:in `send_gem'
10
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/commands/push_command.rb:36:in `execute'
11
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:278:in `invoke'
12
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:147:in `process_args'
13
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:117:in `run'
14
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:65:in `run'
15
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/gem:21:in `<main>'
@@ -0,0 +1,19 @@
1
+ You asked me to pull without telling me which branch you
2
+ want to merge with, and 'branch.master.merge' in
3
+ your configuration file does not tell me, either. Please
4
+ specify which branch you want to use on the command line and
5
+ try again (e.g. 'git pull <repository> <refspec>').
6
+ See git-pull(1) for details.
7
+
8
+ If you often merge with the same branch, you may want to
9
+ use something like the following in your configuration file:
10
+
11
+ [branch "master"]
12
+ remote = <nickname>
13
+ merge = <remote-ref>
14
+
15
+ [remote "<nickname>"]
16
+ url = <url>
17
+ fetch = <refspec>
18
+
19
+ See git-config(1) for details.
@@ -0,0 +1,5 @@
1
+ require "dans_didactic_clock/version"
2
+
3
+ module DansDidacticClock
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,12 @@
1
+ module DidacticClock
2
+ class TimeKeeper
3
+ def verbose_time
4
+ time = Time.now
5
+ minute = Time.min
6
+ hour = Time.hour % 12
7
+ meridian_indicator = time.hour < 12 ? 'AM' : 'PM'
8
+
9
+ "#{minute} minutes past #{hour} o'clock, #{meridian_indicator}"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module DansDidacticClock
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ ERROR: Could not find a valid gem 'openssl' (>= 0) in any repository
2
+ ERROR: Possible alternatives: opendsl, opensrs, open_dsl, openurl
@@ -0,0 +1,39 @@
1
+ rake aborted!
2
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- openssl (LoadError)
3
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
4
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/https.rb:92:in `<top (required)>'
5
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
6
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
7
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:316:in `connection_for'
8
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:368:in `request'
9
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/gemcutter_utilities.rb:56:in `rubygems_api_request'
10
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/commands/push_command.rb:49:in `send_gem'
11
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/commands/push_command.rb:36:in `execute'
12
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:278:in `invoke'
13
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:147:in `process_args'
14
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:117:in `run'
15
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:65:in `run'
16
+ from /home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/gem:21:in `<main>'
17
+ Pushing gem to https://rubygems.org...
18
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:135:in `sh'
19
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:74:in `rubygem_push'
20
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:67:in `block in release_gem'
21
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:114:in `tag_version'
22
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:65:in `release_gem'
23
+ /home/dan/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/gem_helper.rb:38:in `block in install'
24
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `call'
25
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
26
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `each'
27
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `execute'
28
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
29
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
30
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
31
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:581:in `invoke'
32
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
33
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
34
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `each'
35
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
36
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
37
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
38
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/rake.rb:1992:in `run'
39
+ /home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/rake:35:in `<main>'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dans_didactic_clock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Schmidt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: &72568590 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *72568590
25
+ description: Simple app that displays the didactic system time.
26
+ email:
27
+ - daniel.adam.schmidt@gmail.com
28
+ executables:
29
+ - dans_clock_server
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - .rvmrc
35
+ - Gemfile
36
+ - README.md
37
+ - Rakefile
38
+ - bin/dans_clock_server
39
+ - dans_didactic_clock.gemspec
40
+ - ex41_ec.rb
41
+ - gempush-error.txt
42
+ - git-errors.txt
43
+ - lib/dans_didactic_clock.rb
44
+ - lib/dans_didactic_clock/time_keeper.rb
45
+ - lib/dans_didactic_clock/version.rb
46
+ - openssl-gem-error.txt
47
+ - rake-error.txt
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project: dans_didactic_clock
68
+ rubygems_version: 1.8.10
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Didactic Clock Web App
72
+ test_files: []