cohitre-perro 0.9.0 → 0.9.1
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.
- data/Manifest.txt +8 -1
- data/README.txt +1 -1
- data/assets/index.haml +15 -0
- data/assets/javascripts/jquery.js +3549 -0
- data/assets/javascripts/qunit.js +735 -0
- data/assets/server.rb +11 -0
- data/assets/stylesheets/qunit.css +120 -0
- data/assets/stylesheets/reset.css +82 -0
- data/bin/perro +11 -0
- data/lib/perro.rb +19 -25
- metadata +12 -6
- data/test/sample.rb +0 -29
data/assets/server.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "perro"
|
3
|
+
|
4
|
+
PROJECT_HOME = File.expand_path(__FILE__+"/..")
|
5
|
+
|
6
|
+
s = Perro::Server.new( 3000 )
|
7
|
+
|
8
|
+
s.get("/javascripts/:file.js" , :javascript ) { |p| open("#{PROJECT_HOME}/javascripts/#{p[:file]}.js").read }
|
9
|
+
s.get("/stylesheets/:file.css" , :stylesheet ) { |p| open("#{PROJECT_HOME}/stylesheets/#{p[:file]}.css").read }
|
10
|
+
s.haml("/" , "#{PROJECT_HOME}/index.haml")
|
11
|
+
s.start
|
@@ -0,0 +1,120 @@
|
|
1
|
+
body, div, h1 { font-family: 'trebuchet ms', verdana, arial; margin: 0; padding: 0 }
|
2
|
+
body {font-size: 10pt; }
|
3
|
+
h1 { padding: 15px; font-size: large; background-color: #06b; color: white; }
|
4
|
+
h1 a { color: white; }
|
5
|
+
h2 { padding: 10px; background-color: #eee; color: black; margin: 0; font-size: small; font-weight: normal }
|
6
|
+
|
7
|
+
.pass { color: green; }
|
8
|
+
.fail { color: red; }
|
9
|
+
p.result { margin-left: 1em; }
|
10
|
+
|
11
|
+
#banner { height: 2em; border-bottom: 1px solid white; }
|
12
|
+
h2.pass { background-color: green; }
|
13
|
+
h2.fail { background-color: red; }
|
14
|
+
|
15
|
+
div.testrunner-toolbar { background: #eee; border-top: 1px solid black; padding: 10px; }
|
16
|
+
|
17
|
+
ol#tests > li > strong { cursor:pointer; }
|
18
|
+
|
19
|
+
div#fx-tests h4 {
|
20
|
+
background: red;
|
21
|
+
}
|
22
|
+
|
23
|
+
div#fx-tests h4.pass {
|
24
|
+
background: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
div#fx-tests div.box {
|
28
|
+
background: red url(data/cow.jpg) no-repeat;
|
29
|
+
overflow: hidden;
|
30
|
+
border: 2px solid #000;
|
31
|
+
}
|
32
|
+
|
33
|
+
div#fx-tests div.overflow {
|
34
|
+
overflow: visible;
|
35
|
+
}
|
36
|
+
|
37
|
+
div.inline {
|
38
|
+
display: inline;
|
39
|
+
}
|
40
|
+
|
41
|
+
div.autoheight {
|
42
|
+
height: auto;
|
43
|
+
}
|
44
|
+
|
45
|
+
div.autowidth {
|
46
|
+
width: auto;
|
47
|
+
}
|
48
|
+
|
49
|
+
div.autoopacity {
|
50
|
+
opacity: auto;
|
51
|
+
}
|
52
|
+
|
53
|
+
div.largewidth {
|
54
|
+
width: 100px;
|
55
|
+
}
|
56
|
+
|
57
|
+
div.largeheight {
|
58
|
+
height: 100px;
|
59
|
+
}
|
60
|
+
|
61
|
+
div.largeopacity {
|
62
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
|
63
|
+
}
|
64
|
+
|
65
|
+
div.medwidth {
|
66
|
+
width: 50px;
|
67
|
+
}
|
68
|
+
|
69
|
+
div.medheight {
|
70
|
+
height: 50px;
|
71
|
+
}
|
72
|
+
|
73
|
+
div.medopacity {
|
74
|
+
opacity: 0.5;
|
75
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
|
76
|
+
}
|
77
|
+
|
78
|
+
div.nowidth {
|
79
|
+
width: 0px;
|
80
|
+
}
|
81
|
+
|
82
|
+
div.noheight {
|
83
|
+
height: 0px;
|
84
|
+
}
|
85
|
+
|
86
|
+
div.noopacity {
|
87
|
+
opacity: 0;
|
88
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
|
89
|
+
}
|
90
|
+
|
91
|
+
div.hidden {
|
92
|
+
display: none;
|
93
|
+
}
|
94
|
+
|
95
|
+
div#fx-tests div.widewidth {
|
96
|
+
background-repeat: repeat-x;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#fx-tests div.wideheight {
|
100
|
+
background-repeat: repeat-y;
|
101
|
+
}
|
102
|
+
|
103
|
+
div#fx-tests div.widewidth.wideheight {
|
104
|
+
background-repeat: repeat;
|
105
|
+
}
|
106
|
+
|
107
|
+
div#fx-tests div.noback {
|
108
|
+
background-image: none;
|
109
|
+
}
|
110
|
+
|
111
|
+
div.chain, div.chain div { width: 100px; height: 20px; position: relative; float: left; }
|
112
|
+
div.chain div { position: absolute; top: 0px; left: 0px; }
|
113
|
+
|
114
|
+
div.chain.test { background: red; }
|
115
|
+
div.chain.test div { background: green; }
|
116
|
+
|
117
|
+
div.chain.out { background: green; }
|
118
|
+
div.chain.out div { background: red; display: none; }
|
119
|
+
|
120
|
+
div#show-tests * { display: none; }
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 2.6.0
|
6
|
+
*/
|
7
|
+
/* base.css, part of YUI's CSS Foundation */
|
8
|
+
h1 {
|
9
|
+
/*18px via YUI Fonts CSS foundation*/
|
10
|
+
font-size:138.5%;
|
11
|
+
}
|
12
|
+
h2 {
|
13
|
+
/*16px via YUI Fonts CSS foundation*/
|
14
|
+
font-size:123.1%;
|
15
|
+
}
|
16
|
+
h3 {
|
17
|
+
/*14px via YUI Fonts CSS foundation*/
|
18
|
+
font-size:108%;
|
19
|
+
}
|
20
|
+
h1,h2,h3 {
|
21
|
+
/* top & bottom margin based on font size */
|
22
|
+
margin:1em 0;
|
23
|
+
}
|
24
|
+
h1,h2,h3,h4,h5,h6,strong {
|
25
|
+
/*bringing boldness back to headers and the strong element*/
|
26
|
+
font-weight:bold;
|
27
|
+
}
|
28
|
+
abbr,acronym {
|
29
|
+
/*indicating to users that more info is available */
|
30
|
+
border-bottom:1px dotted #000;
|
31
|
+
cursor:help;
|
32
|
+
}
|
33
|
+
em {
|
34
|
+
/*bringing italics back to the em element*/
|
35
|
+
font-style:italic;
|
36
|
+
}
|
37
|
+
del {
|
38
|
+
text-decoration:line-through;
|
39
|
+
}
|
40
|
+
blockquote,ul,ol,dl {
|
41
|
+
/*giving blockquotes and lists room to breath*/
|
42
|
+
margin:1em;
|
43
|
+
}
|
44
|
+
ol,ul,dl {
|
45
|
+
/*bringing lists on to the page with breathing room */
|
46
|
+
margin-left:2em;
|
47
|
+
}
|
48
|
+
ol li {
|
49
|
+
/*giving OL's LIs generated numbers*/
|
50
|
+
list-style: decimal outside;
|
51
|
+
}
|
52
|
+
ul li {
|
53
|
+
/*giving UL's LIs generated disc markers*/
|
54
|
+
list-style: disc outside;
|
55
|
+
}
|
56
|
+
dl dd {
|
57
|
+
/*giving UL's LIs generated numbers*/
|
58
|
+
margin-left:1em;
|
59
|
+
}
|
60
|
+
th,td {
|
61
|
+
/*borders and padding to make the table readable*/
|
62
|
+
border:1px solid #000;
|
63
|
+
padding:.5em;
|
64
|
+
}
|
65
|
+
th {
|
66
|
+
/*distinguishing table headers from data cells*/
|
67
|
+
font-weight:bold;
|
68
|
+
text-align:center;
|
69
|
+
}
|
70
|
+
caption {
|
71
|
+
/*coordinated margin to match cell's padding*/
|
72
|
+
margin-bottom:.5em;
|
73
|
+
/*centered so it doesn't blend in to other content*/
|
74
|
+
text-align:center;
|
75
|
+
}
|
76
|
+
p,fieldset,table,pre {
|
77
|
+
/*so things don't run into each other*/
|
78
|
+
margin-bottom:1em;
|
79
|
+
}
|
80
|
+
/* setting a consistent width, 160px;
|
81
|
+
control of type=file still not possible */
|
82
|
+
input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em;}
|
data/bin/perro
ADDED
data/lib/perro.rb
CHANGED
@@ -4,12 +4,12 @@ require "haml"
|
|
4
4
|
require "sass"
|
5
5
|
|
6
6
|
module Perro
|
7
|
-
VERSION = '0.9.
|
7
|
+
VERSION = '0.9.1'
|
8
8
|
|
9
9
|
def use_rails_helpers
|
10
10
|
begin
|
11
11
|
require 'action_controller'
|
12
|
-
ActionView::Base.helper_modules.each {|m| include m }
|
12
|
+
ActionView::Base.helper_modules.each {|m| include m }
|
13
13
|
rescue
|
14
14
|
puts "It appears that you don't have action_controller."
|
15
15
|
puts "`sudo gem install rails` might help you with that."
|
@@ -43,7 +43,7 @@ module Perro
|
|
43
43
|
out.write( "404 error" )
|
44
44
|
end
|
45
45
|
else
|
46
|
-
|
46
|
+
|
47
47
|
route = handler[:route_object]
|
48
48
|
|
49
49
|
form_params = {}
|
@@ -51,7 +51,7 @@ module Perro
|
|
51
51
|
pair = d.split("=")
|
52
52
|
form_params.merge!( {pair[0].to_sym => pair[1] })
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
user_params = route.match( uri ).merge( form_params ).merge({
|
56
56
|
:path => request.params["PATH_INFO"]
|
57
57
|
})
|
@@ -68,7 +68,7 @@ module Perro
|
|
68
68
|
|
69
69
|
class Server
|
70
70
|
attr_reader :path
|
71
|
-
|
71
|
+
|
72
72
|
def initialize port=3000
|
73
73
|
@global_handler = StringHandler.new()
|
74
74
|
@port = port
|
@@ -76,12 +76,16 @@ module Perro
|
|
76
76
|
|
77
77
|
def static( route , path , mime=:html)
|
78
78
|
mimetypes = {
|
79
|
-
:html => "text/html" ,
|
80
|
-
:javascript => "text/javascript" ,
|
79
|
+
:html => "text/html" ,
|
80
|
+
:javascript => "text/javascript" ,
|
81
81
|
:css => "text/css"
|
82
82
|
}
|
83
83
|
self.get( route , mimetypes[mime] ) do |params|
|
84
|
-
|
84
|
+
if params[:file].nil?
|
85
|
+
open( "#{path}" ).read
|
86
|
+
else
|
87
|
+
open( "#{path}/#{params[:file]}" ).read
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -94,7 +98,7 @@ module Perro
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
end
|
97
|
-
|
101
|
+
|
98
102
|
def sass( route , path )
|
99
103
|
self.get( route , "text/css") do |params|
|
100
104
|
if File.exists?( path ) && !File.directory?( path )
|
@@ -109,36 +113,26 @@ module Perro
|
|
109
113
|
def get route , mime="text/html" , &block
|
110
114
|
@global_handler.push( { :route => route , :mime=>mime } , block )
|
111
115
|
end
|
112
|
-
|
116
|
+
|
113
117
|
def run
|
114
118
|
routes = @global_handler
|
115
119
|
port = @port
|
120
|
+
|
121
|
+
puts '** Perro Server Started'
|
116
122
|
config = Mongrel::Configurator.new :host => "0.0.0.0" do
|
117
123
|
listener :port => port do
|
118
124
|
uri("/" , :handler => routes )
|
119
125
|
end
|
120
126
|
run
|
121
127
|
end
|
122
|
-
puts '** Perro Server Started'
|
123
128
|
puts '** Woof Woof'
|
124
129
|
puts "** Listening to port #{@port}"
|
125
|
-
|
130
|
+
config
|
126
131
|
end
|
127
|
-
|
132
|
+
|
128
133
|
def start
|
129
|
-
|
130
|
-
port = @port
|
131
|
-
config = Mongrel::Configurator.new :host => "0.0.0.0" do
|
132
|
-
listener :port => port do
|
133
|
-
uri("/" , :handler => routes )
|
134
|
-
end
|
135
|
-
run
|
136
|
-
end
|
137
|
-
puts '** Perro Server Started'
|
138
|
-
puts '** Woof Woof'
|
139
|
-
puts "** Listening to port #{@port}"
|
134
|
+
config = self.run
|
140
135
|
puts '** Use CTRL-C to stop.'
|
141
|
-
|
142
136
|
config.join
|
143
137
|
end
|
144
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cohitre-perro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlos
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
13
|
-
default_executable:
|
12
|
+
date: 2008-12-08 00:00:00 -08:00
|
13
|
+
default_executable: perro
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongrel
|
@@ -42,8 +42,8 @@ dependencies:
|
|
42
42
|
description: Perro is a light server built on top of mongrel that helps at least one developer be happy. If it had been designed as production server it would have a cooler name. Like "Dinosaur" or "Freckle". The Internet is a global system of interconnected computer networks. Developer creates files that are served through this global system. Developer may be tempted to develop such files by creating a folder, moving the files to such folder, double clicking them and watching what happens on the browser whose address bar reads "file:///Users/cohitre/development/my-project/index.html". Perro helps developer be happy by helping overcome temptation.
|
43
43
|
email:
|
44
44
|
- carlosrr@gmail.com
|
45
|
-
executables:
|
46
|
-
|
45
|
+
executables:
|
46
|
+
- perro
|
47
47
|
extensions: []
|
48
48
|
|
49
49
|
extra_rdoc_files:
|
@@ -55,10 +55,16 @@ files:
|
|
55
55
|
- Manifest.txt
|
56
56
|
- README.txt
|
57
57
|
- Rakefile
|
58
|
+
- assets/index.haml
|
59
|
+
- assets/server.rb
|
60
|
+
- assets/javascripts/jquery.js
|
61
|
+
- assets/javascripts/qunit.js
|
62
|
+
- assets/stylesheets/qunit.css
|
63
|
+
- assets/stylesheets/reset.css
|
64
|
+
- bin/perro
|
58
65
|
- lib/perro.rb
|
59
66
|
- lib/perro/route.rb
|
60
67
|
- test/test_perro.rb
|
61
|
-
- test/sample.rb
|
62
68
|
has_rdoc: true
|
63
69
|
homepage: http://code.cohitre.com
|
64
70
|
post_install_message:
|
data/test/sample.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "lib/perro"
|
3
|
-
require "sass"
|
4
|
-
require "open-uri"
|
5
|
-
|
6
|
-
HOME_FOLDER = File.expand_path( "~" )
|
7
|
-
|
8
|
-
server = Perro::Server.new(3000)
|
9
|
-
|
10
|
-
server.static( "/javascripts/:file" , "#{HOME_FOLDER}/dev/libs/js" , :javascript )
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
server.haml( "/" , "#{File.expand_path( File.dirname( __FILE__) )}/index.haml" )
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
server.get "/stylesheets/:file.css" do |params|
|
19
|
-
Sass::Engine.new( open("#{HOME_FOLDER}#{params[:file]}.sass").read )
|
20
|
-
end
|
21
|
-
|
22
|
-
server.get "/proxy/:uri" do |params|
|
23
|
-
open( "http://cohitre.com/#{params[:uri]}" ).read
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
server.haml( "/:file" , "#{File.expand_path( File.dirname(__FILE__) )}" )
|
28
|
-
|
29
|
-
server.start
|