consolidating first two exercises into hodgepodge
This commit is contained in:
76
cookbook/015/hodgepodge/Gemfile.lock
Normal file
76
cookbook/015/hodgepodge/Gemfile.lock
Normal file
@@ -0,0 +1,76 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
mail (~> 2.2.19)
|
||||
actionpack (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.5.0)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.14)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.5.0)
|
||||
activerecord (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
arel (~> 2.0.10)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
activesupport (3.0.9)
|
||||
arel (2.0.10)
|
||||
builder (2.1.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
i18n (0.5.0)
|
||||
mail (2.2.19)
|
||||
activesupport (>= 2.3.6)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.16)
|
||||
polyglot (0.3.2)
|
||||
rack (1.2.3)
|
||||
rack-mount (0.6.14)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.9)
|
||||
actionmailer (= 3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
activerecord (= 3.0.9)
|
||||
activeresource (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.9)
|
||||
railties (3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (~> 0.14.4)
|
||||
rake (0.9.2)
|
||||
rdoc (3.9.1)
|
||||
sqlite3 (1.3.4)
|
||||
thor (0.14.6)
|
||||
treetop (1.4.10)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.29)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rails (= 3.0.9)
|
||||
sqlite3
|
@@ -0,0 +1,5 @@
|
||||
class HelloController < ApplicationController
|
||||
def world
|
||||
end
|
||||
|
||||
end
|
25
cookbook/015/hodgepodge/app/controllers/novel_controller.rb
Normal file
25
cookbook/015/hodgepodge/app/controllers/novel_controller.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
$one = 1
|
||||
|
||||
class NovelController < ApplicationController
|
||||
$two = 2
|
||||
|
||||
def index
|
||||
@title = 'Shattered View: a Novel on Rails'
|
||||
one_plus_one = 1 + 1
|
||||
increment_counter one_plus_one
|
||||
end
|
||||
|
||||
def helper_method
|
||||
@help_message = "I see you've come to me for help."
|
||||
end
|
||||
|
||||
def increment_counter(by)
|
||||
@counter ||= 0
|
||||
@counter += by
|
||||
end
|
||||
|
||||
def sequel
|
||||
$three = 3
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,7 @@
|
||||
class StatusController < ApplicationController
|
||||
def index
|
||||
time = Time.now
|
||||
@time = time
|
||||
@ps = `ps aux`
|
||||
end
|
||||
end
|
11
cookbook/015/hodgepodge/app/views/hello/world.html.erb
Normal file
11
cookbook/015/hodgepodge/app/views/hello/world.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<h1>Several increasingly silly ways of displaying “Hello world!”:</h1>
|
||||
|
||||
<p><%= "Hello world!" %></p>
|
||||
<p><%= "Hello" + " world!" %></p>
|
||||
<p><%= w = "world"
|
||||
"Hello #{w}!" %></p>
|
||||
<p><%= 'H' + ?e.chr + ('l' * 2) %><%= ('o word!').gsub('d', 'ld')%></p>
|
||||
|
||||
<% hello = "Hello" %>
|
||||
<% world = "world!" %>
|
||||
<%= hello %> <%= world %>
|
@@ -2,13 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Hodgepodge</title>
|
||||
<%= stylesheet_link_tag :all %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= csrf_meta_tag %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
|
6
cookbook/015/hodgepodge/app/views/novel/index.html.erb
Normal file
6
cookbook/015/hodgepodge/app/views/novel/index.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1><%= @title %></h1>
|
||||
|
||||
<p>I looked up, but saw only the number <%= @counter %></p>
|
||||
|
||||
<p>“What are you doing here?” I asked sharply. “Was it
|
||||
<%= @counter.succ %> who sent you?”</p>
|
2
cookbook/015/hodgepodge/app/views/novel/sequel.html.erb
Normal file
2
cookbook/015/hodgepodge/app/views/novel/sequel.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<p>Here they come, the counting numbers,
|
||||
<%= $one %>, <%= $two %>, <%= $three %>.</p>
|
2
cookbook/015/hodgepodge/app/views/status/index.html.erb
Normal file
2
cookbook/015/hodgepodge/app/views/status/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Processes running at <%= @time %></h1>
|
||||
<pre><%= @ps %></pre>
|
@@ -54,5 +54,5 @@ Hodgepodge::Application.routes.draw do
|
||||
|
||||
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
||||
# Note: This route will make all actions in every controller accessible via GET requests.
|
||||
# match ':controller(/:action(/:id(.:format)))'
|
||||
match ':controller(/:action(/:id(.:format)))'
|
||||
end
|
||||
|
Reference in New Issue
Block a user