picnic 0.6.3 → 0.6.4
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/CHANGELOG.txt +17 -4
- data/lib/picnic/cli.rb +15 -6
- data/lib/picnic/postambles.rb +34 -7
- data/lib/picnic/version.rb +1 -1
- data/lib/picnic.rb +5 -2
- data/vendor/camping-1.5.180/CHANGELOG +12 -0
- data/vendor/camping-1.5.180/lib/camping-unabridged.rb +3 -1
- data/vendor/camping-1.5.180/lib/camping.rb +4 -2
- metadata +2 -2
data/CHANGELOG.txt
CHANGED
@@ -1,14 +1,27 @@
|
|
1
|
-
=== 0.6.
|
1
|
+
=== 0.6.4 :: 2008-05-26
|
2
|
+
|
3
|
+
* Patched bundled Camping library to allow setting expiry time on cookies.
|
4
|
+
* CLI initializer can now be fed an alternate module name for your application.
|
5
|
+
This will override the module that would have been guessed based on the
|
6
|
+
app's name.
|
7
|
+
* Fixed bug where HTTPS operation didn't work under Webrick. You should now
|
8
|
+
again be able to serve over HTTPS when using webrick by supplying the
|
9
|
+
ssl_cert configuration option.
|
10
|
+
See: http://code.google.com/p/rubycas-server/issues/detail?id=45
|
11
|
+
* Fixed bug where the log file was being truncuated whenever the server
|
12
|
+
was started in daemon mode.
|
13
|
+
|
14
|
+
=== 0.6.3 :: 2008-03-14
|
2
15
|
|
3
16
|
* Fixed bug in mongrel postamble that prevented the server from starting when
|
4
17
|
the log level was set to DEBUG.
|
5
18
|
|
6
|
-
=== 0.6.2 ::
|
19
|
+
=== 0.6.2 :: 2008-03-06
|
7
20
|
|
8
21
|
* Fixed some loading problems having to do with the new CAS authenticator
|
9
22
|
introduced in 0.6.0.
|
10
23
|
|
11
|
-
=== 0.6.1 ::
|
24
|
+
=== 0.6.1 :: 2008-02-28
|
12
25
|
|
13
26
|
* Fixed bug introduced in 0.6.0 where webrick and mongrel postambles were
|
14
27
|
broken for apps that don't define any public directories.
|
@@ -16,7 +29,7 @@
|
|
16
29
|
some potential issues with the uri_path config option. Multiple /'s
|
17
30
|
in the path are now automatically removed.
|
18
31
|
|
19
|
-
=== 0.6.0 ::
|
32
|
+
=== 0.6.0 :: 2008-02-26
|
20
33
|
|
21
34
|
* Added support for CAS authentication. See picnic/authentication.rb for
|
22
35
|
details.
|
data/lib/picnic/cli.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'active_support'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'active_support'
|
8
|
+
end
|
9
|
+
|
3
10
|
module Picnic
|
4
11
|
# Provides a command-line interface for your app.
|
5
12
|
# This is useful for creating a 'bin' file for launching your application.
|
@@ -41,11 +48,12 @@ module Picnic
|
|
41
48
|
def initialize(app, options = {})
|
42
49
|
@app = app
|
43
50
|
|
44
|
-
@options = {}
|
45
|
-
@options[:app_path]
|
46
|
-
@options[:
|
47
|
-
@options[:
|
48
|
-
@options[:
|
51
|
+
@options = options || {}
|
52
|
+
@options[:app_path] ||= File.expand_path(File.dirname(File.expand_path(__FILE__))+"/../lib/#{app}.rb")
|
53
|
+
@options[:app_module] ||= app.capitalize
|
54
|
+
@options[:pid_file] ||= "/etc/#{app}/#{app}.pid"
|
55
|
+
@options[:conf_file] ||= nil
|
56
|
+
@options[:verbose] ||= false
|
49
57
|
|
50
58
|
@options = options
|
51
59
|
end
|
@@ -97,7 +105,8 @@ module Picnic
|
|
97
105
|
|
98
106
|
opts.on_tail("-V", "--version", "Show version number") do
|
99
107
|
require "#{path}/lib/#{app}/version"
|
100
|
-
|
108
|
+
app_mod = @options[:app_module].constantize
|
109
|
+
puts "#{app}-#{app_mod::VERSION::STRING}"
|
101
110
|
exit
|
102
111
|
end
|
103
112
|
end.parse!
|
data/lib/picnic/postambles.rb
CHANGED
@@ -36,12 +36,36 @@ module Picnic
|
|
36
36
|
cert_path = Picnic::Conf.ssl_cert
|
37
37
|
key_path = Picnic::Conf.ssl_key || Picnic::Conf.ssl_cert
|
38
38
|
# look for the key in the ssl_cert if no ssl_key is specified
|
39
|
+
|
40
|
+
webrick_options = {
|
41
|
+
:BindAddress => Picnic::Conf.bind_address || "0.0.0.0",
|
42
|
+
:Port => Picnic::Conf.port
|
43
|
+
}
|
44
|
+
|
45
|
+
unless cert_path.nil? && key_path.nil?
|
46
|
+
raise "The specified certificate file #{cert_path.inspect} does not exist. " +
|
47
|
+
" Your 'ssl_cert' configuration setting must be a path to a valid " +
|
48
|
+
" ssl certificate." unless
|
49
|
+
File.exists? cert_path
|
50
|
+
|
51
|
+
raise "The specified key file #{key_path.inspect} does not exist. " +
|
52
|
+
" Your 'ssl_key' configuration setting must be a path to a valid " +
|
53
|
+
" ssl private key." unless
|
54
|
+
File.exists? key_path
|
39
55
|
|
56
|
+
require 'openssl'
|
57
|
+
|
58
|
+
cert = OpenSSL::X509::Certificate.new(File.read(cert_path))
|
59
|
+
key = OpenSSL::PKey::RSA.new(File.read(key_path))
|
60
|
+
|
61
|
+
webrick_options[:SSLEnable] = true
|
62
|
+
webrick_options[:SSLVerifyClient] = ::OpenSSL::SSL::VERIFY_NONE
|
63
|
+
webrick_options[:SSLCertificate] = cert
|
64
|
+
webrick_options[:SSLPrivateKey] = key
|
65
|
+
end
|
66
|
+
|
40
67
|
begin
|
41
|
-
s = WEBrick::HTTPServer.new(
|
42
|
-
:BindAddress => Picnic::Conf.bind_address || "0.0.0.0",
|
43
|
-
:Port => Picnic::Conf.port
|
44
|
-
)
|
68
|
+
s = WEBrick::HTTPServer.new(webrick_options)
|
45
69
|
rescue Errno::EACCES
|
46
70
|
puts "\nThe server could not launch. Are you running on a privileged port? (e.g. port 443) If so, you must run the server as root."
|
47
71
|
exit 2
|
@@ -69,9 +93,11 @@ module Picnic
|
|
69
93
|
trap(:TERM) do
|
70
94
|
s.shutdown
|
71
95
|
end
|
96
|
+
|
97
|
+
server_url = "http#{webrick_options[:SSLEnable] ? 's' : ''}://#{ENV['HOSTNAME'] || 'localhost'}:#{Picnic::Conf.port}#{Picnic::Conf.uri_path}"
|
72
98
|
|
73
99
|
if $DAEMONIZE
|
74
|
-
puts "\n** #{self} will run at
|
100
|
+
puts "\n** #{self} will run at #{server_url} and log to #{Picnic::Conf.log[:file].inspect}. "
|
75
101
|
puts "** Check the log file for further messages!\n\n"
|
76
102
|
|
77
103
|
logdev = $LOG.instance_variable_get(:@logdev).instance_variable_get(:@filename)
|
@@ -82,6 +108,7 @@ module Picnic
|
|
82
108
|
|
83
109
|
WEBrick::Daemon.start do
|
84
110
|
begin
|
111
|
+
#self.init_db_logger
|
85
112
|
write_pid_file if $PID_FILE
|
86
113
|
$LOG.info "Starting #{self} as a WEBrick daemon with process id #{Process.pid}."
|
87
114
|
self.prestart if self.respond_to? :prestart
|
@@ -94,7 +121,7 @@ module Picnic
|
|
94
121
|
end
|
95
122
|
end
|
96
123
|
else
|
97
|
-
puts "\n** #{self} is running at
|
124
|
+
puts "\n** #{self} is running at #{server_url} and logging to #{Picnic::Conf.log[:file].inspect}\n\n"
|
98
125
|
self.prestart if self.respond_to? :prestart
|
99
126
|
s.start
|
100
127
|
end
|
@@ -218,7 +245,7 @@ module Picnic
|
|
218
245
|
def check_log_writable
|
219
246
|
log_file = Picnic::Conf.log['file']
|
220
247
|
begin
|
221
|
-
f = open(log_file, '
|
248
|
+
f = open(log_file, 'a')
|
222
249
|
rescue
|
223
250
|
$stderr.puts "Couldn't write to log file at '#{log_file}' (#{$!})."
|
224
251
|
exit 1
|
data/lib/picnic/version.rb
CHANGED
data/lib/picnic.rb
CHANGED
@@ -46,12 +46,15 @@ class Module
|
|
46
46
|
|
47
47
|
# Initialize your application's database logger.
|
48
48
|
# If enabled, all SQL queries going through ActiveRecord will be logged here.
|
49
|
+
#
|
50
|
+
# THIS SEEMS TO BE BROKEN RIGHT NOW and I can't really understand why.
|
49
51
|
def init_db_logger
|
50
52
|
begin
|
51
53
|
if self::Conf.db_log
|
52
54
|
log_file = self::Conf.db_log[:file] || "#{self.to_s.downcase}_db.log"
|
53
|
-
self::Models::Base.logger = Logger.new(log_file)
|
54
|
-
self::Models::Base.logger.level = "
|
55
|
+
self::Models::Base.logger = Picnic::Utils::Logger.new(log_file)
|
56
|
+
self::Models::Base.logger.level = "Picnic::Utils::Logger::#{self::Conf.db_log[:level] || 'DEBUG'}".constantize
|
57
|
+
$LOG.debug "Logging database queries to #{log_file.inspect}"
|
55
58
|
end
|
56
59
|
rescue Errno::EACCES => e
|
57
60
|
$LOG.warn "Can't write to database log file at '#{log_file}': #{e}"
|
@@ -1,3 +1,15 @@
|
|
1
|
+
= Patches
|
2
|
+
=== 31st Mar, 2008
|
3
|
+
|
4
|
+
* Can now set expiry time for cookies.
|
5
|
+
|
6
|
+
@cookies[:foo] = {:value => "bar", :expires => Time.now + 1.hour}
|
7
|
+
|
8
|
+
The simple method of setting cookies without expiry still works.
|
9
|
+
|
10
|
+
@cookies[:foo] = "bar"
|
11
|
+
|
12
|
+
|
1
13
|
= 1.5
|
2
14
|
=== 3rd Oct, 2006
|
3
15
|
|
@@ -434,7 +434,9 @@ module Camping
|
|
434
434
|
# on before and after overrides with Camping.
|
435
435
|
def service(*a)
|
436
436
|
@body = send(@method, *a) if respond_to? @method
|
437
|
-
@headers['Set-Cookie'] = @cookies.map { |k,v|
|
437
|
+
@headers['Set-Cookie'] = @cookies.map { |k,v|
|
438
|
+
"#{k}=#{C.escape(v[:value] || v)}; path=#{self/"/"}; expires=#{v[:expires] && v[:expires].strftime('%a, %d-%b-%Y %H:%M:%S %Z') || nil}" if v != @k[k]
|
439
|
+
} - [nil]
|
438
440
|
self
|
439
441
|
end
|
440
442
|
|
@@ -25,8 +25,10 @@ o.binmode;else;fh=""end;while l=@in.read(16384);if l=~b;o<<$`.chomp;@in.seek(-$'
|
|
25
25
|
size,IO::SEEK_CUR);break;end;o<<l;end;C.qsp(fn,'&;',fh,q) if fn;fh[:tempfile].rewind if
|
26
26
|
fh.is_a?H;end;elsif@method=="post";q.u C.qsp(@in.read)end;@cookies,@input=
|
27
27
|
@k.dup,q.dup end;def service*a;@body=send(@method,*a)if respond_to?@method
|
28
|
-
@headers["Set-Cookie"]=@cookies.map{|k,v|"#{k}=#{C.escape(v)
|
29
|
-
}
|
28
|
+
@headers["Set-Cookie"]=@cookies.map{|k,v|"#{k}=#{C.escape(v[:value] || v)
|
29
|
+
}; path=#{self/'/'}; expires=#{v[:expires] &&
|
30
|
+
v[:expires].strftime('%a, %d-%b-%Y %H:%M:%S %Z') || nil}"if v!=@k[k]}-[nil];
|
31
|
+
self end;def to_s;a=[];@headers.map{|k,v|[*v].map{|x|a<<
|
30
32
|
"#{k}: #{x}"}};"Status: #{@status}#{Z+a*Z+Z*2+@body}"end;end
|
31
33
|
X=module Controllers;@r=[];class<<self;def r;@r;end;def R*u;r=@r;Class.new{
|
32
34
|
meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end;def M;def M;end;constants.map{|c|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picnic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zukowski
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-26 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|