potatochop 0.0.1.beta → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/potatochop/version.rb +1 -1
- data/lib/potatochop.rb +28 -4
- data/potatochop.gemspec +2 -0
- data/spec/fake_site/bar.html +23 -0
- data/spec/fake_site/css/bar.css +1 -0
- data/spec/fake_site/foo.html.haml +4 -0
- data/spec/fake_site/img/potatochop_cs4_box.png +0 -0
- data/spec/fake_site/js/bar.js +3 -0
- data/spec/potatochop_spec.rb +34 -4
- metadata +45 -5
data/lib/potatochop/version.rb
CHANGED
data/lib/potatochop.rb
CHANGED
@@ -6,23 +6,47 @@ require 'sass'
|
|
6
6
|
module Potatochop
|
7
7
|
class Web < Sinatra::Base
|
8
8
|
get '/*.html' do
|
9
|
-
file_path = File.join(settings.working_dir, "#{params[:splat][0]}.html
|
9
|
+
file_path = File.join(settings.working_dir, "#{params[:splat][0]}.html")
|
10
|
+
# Static html first
|
10
11
|
if File.exists? file_path
|
11
|
-
|
12
|
+
send_file file_path
|
13
|
+
# Haml next
|
14
|
+
elsif File.exists? file_path + ".haml"
|
15
|
+
Haml::Engine.new(File.read("#{file_path}.haml")).render
|
12
16
|
else
|
13
17
|
404
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
21
|
get '/*.css' do
|
18
|
-
file_path = File.join(settings.working_dir, "#{params[:splat][0]}.css
|
22
|
+
file_path = File.join(settings.working_dir, "#{params[:splat][0]}.css")
|
19
23
|
if File.exists? file_path
|
20
24
|
content_type 'text/css', :charset => 'utf-8'
|
21
|
-
|
25
|
+
send_file file_path
|
26
|
+
elsif File.exists? file_path + '.scss'
|
27
|
+
content_type 'text/css', :charset => 'utf-8'
|
28
|
+
Sass::Engine.new(File.read("#{file_path}.scss"), :syntax => :scss).render
|
29
|
+
else
|
30
|
+
404
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
get %r{/(.*).(png|jpg|jpeg|gif)} do
|
35
|
+
file_path = File.join(settings.working_dir, "#{params[:captures][0]}.#{params[:captures][1]}")
|
36
|
+
if File.exists? file_path
|
37
|
+
send_file file_path
|
22
38
|
else
|
23
39
|
404
|
24
40
|
end
|
25
41
|
end
|
26
42
|
|
43
|
+
get '/*.js' do
|
44
|
+
file_path = File.join(settings.working_dir, "#{params[:splat][0]}.js")
|
45
|
+
if File.exists? file_path
|
46
|
+
send_file file_path
|
47
|
+
else
|
48
|
+
404
|
49
|
+
end
|
50
|
+
end
|
27
51
|
end
|
28
52
|
end
|
data/potatochop.gemspec
CHANGED
@@ -17,9 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
gem.add_runtime_dependency 'sinatra'
|
20
|
+
gem.add_runtime_dependency 'thin'
|
20
21
|
gem.add_runtime_dependency 'haml'
|
21
22
|
gem.add_runtime_dependency 'sass'
|
22
23
|
gem.add_development_dependency 'rspec'
|
23
24
|
gem.add_development_dependency 'rake'
|
24
25
|
gem.add_development_dependency 'simplecov'
|
26
|
+
gem.add_development_dependency 'rack-test'
|
25
27
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
Fake batch of mock ups.
|
6
|
+
</title>
|
7
|
+
<link href='css/bar.css' media='screen' rel='stylesheet' type='text/css' />
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<h1>
|
11
|
+
This page is static HTML.
|
12
|
+
</h1>
|
13
|
+
<p>
|
14
|
+
This a paragraph.
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
And here is an image taken from the internet:
|
18
|
+
<br />
|
19
|
+
<img src='img/potatochop_cs4_box.png' />
|
20
|
+
</p>
|
21
|
+
<script src="js/bar.js" type="text/javascript"></script>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
body h1 { color: blue; }
|
Binary file
|
data/spec/potatochop_spec.rb
CHANGED
@@ -8,26 +8,56 @@ describe 'Potatochop' do
|
|
8
8
|
describe 'Web' do
|
9
9
|
app.set('working_dir','/Users/mertonium/Code/potatochop/spec/fake_site')
|
10
10
|
include Rack::Test::Methods
|
11
|
-
|
11
|
+
|
12
12
|
it 'returns an error when a haml page does not exist' do
|
13
13
|
get 'no_exist.html'
|
14
14
|
last_response.should_not be_ok
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it 'renders a haml page that exists' do
|
18
18
|
get '/foo.html'
|
19
19
|
last_response.body.should match('<h1>\s+This is an H1!\s+</h1>')
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'renders an html page that exists' do
|
23
|
+
get '/bar.html'
|
24
|
+
last_response.body.should match('This page is static HTML')
|
25
|
+
end
|
26
|
+
|
22
27
|
it 'returns an error when a sass file does not exist' do
|
23
28
|
get 'no_exist.css'
|
24
29
|
last_response.should_not be_ok
|
25
30
|
end
|
26
|
-
|
27
|
-
it 'renders a
|
31
|
+
|
32
|
+
it 'renders a sass stylesheet that exists' do
|
28
33
|
get '/css/foo.css'
|
29
34
|
last_response.body.should match('body h1 {\s+color: red; }')
|
30
35
|
end
|
36
|
+
|
37
|
+
it 'renders a static stylesheet that exists' do
|
38
|
+
get '/css/bar.css'
|
39
|
+
last_response.body.should match('body h1 { color: blue; }')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns an error when a requested image file does not exist' do
|
43
|
+
get 'no_exist.png'
|
44
|
+
last_response.should_not be_ok
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns a requested image file when it exists' do
|
48
|
+
get '/img/potatochop_cs4_box.png'
|
49
|
+
last_response.should be_ok
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns an error when a requested javascript file does not exist' do
|
53
|
+
get '/no_exist.js'
|
54
|
+
last_response.should_not be_ok
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns the requested javascript file if it exists' do
|
58
|
+
get '/js/bar.js'
|
59
|
+
last_response.should be_ok
|
60
|
+
end
|
31
61
|
|
32
62
|
end
|
33
63
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: potatochop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Mertens
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03
|
12
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thin
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: haml
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +123,22 @@ dependencies:
|
|
107
123
|
- - ! '>='
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rack-test
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
110
142
|
description: Potatochop - because F$%k Photoshop, that's why.
|
111
143
|
email:
|
112
144
|
- john@versahq.com
|
@@ -125,8 +157,12 @@ files:
|
|
125
157
|
- lib/potatochop.rb
|
126
158
|
- lib/potatochop/version.rb
|
127
159
|
- potatochop.gemspec
|
160
|
+
- spec/fake_site/bar.html
|
161
|
+
- spec/fake_site/css/bar.css
|
128
162
|
- spec/fake_site/css/foo.css.scss
|
129
163
|
- spec/fake_site/foo.html.haml
|
164
|
+
- spec/fake_site/img/potatochop_cs4_box.png
|
165
|
+
- spec/fake_site/js/bar.js
|
130
166
|
- spec/helper.rb
|
131
167
|
- spec/potatochop_spec.rb
|
132
168
|
homepage: https://github.com/VersaHQ/potatochop
|
@@ -144,9 +180,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
181
|
none: false
|
146
182
|
requirements:
|
147
|
-
- - ! '
|
183
|
+
- - ! '>='
|
148
184
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
185
|
+
version: '0'
|
150
186
|
requirements: []
|
151
187
|
rubyforge_project:
|
152
188
|
rubygems_version: 1.8.24
|
@@ -155,7 +191,11 @@ specification_version: 3
|
|
155
191
|
summary: Potatochop is a simple server that compiles and serves up HAML and SASS files.
|
156
192
|
The goal is to reduce friction between designers and devs in a Rails project.
|
157
193
|
test_files:
|
194
|
+
- spec/fake_site/bar.html
|
195
|
+
- spec/fake_site/css/bar.css
|
158
196
|
- spec/fake_site/css/foo.css.scss
|
159
197
|
- spec/fake_site/foo.html.haml
|
198
|
+
- spec/fake_site/img/potatochop_cs4_box.png
|
199
|
+
- spec/fake_site/js/bar.js
|
160
200
|
- spec/helper.rb
|
161
201
|
- spec/potatochop_spec.rb
|