Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Shoes.url. Try out sample35.rb.
- Loading branch information
Showing
9 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,4 @@ def logger | |
require 'shoes/logger' | ||
require 'shoes/text_block' | ||
require 'shoes/radio' | ||
require 'shoes/url' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Shoes | ||
$urls = {} | ||
def self.included klass | ||
def klass.url page, m | ||
klass = self | ||
page = /^#{page}$/ | ||
$urls[page] = proc do |s, arg| | ||
klass.class_eval do | ||
define_method :method_missing do |m, *args, &blk| | ||
s.send m, *args, &blk | ||
end | ||
end | ||
arg ? klass.new.send(m, arg) : klass.new.send(m) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ sample18.rb | |
sample19.rb | ||
sample20.rb | ||
sample21.rb | ||
sample28.rb | ||
sample28.rb | ||
sample35.rb |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class PhotoFrame | ||
SPACE = " " | ||
include Shoes | ||
url '/', :index | ||
url '/loogink', :loogink | ||
url '/cy', :cy | ||
|
||
def index | ||
eval(['loogink', 'cy'][rand 2]) | ||
end | ||
|
||
def loogink | ||
background tomato | ||
inscription 'Shoes 4' | ||
flow width: 70 # space | ||
image File.join(Shoes::DIR, '../samples/loogink.png') | ||
para SPACE | ||
para SPACE, fg(strong('She is Loogink.'), white), | ||
'->', link(strong('Cy')){visit '/cy'} | ||
p location | ||
end | ||
|
||
def cy | ||
background paleturquoise | ||
inscription 'Shoes 4' | ||
flow width: 70 # space | ||
image File.join(Shoes::DIR, '../samples/cy.png') | ||
para SPACE | ||
para SPACE, fg(strong('He is Cy.'), gray), ' ->', | ||
link(strong('loogink')){visit '/loogink'} | ||
p location | ||
end | ||
end | ||
|
||
Shoes.app width: 200, height: 120, title: 'Photo Frame' | ||
|
||
# TODO: Remove SPACE and use margin style option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'shoes/spec_helper' | ||
|
||
describe 'Shoes.url' do | ||
subject do | ||
class Hello | ||
include Shoes | ||
url '/', :index | ||
def index; end | ||
end | ||
Shoes.app | ||
end | ||
|
||
it "should have $urls" do | ||
$urls.should be_empty | ||
subject | ||
$urls.should_not be_empty | ||
end | ||
end |
dbea525
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Works great on my OS X.