serve 1.5.0.pre3 → 1.5.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
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.3.0'
5
- gem 'rack-test', '~> 0.6.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.27'
9
- gem 'i18n', '~> 0.6.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'
@@ -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.6.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.0)
29
- rack-test (0.6.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.6.0)
63
+ i18n (~> 0.5.0)
64
64
  jeweler (~> 1.4.0)
65
65
  less (~> 1.2.21)
66
- rack (~> 1.3.0)
67
- rack-test (~> 0.6.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.27)
75
+ tzinfo (~> 0.3.23)
@@ -1,15 +1,13 @@
1
- = Serve - A Rapid Prototyping Framework for Web Applications
1
+ = Serve - Easy ERB, Haml, and Sass
2
2
 
3
- link:../../downloads/jlong/serve/logo-hifi-1.png
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 also has full support for Rails-style partials
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:output
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
@@ -4,6 +4,7 @@ require 'rake'
4
4
  load 'tasks/jeweler.rake'
5
5
  load 'tasks/rdoc.rake'
6
6
  load 'tasks/rspec.rake'
7
+ load 'tasks/website.rake'
7
8
  load 'tasks/undefine.rake'
8
9
 
9
10
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0.pre3
1
+ 1.5.0.pre4
@@ -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.reverse!
186
+ name = args.shift
187
+ raise InvalidArgumentsError unless name
186
188
  {
187
189
  :framework => framework,
188
- :name => (args.first ? args.pop : 'mockups'),
189
- :directory => (args.first ? File.expand_path(args.pop) : Dir.pwd)
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 = (args.shift || '').split(':')
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 = 'output' if output.nil?
210
+ output ||= 'html'
210
211
  {
211
212
  :input => input,
212
213
  :output => output
@@ -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(response.content_type)
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(content_type)
142
- case content_type
143
- when %r{text/html}
144
- ".html"
145
- when %r{text/css}
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
- raise content_type.inspect
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
- @rackified ||= File.directory?("#{@input}/views") && File.directory?("#{@input}/public")
159
+ File.directory?("#{@input}/views") && File.directory?("#{@input}/public")
156
160
  end
161
+
157
162
  end
158
163
 
159
164
  def self.export(options={})
@@ -14,6 +14,7 @@ tmtags
14
14
  *.swp
15
15
 
16
16
  ## PROJECT::GENERAL
17
+ .sass-cache
17
18
  coverage
18
19
  rdoc
19
20
  pkg
@@ -21,4 +22,4 @@ pkg
21
22
  ## PROJECT::SPECIFIC
22
23
  *.gem
23
24
  .rvmrc
24
- .bundle
25
+ .bundle
@@ -5,7 +5,7 @@ describe Serve::Application do
5
5
 
6
6
  before :each do
7
7
  @app = Serve::Application.new
8
- @defopts = {
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
- it "should parse no arguments" do
25
- @app.parse([]).should == @defopts
24
+
25
+ it "no arguments" do
26
+ parse('').should == @options
26
27
  end
27
28
 
28
- it "should parse with only the port" do
29
- @app.parse(["2000"])[:port].should == 2000
29
+ it "with only the port" do
30
+ parse('2000')[:port].should == 2000
30
31
  end
31
32
 
32
- it "should parse with the port and address" do
33
- @app.parse(["1.1.1.1", "2000"]).should ==
34
- @defopts.update(:address => "1.1.1.1", :port=>2000)
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 "should parse with the port, address, and protocol" do
40
- @app.parse(["http://1.1.1.1:2000"]).should ==
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 "should parse help" do
45
- @app.parse([])[:help].should be_false
46
- @app.parse(["-h"])[:help].should be_true
47
- @app.parse(["--help"])[:help].should be_true
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 "should parse version" do
51
- @app.parse([])[:version].should be_false
52
- @app.parse(["-v"])[:version].should be_true
53
- @app.parse(["--version"])[:version].should be_true
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 "should parse environment" do
57
- @app.parse([])[:environment].should == "development"
58
- @app.parse(["production"])[:environment].should == "production"
59
- @app.parse(["test"])[:environment].should == "test"
60
- @app.parse(["development"])[:environment].should == "development"
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 "should parse working directory" do
64
- @app.parse([])[:root].should == Dir.pwd
61
+ it "working directory" do
62
+ parse('')[:root].should == Dir.pwd
65
63
  dir = File.dirname(__FILE__)
66
- @app.parse([dir])[:root].should == File.expand_path(dir)
64
+ parse(dir)[:root].should == File.expand_path(dir)
67
65
  end
68
66
 
69
- it "should parse ceate" do
70
- create = ['create', 'newapp', '/Users/user']
71
- @app.parse(create)[:create][:name].should == 'newapp'
72
- @app.parse(create)[:create][:directory].should == '/Users/user'
73
- @app.parse(create)[:create][:framework].should be_nil
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
- it "should parse convert" do
77
- convert = ['convert', '/Users/user']
78
- @app.parse(convert)[:convert][:directory].should == '/Users/user'
79
- @app.parse(convert)[:convert][:framework].should be_nil
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
- it "should parse create with a javascript framework" do
84
- create = ['create', 'newapp', '/Users/user', '-j', 'jquery']
85
- @app.parse(create)[:create][:name].should == 'newapp'
86
- @app.parse(create)[:create][:directory].should == '/Users/user'
87
- @app.parse(create)[:create][:framework].should == 'jquery'
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 "should parse convert with a javascript framework" do
91
- convert = ['convert', '/Users/user', '--javascript', 'mootools']
92
- @app.parse(convert)[:convert][:directory].should == '/Users/user'
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
- it "should detect invalid arguments" do
98
- lambda { @app.parse(["--invalid"]) }.should raise_error(Serve::Application::InvalidArgumentsError)
99
- lambda { @app.parse(["invalid"]) }.should raise_error(Serve::Application::InvalidArgumentsError)
100
- end
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: -1876988218
4
+ hash: -1876988217
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 0
10
- - pre3
11
- version: 1.5.0.pre3
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-06-22 00:00:00 -04:00
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: 27
32
+ hash: 29
33
33
  segments:
34
34
  - 1
35
- - 3
36
- - 0
37
- version: 1.3.0
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: 7
48
+ hash: 5
49
49
  segments:
50
50
  - 0
51
- - 6
52
- - 0
53
- version: 0.6.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: 37
96
+ hash: 61
97
97
  segments:
98
98
  - 0
99
99
  - 3
100
- - 27
101
- version: 0.3.27
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: 7
112
+ hash: 11
113
113
  segments:
114
114
  - 0
115
- - 6
115
+ - 5
116
116
  - 0
117
- version: 0.6.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://github.com/jlong/serve
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:
@@ -1,6 +0,0 @@
1
- require 'serve/rails'
2
-
3
- ActionController::Routing::RouteSet::Mapper.send :include, Serve::Rails::Routing::MapperExtensions
4
- ActionController::AbstractResponse.module_eval do
5
- attr_accessor :cache_timeout
6
- end