camping 2.1.532 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +72 -53
  3. data/Rakefile +25 -20
  4. data/bin/camping +1 -0
  5. data/book/01_introduction.md +6 -6
  6. data/book/02_getting_started.md +348 -267
  7. data/book/03_more_about_controllers.md +124 -0
  8. data/book/04_more_about_views.md +118 -0
  9. data/book/05_more_about_markaby.md +173 -0
  10. data/book/06_more_about_models.md +58 -0
  11. data/book/06_rules_of_thumb.md +143 -0
  12. data/book/07_philosophy.md +23 -0
  13. data/book/08_publishing_an_app.md +118 -0
  14. data/book/09_upgrade_notes.md +96 -0
  15. data/book/10_middleware.md +69 -0
  16. data/book/11_gear.md +50 -0
  17. data/examples/blog.rb +38 -38
  18. data/lib/camping/ar.rb +20 -5
  19. data/lib/camping/commands.rb +388 -0
  20. data/lib/camping/gear/filters.rb +48 -0
  21. data/lib/camping/gear/inspection.rb +32 -0
  22. data/lib/camping/gear/kuddly.rb +178 -0
  23. data/lib/camping/gear/nancy.rb +170 -0
  24. data/lib/camping/loads.rb +15 -0
  25. data/lib/camping/mab.rb +1 -1
  26. data/lib/camping/reloader.rb +22 -17
  27. data/lib/camping/server.rb +145 -70
  28. data/lib/camping/session.rb +8 -5
  29. data/lib/camping/template.rb +1 -2
  30. data/lib/camping/tools.rb +43 -0
  31. data/lib/camping/version.rb +6 -0
  32. data/lib/camping-unabridged.rb +360 -133
  33. data/lib/camping.rb +78 -47
  34. data/lib/campingtrip.md +341 -0
  35. data/test/app_camping_gear.rb +121 -0
  36. data/test/app_camping_tools.rb +1 -0
  37. data/test/app_config.rb +30 -0
  38. data/test/app_cookies.rb +1 -1
  39. data/test/app_file.rb +3 -3
  40. data/test/app_goes_meta.rb +23 -0
  41. data/test/app_inception.rb +39 -0
  42. data/test/app_markup.rb +5 -20
  43. data/test/app_migrations.rb +16 -0
  44. data/test/app_partials.rb +1 -1
  45. data/test/app_prefixed.rb +88 -0
  46. data/test/app_reloader.rb +1 -2
  47. data/test/app_route_generating.rb +69 -2
  48. data/test/app_sessions.rb +24 -2
  49. data/test/app_simple.rb +18 -18
  50. data/test/apps/migrations.rb +82 -82
  51. data/test/apps/misc.rb +1 -1
  52. data/test/gear/gear_nancy.rb +129 -0
  53. data/test/test_helper.rb +69 -12
  54. metadata +152 -92
  55. data/CHANGELOG +0 -145
  56. data/book/51_upgrading.md +0 -110
@@ -0,0 +1,129 @@
1
+ require 'test_helper'
2
+ require 'camping'
3
+ require 'camping/commands'
4
+ require 'rack'
5
+
6
+ # nuke all the apps
7
+
8
+ Camping.goes :Frank
9
+ Frank.use Rack::Lint
10
+
11
+ module Frank
12
+ get "/" do
13
+ "Hello Friends"
14
+ end
15
+
16
+ get "/accounts" do
17
+ "Get Some Accounts"
18
+ end
19
+
20
+ get '/account/(\d+)' do |*a|
21
+ "Get Some Account numbered #{a.first}"
22
+ end
23
+
24
+ post "/accounts/new" do
25
+ "Try my hardest."
26
+ end
27
+
28
+ get "/home", "/about" do
29
+ "About page"
30
+ end
31
+
32
+ put "/it/all/out/there" do
33
+ "It's all out there now."
34
+ end
35
+
36
+ delete '/this/stuff/' do
37
+ "Everything will be deleted"
38
+ end
39
+
40
+ head '/get/ahead' do
41
+ "The very best you can do"
42
+ end
43
+
44
+ patch '/this/boat' do
45
+ "Row Row Row your boat"
46
+ end
47
+
48
+ link '/to/the/past' do
49
+ "Link! He come to town! come to save! The princess Zelda!"
50
+ end
51
+
52
+ unlink '/game/over' do
53
+ "start over?"
54
+ end
55
+
56
+ end
57
+
58
+ Camping.goes :Bill
59
+
60
+ module Bill::Controllers
61
+ class Friends
62
+ def get
63
+ "It looks like you have lots of friends."
64
+ end
65
+ end
66
+ end
67
+
68
+ module Frank
69
+ get '/friends', &Bill
70
+ end
71
+
72
+ class Frank::Test < TestCase
73
+
74
+ def the_app
75
+ Camping::Apps.select{|a| a.name == "Frank" }.first
76
+ end
77
+
78
+ def the_controllers
79
+ app = the_app
80
+ app::X.constants.filter { |el|
81
+ con = el.to_s
82
+ con != 'I' && con != 'Camper'
83
+ }
84
+ end
85
+
86
+ def test_number_of_controllers
87
+ controllers = the_controllers
88
+ assert (controllers.count == 12), "There are not the right number of controllers: #{controllers.count}."
89
+ end
90
+
91
+ def test_controller_names
92
+ controllers = the_controllers
93
+ assert controllers.include?(:GetIndex), "Not Found: :GetIndex. Controllers: #{controllers}."
94
+ assert controllers.include?(:GetAccounts), "Not Found: :GetAccounts. Controllers: #{controllers}."
95
+ assert controllers.include?(:GetAccountd), "Not Found: :GetAccount. Controllers: #{controllers}."
96
+ assert controllers.include?(:PostAccountsNew), "Not Found: :PostAccountsNew. Controllers: #{controllers}."
97
+ assert controllers.include?(:GetHomeAbout), "Not Found: :GetHomeAbout. Controllers: #{controllers}."
98
+ assert controllers.include?(:PutItAllOutThere), "Not Found: :PutItAllOutThere. Controllers: #{controllers}."
99
+ assert controllers.include?(:DeleteThisStuff), "Not Found: :DeleteThisStuff. Controllers: #{controllers}."
100
+
101
+ assert controllers.include?(:HeadGetAhead), "Not Found: :HeadGetAhead. Controllers: #{controllers}."
102
+ # assert controllers.include?(:OptionsAllTheOptions), "Not Found: :OptionsAllTheOptions. Controllers: #{controllers}."
103
+ assert controllers.include?(:PatchThisBoat), "Not Found: :PatchThisBoat. Controllers: #{controllers}."
104
+ assert controllers.include?(:LinkToThePast), "Not Found: :LinkToThePast. Controllers: #{controllers}."
105
+ assert controllers.include?(:UnlinkGameOver), "Not Found: :UnlinkGameOver. Controllers: #{controllers}."
106
+
107
+ end
108
+
109
+ def test_get_works_for_controllers
110
+ get '/accounts/'
111
+ assert_body "Get Some Accounts", "Body is not what we expect."
112
+ end
113
+
114
+ def test_blocks_take_arguments
115
+ get '/account/15'
116
+ assert_body "Get Some Account numbered 15", "Body is not what we expect."
117
+ end
118
+
119
+ def test_to_proc_works_for_apps
120
+ get '/friends/'
121
+ assert_body "It looks like you have lots of friends.", "Well this is a bummer. Frank is left out, and not called."
122
+ end
123
+
124
+ # TODO: Test that we are returning proper headers, that are not symbols, When Nancying.
125
+ def test_that_header_keys_aint_symbols
126
+
127
+ end
128
+
129
+ end
data/test/test_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
+ $VERBOSE = nil
2
3
 
3
4
  begin
4
5
  require 'rubygems'
@@ -13,22 +14,78 @@ end
13
14
 
14
15
  require 'minitest/autorun'
15
16
  require 'rack/test'
17
+ require "minitest/reporters"
18
+ Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)]
16
19
 
17
- class TestCase < MiniTest::Unit::TestCase
20
+
21
+ module CommandLineCommands
22
+
23
+ def move_to_tmp
24
+ @original_dir = Dir.pwd
25
+ Dir.chdir "test"
26
+ Dir.mkdir("tmp") unless Dir.exist?("tmp")
27
+ Dir.chdir "tmp"
28
+ end
29
+
30
+ def leave_tmp
31
+ Dir.chdir @original_dir
32
+ `rm -rf test/tmp` if File.exist?('test/tmp')
33
+ end
34
+
35
+ def write(file, content)
36
+ raise "cannot write nil" unless file
37
+ file = tmp_file(file)
38
+ folder = File.dirname(file)
39
+ `mkdir -p #{folder}` unless File.exist?(folder)
40
+ File.open(file, 'w') { |f| f.write content }
41
+ end
42
+
43
+ def read(file)
44
+ File.read(tmp_file(file))
45
+ end
46
+
47
+ def tmp_file(file)
48
+ "#{file}"
49
+ end
50
+
51
+ def write_config
52
+ write 'config.kdl', <<-TXT
53
+ // config.kdl
54
+ database {
55
+ default adapter="sqlite3" host="localhost" max_connections=5 timeout=5000
56
+ development
57
+ production adapter="postgres" database="kow"
58
+ }
59
+ hostname "crickets.com"
60
+ friends "_why" "judofyr" "chunky bacon"
61
+ TXT
62
+ end
63
+
64
+ def trash_config
65
+ `rm -rf config.kdl` if File.exist?('config.kdl')
66
+ end
67
+
68
+ end
69
+
70
+ class TestCase < MiniTest::Test
18
71
  include Rack::Test::Methods
19
-
72
+ include CommandLineCommands
73
+
20
74
  def self.inherited(mod)
21
75
  mod.app = Object.const_get(mod.to_s[/\w+/])
22
76
  super
23
77
  end
24
-
78
+
25
79
  class << self
26
80
  attr_accessor :app
27
81
  end
28
-
82
+
29
83
  def body() last_response.body end
30
84
  def app() self.class.app end
31
-
85
+
86
+ # adding this because sometimes the response is wonky???
87
+ def response_body() last_response.to_a end
88
+
32
89
  def assert_reverse
33
90
  begin
34
91
  yield
@@ -37,18 +94,18 @@ class TestCase < MiniTest::Unit::TestCase
37
94
  assert false, "Block didn't fail"
38
95
  end
39
96
  end
40
-
41
- def assert_body(str)
97
+
98
+ def assert_body(str, message="")
42
99
  case str
43
100
  when Regexp
44
- assert_match(str, last_response.body.strip)
101
+ assert_match(str, last_response.body.strip, message)
45
102
  else
46
- assert_equal(str.to_s, last_response.body.strip)
103
+ assert_equal(str.to_s, last_response.body.strip, message)
47
104
  end
48
105
  end
49
-
50
- def assert_status(code)
51
- assert_equal(code, last_response.status)
106
+
107
+ def assert_status(code, message="")
108
+ assert_equal(code, last_response.status, message)
52
109
  end
53
110
 
54
111
  def test_silly; end
metadata CHANGED
@@ -1,126 +1,147 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camping
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.532
5
- prerelease:
4
+ version: 3.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - why the lucky stiff
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
11
+ date: 2023-04-18 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mab
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.3
14
33
  - !ruby/object:Gem::Dependency
15
34
  name: rack
16
35
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
36
  requirements:
19
- - - ! '>='
37
+ - - "~>"
20
38
  - !ruby/object:Gem::Version
21
- version: '1.0'
39
+ version: '3.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.0.4.1
22
43
  type: :runtime
23
44
  prerelease: false
24
45
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
46
  requirements:
27
- - - ! '>='
47
+ - - "~>"
28
48
  - !ruby/object:Gem::Version
29
- version: '1.0'
49
+ version: '3.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.0.4.1
30
53
  - !ruby/object:Gem::Dependency
31
- name: mab
54
+ name: rack-session
32
55
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
56
  requirements:
35
- - - ! '>='
57
+ - - "~>"
36
58
  - !ruby/object:Gem::Version
37
- version: 0.0.3
59
+ version: '2.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.0
38
63
  type: :runtime
39
64
  prerelease: false
40
65
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
66
  requirements:
43
- - - ! '>='
67
+ - - "~>"
44
68
  - !ruby/object:Gem::Version
45
- version: 0.0.3
69
+ version: '2.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.0.0
46
73
  - !ruby/object:Gem::Dependency
47
- name: rake
74
+ name: rackup
48
75
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
76
  requirements:
51
- - - ! '>='
77
+ - - "~>"
52
78
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
79
+ version: 2.1.0
80
+ type: :runtime
55
81
  prerelease: false
56
82
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
83
  requirements:
59
- - - ! '>='
84
+ - - "~>"
60
85
  - !ruby/object:Gem::Version
61
- version: '0'
86
+ version: 2.1.0
62
87
  - !ruby/object:Gem::Dependency
63
- name: rack-test
88
+ name: kdl
64
89
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
90
  requirements:
67
- - - ! '>='
91
+ - - "~>"
68
92
  - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
93
+ version: '1.0'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.0.3
97
+ type: :runtime
71
98
  prerelease: false
72
99
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
100
  requirements:
75
- - - ! '>='
101
+ - - "~>"
76
102
  - !ruby/object:Gem::Version
77
- version: '0'
78
- description:
103
+ version: '1.0'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.0.3
107
+ - !ruby/object:Gem::Dependency
108
+ name: listen
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '3.8'
114
+ type: :runtime
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '3.8'
121
+ description:
79
122
  email: why@ruby-lang.org
80
123
  executables:
81
124
  - camping
82
125
  extensions: []
83
- extra_rdoc_files:
84
- - README.md
85
- - CHANGELOG
86
- - COPYING
87
- - book/01_introduction.md
88
- - book/02_getting_started.md
89
- - book/51_upgrading.md
126
+ extra_rdoc_files: []
90
127
  files:
91
128
  - COPYING
92
129
  - README.md
93
130
  - Rakefile
94
131
  - bin/camping
95
- - test/app_cookies.rb
96
- - test/app_file.rb
97
- - test/app_helpers.rb
98
- - test/app_inline_templates.rb
99
- - test/app_markup.rb
100
- - test/app_partials.rb
101
- - test/app_reloader.rb
102
- - test/app_route_generating.rb
103
- - test/app_sessions.rb
104
- - test/app_simple.rb
105
- - test/apps/env_debug.rb
106
- - test/apps/forms.rb
107
- - test/apps/forward_to_other_controller.rb
108
- - test/apps/migrations.rb
109
- - test/apps/misc.rb
110
- - test/apps/reloader/config.ru
111
- - test/apps/reloader/reload_me.rb
112
- - test/apps/reloader.rb
113
- - test/apps/reloader_indirect.rb
114
- - test/apps/sessions.rb
115
- - test/test_helper.rb
116
- - lib/camping/ar.rb
117
- - lib/camping/mab.rb
118
- - lib/camping/reloader.rb
119
- - lib/camping/server.rb
120
- - lib/camping/session.rb
121
- - lib/camping/template.rb
122
- - lib/camping-unabridged.rb
123
- - lib/camping.rb
132
+ - book/01_introduction.md
133
+ - book/02_getting_started.md
134
+ - book/03_more_about_controllers.md
135
+ - book/04_more_about_views.md
136
+ - book/05_more_about_markaby.md
137
+ - book/06_more_about_models.md
138
+ - book/06_rules_of_thumb.md
139
+ - book/07_philosophy.md
140
+ - book/08_publishing_an_app.md
141
+ - book/09_upgrade_notes.md
142
+ - book/10_middleware.md
143
+ - book/11_gear.md
144
+ - examples/blog.rb
124
145
  - extras/images/badge.gif
125
146
  - extras/images/boys-life.png
126
147
  - extras/images/deerputer.png
@@ -143,41 +164,80 @@ files:
143
164
  - extras/rdoc/generator/template/flipbook/readme.rhtml
144
165
  - extras/rdoc/generator/template/flipbook/reference.rhtml
145
166
  - extras/rdoc/generator/template/flipbook/toc.rhtml
146
- - book/01_introduction.md
147
- - book/02_getting_started.md
148
- - book/51_upgrading.md
149
- - examples/blog.rb
150
- - CHANGELOG
167
+ - lib/camping-unabridged.rb
168
+ - lib/camping.rb
169
+ - lib/camping/ar.rb
170
+ - lib/camping/commands.rb
171
+ - lib/camping/gear/filters.rb
172
+ - lib/camping/gear/inspection.rb
173
+ - lib/camping/gear/kuddly.rb
174
+ - lib/camping/gear/nancy.rb
175
+ - lib/camping/loads.rb
176
+ - lib/camping/mab.rb
177
+ - lib/camping/reloader.rb
178
+ - lib/camping/server.rb
179
+ - lib/camping/session.rb
180
+ - lib/camping/template.rb
181
+ - lib/camping/tools.rb
182
+ - lib/camping/version.rb
183
+ - lib/campingtrip.md
184
+ - test/app_camping_gear.rb
185
+ - test/app_camping_tools.rb
186
+ - test/app_config.rb
187
+ - test/app_cookies.rb
188
+ - test/app_file.rb
189
+ - test/app_goes_meta.rb
190
+ - test/app_helpers.rb
191
+ - test/app_inception.rb
192
+ - test/app_inline_templates.rb
193
+ - test/app_markup.rb
194
+ - test/app_migrations.rb
195
+ - test/app_partials.rb
196
+ - test/app_prefixed.rb
197
+ - test/app_reloader.rb
198
+ - test/app_route_generating.rb
199
+ - test/app_sessions.rb
200
+ - test/app_simple.rb
201
+ - test/apps/env_debug.rb
202
+ - test/apps/forms.rb
203
+ - test/apps/forward_to_other_controller.rb
204
+ - test/apps/migrations.rb
205
+ - test/apps/misc.rb
206
+ - test/apps/reloader.rb
207
+ - test/apps/reloader/config.ru
208
+ - test/apps/reloader/reload_me.rb
209
+ - test/apps/reloader_indirect.rb
210
+ - test/apps/sessions.rb
211
+ - test/gear/gear_nancy.rb
212
+ - test/test_helper.rb
151
213
  homepage: http://camping.rubyforge.org/
152
214
  licenses: []
153
- post_install_message:
215
+ metadata: {}
216
+ post_install_message:
154
217
  rdoc_options:
155
- - --line-numbers
156
- - --quiet
157
- - --main
218
+ - "--line-numbers"
219
+ - "--quiet"
220
+ - "--main"
158
221
  - README
159
- - --exclude
160
- - ^(examples|extras)\/
161
- - --exclude
222
+ - "--exclude"
223
+ - "^(examples|extras)\\/"
224
+ - "--exclude"
162
225
  - lib/camping.rb
163
226
  require_paths:
164
227
  - lib
165
228
  required_ruby_version: !ruby/object:Gem::Requirement
166
- none: false
167
229
  requirements:
168
- - - ! '>='
230
+ - - ">="
169
231
  - !ruby/object:Gem::Version
170
- version: 1.8.2
232
+ version: 3.1.2
171
233
  required_rubygems_version: !ruby/object:Gem::Requirement
172
- none: false
173
234
  requirements:
174
- - - ! '>='
235
+ - - ">="
175
236
  - !ruby/object:Gem::Version
176
237
  version: '0'
177
238
  requirements: []
178
- rubyforge_project: camping
179
- rubygems_version: 1.8.25
180
- signing_key:
181
- specification_version: 3
182
- summary: minature rails for stay-at-home moms
239
+ rubygems_version: 3.4.10
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: micro mighty websites for anyone
183
243
  test_files: []