serve 1.5.0.pre3 → 1.5.0.pre4
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/Gemfile +4 -4
- data/Gemfile.lock +7 -7
- data/README.rdoc +4 -6
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/serve/application.rb +7 -6
- data/lib/serve/export.rb +17 -12
- data/lib/serve/templates/gitignore +2 -1
- data/spec/application_spec.rb +96 -52
- metadata +29 -23
- data/rails/init.rb +0 -6
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem 'rake', '~> 0.9.0'
|
4
|
-
gem 'rack', '~> 1.
|
5
|
-
gem 'rack-test', '~> 0.
|
4
|
+
gem 'rack', '~> 1.2.1'
|
5
|
+
gem 'rack-test', '~> 0.5.7'
|
6
6
|
gem 'tilt', '~> 1.3.1'
|
7
7
|
gem 'activesupport', '~> 3.0.7'
|
8
|
-
gem 'tzinfo', '~> 0.3.
|
9
|
-
gem 'i18n', '~> 0.
|
8
|
+
gem 'tzinfo', '~> 0.3.23'
|
9
|
+
gem 'i18n', '~> 0.5.0'
|
10
10
|
|
11
11
|
group :development do
|
12
12
|
gem 'rspec', '~> 2.6.0'
|
data/Gemfile.lock
CHANGED
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
gemcutter (0.6.1)
|
15
15
|
git (1.2.5)
|
16
16
|
haml (3.1.1)
|
17
|
-
i18n (0.
|
17
|
+
i18n (0.5.0)
|
18
18
|
jeweler (1.4.0)
|
19
19
|
gemcutter (>= 0.1.0)
|
20
20
|
git (>= 1.2.5)
|
@@ -25,8 +25,8 @@ GEM
|
|
25
25
|
treetop (>= 1.4.2)
|
26
26
|
mutter (0.5.3)
|
27
27
|
polyglot (0.3.1)
|
28
|
-
rack (1.3
|
29
|
-
rack-test (0.
|
28
|
+
rack (1.2.3)
|
29
|
+
rack-test (0.5.7)
|
30
30
|
rack (>= 1.0)
|
31
31
|
radius (0.6.1)
|
32
32
|
rake (0.9.0)
|
@@ -60,11 +60,11 @@ DEPENDENCIES
|
|
60
60
|
compass (~> 0.11.1)
|
61
61
|
erubis (~> 2.7.0)
|
62
62
|
haml (~> 3.1.1)
|
63
|
-
i18n (~> 0.
|
63
|
+
i18n (~> 0.5.0)
|
64
64
|
jeweler (~> 1.4.0)
|
65
65
|
less (~> 1.2.21)
|
66
|
-
rack (~> 1.
|
67
|
-
rack-test (~> 0.
|
66
|
+
rack (~> 1.2.1)
|
67
|
+
rack-test (~> 0.5.7)
|
68
68
|
radius (~> 0.6.1)
|
69
69
|
rake (~> 0.9.0)
|
70
70
|
rdiscount (~> 1.6.8)
|
@@ -72,4 +72,4 @@ DEPENDENCIES
|
|
72
72
|
sass (~> 3.1.1)
|
73
73
|
slim (~> 0.9.4)
|
74
74
|
tilt (~> 1.3.1)
|
75
|
-
tzinfo (~> 0.3.
|
75
|
+
tzinfo (~> 0.3.23)
|
data/README.rdoc
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
= Serve -
|
1
|
+
= Serve - Easy ERB, Haml, and Sass
|
2
2
|
|
3
|
-
link:../../downloads/jlong/serve/logo-hifi-
|
3
|
+
link:../../downloads/jlong/serve/logo-hifi-3.png
|
4
4
|
|
5
5
|
Serve is a small Rack-based web server that makes it easy to serve HTML, ERB,
|
6
6
|
Haml, or a variety of template languages from any directory.
|
7
7
|
|
8
|
-
But Serve is much more than a simple web server.
|
9
|
-
|
10
8
|
Serve is meant to be a lightweight version of the Views part of the Rails MVC.
|
11
9
|
This makes Serve an ideal framework for prototyping Rails applications or
|
12
|
-
creating simple websites. Serve
|
10
|
+
creating simple websites. Serve has full support for Rails-style partials
|
13
11
|
and layouts.
|
14
12
|
|
15
13
|
If you use a "Design First" approach to Web application development, you may
|
@@ -283,7 +281,7 @@ project to HTML. To get started with the prerelease version:
|
|
283
281
|
|
284
282
|
To export your project, use the new "export" command:
|
285
283
|
|
286
|
-
serve export project
|
284
|
+
serve export project output
|
287
285
|
|
288
286
|
Where "project" is the path to the project and "output" is the path to the
|
289
287
|
directory where you would like your HTML and CSS generated.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.0.
|
1
|
+
1.5.0.pre4
|
data/lib/serve/application.rb
CHANGED
@@ -136,6 +136,7 @@ module Serve
|
|
136
136
|
end
|
137
137
|
|
138
138
|
private
|
139
|
+
|
139
140
|
def normalize_args(args)
|
140
141
|
args = args.join(' ')
|
141
142
|
args.gsub!(%r{http://}, '')
|
@@ -182,11 +183,12 @@ module Serve
|
|
182
183
|
def extract_create(args)
|
183
184
|
if args.delete('create')
|
184
185
|
framework = extract_javascript_framework(args, '-j', '--javascript')
|
185
|
-
args.
|
186
|
+
name = args.shift
|
187
|
+
raise InvalidArgumentsError unless name
|
186
188
|
{
|
187
189
|
:framework => framework,
|
188
|
-
:name =>
|
189
|
-
:directory => (args.
|
190
|
+
:name => name,
|
191
|
+
:directory => (args.last ? File.expand_path(args.shift) : Dir.pwd)
|
190
192
|
}
|
191
193
|
end
|
192
194
|
end
|
@@ -203,10 +205,9 @@ module Serve
|
|
203
205
|
|
204
206
|
def extract_export(args)
|
205
207
|
if args.delete('export')
|
206
|
-
input, output =
|
207
|
-
output = args.shift if output.nil?
|
208
|
+
input, output = args.shift, args.shift
|
208
209
|
input, output = Dir.pwd, input if output.nil?
|
209
|
-
output
|
210
|
+
output ||= 'html'
|
210
211
|
{
|
211
212
|
:input => input,
|
212
213
|
:output => output
|
data/lib/serve/export.rb
CHANGED
@@ -77,12 +77,12 @@ module Serve
|
|
77
77
|
|
78
78
|
# request the path
|
79
79
|
browser = Rack::Test::Session.new(Rack::MockSession.new(Serve::RackAdapter.new(@root)))
|
80
|
-
browser.get filename
|
80
|
+
browser.get filename, {}, {'REQUEST_URI' => "http://example.org/#{extract_request_path(filename)}"}
|
81
81
|
response = browser.last_response
|
82
82
|
|
83
83
|
# body and extension
|
84
84
|
contents = response.body
|
85
|
-
ext = extract_ext(
|
85
|
+
ext = extract_ext(filename)
|
86
86
|
|
87
87
|
# write contents
|
88
88
|
to_path = "#{@output}/#{remove_ext(filename)}#{ext}"
|
@@ -138,22 +138,27 @@ module Serve
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
def extract_ext(
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
".css"
|
147
|
-
when %r{text/javascript}
|
148
|
-
".js"
|
141
|
+
def extract_ext(path)
|
142
|
+
if path =~ /(\.[A-Za-z]+)\.[A-Za-z]+$/
|
143
|
+
$1
|
144
|
+
elsif path =~ /(\.[A-Za-z]+)$/
|
145
|
+
$1
|
149
146
|
else
|
150
|
-
|
147
|
+
''
|
151
148
|
end
|
152
149
|
end
|
153
150
|
|
151
|
+
def extract_request_path(filename)
|
152
|
+
result = remove_ext(filename)
|
153
|
+
result = result.sub(/index$/, '')
|
154
|
+
result = result.sub(/\/$/, '')
|
155
|
+
result
|
156
|
+
end
|
157
|
+
|
154
158
|
def rackified?
|
155
|
-
|
159
|
+
File.directory?("#{@input}/views") && File.directory?("#{@input}/public")
|
156
160
|
end
|
161
|
+
|
157
162
|
end
|
158
163
|
|
159
164
|
def self.export(options={})
|
data/spec/application_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Serve::Application do
|
|
5
5
|
|
6
6
|
before :each do
|
7
7
|
@app = Serve::Application.new
|
8
|
-
@
|
8
|
+
@options = {
|
9
9
|
:help => false,
|
10
10
|
:version => false,
|
11
11
|
:environment => 'development',
|
@@ -21,83 +21,127 @@ describe Serve::Application do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "parsing" do
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
it "no arguments" do
|
26
|
+
parse('').should == @options
|
26
27
|
end
|
27
28
|
|
28
|
-
it "
|
29
|
-
|
29
|
+
it "with only the port" do
|
30
|
+
parse('2000')[:port].should == 2000
|
30
31
|
end
|
31
32
|
|
32
|
-
it "
|
33
|
-
@
|
34
|
-
|
35
|
-
@app.parse(["1.1.1.1:2000"]).should ==
|
36
|
-
@defopts.update(:address => "1.1.1.1", :port=>2000)
|
33
|
+
it "with the port and address" do
|
34
|
+
parse('1.1.1.1 2000').should == @options.update(:address => "1.1.1.1", :port=>2000)
|
35
|
+
parse('1.1.1.1:2000').should == @options.update(:address => "1.1.1.1", :port=>2000)
|
37
36
|
end
|
38
37
|
|
39
|
-
it "
|
40
|
-
|
41
|
-
@defopts.update(:address => "1.1.1.1", :port=>2000)
|
38
|
+
it "with the port, address, and protocol" do
|
39
|
+
parse('http://1.1.1.1:2000').should == @options.update(:address => "1.1.1.1", :port=>2000)
|
42
40
|
end
|
43
41
|
|
44
|
-
it "
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
it "help" do
|
43
|
+
parse('')[:help].should be_false
|
44
|
+
parse('-h')[:help].should be_true
|
45
|
+
parse('--help')[:help].should be_true
|
48
46
|
end
|
49
47
|
|
50
|
-
it "
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
it "version" do
|
49
|
+
parse('')[:version].should be_false
|
50
|
+
parse('-v')[:version].should be_true
|
51
|
+
parse('--version')[:version].should be_true
|
54
52
|
end
|
55
53
|
|
56
|
-
it "
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
it "environment" do
|
55
|
+
parse('')[:environment].should == "development"
|
56
|
+
parse('production')[:environment].should == "production"
|
57
|
+
parse('test')[:environment].should == "test"
|
58
|
+
parse('development')[:environment].should == "development"
|
61
59
|
end
|
62
60
|
|
63
|
-
it "
|
64
|
-
|
61
|
+
it "working directory" do
|
62
|
+
parse('')[:root].should == Dir.pwd
|
65
63
|
dir = File.dirname(__FILE__)
|
66
|
-
|
64
|
+
parse(dir)[:root].should == File.expand_path(dir)
|
67
65
|
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
describe "create" do
|
68
|
+
it "with standard arguments" do
|
69
|
+
params = parse('create newapp /Users/user')[:create]
|
70
|
+
params[:name].should == 'newapp'
|
71
|
+
params[:directory].should == '/Users/user'
|
72
|
+
params[:framework].should be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it "without parent directory" do
|
76
|
+
params = parse('create newapp')[:create]
|
77
|
+
params[:name].should == 'newapp'
|
78
|
+
params[:directory].should == Dir.pwd
|
79
|
+
end
|
80
|
+
|
81
|
+
it "with no arguments" do
|
82
|
+
lambda { parse('create') }.should raise_error(Serve::Application::InvalidArgumentsError)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "with a javascript framework" do
|
86
|
+
params = parse('create newapp /Users/user -j jquery')[:create]
|
87
|
+
params[:name].should == 'newapp'
|
88
|
+
params[:directory].should == '/Users/user'
|
89
|
+
params[:framework].should == 'jquery'
|
90
|
+
end
|
74
91
|
end
|
75
92
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
93
|
+
describe "convert" do
|
94
|
+
it "with standard arguments" do
|
95
|
+
params = parse('convert /Users/user')[:convert]
|
96
|
+
params[:directory].should == '/Users/user'
|
97
|
+
params[:framework].should be_nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it "with no arguments" do
|
101
|
+
params = parse('convert')[:convert]
|
102
|
+
params[:directory].should == Dir.pwd
|
103
|
+
params[:framework].should be_nil
|
104
|
+
end
|
105
|
+
|
106
|
+
it "with a javascript framework" do
|
107
|
+
params = parse('convert /Users/user --javascript mootools')[:convert]
|
108
|
+
params[:directory].should == '/Users/user'
|
109
|
+
params[:framework].should == 'mootools'
|
110
|
+
end
|
80
111
|
end
|
81
112
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
113
|
+
describe "export" do
|
114
|
+
it "with standard arguments" do
|
115
|
+
params = parse('export input output')[:export]
|
116
|
+
params[:input].should == 'input'
|
117
|
+
params[:output].should == 'output'
|
118
|
+
end
|
119
|
+
|
120
|
+
it "export with just an output directory" do
|
121
|
+
params = parse('export output')[:export]
|
122
|
+
params[:input].should == Dir.pwd
|
123
|
+
params[:output].should == 'output'
|
124
|
+
end
|
125
|
+
|
126
|
+
it "export with no arguments" do
|
127
|
+
params = parse('export')[:export]
|
128
|
+
params[:input].should == Dir.pwd
|
129
|
+
params[:output].should == 'html'
|
130
|
+
end
|
88
131
|
end
|
89
132
|
|
90
|
-
it "
|
91
|
-
|
92
|
-
|
93
|
-
@app.parse(convert)[:convert][:framework].should == 'mootools'
|
133
|
+
it "with invalid arguments" do
|
134
|
+
lambda { parse('--invalid') }.should raise_error(Serve::Application::InvalidArgumentsError)
|
135
|
+
lambda { parse('invalid') }.should raise_error(Serve::Application::InvalidArgumentsError)
|
94
136
|
end
|
95
137
|
|
138
|
+
private
|
96
139
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
140
|
+
def parse(*args)
|
141
|
+
args = args.split(' ')
|
142
|
+
@app.parse(*args)
|
143
|
+
end
|
144
|
+
|
101
145
|
end
|
102
146
|
|
103
147
|
describe "running" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -1876988217
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.5.0.
|
10
|
+
- pre4
|
11
|
+
version: 1.5.0.pre4
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- John W. Long
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-07-05 00:00:00 -04:00
|
22
22
|
default_executable: serve
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,12 +29,12 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 29
|
33
33
|
segments:
|
34
34
|
- 1
|
35
|
-
-
|
36
|
-
-
|
37
|
-
version: 1.
|
35
|
+
- 2
|
36
|
+
- 1
|
37
|
+
version: 1.2.1
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
@@ -45,12 +45,12 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 5
|
49
49
|
segments:
|
50
50
|
- 0
|
51
|
-
-
|
52
|
-
-
|
53
|
-
version: 0.
|
51
|
+
- 5
|
52
|
+
- 7
|
53
|
+
version: 0.5.7
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -93,12 +93,12 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
96
|
+
hash: 61
|
97
97
|
segments:
|
98
98
|
- 0
|
99
99
|
- 3
|
100
|
-
-
|
101
|
-
version: 0.3.
|
100
|
+
- 23
|
101
|
+
version: 0.3.23
|
102
102
|
type: :runtime
|
103
103
|
version_requirements: *id005
|
104
104
|
- !ruby/object:Gem::Dependency
|
@@ -109,12 +109,12 @@ dependencies:
|
|
109
109
|
requirements:
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
112
|
+
hash: 11
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
-
|
115
|
+
- 5
|
116
116
|
- 0
|
117
|
-
version: 0.
|
117
|
+
version: 0.5.0
|
118
118
|
type: :runtime
|
119
119
|
version_requirements: *id006
|
120
120
|
- !ruby/object:Gem::Dependency
|
@@ -178,7 +178,6 @@ files:
|
|
178
178
|
- lib/serve/templates/view_helpers.rb
|
179
179
|
- lib/serve/version.rb
|
180
180
|
- lib/serve/view_helpers.rb
|
181
|
-
- rails/init.rb
|
182
181
|
- spec/application_spec.rb
|
183
182
|
- spec/fixtures/directory/index.html
|
184
183
|
- spec/fixtures/hello.html
|
@@ -187,10 +186,17 @@ files:
|
|
187
186
|
- spec/router_spec.rb
|
188
187
|
- spec/spec_helper.rb
|
189
188
|
has_rdoc: true
|
190
|
-
homepage: http://
|
191
|
-
licenses:
|
192
|
-
|
193
|
-
post_install_message:
|
189
|
+
homepage: http://get-serve.com
|
190
|
+
licenses:
|
191
|
+
- MIT
|
192
|
+
post_install_message: |-
|
193
|
+
Thanks for installing Serve! If you plan to use Serve with another
|
194
|
+
template language (apart from ERB), don't forget to install it.
|
195
|
+
|
196
|
+
If you want use Sass or Compass remember to install them, too!
|
197
|
+
|
198
|
+
Serve doesn't install these dependencies by default, so that you can
|
199
|
+
make your own decisions about what you want to use.
|
194
200
|
rdoc_options:
|
195
201
|
- --charset=UTF-8
|
196
202
|
require_paths:
|