camping 3.2.4 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -16
- data/Rakefile +33 -15
- data/book/01_introduction.md +2 -3
- data/book/02_getting_started.md +39 -77
- data/lib/camping/commands.rb +1 -1
- data/lib/camping/loader.rb +9 -6
- data/lib/camping/loads.rb +5 -5
- data/lib/camping/sequel.rb +31 -0
- data/lib/camping/server.rb +5 -1
- data/lib/camping/version.rb +1 -1
- data/lib/camping-unabridged.rb +1 -0
- data/lib/camping.rb +1 -0
- data/test/app_loader.rb +14 -1
- data/test/config_reloader.rb +3 -3
- data/test/integration/Gemfile +1 -1
- data/test/integration/Rakefile +0 -27
- data/test/integration/kindling/starty.rb +7 -0
- data/test/reload_reloader.rb +7 -10
- data/test/server/helper.rb +13 -0
- data/test/server/spec_server.rb +103 -0
- data/test/test_helper.rb +8 -24
- metadata +67 -8
- data/lib/campingtrip.md +0 -341
- /data/lib/{camping/gear → gear}/filters.rb +0 -0
- /data/lib/{camping/gear → gear}/firewatch.rb +0 -0
- /data/lib/{camping/gear → gear}/inspection.rb +0 -0
- /data/lib/{camping/gear → gear}/kuddly.rb +0 -0
- /data/lib/{camping/gear → gear}/nancy.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c98ea95a52b19b1bafad3d1c1d4a74dfa0eefe03af35aab54e646b4f772cc659
|
4
|
+
data.tar.gz: e56f1ba3b83d5881335546e8f8d3285337c327b992c5e451b9e4484854f9abdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f99eb2260eaa7df8c87dc4204f7e5818e9f3fe21a0fc871b0b7fe3b8780dae1492c654ee0c80c102abbf5d2087d2b22891d94c1c7b0c698c52cbdba91fc2791
|
7
|
+
data.tar.gz: 38c338c173435474a95cb804194c4f0a09c75acaaf971abdefb1f3fd78fc9bf8d4cdf8216275a47c9f4c204f0411be48dbb514097d227b7d294d097d5a6546a6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
![Build Status](https://github.com/camping/camping/actions/workflows/camping.yml/badge.svg) ![Build Status](https://github.com/camping/camping/actions/workflows/integration.yml/badge.svg)
|
2
2
|
|
3
|
-
# Camping, a Microframework
|
3
|
+
# ⛺️ Camping, a Microframework
|
4
4
|
|
5
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
|
@@ -72,12 +72,6 @@ Line and enter:
|
|
72
72
|
gem install camping
|
73
73
|
```
|
74
74
|
|
75
|
-
Also make certain to have Bundler installed:
|
76
|
-
|
77
|
-
```
|
78
|
-
gem install bundler
|
79
|
-
```
|
80
|
-
|
81
75
|
~~Even better, install the Camping Omnibus, a full package of recommended libs:~~ Camping Omnibus will return for summer vacation.
|
82
76
|
|
83
77
|
Now make a new directory filled with your camp essentials using the `camping new` command:
|
@@ -109,10 +103,16 @@ documentation for all the different parts of Camping.
|
|
109
103
|
useful tricks that we've collected over the years. Don't be afraid to share
|
110
104
|
your own discoveries; the more, the better!
|
111
105
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
106
|
+
We have a Discord channel over at the Ruby Punks community, so if you feel
|
107
|
+
like chatting with us, you should join [#camping](https://discord.gg/JSmPBsWgFt). Once our chattin' leads to action, we open up an issue on Github and move the conversation over there.
|
108
|
+
|
109
|
+
## Contributing
|
110
|
+
|
111
|
+
Camping is under active development, and we'd love some help!. Our current focus is bug fixes, documentation, and tests. We have a [number of issues](https://github.com/camping/camping/issues?q=is%3Aissue+is%3Aopen+label%3A%22Great+for+new+Contributors%22) open for new contributors to get crackin!
|
112
|
+
|
113
|
+
To begin contributing, [Fork Camping](https://github.com/camping/camping/fork), Then make a new branch, (`git checkout -b my_branch_name`) with your changes. When you're ready to bring all that hard work on over, open a draft PR and ping Karl to take a look, He'll help you fix any issues and help you get it inside of old Camping.
|
114
|
+
|
115
|
+
Have a suggestion? Open an issue with what you think we ought to be doing with our lives, and we'll talk about it. Don't be shy.
|
116
116
|
|
117
117
|
## Running Tests
|
118
118
|
|
@@ -120,11 +120,8 @@ Tests should be run using bundler and rake: `bundle exec rake`.
|
|
120
120
|
|
121
121
|
## Minting Releases
|
122
122
|
|
123
|
-
We use Ruby Gems to distribute versions of Camping.
|
123
|
+
We use Ruby Gems to distribute versions of Camping. When you're ready to mint a release, run: `gem build -o camping.gem`, then `gem push camping.gem`.
|
124
124
|
|
125
125
|
## Authors
|
126
126
|
|
127
|
-
Camping was originally crafted by [why the lucky stiff](http://en.wikipedia.org/wiki/Why_the_lucky_stiff),
|
128
|
-
but is now maintained by the _community_. This simply means that if we like your
|
129
|
-
patch, it will be applied. Everything is managed through [the mailing list](http://rubyforge.org/mailman/listinfo/camping-list),
|
130
|
-
so just subscribe and you can instantly take part in shaping Camping.
|
127
|
+
Camping was originally crafted by [why the lucky stiff](http://en.wikipedia.org/wiki/Why_the_lucky_stiff), but is now maintained by the _community_. This simply means that if we like your patch, it will be applied. Everything is managed through this Github repo, so just [open an issue](https://github.com/camping/camping/issues/new) and you can instantly take part in shaping Camping.
|
data/Rakefile
CHANGED
@@ -17,13 +17,14 @@ else
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
require "bundler/gem_tasks"
|
20
21
|
require 'rake'
|
21
22
|
require 'rake/clean'
|
22
23
|
require 'rake/testtask'
|
23
24
|
require 'tempfile'
|
24
25
|
require 'open3'
|
25
26
|
|
26
|
-
require File.expand_path('../constants', __FILE__)
|
27
|
+
# require File.expand_path('../constants', __FILE__)
|
27
28
|
|
28
29
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
|
29
30
|
|
@@ -75,21 +76,38 @@ desc "Packages Camping."
|
|
75
76
|
task :package => :clean
|
76
77
|
|
77
78
|
## Tests
|
78
|
-
|
79
|
-
t.libs << "test"
|
80
|
-
t.test_files = FileList['test/app_*.rb', 'test/gear/gear_*.rb']
|
81
|
-
end
|
79
|
+
namespace :test do
|
82
80
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
Rake::TestTask.new(:camping) do |t|
|
82
|
+
t.libs << "test"
|
83
|
+
t.test_files = FileList['test/app_*.rb']
|
84
|
+
end
|
85
|
+
|
86
|
+
Rake::TestTask.new(:gear) do |t|
|
87
|
+
t.libs << "test"
|
88
|
+
t.test_files = FileList['test/gear/gear_*.rb']
|
89
|
+
end
|
90
|
+
|
91
|
+
## Reloader Tests
|
92
|
+
Rake::TestTask.new(:reloader) do |t|
|
93
|
+
t.libs << "test"
|
94
|
+
t.test_files = FileList['test/reload_*.rb']
|
95
|
+
end
|
96
|
+
|
97
|
+
## Config Reloader Tests
|
98
|
+
Rake::TestTask.new(:configreloader) do |t|
|
99
|
+
t.libs << "test"
|
100
|
+
t.test_files = FileList['test/config_*.rb']
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Run Camping::Server tests"
|
104
|
+
Rake::TestTask.new("server") do |t|
|
105
|
+
t.libs << 'test/server'
|
106
|
+
t.test_files = FileList["test/server/**/spec_*.rb"]
|
107
|
+
t.warning = false
|
108
|
+
t.verbose = false
|
109
|
+
end
|
88
110
|
|
89
|
-
## Config Reloader Tests
|
90
|
-
Rake::TestTask.new(:configreloader) do |t|
|
91
|
-
t.libs << "test"
|
92
|
-
t.test_files = FileList['test/config_*.rb']
|
93
111
|
end
|
94
112
|
|
95
113
|
## Diff
|
@@ -119,7 +137,7 @@ end
|
|
119
137
|
error = false
|
120
138
|
|
121
139
|
## Check
|
122
|
-
task :check => ["test", "reloader", "configreloader", "check:valid", "check:equal", "check:size", "check:lines", "check:exit"]
|
140
|
+
task :check => ["test:camping", "test:gear", "test:reloader", "test:configreloader", "test:server", "check:valid", "check:equal", "check:size", "check:lines", "check:exit"]
|
123
141
|
namespace :check do
|
124
142
|
|
125
143
|
desc "Check source code validity"
|
data/book/01_introduction.md
CHANGED
@@ -11,9 +11,8 @@ currently a very much work in progress, and we'll be very grateful if you want
|
|
11
11
|
to help out.)
|
12
12
|
|
13
13
|
If you at any moment need some help or have any questions or comments, we
|
14
|
-
highly recommend [
|
15
|
-
|
16
|
-
at [#camping @ irc.freenode.net](http://java.freenode.net/?channel=camping)
|
14
|
+
highly recommend [opening an issue](https://github.com/camping/camping/issues/new) to ask for help. We've got plenty of nice people willing to help. We also have a Discord channel
|
15
|
+
at [rubypunks](https://discord.gg/JSmPBsWgFt)
|
17
16
|
if you're into that sort of thing.
|
18
17
|
|
19
18
|
Enough talk. Ready? Let's ["get started"](02_getting_started.md).
|
data/book/02_getting_started.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Getting Started
|
2
2
|
|
3
|
+
You'll need Ruby Gems to get camping. Install camping like so:
|
4
|
+
|
5
|
+
```bash
|
6
|
+
gem install camping
|
7
|
+
```
|
8
|
+
|
3
9
|
Start a new text file called camp.rb. Here's what you put inside:
|
4
10
|
|
5
11
|
```ruby
|
@@ -10,7 +16,7 @@ Camping.goes :Nuts
|
|
10
16
|
Save it. Then, open a command prompt in the same directory. You'll want to
|
11
17
|
run:
|
12
18
|
|
13
|
-
```
|
19
|
+
```bash
|
14
20
|
$ camping
|
15
21
|
```
|
16
22
|
|
@@ -20,8 +26,7 @@ And you should get a message which reads:
|
|
20
26
|
** Camping running on 0.0.0.0:3301.
|
21
27
|
```
|
22
28
|
|
23
|
-
This means that right now The Camping Server is running on port 3301 on your
|
24
|
-
machine. Open your browser and visit http://localhost:3301/.
|
29
|
+
This means that right now The Camping Server is running on port 3301 on your machine. Open your browser and visit http://localhost:3301/.
|
25
30
|
|
26
31
|
Your browser window should show:
|
27
32
|
|
@@ -31,29 +36,23 @@ Camping Problem!
|
|
31
36
|
/ Not found
|
32
37
|
```
|
33
38
|
|
34
|
-
No problem with that. The Camping Server is running, but it doesn't know what
|
35
|
-
to show. Let's tell them.
|
39
|
+
No problem with that. The Camping Server is running, but it doesn't know what to show. Let's tell them.
|
36
40
|
|
37
41
|
## Hello clock
|
38
42
|
|
39
|
-
So, you've got Camping installed and it's running. Keep it running. You can
|
40
|
-
edit files and The Camping Server will reload automatically. When you need to
|
41
|
-
stop the server, press Control-C.
|
43
|
+
So, you've got Camping installed and it's running. Keep it running. You can edit files and The Camping Server will reload automatically. When you need to stop the server, press **Control-C**.
|
42
44
|
|
43
45
|
Let's show something. At the bottom of camp.rb add:
|
44
46
|
|
45
47
|
```ruby
|
46
48
|
module Nuts::Controllers
|
47
49
|
class Index < R '/'
|
48
|
-
def get
|
49
|
-
Time.now.to_s
|
50
|
-
end
|
50
|
+
def get = Time.now.to_s
|
51
51
|
end
|
52
52
|
end
|
53
53
|
```
|
54
54
|
|
55
|
-
Save the file and refresh the browser window. Your browser window should show
|
56
|
-
the time, e.g.
|
55
|
+
Save the file and refresh the browser window. Your browser window should show the time, e.g.
|
57
56
|
|
58
57
|
```
|
59
58
|
Sun Jul 15 12:56:15 +0200 2007
|
@@ -61,9 +60,7 @@ Sun Jul 15 12:56:15 +0200 2007
|
|
61
60
|
|
62
61
|
## Enjoying the view
|
63
62
|
|
64
|
-
The Camping microframework allows us to separate our code using the MVC
|
65
|
-
(Model-View-Controller) design pattern. Let's add a view to our Nuts
|
66
|
-
application. Replace the <tt>module Nuts::Controllers</tt> with:
|
63
|
+
The Camping microframework allows us to separate our code using the MVC (Model-View-Controller) design pattern. Let's add a view to our Nuts application. Replace the <tt>module Nuts::Controllers</tt> with:
|
67
64
|
|
68
65
|
```ruby
|
69
66
|
module Nuts::Controllers
|
@@ -76,6 +73,8 @@ module Nuts::Controllers
|
|
76
73
|
end
|
77
74
|
```
|
78
75
|
|
76
|
+
And below it add:
|
77
|
+
|
79
78
|
```ruby
|
80
79
|
module Nuts::Views
|
81
80
|
def layout
|
@@ -87,14 +86,11 @@ module Nuts::Views
|
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
|
-
def sundial
|
91
|
-
p "The current time is: #{@time}"
|
92
|
-
end
|
89
|
+
def sundial = p "The current time is: #{@time}"
|
93
90
|
end
|
94
91
|
```
|
95
92
|
|
96
|
-
Save the file, refresh your browser window and it should show a message
|
97
|
-
like:
|
93
|
+
Save the file, refresh your browser window and it should show a message like:
|
98
94
|
|
99
95
|
```
|
100
96
|
The current time is: Sun Jul 15 13:05:41 +0200 2013
|
@@ -102,59 +98,39 @@ The current time is: Sun Jul 15 13:05:41 +0200 2013
|
|
102
98
|
|
103
99
|
And the window title reads "Nuts And GORP".
|
104
100
|
|
105
|
-
Here you can see we call <tt>render :sundial</tt> from our controller. This
|
106
|
-
does exactly what it says, and renders our <tt>sundial</tt> method. We've also
|
107
|
-
added a special method called <tt>layout</tt> which Camping will automatically
|
108
|
-
wrap our sundial output in. If you're familiar with HTML, you'll see that our
|
109
|
-
view contains what looks HTML tag names. This is Markaby, which is like
|
110
|
-
writing HTML using Ruby!
|
101
|
+
Here you can see we call <tt>render :sundial</tt> from our controller. This does exactly what it says, and renders our <tt>sundial</tt> method. We've also added a special method called <tt>layout</tt> which Camping will automatically wrap our sundial output in. If you're familiar with HTML, you'll see that our view contains what looks HTML tag names. This is Markaby, which is like writing HTML using Ruby!
|
111
102
|
|
112
|
-
Soon enough, you'll find that you can return anything from the controller, and
|
113
|
-
it will be sent to the browser. But let's keep that for later and start
|
114
|
-
investigating the routes.
|
103
|
+
Soon enough, you'll find that you can return anything from the controller, and it will be sent to the browser. But let's keep that for later and start investigating the routes.
|
115
104
|
|
116
105
|
## Routes
|
117
106
|
|
118
|
-
You probably noticed the weird <tt>R '/'</tt> syntax in the previous page.
|
119
|
-
This is an uncommon feature of Ruby that is used in our favorite
|
120
|
-
microframework, to describe the routes which the controller can be accessed
|
121
|
-
on.
|
107
|
+
You probably noticed the weird <tt>R '/'</tt> syntax in the previous page. This is an uncommon feature of Ruby that is used in our favorite microframework, to describe the routes which the controller can be accessed on.
|
122
108
|
|
123
|
-
These routes can be very powerful, but we're going to have look at the
|
124
|
-
simplest ones first.
|
109
|
+
These routes can be very powerful, but we're going to have look at the simplest ones first.
|
125
110
|
|
126
111
|
```ruby
|
127
112
|
module Nuts::Controllers
|
128
113
|
class Words < R '/welcome/to/my/site'
|
129
|
-
def get
|
130
|
-
"You got here by: /welcome/to/my/site"
|
131
|
-
end
|
114
|
+
def get = "You got here by: /welcome/to/my/site"
|
132
115
|
end
|
133
116
|
|
134
117
|
class Digits < R '/nuts/(\d+)'
|
135
|
-
def get(number)
|
136
|
-
"You got here by: /nuts/#{number}"
|
137
|
-
end
|
118
|
+
def get(number) = "You got here by: /nuts/#{number}"
|
138
119
|
end
|
139
120
|
|
140
121
|
class Segment < R '/gorp/([^/]+)'
|
141
|
-
def get(everything_else_than_a_slash)
|
142
|
-
"You got here by: /gorp/#{everything_else_than_a_slash}"
|
143
|
-
end
|
122
|
+
def get(everything_else_than_a_slash) = "You got here by: /gorp/#{everything_else_than_a_slash}"
|
144
123
|
end
|
145
124
|
|
146
125
|
class DigitsAndEverything < R '/nuts/(\d+)/([^/]+)'
|
147
|
-
def get(number, everything)
|
148
|
-
"You got here by: /nuts/#{number}/#{everything}"
|
149
|
-
end
|
126
|
+
def get(number, everything) = "You got here by: /nuts/#{number}/#{everything}"
|
150
127
|
end
|
151
128
|
end
|
152
129
|
```
|
153
130
|
|
154
|
-
Add this to `
|
131
|
+
Add this to `camp.rb` and try if you can hit all of the controllers.
|
155
132
|
|
156
|
-
Also notice how everything inside a parenthesis gets passed into the method,
|
157
|
-
and is ready at your disposal.
|
133
|
+
Also notice how everything inside a parenthesis gets passed into the method, and is ready at your disposal.
|
158
134
|
|
159
135
|
### Simpler routes
|
160
136
|
|
@@ -163,44 +139,32 @@ This just in:
|
|
163
139
|
```ruby
|
164
140
|
module Nuts::Controllers
|
165
141
|
class Index
|
166
|
-
def get
|
167
|
-
"You got here by: /"
|
168
|
-
end
|
142
|
+
def get = "You got here by: /"
|
169
143
|
end
|
170
144
|
|
171
145
|
class WelcomeToMySite
|
172
|
-
def get
|
173
|
-
"You got here by: /welcome/to/my/site"
|
174
|
-
end
|
146
|
+
def get = "You got here by: /welcome/to/my/site"
|
175
147
|
end
|
176
148
|
|
177
149
|
class NutsN
|
178
|
-
def get(number)
|
179
|
-
"You got here by: /nuts/#{number}"
|
180
|
-
end
|
150
|
+
def get(number)= "You got here by: /nuts/#{number}"
|
181
151
|
end
|
182
152
|
|
183
153
|
class GorpX
|
184
|
-
def get(everything_else_than_a_slash)
|
185
|
-
"You got here by: /gorp/#{everything_else_than_a_slash}"
|
186
|
-
end
|
154
|
+
def get(everything_else_than_a_slash) = "You got here by: /gorp/#{everything_else_than_a_slash}"
|
187
155
|
end
|
188
156
|
|
189
157
|
class NutsNX
|
190
|
-
def get(number, everything)
|
191
|
-
"You got here by: /nuts/#{number}/#{everything}"
|
192
|
-
end
|
158
|
+
def get(number, everything) = "You got here by: /nuts/#{number}/#{everything}"
|
193
159
|
end
|
194
160
|
end
|
195
161
|
```
|
196
162
|
|
197
|
-
Drop the <tt>< R</tt>-part and it
|
198
|
-
succeed, but it can simplify your application once in a while.
|
163
|
+
Drop the <tt>< R</tt>-part and it attempts to read your mind. It won't always succeed, but it can simplify your application once in a while.
|
199
164
|
|
200
165
|
## Modeling the world
|
201
166
|
|
202
|
-
You can get pretty far with what you've learned now, and hopefully you've been
|
203
|
-
playing a bit off-book, but it's time to take the next step: Storing data.
|
167
|
+
You can get pretty far with what you've learned now, and hopefully you've been playing a bit off-book, but it's time to take the next step: Storing data.
|
204
168
|
|
205
169
|
Let's start over again.
|
206
170
|
|
@@ -213,8 +177,7 @@ module Nuts::Models
|
|
213
177
|
end
|
214
178
|
```
|
215
179
|
|
216
|
-
Obviously, this won't do anything, since we don't have any controllers, but
|
217
|
-
let's rather have a look at what we _do_ have.
|
180
|
+
Obviously, this won't do anything, since we don't have any controllers, but let's rather have a look at what we _do_ have.
|
218
181
|
|
219
182
|
We have a model named Page. This means we now can store wiki pages and
|
220
183
|
retrieve them later. In fact, we can have as many models as we want. Need one
|
@@ -278,7 +241,7 @@ class AddTagColumn < V 1.1
|
|
278
241
|
end
|
279
242
|
```
|
280
243
|
|
281
|
-
Now we just need to tell Camping to use our migration. Write this at the bottom of
|
244
|
+
Now we just need to tell Camping to use our migration. Write this at the bottom of camp.rb
|
282
245
|
|
283
246
|
```ruby
|
284
247
|
def Nuts.create
|
@@ -292,7 +255,7 @@ we only want to create our skeleton (or upgrade if needed). Start The Camping
|
|
292
255
|
Server again and observe:
|
293
256
|
|
294
257
|
```bash
|
295
|
-
$ camping
|
258
|
+
$ camping camp.rb
|
296
259
|
** Starting Mongrel on 0.0.0.0:3301
|
297
260
|
-- create_table("nuts_schema_infos")
|
298
261
|
-> 0.1035s
|
@@ -315,7 +278,7 @@ is good way to familiarize with your models. Test your models adding some
|
|
315
278
|
data by bare hand before addin it to the application.
|
316
279
|
|
317
280
|
```bash
|
318
|
-
$ camping -C
|
281
|
+
$ camping -C camp.rb
|
319
282
|
** Starting console
|
320
283
|
>>
|
321
284
|
```
|
@@ -354,8 +317,7 @@ Now I have two pages: One about hiking and one about fishing.
|
|
354
317
|
|
355
318
|
## Wrapping it up
|
356
319
|
|
357
|
-
Wouldn't it be nice if we could show this wonderful our pages in a browser?
|
358
|
-
Update nuts.rb so it also contains something like this:
|
320
|
+
Wouldn't it be nice if we could show this wonderful our pages in a browser? Update camp.rb so it also contains something like this:
|
359
321
|
|
360
322
|
```ruby
|
361
323
|
module Nuts::Controllers
|
data/lib/camping/commands.rb
CHANGED
data/lib/camping/loader.rb
CHANGED
@@ -66,10 +66,10 @@ module Camping
|
|
66
66
|
|
67
67
|
# pass through methods to the Listener.
|
68
68
|
# for testing purposes.
|
69
|
-
def processing_events
|
70
|
-
def stop
|
71
|
-
def pause
|
72
|
-
def start
|
69
|
+
def processing_events? = @listener.processing?
|
70
|
+
def stop = @listener.stop
|
71
|
+
def pause = @listener.pause
|
72
|
+
def start = @listener.start
|
73
73
|
|
74
74
|
def name
|
75
75
|
@name ||= begin
|
@@ -108,9 +108,10 @@ module Camping
|
|
108
108
|
key = app.name.to_sym
|
109
109
|
hash[key] = app
|
110
110
|
|
111
|
-
apps.
|
111
|
+
if !@apps.include?(key)
|
112
112
|
@callback.call(app) if @callback
|
113
113
|
app.create if app.respond_to?(:create)
|
114
|
+
app.kindling if app.respond_to?(:kindling)
|
114
115
|
end
|
115
116
|
|
116
117
|
hash
|
@@ -188,6 +189,7 @@ module Camping
|
|
188
189
|
def setup_zeit(loader)
|
189
190
|
loader.push_dir("#{@root}/apps") if can_add_directory "#{@root}/apps"
|
190
191
|
loader.push_dir("#{@root}/lib") if can_add_directory "#{@root}/lib"
|
192
|
+
loader.ignore("#{@root}/lib/camping-unabridged.rb")
|
191
193
|
loader.enable_reloading if ENV['environment'] == 'development'
|
192
194
|
loader.setup
|
193
195
|
end
|
@@ -195,7 +197,7 @@ module Camping
|
|
195
197
|
# verifies that we can add a directory to the loader.
|
196
198
|
# used for testing to prevent multiple loaders from watching the same directory.
|
197
199
|
def can_add_directory(directory)
|
198
|
-
if Dir.exist?(
|
200
|
+
if Dir.exist?(directory)
|
199
201
|
Loaders.each do |loader|
|
200
202
|
return false if loader.dirs.include? directory
|
201
203
|
end
|
@@ -218,6 +220,7 @@ module Camping
|
|
218
220
|
def reload_directory(directory)
|
219
221
|
files, folders = folders_and_files_in(directory)
|
220
222
|
files.each {|file|
|
223
|
+
next if file.include? "unabridged"
|
221
224
|
@requires << [file, File.expand_path(file)]
|
222
225
|
load file
|
223
226
|
}
|
data/lib/camping/loads.rb
CHANGED
@@ -9,8 +9,8 @@ require 'bundler/setup'
|
|
9
9
|
# internal dependencies
|
10
10
|
require 'camping/tools'
|
11
11
|
require 'camping/campguide'
|
12
|
-
require '
|
13
|
-
require '
|
14
|
-
require '
|
15
|
-
require '
|
16
|
-
require '
|
12
|
+
require 'gear/filters'
|
13
|
+
require 'gear/nancy'
|
14
|
+
require 'gear/inspection'
|
15
|
+
require 'gear/kuddly'
|
16
|
+
require 'gear/firewatch'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class MissingLibrary < Exception #:nodoc: all
|
2
|
+
end
|
3
|
+
begin
|
4
|
+
require 'sequel'
|
5
|
+
rescue LoadError => e
|
6
|
+
raise MissingLibrary, "Sequel gem could not be loaded (is it installed?): #{e.message}"
|
7
|
+
end
|
8
|
+
|
9
|
+
$SEQUEL_EXTRAS = %{
|
10
|
+
Sequel::Model.plugin :timestamps
|
11
|
+
Base = Sequel::Model
|
12
|
+
|
13
|
+
# class SchemaInfo < Base
|
14
|
+
# end
|
15
|
+
}
|
16
|
+
|
17
|
+
module Camping
|
18
|
+
module Models
|
19
|
+
module_eval $SEQUEL_EXTRAS
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Camping::S.sub!(/autoload\s*:Base\s*,\s*['"]camping\/sequel['"]/, $SEQUEL_EXTRAS)
|
24
|
+
Camping::Apps.each do |c|
|
25
|
+
c::Models.module_eval $SEQUEL_EXTRAS.gsub('Camping', c.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
ENV['DATABASE_URL'] = 'db/camp.db' if ENV['DATABASE_URL'] == ''
|
29
|
+
|
30
|
+
# connect to a database by default
|
31
|
+
DB = Sequel.connect(ENV['DATABASE_URL'])
|
data/lib/camping/server.rb
CHANGED
@@ -3,7 +3,7 @@ require 'erb'
|
|
3
3
|
require 'rack'
|
4
4
|
require 'rackup'
|
5
5
|
require 'camping/version'
|
6
|
-
require '
|
6
|
+
require 'gear/firewatch'
|
7
7
|
require 'camping/loader'
|
8
8
|
require 'camping/commands'
|
9
9
|
|
@@ -142,6 +142,10 @@ module Camping
|
|
142
142
|
exit
|
143
143
|
end
|
144
144
|
|
145
|
+
Dir['kindling/*.rb'].each do |kindling|
|
146
|
+
require_relative File.expand_path(kindling)
|
147
|
+
end
|
148
|
+
|
145
149
|
@reloader.reload!
|
146
150
|
r = @reloader
|
147
151
|
|
data/lib/camping/version.rb
CHANGED
data/lib/camping-unabridged.rb
CHANGED
data/lib/camping.rb
CHANGED
@@ -81,6 +81,7 @@ IO.read(a.set:__FILE__,$`)=~/^__END__/&&(b=$'.split(/^@@\s*(.+?)\s*\r?\n/m)
|
|
81
81
|
a.set :_meta, H[file: fl, line_number: ln, parent: self,
|
82
82
|
root: (name != "Cam\ping" ? '/' + CampTools.to_snake(name) : '/')];C.configure(a)end end
|
83
83
|
module Views;include X,Helpers end;module Models
|
84
|
+
autoload :Base, 'camping/sequel'
|
84
85
|
Helpers.include(X,self) end;autoload:Mab,'camping/mab'
|
85
86
|
autoload:Template,'camping/template';pack Gear::Inspection;pack Gear::Filters
|
86
87
|
pack Gear::Nancy;pack Gear::Kuddly;pack Gear::Firewatch;C end
|
data/test/app_loader.rb
CHANGED
@@ -5,6 +5,11 @@ require 'camping/loader'
|
|
5
5
|
module Donuts end
|
6
6
|
module Loader end
|
7
7
|
|
8
|
+
def Loader.create
|
9
|
+
puts "creating..."
|
10
|
+
options.my_name = "slim shady"
|
11
|
+
end
|
12
|
+
|
8
13
|
# for Reloading stuff
|
9
14
|
module TestCaseLoaderToo
|
10
15
|
def loader
|
@@ -18,7 +23,7 @@ module TestCaseLoaderToo
|
|
18
23
|
end
|
19
24
|
|
20
25
|
def after_all
|
21
|
-
|
26
|
+
leave_dir
|
22
27
|
super
|
23
28
|
end
|
24
29
|
end
|
@@ -50,4 +55,12 @@ class Donuts::Test < TestCase
|
|
50
55
|
assert_equal "text/html", last_response.headers['content-type']
|
51
56
|
end
|
52
57
|
|
58
|
+
def test_create_method
|
59
|
+
# Tests that our app even has a create method
|
60
|
+
assert(Loader.respond_to?(:create), "test/app_loader.rb: Loader doesn't respond to create method")
|
61
|
+
|
62
|
+
# Test that our create method code is actually run and that It has an effect.
|
63
|
+
assert_equal("slim shady", Loader.options.my_name, "test/app_loader.rb: create method wasn't even loaded.")
|
64
|
+
end
|
65
|
+
|
53
66
|
end
|
data/test/config_reloader.rb
CHANGED
@@ -2,6 +2,9 @@ require_relative 'test_helper'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'camping/loader'
|
4
4
|
|
5
|
+
# This test file is mostly the same as reload_reloader.rb.
|
6
|
+
# Except this checks to see if a config.ru app is reloaded correctly.
|
7
|
+
|
5
8
|
$counter = 0
|
6
9
|
|
7
10
|
# for Reloading stuff
|
@@ -16,11 +19,9 @@ module TestCaseLoader
|
|
16
19
|
move_to_reloader
|
17
20
|
loader.reload!
|
18
21
|
assert Object.const_defined?(:Reloader), "Reloader didn't load app"
|
19
|
-
# puts "before_all called"
|
20
22
|
end
|
21
23
|
|
22
24
|
def after_all
|
23
|
-
# puts "after_all called"
|
24
25
|
assert Object.const_defined?(:Reloader), "Test removed app"
|
25
26
|
loader.remove_constants
|
26
27
|
# breaks in CI for some reason.
|
@@ -41,7 +42,6 @@ class TestConfigRu < TestCase
|
|
41
42
|
super
|
42
43
|
$counter = 0
|
43
44
|
loader.reload!
|
44
|
-
# puts "setup called"
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_counter
|