zuk-picnic 0.7.999.20090212 → 0.8.0.20090318
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/authentication.rb +40 -4
- data/lib/picnic/cli.rb +29 -29
- data/lib/picnic/server.rb +1 -0
- data/lib/picnic/version.rb +2 -2
- data/lib/picnic.rb +0 -37
- metadata +15 -2
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.8.0 :: 2009-03-18
|
2
|
+
|
3
|
+
* Overhauled for Camping 2.0. Major changes throughout. Some things to
|
4
|
+
watch out for:
|
5
|
+
* Your app's bin script should now specify :app_file instead of :app_path,
|
6
|
+
and :app_file should point to your Camping app's main .rb file.
|
7
|
+
* Postamples for Mongrel and WEBrick are gone, since everything is now
|
8
|
+
handled by Rack. It is also now possible to run Picnic apps on Phusion
|
9
|
+
Passenger (mod_rails/mod_rack).
|
10
|
+
|
1
11
|
=== 0.7.1 :: 2008-11-10
|
2
12
|
|
3
13
|
* Fixed config file loading problems rooted in $APP_PATH inconsistencies.
|
data/Manifest.txt
CHANGED
@@ -9,21 +9,38 @@ lib/picnic/authentication.rb
|
|
9
9
|
lib/picnic/cli.rb
|
10
10
|
lib/picnic/conf.rb
|
11
11
|
lib/picnic/controllers.rb
|
12
|
-
lib/picnic/
|
12
|
+
lib/picnic/logger.rb
|
13
|
+
lib/picnic/server.rb
|
13
14
|
lib/picnic/service_control.rb
|
14
|
-
lib/picnic/utils.rb
|
15
15
|
lib/picnic/version.rb
|
16
|
+
picnic.gemspec
|
16
17
|
setup.rb
|
17
18
|
test/picnic_test.rb
|
18
19
|
test/test_helper.rb
|
19
|
-
vendor/camping-
|
20
|
-
vendor/camping-
|
21
|
-
vendor/camping-
|
22
|
-
vendor/camping-
|
23
|
-
vendor/camping-
|
24
|
-
vendor/camping-
|
25
|
-
vendor/camping-
|
26
|
-
vendor/camping-
|
27
|
-
vendor/camping-
|
28
|
-
vendor/camping-
|
29
|
-
vendor/camping-
|
20
|
+
vendor/camping-2.0.20090212/CHANGELOG
|
21
|
+
vendor/camping-2.0.20090212/COPYING
|
22
|
+
vendor/camping-2.0.20090212/README
|
23
|
+
vendor/camping-2.0.20090212/Rakefile
|
24
|
+
vendor/camping-2.0.20090212/bin/camping
|
25
|
+
vendor/camping-2.0.20090212/doc/camping.1.gz
|
26
|
+
vendor/camping-2.0.20090212/examples/README
|
27
|
+
vendor/camping-2.0.20090212/examples/blog.rb
|
28
|
+
vendor/camping-2.0.20090212/examples/campsh.rb
|
29
|
+
vendor/camping-2.0.20090212/examples/tepee.rb
|
30
|
+
vendor/camping-2.0.20090212/extras/Camping.gif
|
31
|
+
vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb
|
32
|
+
vendor/camping-2.0.20090212/extras/permalink.gif
|
33
|
+
vendor/camping-2.0.20090212/lib/camping-unabridged.rb
|
34
|
+
vendor/camping-2.0.20090212/lib/camping.rb
|
35
|
+
vendor/camping-2.0.20090212/lib/camping/ar.rb
|
36
|
+
vendor/camping-2.0.20090212/lib/camping/ar/session.rb
|
37
|
+
vendor/camping-2.0.20090212/lib/camping/mab.rb
|
38
|
+
vendor/camping-2.0.20090212/lib/camping/reloader.rb
|
39
|
+
vendor/camping-2.0.20090212/lib/camping/server.rb
|
40
|
+
vendor/camping-2.0.20090212/lib/camping/session.rb
|
41
|
+
vendor/camping-2.0.20090212/setup.rb
|
42
|
+
vendor/camping-2.0.20090212/test/apps/env_debug.rb
|
43
|
+
vendor/camping-2.0.20090212/test/apps/forms.rb
|
44
|
+
vendor/camping-2.0.20090212/test/apps/misc.rb
|
45
|
+
vendor/camping-2.0.20090212/test/apps/sessions.rb
|
46
|
+
vendor/camping-2.0.20090212/test/test_camping.rb
|
data/Rakefile
CHANGED
@@ -22,6 +22,7 @@ ENV['NODOT'] = '1'
|
|
22
22
|
|
23
23
|
NAME = "picnic"
|
24
24
|
REV = nil
|
25
|
+
#REV = Time.now.strftime('%Y%m%d%H%M')
|
25
26
|
#REV = `svn info`[/Revision: (\d+)/, 1] rescue nil
|
26
27
|
VERS = ENV['VERSION'] || (Picnic::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
27
28
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
@@ -56,6 +57,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
56
57
|
|
57
58
|
# note that camping-1.5.0.180 is now bundled with picnic in the vendor directory.
|
58
59
|
p.extra_deps = [
|
60
|
+
'rack',
|
59
61
|
'markaby',
|
60
62
|
'activesupport'
|
61
63
|
]
|
@@ -3,6 +3,42 @@ module Picnic #:nodoc:
|
|
3
3
|
# for your Camping app.
|
4
4
|
#
|
5
5
|
module Authentication
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.module_eval do
|
9
|
+
# Enable authentication for your app.
|
10
|
+
#
|
11
|
+
# For example:
|
12
|
+
#
|
13
|
+
# Camping.goes :Blog
|
14
|
+
# Blog.picnic!
|
15
|
+
#
|
16
|
+
# $CONF[:authentication] ||= {:username => 'admin', :password => 'picnic'}
|
17
|
+
# Blog.authenticate_using :basic
|
18
|
+
#
|
19
|
+
# module Blog
|
20
|
+
# def self.authenticate(credentials)
|
21
|
+
# credentials[:username] == Taskr::Conf[:authentication][:username] &&
|
22
|
+
# credentials[:password] == Taskr::Conf[:authentication][:password]
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Note that in the above example we use the authentication configuration from
|
27
|
+
# your app's conf file.
|
28
|
+
#
|
29
|
+
def authenticate_using(mod)
|
30
|
+
mod = Picnic::Authentication.const_get(mod.to_s.camelize) unless mod.kind_of? Module
|
31
|
+
|
32
|
+
$LOG.info("Enabling authentication for all requests using #{mod.inspect}.")
|
33
|
+
|
34
|
+
module_eval do
|
35
|
+
include mod
|
36
|
+
end
|
37
|
+
end
|
38
|
+
module_function :authenticate_using
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
6
42
|
# Picnic::Authentication::Basic provides Basic HTTP Authentication for your Camping app.
|
7
43
|
# The module defines a <tt>service</tt> method that only continues the request chain when
|
8
44
|
# proper credentials are provided by the client (browser).
|
@@ -50,7 +86,7 @@ module Picnic #:nodoc:
|
|
50
86
|
# Reads the username and password from the headers and returns them.
|
51
87
|
def read_credentials
|
52
88
|
if d = %w{REDIRECT_X_HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION}.inject([]) \
|
53
|
-
{ |d,h| env.has_key?(h) ? env[h].to_s.split : d }
|
89
|
+
{ |d,h| @env.has_key?(h) ? @env[h].to_s.split : d }
|
54
90
|
u,p = ::Base64.decode64(d[1]).split(':')[0..1] if d[0] == 'Basic'
|
55
91
|
return {:username => u, :password => p}
|
56
92
|
end
|
@@ -68,9 +104,9 @@ module Picnic #:nodoc:
|
|
68
104
|
s = super(*a)
|
69
105
|
else
|
70
106
|
@status = 401
|
71
|
-
|
72
|
-
|
73
|
-
|
107
|
+
headers['Content-type'] = @headers['Content-type'] || 'text/plain'
|
108
|
+
#headers['Status'] = 'Unauthorized'
|
109
|
+
headers['WWW-Authenticate'] = "Basic realm=\"#{app}\""
|
74
110
|
@body = 'Unauthorized'
|
75
111
|
s = self
|
76
112
|
end
|
data/lib/picnic/cli.rb
CHANGED
@@ -19,7 +19,7 @@ module Picnic
|
|
19
19
|
#
|
20
20
|
# cli = Picnic::Cli.new(
|
21
21
|
# 'foo',
|
22
|
-
# :
|
22
|
+
# :app_file => "/path/to/foo.br"
|
23
23
|
# )
|
24
24
|
#
|
25
25
|
# cli.handle_cli_input
|
@@ -44,7 +44,7 @@ module Picnic
|
|
44
44
|
@app = app
|
45
45
|
|
46
46
|
@options = options || {}
|
47
|
-
@options[:app_file] ||= File.expand_path(File.dirname(File.expand_path(
|
47
|
+
@options[:app_file] ||= File.expand_path(File.dirname(File.expand_path(__FILE__))+"/../lib/#{app}.rb")
|
48
48
|
@options[:app_name] ||= app
|
49
49
|
@options[:app_module] ||= app.capitalize
|
50
50
|
@options[:pid_file] ||= "/etc/#{app}/#{app}.pid"
|
@@ -53,22 +53,29 @@ module Picnic
|
|
53
53
|
|
54
54
|
# Parses command line options given to the script.
|
55
55
|
def handle_cli_input
|
56
|
-
if File.exists? options[:app_file]
|
56
|
+
# if File.exists? options[:app_file]
|
57
57
|
# try to use given app base path
|
58
58
|
$APP_ROOT = File.dirname(options[:app_file]).gsub(/\/(lib|bin)\/?$/, '')
|
59
|
-
else
|
60
|
-
require 'rubygems'
|
61
|
-
|
62
|
-
# fall back to using gem installation
|
63
|
-
matches = Gem::source_index.find_name(app)
|
64
|
-
raise LoadError, "#{app} gem doesn't appear to be installed!" if matches.empty?
|
65
|
-
|
66
|
-
gem_spec = matches.last
|
67
|
-
$APP_ROOT = gem_spec.full_gem_path
|
68
|
-
|
69
|
-
gem(app)
|
59
|
+
# else
|
60
|
+
# require 'rubygems'
|
61
|
+
#
|
62
|
+
# # fall back to using gem installation
|
63
|
+
# matches = Gem::source_index.find_name(app)
|
64
|
+
# raise LoadError, "#{app} gem doesn't appear to be installed!" if matches.empty?
|
65
|
+
#
|
66
|
+
# gem_spec = matches.last
|
67
|
+
# $APP_ROOT = gem_spec.full_gem_path
|
68
|
+
#
|
69
|
+
# gem(app)
|
70
|
+
# end
|
71
|
+
|
72
|
+
unless File.file?(options[:app_file])
|
73
|
+
raise ArgumentError, "options[:app_file] points to #{options[:app_file].inspect} but this does not appear to be a valid Camping application!}"
|
70
74
|
end
|
71
75
|
|
76
|
+
|
77
|
+
puts "Loading #{app.inspect} code from #{$APP_ROOT.inspect}..."
|
78
|
+
|
72
79
|
$: << $APP_ROOT+"/lib"
|
73
80
|
|
74
81
|
$PID_FILE = @options[:pid_file]
|
@@ -76,11 +83,9 @@ module Picnic
|
|
76
83
|
$VERBOSE = @options[:verbose]
|
77
84
|
|
78
85
|
opts = OptionParser.new do |opts|
|
79
|
-
opts.banner = "
|
80
|
-
opts.define_head "
|
81
|
-
opts.separator ""
|
82
|
-
opts.separator "Application options:"
|
83
|
-
|
86
|
+
#opts.banner = ""
|
87
|
+
#opts.define_head ""
|
88
|
+
#opts.separator ""
|
84
89
|
opts.on("-d", "--daemonize", "Run daemonized in the background") do
|
85
90
|
$DAEMONIZE = true
|
86
91
|
end
|
@@ -106,9 +111,6 @@ module Picnic
|
|
106
111
|
@options[:extra_cli_options].call(opts)
|
107
112
|
end
|
108
113
|
|
109
|
-
opts.separator ""
|
110
|
-
opts.separator "Picnic options:"
|
111
|
-
|
112
114
|
# No argument, shows at tail. This will print an options summary.
|
113
115
|
# Try it and see!
|
114
116
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -146,14 +148,12 @@ module Picnic
|
|
146
148
|
Dir.chdir $APP_ROOT
|
147
149
|
File.umask 0000
|
148
150
|
|
149
|
-
STDIN.reopen "
|
150
|
-
STDOUT.reopen
|
151
|
-
STDERR.reopen
|
151
|
+
STDIN.reopen $CONF.log[:file], "a"
|
152
|
+
STDOUT.reopen $CONF.log[:file], "a"
|
153
|
+
STDERR.reopen $CONF.log[:file], "a"
|
152
154
|
|
153
|
-
|
154
|
-
|
155
|
-
at_exit { File.delete($PID_FILE) if File.exist?($PID_FILE) }
|
156
|
-
end
|
155
|
+
File.open($PID_FILE, 'w'){ |f| f.write("#{Process.pid}") }
|
156
|
+
at_exit { File.delete($PID_FILE) if File.exist?($PID_FILE) }
|
157
157
|
end
|
158
158
|
|
159
159
|
server = Picnic::Server::Base.new($CONF, [options[:app_file]])
|
data/lib/picnic/server.rb
CHANGED
data/lib/picnic/version.rb
CHANGED
data/lib/picnic.rb
CHANGED
@@ -8,41 +8,4 @@ require "camping"
|
|
8
8
|
|
9
9
|
|
10
10
|
module Picnic
|
11
|
-
|
12
|
-
def self.included(base)
|
13
|
-
base.mod_eval do
|
14
|
-
# Enable authentication for your app.
|
15
|
-
#
|
16
|
-
# For example:
|
17
|
-
#
|
18
|
-
# Camping.goes :Blog
|
19
|
-
# Blog.picnic!
|
20
|
-
#
|
21
|
-
# $CONF[:authentication] ||= {:username => 'admin', :password => 'picnic'}
|
22
|
-
# Blog.authenticate_using :basic
|
23
|
-
#
|
24
|
-
# module Blog
|
25
|
-
# def self.authenticate(credentials)
|
26
|
-
# credentials[:username] == Taskr::Conf[:authentication][:username] &&
|
27
|
-
# credentials[:password] == Taskr::Conf[:authentication][:password]
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# Note that in the above example we use the authentication configuration from
|
32
|
-
# your app's conf file.
|
33
|
-
#
|
34
|
-
def authenticate_using(mod)
|
35
|
-
load "picnic/authentication.rb"
|
36
|
-
mod = self::Authentication.const_get(mod.to_s.camelize) unless mod.kind_of? Module
|
37
|
-
|
38
|
-
$LOG.info("Enabling authentication for all requests using #{mod.inspect}.")
|
39
|
-
|
40
|
-
module_eval do
|
41
|
-
include mod
|
42
|
-
end
|
43
|
-
end
|
44
|
-
module_function :authenticate_using
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuk-picnic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0.20090318
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zukowski
|
@@ -9,11 +9,22 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: markaby
|
27
|
+
type: :runtime
|
17
28
|
version_requirement:
|
18
29
|
version_requirements: !ruby/object:Gem::Requirement
|
19
30
|
requirements:
|
@@ -23,6 +34,7 @@ dependencies:
|
|
23
34
|
version:
|
24
35
|
- !ruby/object:Gem::Dependency
|
25
36
|
name: activesupport
|
37
|
+
type: :runtime
|
26
38
|
version_requirement:
|
27
39
|
version_requirements: !ruby/object:Gem::Requirement
|
28
40
|
requirements:
|
@@ -32,6 +44,7 @@ dependencies:
|
|
32
44
|
version:
|
33
45
|
- !ruby/object:Gem::Dependency
|
34
46
|
name: hoe
|
47
|
+
type: :development
|
35
48
|
version_requirement:
|
36
49
|
version_requirements: !ruby/object:Gem::Requirement
|
37
50
|
requirements:
|