bmarzolf-picnic 0.8.0.20090420
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 +1 -0
- data/History.txt +78 -0
- data/LICENSE.txt +165 -0
- data/Manifest.txt +45 -0
- data/README.txt +31 -0
- data/Rakefile +64 -0
- data/lib/picnic/authentication.rb +254 -0
- data/lib/picnic/cli.rb +165 -0
- data/lib/picnic/conf.rb +135 -0
- data/lib/picnic/controllers.rb +4 -0
- data/lib/picnic/logger.rb +41 -0
- data/lib/picnic/server.rb +99 -0
- data/lib/picnic/service_control.rb +274 -0
- data/lib/picnic/version.rb +9 -0
- data/lib/picnic.rb +11 -0
- data/setup.rb +1585 -0
- data/test/picnic_test.rb +11 -0
- data/test/test_helper.rb +2 -0
- data/vendor/camping-2.0.20090420/CHANGELOG +118 -0
- data/vendor/camping-2.0.20090420/COPYING +18 -0
- data/vendor/camping-2.0.20090420/README +82 -0
- data/vendor/camping-2.0.20090420/Rakefile +180 -0
- data/vendor/camping-2.0.20090420/bin/camping +97 -0
- data/vendor/camping-2.0.20090420/doc/camping.1.gz +0 -0
- data/vendor/camping-2.0.20090420/examples/README +5 -0
- data/vendor/camping-2.0.20090420/examples/blog.rb +375 -0
- data/vendor/camping-2.0.20090420/examples/campsh.rb +629 -0
- data/vendor/camping-2.0.20090420/examples/tepee.rb +242 -0
- data/vendor/camping-2.0.20090420/extras/Camping.gif +0 -0
- data/vendor/camping-2.0.20090420/extras/permalink.gif +0 -0
- data/vendor/camping-2.0.20090420/lib/camping/ar/session.rb +132 -0
- data/vendor/camping-2.0.20090420/lib/camping/ar.rb +78 -0
- data/vendor/camping-2.0.20090420/lib/camping/mab.rb +26 -0
- data/vendor/camping-2.0.20090420/lib/camping/reloader.rb +184 -0
- data/vendor/camping-2.0.20090420/lib/camping/server.rb +159 -0
- data/vendor/camping-2.0.20090420/lib/camping/session.rb +75 -0
- data/vendor/camping-2.0.20090420/lib/camping-unabridged.rb +630 -0
- data/vendor/camping-2.0.20090420/lib/camping.rb +52 -0
- data/vendor/camping-2.0.20090420/setup.rb +1551 -0
- data/vendor/camping-2.0.20090420/test/apps/env_debug.rb +65 -0
- data/vendor/camping-2.0.20090420/test/apps/forms.rb +95 -0
- data/vendor/camping-2.0.20090420/test/apps/misc.rb +86 -0
- data/vendor/camping-2.0.20090420/test/apps/sessions.rb +38 -0
- data/vendor/camping-2.0.20090420/test/test_camping.rb +54 -0
- metadata +140 -0
data/test/picnic_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,118 @@
|
|
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
|
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 !
|
19
|
+
|
20
|
+
= 1.5
|
21
|
+
=== 3rd Oct, 2006
|
22
|
+
|
23
|
+
* Camping::Apps stores an array of classes for all loaded apps.
|
24
|
+
* bin/camping can be given a directory. Like: <tt>camping examples/</tt>
|
25
|
+
* Console mode -- thank zimbatm. Use: camping -C yourapp.rb
|
26
|
+
* Call controllers with Camping.method_missing.
|
27
|
+
|
28
|
+
Tepee.get(:Index) #=> (Response)
|
29
|
+
Blog.post(:Delete, id) #=> (Response)
|
30
|
+
|
31
|
+
Blog.post(:Login, :input => {'username' => 'admin', 'password' => 'camping'})
|
32
|
+
#=> #<Blog::Controllers::Login @user=... >
|
33
|
+
|
34
|
+
Blog.get(:Info, :env => {:HTTP_HOST => 'wagon'})
|
35
|
+
#=> #<Blog::Controllers::Info @env={'HTTP_HOST'=>'wagon'} ...>
|
36
|
+
|
37
|
+
* Using \r\n instead of \n on output. FastCGI has these needs.
|
38
|
+
* ActiveRecord no longer required or installed.
|
39
|
+
* If you refer to Models::Base, however, ActiveRecord will be loaded with autoload. (see lib/camping/db.rb)
|
40
|
+
* new Camping::FastCGI.serve which will serve a whole directory of apps
|
41
|
+
(see http://code.whytheluckystiff.net/camping/wiki/TheCampingServer)
|
42
|
+
* ~/.campingrc can contain database connection info if you want your default to be something other than SQLite.
|
43
|
+
|
44
|
+
database:
|
45
|
+
adapter: mysql
|
46
|
+
username: camping
|
47
|
+
socket: /tmp/mysql.sock
|
48
|
+
password: NOFORESTFIRES
|
49
|
+
database: camping
|
50
|
+
|
51
|
+
* controllers are now *ordered*. uses the inherited hook to keep track of all
|
52
|
+
classes created with R. those classes are scanned, in order, when a request is
|
53
|
+
made. any other controllers are handled first. so if you plan on overriding the
|
54
|
+
urls method, be sure to subclass from R().
|
55
|
+
* Console mode will load .irbrc in the working directory, if present.
|
56
|
+
(for example, in my ~/git/balloon directory, i have this in the .irbrc:
|
57
|
+
include Balloon::Models
|
58
|
+
when camping -C balloon.rb gets run, the models all get included in main.)
|
59
|
+
* And, of course, many other bugfixes from myself and the loyal+kind zimbatm...
|
60
|
+
* Markaby updated to 0.5. (See its CHANGELOG.)
|
61
|
+
|
62
|
+
= 1.4.2
|
63
|
+
=== 18th May, 2006
|
64
|
+
|
65
|
+
* Efficient file uploads for multipart/form-data POSTs.
|
66
|
+
* Camping tool now uses Mongrel, if available. If not, sticks with WEBrick.
|
67
|
+
* Multiple apps can be loaded with the camping tool, each mounted according to their file name.
|
68
|
+
|
69
|
+
= 1.4.1
|
70
|
+
=== 3rd May, 2006
|
71
|
+
|
72
|
+
* Streaming HTTP support. If body is IO, will simply pass to the controller. Mongrel, in particular, supports this nicely.
|
73
|
+
|
74
|
+
= 1.4
|
75
|
+
=== 11th April, 2006
|
76
|
+
|
77
|
+
* Moved Camping::Controllers::Base to Camping::Base.
|
78
|
+
* Moved Camping::Controllers::R to Camping::R.
|
79
|
+
* New session library (lib/camping/session.rb).
|
80
|
+
* WEBrick handler (lib/camping/webrick.rb) and Mongrel handler (lib/camping/mongrel.rb).
|
81
|
+
* Helpers#URL, builds a complete URL for a route. Returns a URI object. This way relative links could just return self.URL.path.
|
82
|
+
* Base#initialize takes over some of Base#service's duties.
|
83
|
+
* ENV now available as @env in controllers and views.
|
84
|
+
* Beautiful multi-page docs without frames!
|
85
|
+
|
86
|
+
= 1.3
|
87
|
+
=== 28th January, 2006
|
88
|
+
|
89
|
+
* bin/camping: an application launcher.
|
90
|
+
* <tt>Camping.run(request, response)</tt> now changed to <tt>controller = Camping.run(request, env)</tt>
|
91
|
+
* This means outputting the response is the wrapper/server's job. See bin/camping, you can do a controller.to_s at the least.
|
92
|
+
* <tt>Controllers::Base.env</tt> is the new thread-safe home for <tt>ENV</tt>.
|
93
|
+
* The input hash now works more like Rails params. You can call keys
|
94
|
+
like methods or with symbols or strings.
|
95
|
+
* Queries are now parsed more like PHP/Rails, in that you can denote
|
96
|
+
structure with brackets: post[user]=_why;post[id]=2
|
97
|
+
* Auto-prefix table names, to help prevent name clash.
|
98
|
+
* Helpers.errors_for simple validation.
|
99
|
+
* Lots of empty :href and :action attributes, a bug.
|
100
|
+
* New single-page flipbook RDoc template.
|
101
|
+
|
102
|
+
= 1.2
|
103
|
+
=== 23rd January, 2006
|
104
|
+
|
105
|
+
* Camping.goes allows fresh modules build from all Camping parts.
|
106
|
+
* File uploads now supported (multipart/form-data).
|
107
|
+
* Helpers.R can rebuild routes.
|
108
|
+
* Helpers./ for tracing paths from the root.
|
109
|
+
|
110
|
+
= 1.1
|
111
|
+
=== 19th January, 2006
|
112
|
+
|
113
|
+
* Allowed request and response streams to be passed in, to allow WEBrick and FastCGI support.
|
114
|
+
|
115
|
+
= 1.0
|
116
|
+
=== 17th January, 2006
|
117
|
+
|
118
|
+
* Initial checkin, see announcement at http://redhanded.hobix.com/bits/campingAMicroframework.html.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2006 why the lucky stiff
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,82 @@
|
|
1
|
+
== Camping, a Microframework
|
2
|
+
|
3
|
+
Camping is a web framework which consistently stays at less than 3kb of code.
|
4
|
+
You can probably view the complete source code on a single page. But, you
|
5
|
+
know, it's so small that, if you think about it, what can it really do?
|
6
|
+
|
7
|
+
The idea here is to store a complete fledgling web application in a single
|
8
|
+
file like many small CGIs. But to organize it as a Model-View-Controller
|
9
|
+
application like Rails does. You can then easily move it to Rails once you've
|
10
|
+
got it going.
|
11
|
+
|
12
|
+
== A Camping Skeleton
|
13
|
+
|
14
|
+
A skeletal Camping blog could look like this:
|
15
|
+
|
16
|
+
require 'camping'
|
17
|
+
|
18
|
+
Camping.goes :Blog
|
19
|
+
|
20
|
+
module Blog::Models
|
21
|
+
class Post < Base; belongs_to :user; end
|
22
|
+
class Comment < Base; belongs_to :user; end
|
23
|
+
class User < Base; end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Blog::Controllers
|
27
|
+
class Index < R '/'
|
28
|
+
def get
|
29
|
+
@posts = Post.find :all
|
30
|
+
render :index
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module Blog::Views
|
36
|
+
def layout
|
37
|
+
html do
|
38
|
+
body do
|
39
|
+
self << yield
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def index
|
45
|
+
for post in @posts
|
46
|
+
h1 post.title
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
== Installation
|
52
|
+
|
53
|
+
Interested yet? Luckily it's quite easy to install Camping. We'll be using a tool called RubyGems, so if you don't have that installed yet, go grab it! Once that's sorted out, open up a Terminal or Command Line and enter:
|
54
|
+
|
55
|
+
* <tt>gem install camping</tt>
|
56
|
+
|
57
|
+
Or for the bleeding edge:
|
58
|
+
|
59
|
+
* <tt>gem install camping --source http://gems.judofyr.net</tt>
|
60
|
+
|
61
|
+
This will download everything you need and get you all set up. If you're installing camping manually, you'll need to make sure you have 'rack' installed as well, the interface Camping uses to talk to your web server. You'll also need 'markaby' for the views, and 'activerecord' if you're going to be using databases.
|
62
|
+
|
63
|
+
== Learning
|
64
|
+
|
65
|
+
* Start by reading the documentation in {the Camping module}[link:classes/Camping.html]
|
66
|
+
- it should get you started pretty quick.
|
67
|
+
* {The wiki}[http://wiki.github.com/why/camping] is the place for all tiny,
|
68
|
+
useful tricks that we've collected over the years. Don't be afraid to
|
69
|
+
share your own discoveries; the more, the better!
|
70
|
+
* Still wondering? Subscribe to {the mailing list}[http://rubyforge.org/mailman/listinfo/camping-list].
|
71
|
+
This is where it's all happening! Don't worry, though, the volume is just
|
72
|
+
as micro as Camping itself.
|
73
|
+
|
74
|
+
== Authors
|
75
|
+
|
76
|
+
Camping was originally started by{why the lucky stiff}[http://en.wikipedia.org/wiki/Why_the_lucky_stiff],
|
77
|
+
but is now maintained by the _community_. This simply means that if we like your
|
78
|
+
patch, it will be applied. Everything is managed through {the mailing list}[http://rubyforge.org/mailman/listinfo/camping-list],
|
79
|
+
so just subscribe and you'll become a contributor too. Remember: writing the
|
80
|
+
code is just half the job, without some serious thinking from you we won't get
|
81
|
+
any further.
|
82
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'fileutils'
|
7
|
+
begin
|
8
|
+
gem 'rdoc', '~> 2.2.0'
|
9
|
+
require 'rdoc'
|
10
|
+
$:.unshift 'extras'
|
11
|
+
rescue Gem::LoadError
|
12
|
+
puts "RDoc 2.2 required to build docs"
|
13
|
+
puts "Please run `gem install rdoc --version 2.2`"
|
14
|
+
end
|
15
|
+
include FileUtils
|
16
|
+
|
17
|
+
NAME = "camping"
|
18
|
+
REV = (`#{ENV['GIT'] || "git"} rev-list HEAD`.split.length + 1).to_s rescue nil
|
19
|
+
VERS = ENV['VERSION'] || ("1.9" + (REV ? ".#{REV}" : ""))
|
20
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
|
21
|
+
RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation",
|
22
|
+
"--opname", "index.html",
|
23
|
+
"--line-numbers",
|
24
|
+
"--main", "README",
|
25
|
+
"--inline-source"]
|
26
|
+
|
27
|
+
desc "Packages up Camping."
|
28
|
+
task :default => [:check]
|
29
|
+
task :package => [:clean]
|
30
|
+
|
31
|
+
task :doc => [:before_doc, :rdoc, :after_doc]
|
32
|
+
|
33
|
+
task :before_doc do
|
34
|
+
mv "lib/camping.rb", "lib/camping-mural.rb"
|
35
|
+
mv "lib/camping-unabridged.rb", "lib/camping.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
40
|
+
rdoc.options += RDOC_OPTS
|
41
|
+
rdoc.template = "flipbook"
|
42
|
+
rdoc.main = "README"
|
43
|
+
rdoc.title = "Camping, the Documentation"
|
44
|
+
rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/camping.rb', 'lib/camping/*.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
task :after_doc do
|
48
|
+
mv "lib/camping.rb", "lib/camping-unabridged.rb"
|
49
|
+
mv "lib/camping-mural.rb", "lib/camping.rb"
|
50
|
+
cp "extras/Camping.gif", "doc/rdoc/"
|
51
|
+
cp "extras/permalink.gif", "doc/rdoc/"
|
52
|
+
end
|
53
|
+
|
54
|
+
spec =
|
55
|
+
Gem::Specification.new do |s|
|
56
|
+
s.name = NAME
|
57
|
+
s.version = VERS
|
58
|
+
s.platform = Gem::Platform::RUBY
|
59
|
+
s.has_rdoc = true
|
60
|
+
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
61
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)\/', '--exclude', 'lib/camping.rb']
|
62
|
+
s.summary = "minature rails for stay-at-home moms"
|
63
|
+
s.description = s.summary
|
64
|
+
s.author = "why the lucky stiff"
|
65
|
+
s.email = 'why@ruby-lang.org'
|
66
|
+
s.homepage = 'http://code.whytheluckystiff.net/camping/'
|
67
|
+
s.executables = ['camping']
|
68
|
+
|
69
|
+
s.add_dependency('markaby', '>=0.5')
|
70
|
+
s.add_dependency('rack', '>=0.3')
|
71
|
+
s.required_ruby_version = '>= 1.8.2'
|
72
|
+
|
73
|
+
s.files = %w(COPYING README Rakefile) +
|
74
|
+
Dir.glob("{bin,doc,test,lib,extras}/**/*") +
|
75
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
76
|
+
Dir.glob("examples/**/*.rb") +
|
77
|
+
Dir.glob("tools/*.rb")
|
78
|
+
|
79
|
+
s.require_path = "lib"
|
80
|
+
# s.extensions = FileList["ext/**/extconf.rb"].to_a
|
81
|
+
s.bindir = "bin"
|
82
|
+
end
|
83
|
+
|
84
|
+
omni =
|
85
|
+
Gem::Specification.new do |s|
|
86
|
+
s.name = "camping-omnibus"
|
87
|
+
s.version = VERS
|
88
|
+
s.platform = Gem::Platform::RUBY
|
89
|
+
s.summary = "the camping meta-package for updating ActiveRecord, Mongrel and SQLite3 bindings"
|
90
|
+
s.description = s.summary
|
91
|
+
%w[author email homepage].each { |x| s.__send__("#{x}=", spec.__send__(x)) }
|
92
|
+
|
93
|
+
s.add_dependency('camping', "=#{VERS}")
|
94
|
+
s.add_dependency('activerecord')
|
95
|
+
s.add_dependency('sqlite3-ruby', '>=1.1.0.1')
|
96
|
+
s.add_dependency('mongrel')
|
97
|
+
s.add_dependency('acts_as_versioned')
|
98
|
+
s.add_dependency('RedCloth')
|
99
|
+
end
|
100
|
+
|
101
|
+
Rake::GemPackageTask.new(spec) do |p|
|
102
|
+
p.need_tar = true
|
103
|
+
p.gem_spec = spec
|
104
|
+
end
|
105
|
+
|
106
|
+
Rake::GemPackageTask.new(omni) do |p|
|
107
|
+
p.gem_spec = omni
|
108
|
+
end
|
109
|
+
|
110
|
+
task :install do
|
111
|
+
sh %{rake package}
|
112
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
113
|
+
end
|
114
|
+
|
115
|
+
task :uninstall => [:clean] do
|
116
|
+
sh %{sudo gem uninstall #{NAME}}
|
117
|
+
end
|
118
|
+
|
119
|
+
Rake::TestTask.new(:test) do |t|
|
120
|
+
t.test_files = FileList['test/test_*.rb']
|
121
|
+
# t.warning = true
|
122
|
+
# t.verbose = true
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "Compare camping and camping-unabridged parse trees"
|
126
|
+
task :diff do
|
127
|
+
if `which parse_tree_show`.strip.empty?
|
128
|
+
STDERR.puts "ERROR: parse_tree_show missing : `gem install ParseTree`"
|
129
|
+
exit 1
|
130
|
+
end
|
131
|
+
|
132
|
+
sh "parse_tree_show lib/camping.rb > .camping.pt"
|
133
|
+
sh "parse_tree_show lib/camping-unabridged.rb > .camping-unabridged.pt"
|
134
|
+
sh "diff -u .camping-unabridged.pt .camping.pt | less"
|
135
|
+
end
|
136
|
+
|
137
|
+
task :ruby_diff do
|
138
|
+
require 'ruby2ruby'
|
139
|
+
c = Ruby2Ruby.translate(File.read("lib/camping.rb"))
|
140
|
+
n = Ruby2Ruby.translate(File.read("lib/camping-unabridged.rb"))
|
141
|
+
|
142
|
+
File.open(".camping-unabridged.rb.rb","w"){|f|f<<c}
|
143
|
+
File.open(".camping.rb.rb","w"){|f|f<<n}
|
144
|
+
|
145
|
+
sh "diff -u .camping-unabridged.rb.rb .camping.rb.rb | less"
|
146
|
+
end
|
147
|
+
|
148
|
+
task :check => ["check:valid", "check:size", "check:lines"]
|
149
|
+
namespace :check do
|
150
|
+
|
151
|
+
desc "Check source code validity"
|
152
|
+
task :valid do
|
153
|
+
ruby "-rubygems", "-w", "lib/camping-unabridged.rb"
|
154
|
+
ruby "-rubygems", "-w", "lib/camping.rb"
|
155
|
+
end
|
156
|
+
|
157
|
+
SIZE_LIMIT = 4096
|
158
|
+
desc "Compare camping sizes to unabridged"
|
159
|
+
task :size do
|
160
|
+
FileList["lib/camping*.rb"].each do |path|
|
161
|
+
s = File.size(path)
|
162
|
+
puts "%21s : % 6d % 4d%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)]
|
163
|
+
end
|
164
|
+
if File.size("lib/camping.rb") > SIZE_LIMIT
|
165
|
+
STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
desc "Verify that line lenght doesn't exceed 80 chars for camping.rb"
|
170
|
+
task :lines do
|
171
|
+
i = 1
|
172
|
+
File.open("lib/camping.rb").each_line do |line|
|
173
|
+
if line.size > 81 # 1 added for \n
|
174
|
+
STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})"
|
175
|
+
end
|
176
|
+
i += 1
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
trap("INT") { exit }
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'stringio'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
$:.unshift File.dirname(__FILE__) + "/../lib"
|
10
|
+
require 'camping'
|
11
|
+
require 'camping/server'
|
12
|
+
|
13
|
+
conf = OpenStruct.new(:host => '0.0.0.0', :port => 3301)
|
14
|
+
|
15
|
+
# Setup paths
|
16
|
+
if home = ENV['HOME'] # POSIX
|
17
|
+
db_path = File.join(home, '.camping.db')
|
18
|
+
rc_path = File.join(home, '.campingrc')
|
19
|
+
elsif home = ENV['APPDATA'] # MSWIN
|
20
|
+
db_path = File.join(home, 'Camping.db')
|
21
|
+
rc_path = File.join(home, 'Campingrc')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parse options
|
25
|
+
opts = OptionParser.new do |opts|
|
26
|
+
opts.banner = "Usage: camping app1.rb, app2.rb..."
|
27
|
+
opts.define_head "#{File.basename($0)}, the microframework ON-button for ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
28
|
+
opts.separator ""
|
29
|
+
opts.separator "Specific options:"
|
30
|
+
|
31
|
+
opts.on("-h", "--host HOSTNAME", "Host for web server to bind to (default is all IPs)") { |conf.host| }
|
32
|
+
opts.on("-p", "--port NUM", "Port for web server (defaults to #{conf.port})") { |conf.port| }
|
33
|
+
opts.on("-d", "--database FILE", "SQLite3 database path (defaults to #{db_path ? db_path : '<none>'})") { |db_path| conf.database = {:adapter => 'sqlite3', :database => db_path} }
|
34
|
+
opts.on("-C", "--console", "Run in console mode with IRB") { conf.server = "console" }
|
35
|
+
server_list = ["mongrel", "webrick", "console"]
|
36
|
+
opts.on("-s", "--server NAME", server_list, "Server to force (#{server_list.join(', ')})") { |conf.server| }
|
37
|
+
|
38
|
+
opts.separator ""
|
39
|
+
opts.separator "Common options:"
|
40
|
+
|
41
|
+
# No argument, shows at tail. This will print an options summary.
|
42
|
+
# Try it and see!
|
43
|
+
opts.on_tail("-?", "--help", "Show this message") do
|
44
|
+
puts opts
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
# Another typical switch to print the version.
|
49
|
+
opts.on_tail("-v", "--version", "Show version") do
|
50
|
+
puts Gem.loaded_specs['camping'].version
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
opts.parse! ARGV
|
57
|
+
rescue OptionParser::ParseError => ex
|
58
|
+
STDERR.puts "!! #{ex.message}"
|
59
|
+
puts "** use `#{File.basename($0)} --help` for more details..."
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
|
63
|
+
if ARGV.length < 1
|
64
|
+
puts opts
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
# Load configuration if any
|
69
|
+
if rc_path and File.exists?(rc_path)
|
70
|
+
YAML.load_file(rc_path).each do |k,v|
|
71
|
+
conf.send("#{k}=", v) unless conf.send(k)
|
72
|
+
end
|
73
|
+
puts "** conf file #{rc_path} loaded"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Default db
|
77
|
+
if conf.database.nil? and db_path
|
78
|
+
conf.database = { :adapter => 'sqlite3', :database => db_path }
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# get a copy of the paths to pass to the server
|
83
|
+
paths = ARGV.dup
|
84
|
+
|
85
|
+
# Check that mongrel exists
|
86
|
+
if conf.server.nil? || conf.server == "mongrel"
|
87
|
+
begin
|
88
|
+
require 'mongrel'
|
89
|
+
conf.server = "mongrel"
|
90
|
+
rescue LoadError
|
91
|
+
puts "!! could not load mongrel. Falling back to webrick."
|
92
|
+
conf.server = "webrick"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
server = Camping::Server.new(conf, paths)
|
97
|
+
server.start
|
Binary file
|