camping 2.1.532 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +72 -53
- data/Rakefile +25 -20
- data/bin/camping +1 -0
- data/book/01_introduction.md +6 -6
- data/book/02_getting_started.md +348 -267
- data/book/03_more_about_controllers.md +124 -0
- data/book/04_more_about_views.md +118 -0
- data/book/05_more_about_markaby.md +173 -0
- data/book/06_more_about_models.md +58 -0
- data/book/06_rules_of_thumb.md +143 -0
- data/book/07_philosophy.md +23 -0
- data/book/08_publishing_an_app.md +118 -0
- data/book/09_upgrade_notes.md +96 -0
- data/book/10_middleware.md +69 -0
- data/book/11_gear.md +50 -0
- data/examples/blog.rb +38 -38
- data/lib/camping/ar.rb +20 -5
- data/lib/camping/commands.rb +388 -0
- data/lib/camping/gear/filters.rb +48 -0
- data/lib/camping/gear/inspection.rb +32 -0
- data/lib/camping/gear/kuddly.rb +178 -0
- data/lib/camping/gear/nancy.rb +170 -0
- data/lib/camping/loads.rb +15 -0
- data/lib/camping/mab.rb +1 -1
- data/lib/camping/reloader.rb +22 -17
- data/lib/camping/server.rb +145 -70
- data/lib/camping/session.rb +8 -5
- data/lib/camping/template.rb +1 -2
- data/lib/camping/tools.rb +43 -0
- data/lib/camping/version.rb +6 -0
- data/lib/camping-unabridged.rb +360 -133
- data/lib/camping.rb +78 -47
- data/lib/campingtrip.md +341 -0
- data/test/app_camping_gear.rb +121 -0
- data/test/app_camping_tools.rb +1 -0
- data/test/app_config.rb +30 -0
- data/test/app_cookies.rb +1 -1
- data/test/app_file.rb +3 -3
- data/test/app_goes_meta.rb +23 -0
- data/test/app_inception.rb +39 -0
- data/test/app_markup.rb +5 -20
- data/test/app_migrations.rb +16 -0
- data/test/app_partials.rb +1 -1
- data/test/app_prefixed.rb +88 -0
- data/test/app_reloader.rb +1 -2
- data/test/app_route_generating.rb +69 -2
- data/test/app_sessions.rb +24 -2
- data/test/app_simple.rb +18 -18
- data/test/apps/migrations.rb +82 -82
- data/test/apps/misc.rb +1 -1
- data/test/gear/gear_nancy.rb +129 -0
- data/test/test_helper.rb +69 -12
- metadata +152 -92
- data/CHANGELOG +0 -145
- data/book/51_upgrading.md +0 -110
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '052823190781b546bd66ebc9b1e2a164f865d9ad458bb22d81ce44b283644765'
|
4
|
+
data.tar.gz: 4508bee443828152aaa80195e8444a69dcce31fd4d29327b1cab0fa33956d263
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8601001442164208e68d09f7d3f03f966c9a421bb4ad0e6b52358557732e785ec8ee838e3a951f07f1b6d021197bdcc5eb7b395ae8eba5f328fa589324cbad10
|
7
|
+
data.tar.gz: 061ff21f2a306316d99dfc601a3581f940bffdda253904ffbbe60a283fa43a3c7f876ddb3ef3e4d19ab96006437af9575056e52dbfa663ec262c948854d01213
|
data/README.md
CHANGED
@@ -1,96 +1,115 @@
|
|
1
|
-
|
1
|
+
![Build Status](https://github.com/camping/camping/actions/workflows/ruby.yml/badge.svg)
|
2
2
|
|
3
|
-
#Camping, a Microframework
|
3
|
+
# Camping, a Microframework
|
4
4
|
|
5
|
-
Camping is a web framework which
|
5
|
+
Camping is a micro web framework which stays as small as possible.
|
6
6
|
You can probably view the complete source code on a single page. But, you
|
7
|
-
know, it's so small that, if you think about it, what can it really do?
|
7
|
+
know, it's so small that, if you think about it, what can it really do? Apparently
|
8
|
+
it can do a lot. It's pretty swell.
|
8
9
|
|
9
10
|
The idea here is to store a complete fledgling web application in a single
|
10
11
|
file like many small CGIs. But to organize it as a Model-View-Controller
|
11
|
-
application
|
12
|
-
|
12
|
+
application. And with time, you can move your Models, Views, and Controllers into
|
13
|
+
other files as your app grows.
|
13
14
|
|
14
|
-
|
15
|
+
Camping supports multiple *apps*, capsuled code that runs together. Each app can
|
16
|
+
have independent models, routes, and controllers.
|
17
|
+
|
18
|
+
Pack your gear when you go Camping! With a simple plugin system, Camping is easily
|
19
|
+
extensible. Add all sorts of useful and silly things.
|
20
|
+
|
21
|
+
## A Camping Skeleton
|
15
22
|
|
16
23
|
A skeletal Camping blog could look like this:
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
Camping.goes :Blog
|
25
|
+
```ruby
|
26
|
+
require 'camping'
|
21
27
|
|
22
|
-
|
23
|
-
class Post < Base; belongs_to :user; end
|
24
|
-
class Comment < Base; belongs_to :user; end
|
25
|
-
class User < Base; end
|
26
|
-
end
|
28
|
+
Camping.goes :Blog
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
30
|
+
module Blog::Models
|
31
|
+
class Post < Base; belongs_to :user; end
|
32
|
+
class Comment < Base; belongs_to :user; end
|
33
|
+
class User < Base; end
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
module Blog::Controllers
|
37
|
+
class Index
|
38
|
+
def get
|
39
|
+
@posts = Post.find :all
|
40
|
+
render :index
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module Blog::Views
|
46
|
+
def layout
|
47
|
+
html do
|
48
|
+
head { title "My Blog" }
|
49
|
+
body do
|
50
|
+
h1 "My Blog"
|
51
|
+
self << yield
|
46
52
|
end
|
53
|
+
end
|
54
|
+
end
|
47
55
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
56
|
+
def index
|
57
|
+
@posts.each do |post|
|
58
|
+
h1 post.title
|
53
59
|
end
|
54
|
-
|
55
|
-
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
## Installation
|
56
65
|
|
57
66
|
Interested yet? Luckily it's quite easy to install Camping. We'll be using
|
58
67
|
a tool called RubyGems, so if you don't have that installed yet, go grab it!
|
59
68
|
Once that's sorted out, open up a Terminal or Command Line and enter:
|
60
69
|
|
61
|
-
|
70
|
+
```
|
71
|
+
gem install camping
|
72
|
+
```
|
62
73
|
|
63
|
-
Even better, install the Camping Omnibus, a full package of recommended libs
|
74
|
+
~~Even better, install the Camping Omnibus, a full package of recommended libs:~~ Camping Omnibus will return for summer vacation.
|
64
75
|
|
65
|
-
|
76
|
+
```
|
77
|
+
gem install camping-omnibus
|
78
|
+
```
|
66
79
|
|
67
80
|
If not, you should be aware of that Camping itself only depends on
|
68
|
-
[Rack](
|
69
|
-
need to install **[markaby](
|
81
|
+
[Rack](https://github.com/rack/rack), and if you're going to use the views you also
|
82
|
+
need to install **[markaby](https://github.com/markaby/markaby)**, and if you're going to use the database you need
|
70
83
|
**activerecord** as well.
|
71
84
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
85
|
+
```
|
86
|
+
gem install markaby
|
87
|
+
gem install activerecord
|
88
|
+
```
|
76
89
|
|
77
|
-
|
90
|
+
## Learning
|
91
|
+
|
92
|
+
First of all, you should read [the first chapters](/book/01_introduction.md)
|
78
93
|
of The Camping Book. It should hopefully get you started pretty quick. While
|
79
94
|
you're doing that, you should be aware of the _reference_ which contains
|
80
95
|
documentation for all the different parts of Camping.
|
81
96
|
|
82
|
-
[The wiki](
|
97
|
+
[The wiki](https://github.com/camping/camping/wiki) is the place for all tiny,
|
83
98
|
useful tricks that we've collected over the years. Don't be afraid to share
|
84
99
|
your own discoveries; the more, the better!
|
85
100
|
|
86
|
-
And if there's anything you're wondering about, don't be shy, but rather
|
101
|
+
And if there's anything you're wondering about, don't be shy, but rather
|
87
102
|
subscribe to [the mailing list](http://rubyforge.org/mailman/listinfo/camping-list)
|
88
103
|
and ask there. We also have an IRC channel over at Freenode, so if you feel
|
89
104
|
like chatting with us, you should join [#camping @ irc.freenode.net](http://java.freenode.net/?channel=camping).
|
90
105
|
|
91
|
-
##
|
106
|
+
## Running Tests
|
107
|
+
|
108
|
+
Tests should be run using bundler and rake: `bundle exec rake`.
|
109
|
+
|
110
|
+
## Authors
|
92
111
|
|
93
112
|
Camping was originally crafted by [why the lucky stiff](http://en.wikipedia.org/wiki/Why_the_lucky_stiff),
|
94
113
|
but is now maintained by the _community_. This simply means that if we like your
|
95
114
|
patch, it will be applied. Everything is managed through [the mailing list](http://rubyforge.org/mailman/listinfo/camping-list),
|
96
|
-
so just subscribe and you can instantly take
|
115
|
+
so just subscribe and you can instantly take part in shaping Camping.
|
data/Rakefile
CHANGED
@@ -44,17 +44,17 @@ else
|
|
44
44
|
require 'rdoc/generator/singledarkfish'
|
45
45
|
rdoc.options += ['-f', 'singledarkfish', *RDOC_OPTS]
|
46
46
|
rdoc.template = "flipbook"
|
47
|
-
|
47
|
+
|
48
48
|
rdoc.rdoc_dir = 'doc'
|
49
49
|
rdoc.title = "Camping, a Microframework"
|
50
50
|
rdoc.rdoc_files.add ['README', 'lib/camping-unabridged.rb', 'lib/camping/**/*.rb', 'book/*']
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
|
55
55
|
task :rubygems_docs do
|
56
56
|
require 'rubygems/doc_manager'
|
57
|
-
|
57
|
+
|
58
58
|
def spec.installation_path; '.' end
|
59
59
|
def spec.full_gem_path; '.' end
|
60
60
|
manager = Gem::DocManager.new(spec)
|
@@ -67,26 +67,29 @@ task :package => :clean
|
|
67
67
|
## Tests
|
68
68
|
Rake::TestTask.new(:test) do |t|
|
69
69
|
t.libs << "test"
|
70
|
-
t.test_files = FileList['test/app_*.rb']
|
70
|
+
t.test_files = FileList['test/app_*.rb', 'test/gear/gear_*.rb']
|
71
71
|
end
|
72
72
|
|
73
73
|
## Diff
|
74
74
|
desc "Compare camping and camping-unabridged"
|
75
75
|
task :diff do
|
76
|
-
require '
|
77
|
-
require '
|
76
|
+
require 'parser/current'
|
77
|
+
require 'unparser'
|
78
|
+
require 'pp'
|
78
79
|
u = Tempfile.new('unabridged')
|
79
80
|
m = Tempfile.new('mural')
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
|
82
|
+
usexp = Parser::CurrentRuby.parse(File.read("lib/camping-unabridged.rb"))
|
83
|
+
msexp = Parser::CurrentRuby.parse(File.read("lib/camping.rb"))
|
84
|
+
|
85
|
+
u << Unparser.unparse(usexp)
|
86
|
+
m << Unparser.unparse(msexp)
|
87
|
+
|
85
88
|
u.flush
|
86
89
|
m.flush
|
87
|
-
|
90
|
+
|
88
91
|
sh "diff -u #{u.path} #{m.path} | less"
|
89
|
-
|
92
|
+
|
90
93
|
u.delete
|
91
94
|
m.delete
|
92
95
|
end
|
@@ -107,23 +110,25 @@ namespace :check do
|
|
107
110
|
require 'ruby_parser'
|
108
111
|
u = RubyParser.new.parse(File.read("lib/camping-unabridged.rb"))
|
109
112
|
m = RubyParser.new.parse(File.read("lib/camping.rb"))
|
110
|
-
|
113
|
+
|
111
114
|
u.reject! do |sexp|
|
112
115
|
sexp.is_a?(Sexp) and sexp[1] == s(:gvar, :$LOADED_FEATURES)
|
113
116
|
end
|
114
|
-
|
117
|
+
|
115
118
|
unless u == m
|
116
119
|
STDERR.puts "camping.rb and camping-unabridged.rb are not synchronized."
|
117
120
|
error = true
|
121
|
+
else
|
122
|
+
puts "✅ synchronized....."
|
118
123
|
end
|
119
124
|
end
|
120
125
|
|
121
|
-
SIZE_LIMIT =
|
126
|
+
SIZE_LIMIT = 6144
|
122
127
|
desc "Compare camping sizes to unabridged"
|
123
128
|
task :size do
|
124
129
|
FileList["lib/camping*.rb"].each do |path|
|
125
130
|
s = File.size(path)
|
126
|
-
puts "%21s : % 6d % 4d
|
131
|
+
puts "%21s : % 6d % 4d%%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)]
|
127
132
|
end
|
128
133
|
if File.size("lib/camping.rb") > SIZE_LIMIT
|
129
134
|
STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})"
|
@@ -131,18 +136,18 @@ namespace :check do
|
|
131
136
|
end
|
132
137
|
end
|
133
138
|
|
134
|
-
desc "Verify that line
|
139
|
+
desc "Verify that line length doesn't exceed 80 (120) chars for camping.rb"
|
135
140
|
task :lines do
|
136
141
|
i = 1
|
137
142
|
File.open("lib/camping.rb").each_line do |line|
|
138
|
-
if line.size >
|
143
|
+
if line.size > 121 # 1 added for \n
|
139
144
|
error = true
|
140
145
|
STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})"
|
141
146
|
end
|
142
147
|
i += 1
|
143
148
|
end
|
144
149
|
end
|
145
|
-
|
150
|
+
|
146
151
|
task :exit do
|
147
152
|
exit 1 if error
|
148
153
|
end
|
data/bin/camping
CHANGED
data/book/01_introduction.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#Introduction
|
1
|
+
# Introduction
|
2
2
|
|
3
|
-
Camping is a small web framework, less than
|
4
|
-
the vein of
|
3
|
+
Camping is a small, micro web framework, less than 5k, a little white blood cell in
|
4
|
+
the vein of Ruby. This little book will start with a tutorial which takes
|
5
5
|
about fifteen minutes - by the end you should have a little Camping site up.
|
6
|
-
The following chapters will eventually go deeper into how
|
7
|
-
|
6
|
+
The following chapters will eventually go deeper into how Camping, HTTP and
|
7
|
+
Rack work.
|
8
8
|
|
9
9
|
("Eventually", because these chapters are not written yet. This book is
|
10
10
|
currently a very much work in progress, and we'll be very grateful if you want
|
@@ -14,6 +14,6 @@ If you at any moment need some help or have any questions or comments, we
|
|
14
14
|
highly recommend [the mailing list](http://rubyforge.org/mailman/listinfo/camping-list)
|
15
15
|
which got plenty of nice people willing to help. We also have an IRC-channel
|
16
16
|
at [#camping @ irc.freenode.net](http://java.freenode.net/?channel=camping)
|
17
|
-
if you're into that sort of
|
17
|
+
if you're into that sort of thing.
|
18
18
|
|
19
19
|
Enough talk. Ready? Let's ["get started"](02_getting_started.md).
|