camping 1.5.180 → 2.0.rc0
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 +35 -0
- data/README +43 -68
- data/Rakefile +155 -86
- data/bin/camping +64 -246
- data/book/01_introduction +19 -0
- data/book/02_getting_started +443 -0
- data/book/51_upgrading +93 -0
- data/doc/api.html +1953 -0
- data/doc/book.html +73 -0
- data/doc/book/01_introduction.html +57 -0
- data/doc/book/02_getting_started.html +573 -0
- data/doc/book/51_upgrading.html +146 -0
- data/doc/created.rid +1 -0
- data/{extras → doc/images}/Camping.gif +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/{extras → doc/images}/permalink.gif +0 -0
- data/doc/index.html +148 -0
- data/doc/js/camping.js +79 -0
- data/doc/js/jquery.js +32 -0
- data/doc/rdoc.css +117 -0
- data/examples/blog.rb +280 -181
- data/extras/images/badge.gif +0 -0
- data/extras/images/boys-life.png +0 -0
- data/extras/images/deerputer.png +0 -0
- data/extras/images/diagram.png +0 -0
- data/extras/images/hill.png +0 -0
- data/extras/images/i-wish.png +0 -0
- data/extras/images/latl.png +0 -0
- data/extras/images/little-wheels.png +0 -0
- data/extras/images/square-badge.png +0 -0
- data/extras/images/uniform.png +0 -0
- data/extras/images/whale-bounce.png +0 -0
- data/extras/rdoc/generator/singledarkfish.rb +205 -0
- data/extras/rdoc/generator/template/flipbook/images/Camping.gif +0 -0
- data/extras/rdoc/generator/template/flipbook/images/loadingAnimation.gif +0 -0
- data/extras/rdoc/generator/template/flipbook/images/permalink.gif +0 -0
- data/extras/rdoc/generator/template/flipbook/js/camping.js +79 -0
- data/extras/rdoc/generator/template/flipbook/js/jquery.js +32 -0
- data/extras/rdoc/generator/template/flipbook/page.rhtml +30 -0
- data/extras/rdoc/generator/template/flipbook/rdoc.css +117 -0
- data/extras/rdoc/generator/template/flipbook/readme.rhtml +31 -0
- data/extras/rdoc/generator/template/flipbook/reference.rhtml +71 -0
- data/extras/rdoc/generator/template/flipbook/toc.rhtml +43 -0
- data/lib/camping-unabridged.rb +420 -481
- data/lib/camping.rb +40 -55
- data/lib/camping/{db.rb → ar.rb} +5 -8
- data/lib/camping/mab.rb +26 -0
- data/lib/camping/reloader.rb +175 -147
- data/lib/camping/server.rb +178 -0
- data/lib/camping/session.rb +34 -121
- data/test/apps/env_debug.rb +65 -0
- data/test/apps/forms.rb +95 -0
- data/test/apps/forward_to_other_controller.rb +60 -0
- data/test/apps/migrations.rb +97 -0
- data/test/apps/misc.rb +86 -0
- data/test/apps/sessions.rb +38 -0
- metadata +120 -80
- data/doc/camping.1.gz +0 -0
- data/examples/campsh.rb +0 -630
- data/examples/tepee.rb +0 -242
- data/extras/flipbook_rdoc.rb +0 -491
- data/lib/camping/fastcgi.rb +0 -244
- data/lib/camping/webrick.rb +0 -65
- data/test/test_xhtml_trans.rb +0 -55
data/CHANGELOG
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
= 2.0
|
2
|
+
=== ???, 2009
|
3
|
+
* Speed-up of Camping::Mab (thanks zimbatm!)
|
4
|
+
* @state is now an alias of @env['rack.session']
|
5
|
+
* Camping.use injects a Rack middleware.
|
6
|
+
* Update Flipbook to RDoc 2.4
|
7
|
+
* Removed old examples.
|
8
|
+
* Updated examples/blog.rb
|
9
|
+
* Camping::Apps returns!
|
10
|
+
* Session-cookies now timeout naturally (thanks jenna!)
|
11
|
+
* You can now `throw :halt` to halt the response in a helper.
|
12
|
+
* Camping::H#u is gone (was an alias to merge!)
|
13
|
+
* Camping::Session now uses session-cookies. The AR-backend is gone for now.
|
14
|
+
* camping/db.rb has been renamed to camping/ar.rb.
|
15
|
+
* Camping now uses Rack internally. Every app responds to #call.
|
16
|
+
|
17
|
+
= 1.6
|
18
|
+
=== Never released
|
19
|
+
|
20
|
+
* Camping::Apps removed, it wasn't reliable.
|
21
|
+
* bin/camping server kinds splitted in various files.
|
22
|
+
* NotFound and ServerError controllers changed to methods :
|
23
|
+
|
24
|
+
r404 : called when a controller was not found
|
25
|
+
r500 : called on uncaught exception
|
26
|
+
r501 : called on undefined method
|
27
|
+
|
28
|
+
All of those can be overridden at your taste.
|
29
|
+
|
30
|
+
* Markaby no longer required. Like AR, is it autoloaded on (Mab) usage.
|
31
|
+
* Camping::H is now inheriting from Hash instead of HashWithIndifferentAccess.
|
32
|
+
* Which made possible to remove the last strict dependency : active_support
|
33
|
+
* #errors_for removed, it wasn't really used
|
34
|
+
* Bug fixes !
|
35
|
+
|
1
36
|
= 1.5
|
2
37
|
=== 3rd Oct, 2006
|
3
38
|
|
data/README
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
|
1
|
+
= Camping, a Microframework
|
2
2
|
|
3
|
-
Camping is a web framework which consistently stays at less than
|
4
|
-
You can probably view the complete source code on a single page.
|
5
|
-
it's so small that, if you think about it, what can it really do?
|
3
|
+
Camping is a web framework which consistently stays at less than 4kB 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
6
|
|
7
|
-
The idea here is to store a complete fledgling web application in a single
|
8
|
-
like many small CGIs.
|
9
|
-
like Rails does.
|
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.
|
10
11
|
|
11
12
|
== A Camping Skeleton
|
12
13
|
|
@@ -23,7 +24,7 @@ A skeletal Camping blog could look like this:
|
|
23
24
|
end
|
24
25
|
|
25
26
|
module Blog::Controllers
|
26
|
-
class Index
|
27
|
+
class Index
|
27
28
|
def get
|
28
29
|
@posts = Post.find :all
|
29
30
|
render :index
|
@@ -34,86 +35,60 @@ A skeletal Camping blog could look like this:
|
|
34
35
|
module Blog::Views
|
35
36
|
def layout
|
36
37
|
html do
|
38
|
+
head { title "My Blog" }
|
37
39
|
body do
|
40
|
+
h1 "My Blog"
|
38
41
|
self << yield
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
46
|
def index
|
44
|
-
|
47
|
+
@posts.each do |post|
|
45
48
|
h1 post.title
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
49
|
-
|
50
|
-
Some things you might have noticed:
|
51
|
-
|
52
|
-
* Camping::Models uses ActiveRecord to do its work. We love ActiveRecord!
|
53
|
-
* Camping::Controllers can be assigned URLs in the class definition. Neat?
|
54
|
-
* Camping::Views describes HTML using pure Ruby. Markup as Ruby, which we
|
55
|
-
call Markaby.
|
56
|
-
* You use Camping::goes to make a copy of the Camping framework under your
|
57
|
-
own module name (in this case: <tt>Blog</tt>.)
|
58
|
-
|
59
|
-
<b>NOTE:</b> Camping auto-prefixes table names. If your class is named
|
60
|
-
<tt>Blog::Models::Post</tt>, your table will be called <b>blog_posts</b>.
|
61
|
-
Since many Camping apps can be attached to a database at once, this helps
|
62
|
-
prevent name clash.
|
63
|
-
|
64
|
-
(If you want to see the full blog example, check out <tt>examples/blog/blog.rb</tt>
|
65
|
-
for the complete code.)
|
66
|
-
|
67
|
-
If you want to write larger applications with Camping, you are encouraged to
|
68
|
-
split the application into distinct parts which can be mounted at URLs on your
|
69
|
-
web server. You might have a blog at /blog and a wiki at /wiki. Each
|
70
|
-
self-contained. But you can certainly share layouts and models by storing them
|
71
|
-
in plain Ruby scripts.
|
72
|
-
|
73
|
-
Interested yet? Okay, okay, one step at a time.
|
74
|
-
|
52
|
+
|
75
53
|
== Installation
|
76
54
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
* <tt>gem install camping --source code.whytheluckystiff.net</tt>
|
82
|
-
|
83
|
-
You are encourage to install Camping and SQLite3, since it is a small database
|
84
|
-
which fits perfectly with our compact bylaws, works well with the examples.
|
85
|
-
|
86
|
-
* See http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for instructions.
|
55
|
+
Interested yet? Luckily it's quite easy to install Camping. We'll be using
|
56
|
+
a tool called RubyGems, so if you don't have that installed yet, go grab it!
|
57
|
+
Once that's sorted out, open up a Terminal or Command Line and enter:
|
87
58
|
|
88
|
-
|
59
|
+
gem install camping
|
89
60
|
|
90
|
-
|
91
|
-
If you run them from the commandline, you'll probably just see a pile of HTML.
|
61
|
+
Even better, install the Camping Omnibus, a full package of recommended libs:
|
92
62
|
|
93
|
-
|
63
|
+
gem install camping-omnibus --source http://gems.judofyr.net
|
94
64
|
|
95
|
-
|
96
|
-
|
65
|
+
If not, you should be aware of that Camping itself only depends on
|
66
|
+
Rack[http://rack.rubyforge.org], and if you're going to use the views you also
|
67
|
+
need to install +markaby+, and if you're going to use the database you need
|
68
|
+
+activerecord+ as well.
|
97
69
|
|
98
|
-
|
70
|
+
gem install markaby
|
71
|
+
gem install activerecord
|
72
|
+
|
73
|
+
== Learning
|
99
74
|
|
100
|
-
|
101
|
-
|
75
|
+
First of all, you should read {the first chapters}[link:book/01_introduction.html]
|
76
|
+
of The Camping Book. It should hopefully get you started pretty quick. While
|
77
|
+
you're doing that, you should be aware of the _reference_ which contains
|
78
|
+
documentation for all the different parts of Camping.
|
102
79
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
be stored in a module called <tt>Test</tt>. Case is not imporant, though. The
|
107
|
-
module can be called <tt>TeSt</tt> or any other permutation.
|
108
|
-
3. Your script's postamble (anything enclosed in <tt>if __FILE__ == $0</tt>) will be
|
109
|
-
ignored by the tool, since the tool will create an SQLite3 database at
|
110
|
-
<tt>~/.camping.db</tt>. Or, on Windows, <tt>$USER/Application Data/Camping.db</tt>.
|
111
|
-
4. If your application's module has a <tt>create</tt> method, it will be executed before
|
112
|
-
the web server starts up.
|
80
|
+
{The wiki}[http://wiki.github.com/camping/camping] is the place for all tiny,
|
81
|
+
useful tricks that we've collected over the years. Don't be afraid to share
|
82
|
+
your own discoveries; the more, the better!
|
113
83
|
|
114
|
-
|
84
|
+
And if there's anything you're wondering about, don't be shy, but rather
|
85
|
+
subscribe to {the mailing list}[http://rubyforge.org/mailman/listinfo/camping-list]
|
86
|
+
and ask there. We also have an IRC channel over at Freenode, so if you feel
|
87
|
+
like chatting with us, you should join {#camping @ irc.freenode.net}[http://java.freenode.net/?channel=camping].
|
115
88
|
|
116
|
-
|
117
|
-
with the Camping Rules of Thumb which are listed on the wiki:
|
118
|
-
http://code.whytheluckystiff.net/camping/wiki/CampingRulesOfThumb
|
89
|
+
== Authors
|
119
90
|
|
91
|
+
Camping was originally crafted by {why the lucky stiff}[http://en.wikipedia.org/wiki/Why_the_lucky_stiff],
|
92
|
+
but is now maintained by the _community_. This simply means that if we like your
|
93
|
+
patch, it will be applied. Everything is managed through {the mailing list}[http://rubyforge.org/mailman/listinfo/camping-list],
|
94
|
+
so just subscribe and you can instantly take a part in shaping Camping.
|
data/Rakefile
CHANGED
@@ -1,108 +1,119 @@
|
|
1
|
+
$:.unshift 'extras'
|
1
2
|
require 'rake'
|
2
3
|
require 'rake/clean'
|
3
4
|
require 'rake/gempackagetask'
|
4
|
-
require 'rake/rdoctask'
|
5
5
|
require 'rake/testtask'
|
6
|
-
require '
|
7
|
-
|
6
|
+
require 'tempfile'
|
7
|
+
require 'open3'
|
8
|
+
|
9
|
+
task :default => :check
|
8
10
|
|
11
|
+
## Constants
|
9
12
|
NAME = "camping"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
BRANCH = "2.0"
|
14
|
+
GIT = ENV['GIT'] || "git"
|
15
|
+
REV = `#{GIT} rev-list HEAD`.strip.split.length
|
16
|
+
VERS = ENV['VERSION'] || (REV.zero? ? BRANCH : [BRANCH, REV] * '.')
|
17
|
+
|
18
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
|
19
|
+
RDOC_OPTS = ["--line-numbers", "--quiet", "--main", "README"]
|
20
|
+
|
21
|
+
## Packaging
|
22
|
+
spec =
|
23
|
+
Gem::Specification.new do |s|
|
24
|
+
s.name = NAME
|
25
|
+
s.version = VERS
|
26
|
+
s.platform = Gem::Platform::RUBY
|
27
|
+
s.has_rdoc = true
|
28
|
+
s.extra_rdoc_files = FileList["README", "CHANGELOG", "COPYING", "book/*"].to_a
|
29
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)\/', '--exclude', 'lib/camping.rb']
|
30
|
+
s.summary = "minature rails for stay-at-home moms"
|
31
|
+
s.author = "why the lucky stiff"
|
32
|
+
s.email = 'why@ruby-lang.org'
|
33
|
+
s.homepage = 'http://camping.rubyforge.org/'
|
34
|
+
s.rubyforge_project = 'camping'
|
35
|
+
s.executables = ['camping']
|
36
|
+
|
37
|
+
s.add_dependency('rack', '>=1.0')
|
38
|
+
s.required_ruby_version = '>= 1.8.2'
|
39
|
+
|
40
|
+
s.files = %w(COPYING README Rakefile) +
|
41
|
+
Dir.glob("{bin,doc,test,lib,extras,book}/**/*") +
|
42
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
43
|
+
Dir.glob("examples/**/*.rb") +
|
44
|
+
Dir.glob("tools/*.rb")
|
45
|
+
|
46
|
+
s.require_path = "lib"
|
47
|
+
s.bindir = "bin"
|
48
|
+
end
|
29
49
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
50
|
+
omni =
|
51
|
+
Gem::Specification.new do |s|
|
52
|
+
s.name = "camping-omnibus"
|
53
|
+
s.version = VERS
|
54
|
+
s.platform = Gem::Platform::RUBY
|
55
|
+
s.summary = "the camping meta-package for updating ActiveRecord, Mongrel and SQLite3 bindings"
|
56
|
+
%w[author email homepage rubyforge_project].each { |x| s.__send__("#{x}=", spec.__send__(x)) }
|
57
|
+
|
58
|
+
s.add_dependency('camping', "=#{VERS}")
|
59
|
+
s.add_dependency('activerecord')
|
60
|
+
s.add_dependency('sqlite3-ruby', '>=1.1.0.1')
|
61
|
+
s.add_dependency('mongrel')
|
62
|
+
s.add_dependency('RedCloth')
|
63
|
+
end
|
64
|
+
|
65
|
+
## RDoc
|
66
|
+
|
67
|
+
begin
|
68
|
+
gem 'rdoc', '~> 2.4.0'
|
69
|
+
rescue LoadError
|
70
|
+
# Don't complain yet.
|
37
71
|
end
|
38
72
|
|
39
|
-
|
40
|
-
|
41
|
-
mv "lib/camping-mural.rb", "lib/camping.rb"
|
42
|
-
cp "extras/Camping.gif", "doc/rdoc/"
|
43
|
-
cp "extras/permalink.gif", "doc/rdoc/"
|
44
|
-
sh %{scp -r doc/rdoc/* #{ENV['USER']}@rubyforge.org:/var/www/gforge-projects/camping/}
|
45
|
-
end
|
73
|
+
require 'rdoc/rdoc'
|
74
|
+
require 'rake/rdoctask'
|
46
75
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
s.author = "why the lucky stiff"
|
58
|
-
s.email = 'why@ruby-lang.org'
|
59
|
-
s.homepage = 'http://code.whytheluckystiff.net/camping/'
|
60
|
-
s.executables = ['camping']
|
61
|
-
|
62
|
-
s.add_dependency('activesupport', '>=1.3.1')
|
63
|
-
s.add_dependency('markaby', '>=0.5')
|
64
|
-
s.add_dependency('metaid')
|
65
|
-
s.required_ruby_version = '>= 1.8.2'
|
66
|
-
|
67
|
-
s.files = %w(COPYING README Rakefile) +
|
68
|
-
Dir.glob("{bin,doc,test,lib,extras}/**/*") +
|
69
|
-
Dir.glob("ext/**/*.{h,c,rb}") +
|
70
|
-
Dir.glob("examples/**/*.rb") +
|
71
|
-
Dir.glob("tools/*.rb")
|
72
|
-
|
73
|
-
s.require_path = "lib"
|
74
|
-
# s.extensions = FileList["ext/**/extconf.rb"].to_a
|
75
|
-
s.bindir = "bin"
|
76
|
+
Rake::RDocTask.new(:docs) do |rdoc|
|
77
|
+
if defined?(RDoc::VERSION) && RDoc::VERSION[0,3] == "2.4"
|
78
|
+
# We have a recent version of RDoc, so let's use flipbook.
|
79
|
+
require 'rdoc/generator/singledarkfish'
|
80
|
+
rdoc.options += ['-f', 'singledarkfish', *RDOC_OPTS]
|
81
|
+
rdoc.template = "flipbook"
|
82
|
+
else
|
83
|
+
# Use whatever template is available, and give a little warning.
|
84
|
+
task :docs do
|
85
|
+
puts "** Camping needs RDoc 2.4 in order to use the Flipbook template."
|
76
86
|
end
|
87
|
+
end
|
88
|
+
|
89
|
+
rdoc.inline_source = false # --inline-source is deprecated
|
90
|
+
rdoc.rdoc_dir = 'doc'
|
91
|
+
rdoc.title = "Camping, a Microframework"
|
92
|
+
rdoc.rdoc_files.add ['README', 'lib/camping-unabridged.rb', 'lib/camping/**/*.rb', 'book/*']
|
93
|
+
end
|
94
|
+
|
95
|
+
task :rubygems_docs do
|
96
|
+
require 'rubygems/doc_manager'
|
97
|
+
|
98
|
+
def spec.installation_path; '.' end
|
99
|
+
def spec.full_gem_path; '.' end
|
100
|
+
manager = Gem::DocManager.new(spec)
|
101
|
+
manager.generate_rdoc
|
102
|
+
end
|
77
103
|
|
78
|
-
|
79
|
-
|
80
|
-
s.name = "camping-omnibus"
|
81
|
-
s.version = VERS
|
82
|
-
s.platform = Gem::Platform::RUBY
|
83
|
-
s.summary = "the camping meta-package for updating ActiveRecord, Mongrel and SQLite3 bindings"
|
84
|
-
s.description = s.summary
|
85
|
-
%w[author email homepage].each { |x| s.__send__("#{x}=", spec.__send__(x)) }
|
86
|
-
|
87
|
-
s.add_dependency('camping', "=#{VERS}")
|
88
|
-
s.add_dependency('activerecord')
|
89
|
-
s.add_dependency('sqlite3-ruby', '>=1.1.0.1')
|
90
|
-
s.add_dependency('mongrel')
|
91
|
-
s.add_dependency('acts_as_versioned')
|
92
|
-
s.add_dependency('RedCloth')
|
93
|
-
end
|
104
|
+
desc "Packages Camping."
|
105
|
+
task :package => :clean
|
94
106
|
|
95
107
|
Rake::GemPackageTask.new(spec) do |p|
|
96
|
-
|
97
|
-
|
108
|
+
p.need_tar = true
|
109
|
+
p.gem_spec = spec
|
98
110
|
end
|
99
111
|
|
100
112
|
Rake::GemPackageTask.new(omni) do |p|
|
101
|
-
|
113
|
+
p.gem_spec = omni
|
102
114
|
end
|
103
115
|
|
104
|
-
task :install do
|
105
|
-
sh %{rake package}
|
116
|
+
task :install => :package do
|
106
117
|
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
107
118
|
end
|
108
119
|
|
@@ -110,8 +121,66 @@ task :uninstall => [:clean] do
|
|
110
121
|
sh %{sudo gem uninstall #{NAME}}
|
111
122
|
end
|
112
123
|
|
124
|
+
## Tests
|
113
125
|
Rake::TestTask.new(:test) do |t|
|
114
126
|
t.test_files = FileList['test/test_*.rb']
|
115
127
|
# t.warning = true
|
116
128
|
# t.verbose = true
|
117
129
|
end
|
130
|
+
|
131
|
+
## Diff
|
132
|
+
desc "Compare camping and camping-unabridged"
|
133
|
+
task :diff do
|
134
|
+
require 'ruby2ruby'
|
135
|
+
require 'ruby_parser'
|
136
|
+
u = Tempfile.new('unabridged')
|
137
|
+
m = Tempfile.new('mural')
|
138
|
+
|
139
|
+
u << Ruby2Ruby.new.process(RubyParser.new.parse(File.read("lib/camping.rb")))
|
140
|
+
m << Ruby2Ruby.new.process(RubyParser.new.parse(File.read("lib/camping-unabridged.rb")))
|
141
|
+
|
142
|
+
sh "diff -u #{u.path} #{m.path} | less"
|
143
|
+
|
144
|
+
u.delete
|
145
|
+
m.delete
|
146
|
+
end
|
147
|
+
|
148
|
+
## Check
|
149
|
+
task :check => ["check:valid", "check:size", "check:lines"]
|
150
|
+
namespace :check do
|
151
|
+
|
152
|
+
desc "Check source code validity"
|
153
|
+
task :valid do
|
154
|
+
require 'ruby_parser'
|
155
|
+
u = RubyParser.new.parse(File.read("lib/camping-unabridged.rb"))
|
156
|
+
m = RubyParser.new.parse(File.read("lib/camping.rb"))
|
157
|
+
|
158
|
+
unless u == m
|
159
|
+
STDERR.puts "camping.rb and camping-unabridged.rb are not synchronized."
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
SIZE_LIMIT = 4096
|
164
|
+
desc "Compare camping sizes to unabridged"
|
165
|
+
task :size do
|
166
|
+
FileList["lib/camping*.rb"].each do |path|
|
167
|
+
s = File.size(path)
|
168
|
+
puts "%21s : % 6d % 4d%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)]
|
169
|
+
end
|
170
|
+
if File.size("lib/camping.rb") > SIZE_LIMIT
|
171
|
+
STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
desc "Verify that line lenght doesn't exceed 80 chars for camping.rb"
|
176
|
+
task :lines do
|
177
|
+
i = 1
|
178
|
+
File.open("lib/camping.rb").each_line do |line|
|
179
|
+
if line.size > 81 # 1 added for \n
|
180
|
+
STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})"
|
181
|
+
end
|
182
|
+
i += 1
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|