picnic 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Manifest.txt +30 -13
- data/Rakefile +2 -0
- data/lib/picnic.rb +5 -120
- data/lib/picnic/authentication.rb +40 -4
- data/lib/picnic/cli.rb +86 -43
- data/lib/picnic/conf.rb +45 -43
- data/lib/picnic/logger.rb +41 -0
- data/lib/picnic/server.rb +99 -0
- data/lib/picnic/version.rb +2 -2
- data/picnic.gemspec +44 -0
- data/vendor/{camping-1.5.180 → camping-2.0.20090212}/CHANGELOG +17 -10
- data/vendor/{camping-1.5.180 → camping-2.0.20090212}/COPYING +0 -0
- data/vendor/{camping-1.5.180 → camping-2.0.20090212}/README +2 -2
- data/vendor/{camping-1.5.180 → camping-2.0.20090212}/Rakefile +62 -5
- data/vendor/camping-2.0.20090212/bin/camping +99 -0
- data/vendor/camping-2.0.20090212/doc/camping.1.gz +0 -0
- data/vendor/camping-2.0.20090212/examples/README +5 -0
- data/vendor/camping-2.0.20090212/examples/blog.rb +375 -0
- data/vendor/camping-2.0.20090212/examples/campsh.rb +629 -0
- data/vendor/camping-2.0.20090212/examples/tepee.rb +242 -0
- data/vendor/camping-2.0.20090212/extras/Camping.gif +0 -0
- data/vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb +491 -0
- data/vendor/camping-2.0.20090212/extras/permalink.gif +0 -0
- data/vendor/{camping-1.5.180 → camping-2.0.20090212}/lib/camping-unabridged.rb +168 -294
- data/vendor/camping-2.0.20090212/lib/camping.rb +54 -0
- data/vendor/{camping-1.5.180/lib/camping/db.rb → camping-2.0.20090212/lib/camping/ar.rb} +4 -4
- data/vendor/{camping-1.5.180/lib/camping → camping-2.0.20090212/lib/camping/ar}/session.rb +23 -14
- data/vendor/camping-2.0.20090212/lib/camping/mab.rb +26 -0
- data/vendor/camping-2.0.20090212/lib/camping/reloader.rb +163 -0
- data/vendor/camping-2.0.20090212/lib/camping/server.rb +158 -0
- data/vendor/camping-2.0.20090212/lib/camping/session.rb +74 -0
- data/vendor/camping-2.0.20090212/setup.rb +1551 -0
- data/vendor/camping-2.0.20090212/test/apps/env_debug.rb +65 -0
- data/vendor/camping-2.0.20090212/test/apps/forms.rb +95 -0
- data/vendor/camping-2.0.20090212/test/apps/misc.rb +86 -0
- data/vendor/camping-2.0.20090212/test/apps/sessions.rb +38 -0
- data/vendor/camping-2.0.20090212/test/test_camping.rb +54 -0
- metadata +43 -16
- data/lib/picnic/postambles.rb +0 -292
- data/lib/picnic/utils.rb +0 -36
- data/vendor/camping-1.5.180/lib/camping.rb +0 -57
- data/vendor/camping-1.5.180/lib/camping/fastcgi.rb +0 -244
- data/vendor/camping-1.5.180/lib/camping/reloader.rb +0 -163
- data/vendor/camping-1.5.180/lib/camping/webrick.rb +0 -65
data/lib/picnic/conf.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
1
3
|
module Picnic
|
2
4
|
# Provides an interface for accessing your Picnic app's configuration file.
|
3
5
|
#
|
@@ -11,18 +13,21 @@ module Picnic
|
|
11
13
|
# puts Conf[:authentication][:username]
|
12
14
|
# # ... etc.
|
13
15
|
class Conf
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def initialize(from_hash = {})
|
17
|
+
@conf = HashWithIndifferentAccess.new(from_hash)
|
18
|
+
|
19
|
+
@conf[:log] ||= HashWithIndifferentAccess.new
|
20
|
+
@conf[:log].merge!(:file => STDOUT, :level => 'DEBUG')
|
21
|
+
|
22
|
+
@conf[:uri_path] ||= "/"
|
23
|
+
end
|
19
24
|
|
20
25
|
# Read a configuration option.
|
21
26
|
#
|
22
27
|
# For example:
|
23
28
|
# puts Conf[:server]
|
24
|
-
def
|
25
|
-
|
29
|
+
def [](key)
|
30
|
+
@conf[key]
|
26
31
|
end
|
27
32
|
|
28
33
|
# Another way of reading a configuration option.
|
@@ -30,10 +35,15 @@ module Picnic
|
|
30
35
|
# The following statements are equivalent:
|
31
36
|
# puts Conf[:server]
|
32
37
|
# puts Conf.server
|
33
|
-
def
|
38
|
+
def method_missing(method, *args)
|
34
39
|
self[method]
|
35
40
|
end
|
36
41
|
|
42
|
+
# Needs to be defined when we have a custom method_missing().
|
43
|
+
def respond_to?(method)
|
44
|
+
(@conf.stringify_keys.keys).include?(method.to_s) || super
|
45
|
+
end
|
46
|
+
|
37
47
|
# Returns the path to your application's example config file.
|
38
48
|
#
|
39
49
|
# The example config file should be in the root directory of
|
@@ -41,32 +51,27 @@ module Picnic
|
|
41
51
|
# <tt>config.example.yml</tt>. This file is used as a template
|
42
52
|
# for your app's configuration, to be customized by the end
|
43
53
|
# user.
|
44
|
-
def
|
45
|
-
|
46
|
-
app_path = File.expand_path($APP_PATH)
|
47
|
-
else
|
48
|
-
caller.last =~ /^(.*?):\d+$/
|
49
|
-
app_path = File.dirname(File.expand_path($1))
|
50
|
-
end
|
51
|
-
app_path+'/config.example.yml'
|
54
|
+
def example_config_file_path(app_root)
|
55
|
+
"#{app_root}/config.example.yml"
|
52
56
|
end
|
53
57
|
|
54
58
|
# Copies the example config file into the appropriate
|
55
59
|
# configuration directory.
|
56
60
|
#
|
57
|
-
# +
|
61
|
+
# +app_name+:: The name of your application. For example: <tt>foo</tt>
|
62
|
+
# +app_root+:: The path to your application's root directory. For example: <tt>/srv/www/camping/foo/</tt>
|
58
63
|
# +dest_conf_file:: The path where the example conf file should be copied to.
|
59
64
|
# For example: <tt>/etc/foo/config.yml</tt>
|
60
|
-
def
|
65
|
+
def copy_example_config_file(app_name, app_root, dest_conf_file)
|
61
66
|
require 'fileutils'
|
62
67
|
|
63
|
-
example_conf_file = example_config_file_path
|
68
|
+
example_conf_file = example_config_file_path(app_root)
|
64
69
|
|
65
|
-
puts "\n#{
|
70
|
+
puts "\n#{app_name.to_s.upcase} SERVER HAS NOT YET BEEN CONFIGURED!!!\n"
|
66
71
|
puts "\nAttempting to copy sample configuration from '#{example_conf_file}' to '#{dest_conf_file}'...\n"
|
67
72
|
|
68
73
|
unless File.exists? example_conf_file
|
69
|
-
puts "\nThe example conf file does not exist! The author of #{
|
74
|
+
puts "\nThe example conf file does not exist! The author of #{app_name} may have forgotten to include it. You'll have to create the config file manually.\n"
|
70
75
|
exit 2
|
71
76
|
end
|
72
77
|
|
@@ -84,50 +89,47 @@ module Picnic
|
|
84
89
|
end
|
85
90
|
|
86
91
|
puts "\nA sample configuration has been created for you in '#{dest_conf_file}'. Please edit this file to" +
|
87
|
-
" suit your needs and then run #{
|
92
|
+
" suit your needs and then run #{app_name} again.\n"
|
88
93
|
exit 1
|
89
94
|
end
|
90
95
|
|
91
|
-
# Loads the configuration from the
|
96
|
+
# Loads the configuration from the YAML file for the given app.
|
92
97
|
#
|
93
|
-
# <tt>
|
98
|
+
# <tt>app_name</tt> should be the name of your app; for example: <tt>foo</tt>
|
99
|
+
# <tt>app_root</tt> should be the path to your application's root directory; for example:: <tt>/srv/www/camping/foo/</tt>
|
100
|
+
# [<tt>config_file</tt>] can be the path to an alternate location for the config file to load
|
94
101
|
#
|
95
|
-
# By default, the configuration will be loaded from <tt>/etc/<
|
96
|
-
|
97
|
-
|
102
|
+
# By default, the configuration will be loaded from <tt>/etc/<app_name>/config.yml</tt>.
|
103
|
+
def load_from_file(app_name, app_root, config_file = nil)
|
104
|
+
conf_file = config_file || "/etc/#{app_name.to_s.downcase}/config.yml"
|
98
105
|
|
99
|
-
|
100
|
-
|
101
|
-
puts "Loading configuration for #{app} from '#{conf_file}'..."
|
106
|
+
puts "Loading configuration for #{app_name.inspect} from #{conf_file.inspect}..."
|
102
107
|
|
103
108
|
begin
|
104
109
|
conf_file = etc_conf = conf_file
|
105
110
|
unless File.exists? conf_file
|
106
111
|
# can use local config.yml file in case we're running non-gem installation
|
107
|
-
conf_file =
|
112
|
+
conf_file = "#{app_root}/config.yml"
|
108
113
|
end
|
109
114
|
|
110
115
|
unless File.exists? conf_file
|
111
|
-
copy_example_config_file(
|
116
|
+
copy_example_config_file(app_name, app_root, etc_conf)
|
112
117
|
end
|
113
118
|
|
114
119
|
loaded_conf = HashWithIndifferentAccess.new(YAML.load_file(conf_file))
|
115
120
|
|
116
|
-
|
117
|
-
$CONF = HashWithIndifferentAccess.new($CONF)
|
118
|
-
$CONF = $CONF.merge(loaded_conf)
|
119
|
-
else
|
120
|
-
$CONF = loaded_conf
|
121
|
-
end
|
122
|
-
|
123
|
-
$CONF[:log][:file] = STDOUT unless $CONF[:log][:file]
|
121
|
+
@conf.merge!(loaded_conf)
|
124
122
|
|
125
|
-
rescue
|
126
|
-
raise "Your #{
|
123
|
+
rescue => e
|
124
|
+
raise "Your #{app_name} configuration may be invalid."+
|
127
125
|
" Please double-check check your config.yml file."+
|
128
126
|
" Make sure that you are using spaces instead of tabs for your indentation!!" +
|
129
|
-
"\n\nTHE UNDERLYING ERROR WAS:\n#{
|
127
|
+
"\n\nTHE UNDERLYING ERROR WAS:\n#{e.inspect}"
|
130
128
|
end
|
131
129
|
end
|
130
|
+
|
131
|
+
def merge_defaults(defaults)
|
132
|
+
@conf = HashWithIndifferentAccess.new(HashWithIndifferentAccess.new(defaults).merge(@conf))
|
133
|
+
end
|
132
134
|
end
|
133
135
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Picnic
|
4
|
+
module Logger
|
5
|
+
|
6
|
+
# Makes available a Logger instance under the global $LOG variable.
|
7
|
+
def init_global_logger!
|
8
|
+
logdev = ($CONF && $CONF.log[:file]) || STDOUT
|
9
|
+
$LOG = Picnic::Logger::Base.new(logdev)
|
10
|
+
$LOG.level = Picnic::Logger::Base.const_get(($CONF && $CONF.log[:level]) || 'DEBUG')
|
11
|
+
|
12
|
+
puts "Initialized global logger to #{logdev.inspect}."
|
13
|
+
end
|
14
|
+
module_function :init_global_logger!
|
15
|
+
|
16
|
+
class Base < ::Logger
|
17
|
+
def initialize(logdev, shift_age = 0, shift_size = 1048576)
|
18
|
+
begin
|
19
|
+
super
|
20
|
+
rescue Exception
|
21
|
+
puts "WARNING: Couldn't create Logger with output '#{logdev}'. Logger output will be redirected to STDOUT."
|
22
|
+
super(STDOUT, shift_age, shift_size)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_message(severity, datetime, progrname, msg)
|
27
|
+
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Custom log formatter used by the Picnic Logger.
|
32
|
+
class Formatter < ::Logger::Formatter
|
33
|
+
Format = "[%s#%d] %5s -- %s: %s\n"
|
34
|
+
|
35
|
+
def call(severity, time, progname, msg)
|
36
|
+
Format % [format_datetime(time), $$, severity, progname,
|
37
|
+
msg2str(msg)]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'camping/server'
|
2
|
+
|
3
|
+
module Picnic::Server
|
4
|
+
class Base < Camping::Server::Base
|
5
|
+
def start
|
6
|
+
handler, conf = case @conf.server
|
7
|
+
when "console"
|
8
|
+
ARGV.clear
|
9
|
+
IRB.start
|
10
|
+
exit
|
11
|
+
when "mongrel"
|
12
|
+
prep_mongrel
|
13
|
+
when "webrick"
|
14
|
+
prep_webrick
|
15
|
+
end
|
16
|
+
|
17
|
+
rapp = apps.first
|
18
|
+
|
19
|
+
if @conf.uri_path
|
20
|
+
rapp = Rack::URLMap.new(@conf.uri_path => rapp)
|
21
|
+
end
|
22
|
+
|
23
|
+
rapp = Rack::Static.new(rapp, @conf[:static]) if @conf[:static]
|
24
|
+
rapp = Rack::ContentLength.new(rapp)
|
25
|
+
rapp = FixContentLength.new(rapp)
|
26
|
+
rapp = Rack::Lint.new(rapp)
|
27
|
+
rapp = Camping::Server::XSendfile.new(rapp)
|
28
|
+
rapp = Rack::ShowExceptions.new(rapp)
|
29
|
+
|
30
|
+
handler.run(rapp, conf)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def prep_webrick
|
37
|
+
handler = Rack::Handler::WEBrick
|
38
|
+
options = {
|
39
|
+
:BindAddress => @conf.bind_address || "0.0.0.0",
|
40
|
+
:Port => @conf.port
|
41
|
+
}
|
42
|
+
|
43
|
+
cert_path = @conf.ssl_cert
|
44
|
+
key_path = @conf.ssl_key || @conf.ssl_cert
|
45
|
+
# look for the key in the ssl_cert if no ssl_key is specified
|
46
|
+
|
47
|
+
unless cert_path.nil? && key_path.nil?
|
48
|
+
raise "The specified certificate file #{cert_path.inspect} does not exist or is not readable. " +
|
49
|
+
" Your 'ssl_cert' configuration setting must be a path to a valid " +
|
50
|
+
" ssl certificate." unless
|
51
|
+
File.exists? cert_path
|
52
|
+
|
53
|
+
raise "The specified key file #{key_path.inspect} does not exist or is not readable. " +
|
54
|
+
" Your 'ssl_key' configuration setting must be a path to a valid " +
|
55
|
+
" ssl private key." unless
|
56
|
+
File.exists? key_path
|
57
|
+
|
58
|
+
require 'openssl'
|
59
|
+
require 'webrick/https'
|
60
|
+
|
61
|
+
cert = OpenSSL::X509::Certificate.new(File.read(cert_path))
|
62
|
+
key = OpenSSL::PKey::RSA.new(File.read(key_path))
|
63
|
+
|
64
|
+
options[:SSLEnable] = true
|
65
|
+
options[:SSLVerifyClient] = ::OpenSSL::SSL::VERIFY_NONE
|
66
|
+
options[:SSLCertificate] = cert
|
67
|
+
options[:SSLPrivateKey] = key
|
68
|
+
end
|
69
|
+
|
70
|
+
return handler, options
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def prep_mongrel
|
75
|
+
handler = Rack::Handler::Mongrel
|
76
|
+
options = {
|
77
|
+
:Host => @conf.bind_address || "0.0.0.0",
|
78
|
+
:Port => @conf.port
|
79
|
+
}
|
80
|
+
|
81
|
+
return handler, options
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
class FixContentLength
|
87
|
+
def initialize(app)
|
88
|
+
@app = app
|
89
|
+
end
|
90
|
+
|
91
|
+
def call(env)
|
92
|
+
status, headers, body = @app.call(env)
|
93
|
+
if headers.has_key?('Content-Length') && headers['Content-Length'].to_i == 0
|
94
|
+
headers['Content-Length'] = body.body.length.to_s
|
95
|
+
end
|
96
|
+
[status, headers, body]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/picnic/version.rb
CHANGED
data/picnic.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{picnic}
|
5
|
+
s.version = '0.8.0.' + Time.now.strftime('%Y%m%d')
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Matt Zukowski"]
|
9
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
10
|
+
s.description = %q{Camping for sissies}
|
11
|
+
s.email = %q{matt@roughest.net}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG.txt", "History.txt", "LICENSE.txt", "Manifest.txt", "README.txt"]
|
13
|
+
s.files = ["CHANGELOG.txt", "History.txt", "LICENSE.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/picnic.rb", "lib/picnic/authentication.rb", "lib/picnic/cli.rb", "lib/picnic/conf.rb", "lib/picnic/controllers.rb", "lib/picnic/logger.rb", "lib/picnic/server.rb", "lib/picnic/service_control.rb", "lib/picnic/version.rb", "setup.rb", "test/picnic_test.rb", "test/test_helper.rb", "vendor/camping-2.0.20090212/CHANGELOG", "vendor/camping-2.0.20090212/COPYING", "vendor/camping-2.0.20090212/README", "vendor/camping-2.0.20090212/Rakefile", "vendor/camping-2.0.20090212/bin/camping", "vendor/camping-2.0.20090212/doc/camping.1.gz", "vendor/camping-2.0.20090212/examples/README", "vendor/camping-2.0.20090212/examples/blog.rb", "vendor/camping-2.0.20090212/examples/campsh.rb", "vendor/camping-2.0.20090212/examples/tepee.rb", "vendor/camping-2.0.20090212/extras/Camping.gif", "vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb", "vendor/camping-2.0.20090212/extras/permalink.gif", "vendor/camping-2.0.20090212/lib/camping-unabridged.rb", "vendor/camping-2.0.20090212/lib/camping.rb", "vendor/camping-2.0.20090212/lib/camping/ar.rb", "vendor/camping-2.0.20090212/lib/camping/ar/session.rb", "vendor/camping-2.0.20090212/lib/camping/mab.rb", "vendor/camping-2.0.20090212/lib/camping/reloader.rb", "vendor/camping-2.0.20090212/lib/camping/server.rb", "vendor/camping-2.0.20090212/lib/camping/session.rb", "vendor/camping-2.0.20090212/setup.rb", "vendor/camping-2.0.20090212/test/apps/env_debug.rb", "vendor/camping-2.0.20090212/test/apps/forms.rb", "vendor/camping-2.0.20090212/test/apps/misc.rb", "vendor/camping-2.0.20090212/test/apps/sessions.rb", "vendor/camping-2.0.20090212/test/test_camping.rb"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://picnic.rubyforge.org}
|
16
|
+
s.rdoc_options = ["--main", "README.txt"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{picnic}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Camping for sissies}
|
21
|
+
s.test_files = ["test/picnic_test.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 2
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
29
|
+
s.add_runtime_dependency(%q<markaby>, [">= 0"])
|
30
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
31
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
34
|
+
s.add_dependency(%q<markaby>, [">= 0"])
|
35
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
37
|
+
end
|
38
|
+
else
|
39
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
40
|
+
s.add_dependency(%q<markaby>, [">= 0"])
|
41
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
42
|
+
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
43
|
+
end
|
44
|
+
end
|
@@ -1,14 +1,21 @@
|
|
1
|
-
=
|
2
|
-
===
|
3
|
-
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
= 1.6
|
2
|
+
=== ???, 2007
|
3
|
+
|
4
|
+
* Camping::Apps removed, it wasn't reliable.
|
5
|
+
* bin/camping server kinds splitted in various files.
|
6
|
+
* NotFound and ServerError controllers changed to methods :
|
7
|
+
|
8
|
+
r404 : called when a controller was not found
|
9
|
+
r500 : called on uncaught exception
|
10
|
+
r501 : called on undefined method
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
All of those can be overridden at your taste.
|
13
|
+
|
14
|
+
* Markaby no longer required. Like AR, is it autoloaded on (Mab) usage.
|
15
|
+
* Camping::H is now inheriting from Hash instead of HashWithIndifferentAccess.
|
16
|
+
* Which made possible to remove the last strict dependency : active_support
|
17
|
+
* #errors_for removed, it wasn't really used
|
18
|
+
* Bug fixes !
|
12
19
|
|
13
20
|
= 1.5
|
14
21
|
=== 3rd Oct, 2006
|
File without changes
|
@@ -78,7 +78,7 @@ Interested yet? Okay, okay, one step at a time.
|
|
78
78
|
|
79
79
|
Or for the bleeding edge:
|
80
80
|
|
81
|
-
* <tt>gem install camping --source code.whytheluckystiff.net</tt>
|
81
|
+
* <tt>gem install camping --source http://code.whytheluckystiff.net</tt>
|
82
82
|
|
83
83
|
You are encourage to install Camping and SQLite3, since it is a small database
|
84
84
|
which fits perfectly with our compact bylaws, works well with the examples.
|
@@ -93,7 +93,7 @@ If you run them from the commandline, you'll probably just see a pile of HTML.
|
|
93
93
|
Camping comes with an tool for launching apps from the commandline:
|
94
94
|
|
95
95
|
* Run: <tt>camping blog.rb</tt>
|
96
|
-
* Visit http://localhost:3301/
|
96
|
+
* Visit http://localhost:3301/ to use the app.
|
97
97
|
|
98
98
|
== How the Camping Tool Works
|
99
99
|
|
@@ -7,9 +7,9 @@ require 'fileutils'
|
|
7
7
|
include FileUtils
|
8
8
|
|
9
9
|
NAME = "camping"
|
10
|
-
REV =
|
11
|
-
VERS = ENV['VERSION'] || ("1.
|
12
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log']
|
10
|
+
REV = (`#{ENV['GIT'] || "git"} rev-list HEAD`.split.length + 1).to_s rescue nil
|
11
|
+
VERS = ENV['VERSION'] || ("1.9" + (REV ? ".#{REV}" : ""))
|
12
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
|
13
13
|
RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation",
|
14
14
|
"--opname", "index.html",
|
15
15
|
"--line-numbers",
|
@@ -17,7 +17,7 @@ RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation",
|
|
17
17
|
"--inline-source"]
|
18
18
|
|
19
19
|
desc "Packages up Camping."
|
20
|
-
task :default => [:
|
20
|
+
task :default => [:check]
|
21
21
|
task :package => [:clean]
|
22
22
|
|
23
23
|
task :doc => [:before_doc, :rdoc, :after_doc]
|
@@ -59,8 +59,8 @@ spec =
|
|
59
59
|
s.homepage = 'http://code.whytheluckystiff.net/camping/'
|
60
60
|
s.executables = ['camping']
|
61
61
|
|
62
|
-
s.add_dependency('activesupport', '>=1.3.1')
|
63
62
|
s.add_dependency('markaby', '>=0.5')
|
63
|
+
s.add_dependency('rack', '>=0.3')
|
64
64
|
s.add_dependency('metaid')
|
65
65
|
s.required_ruby_version = '>= 1.8.2'
|
66
66
|
|
@@ -115,3 +115,60 @@ Rake::TestTask.new(:test) do |t|
|
|
115
115
|
# t.warning = true
|
116
116
|
# t.verbose = true
|
117
117
|
end
|
118
|
+
|
119
|
+
desc "Compare camping and camping-unabridged parse trees"
|
120
|
+
task :diff do
|
121
|
+
if `which parse_tree_show`.strip.empty?
|
122
|
+
STDERR.puts "ERROR: parse_tree_show missing : `gem install ParseTree`"
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
|
126
|
+
sh "parse_tree_show lib/camping.rb > .camping.pt"
|
127
|
+
sh "parse_tree_show lib/camping-unabridged.rb > .camping-unabridged.pt"
|
128
|
+
sh "diff -u .camping-unabridged.pt .camping.pt | less"
|
129
|
+
end
|
130
|
+
|
131
|
+
task :ruby_diff do
|
132
|
+
require 'ruby2ruby'
|
133
|
+
c = Ruby2Ruby.translate(File.read("lib/camping.rb"))
|
134
|
+
n = Ruby2Ruby.translate(File.read("lib/camping-unabridged.rb"))
|
135
|
+
|
136
|
+
File.open(".camping-unabridged.rb.rb","w"){|f|f<<c}
|
137
|
+
File.open(".camping.rb.rb","w"){|f|f<<n}
|
138
|
+
|
139
|
+
sh "diff -u .camping-unabridged.rb.rb .camping.rb.rb | less"
|
140
|
+
end
|
141
|
+
|
142
|
+
task :check => ["check:valid", "check:size", "check:lines"]
|
143
|
+
namespace :check do
|
144
|
+
|
145
|
+
desc "Check source code validity"
|
146
|
+
task :valid do
|
147
|
+
ruby "-rubygems", "-w", "lib/camping-unabridged.rb"
|
148
|
+
ruby "-rubygems", "-w", "lib/camping.rb"
|
149
|
+
end
|
150
|
+
|
151
|
+
SIZE_LIMIT = 4096
|
152
|
+
desc "Compare camping sizes to unabridged"
|
153
|
+
task :size do
|
154
|
+
FileList["lib/camping*.rb"].each do |path|
|
155
|
+
s = File.size(path)
|
156
|
+
puts "%21s : % 6d % 4d%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)]
|
157
|
+
end
|
158
|
+
if File.size("lib/camping.rb") > SIZE_LIMIT
|
159
|
+
STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Verify that line lenght doesn't exceed 80 chars for camping.rb"
|
164
|
+
task :lines do
|
165
|
+
i = 1
|
166
|
+
File.open("lib/camping.rb").each_line do |line|
|
167
|
+
if line.size > 81 # 1 added for \n
|
168
|
+
STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})"
|
169
|
+
end
|
170
|
+
i += 1
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|