camping 1.4 → 1.4.2

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.
Binary file
Binary file
Binary file
@@ -1,6 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'webrick/httpserver'
3
- s = WEBrick::HTTPServer.new(:BindAddress => 'localhost', :Port => 3044)
4
- s.mount("/", WEBrick::HTTPServlet::CGIHandler, "charts.rb")
5
- trap( :INT ) { s.shutdown }
6
- s.start
data/examples/serve DELETED
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env ruby
2
- RAILS_CONNECTION_ADAPTERS = %w[sqlite]
3
-
4
- #
5
- # Serves all examples, mounted into Webrick.
6
- #
7
- $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
8
- require 'stringio'
9
- require 'webrick/httpserver'
10
- require 'camping/webrick'
11
-
12
- # All applications share a single database
13
- Camping::Models::Base.establish_connection :adapter => 'sqlite3', :database => 'serve.db'
14
- Camping::Models::Base.logger = Logger.new('camping.log')
15
-
16
- # Find the working applications
17
- def find_apps
18
- apps =
19
- Dir['*'].select do |d|
20
- if File.directory? "#{d}"
21
- begin
22
- load "#{d}/#{d}.rb"
23
- true
24
- rescue Exception => e
25
- puts "Camping app `#{d}' will not load: #{e.class} #{e.message}"
26
- end
27
- end
28
- end
29
- apps.map! do |app|
30
- begin
31
- klass = Object.const_get(Object.constants.grep(/^#{app}$/i)[0])
32
- klass.create if klass.respond_to? :create
33
- [app, klass]
34
- rescue Exception => e
35
- puts "Camping app `#{app}' will not load: #{e.class} #{e.message}"
36
- end
37
- end
38
- apps.compact
39
- end
40
-
41
- def index_page req, resp, apps
42
- welcome = "Welcome to the Camping Example Server"
43
- b = Markaby::Builder.new({}, {})
44
- b = b.instance_eval do
45
- html do
46
- head do
47
- title welcome
48
- style <<-END, :type => 'text/css'
49
- body {
50
- font-family: verdana, arial, sans-serif;
51
- padding: 10px 40px;
52
- margin: 0;
53
- }
54
- h1, h2, h3, h4, h5, h6 {
55
- font-family: utopia, georgia, serif;
56
- }
57
- END
58
- end
59
- body do
60
- h1 welcome
61
- p %{
62
- Good day. These are the Camping sample applications. The code
63
- for each of these applications is available in its own folder
64
- under examples. A link to the application's source code is
65
- also given next to each one.
66
- }
67
- p %{Well, click on the application's name to give a try.}
68
- ul do
69
- apps.each do |app, klass|
70
- li do
71
- h3(:style => "display: inline") { a app, :href => "/#{app}" }
72
- small { text " / " ; a "View Source", :href => "/code/#{app}" }
73
- end
74
- end
75
- end
76
- end
77
- end
78
- end
79
- resp.body = b.to_s
80
- end
81
-
82
- apps = find_apps
83
- s = WEBrick::HTTPServer.new(:BindAddress => '0.0.0.0', :Port => 3301)
84
-
85
- # Root mount displays applications mounted
86
- s.mount_proc("/") do |req, resp|
87
- index_page req, resp, apps
88
- end
89
-
90
- # Mount which handles each application
91
- apps.each do |app, klass|
92
- # Mount for view source
93
- s.mount_proc("/code/#{app}") do |req, resp|
94
- resp.header['Content-Type'] = 'text/plain'
95
- resp.body = File.read("#{app}/#{app}.rb")
96
- end
97
-
98
- s.mount("/#{app}", WEBrick::CampingHandler, klass)
99
- end
100
-
101
- # Server up
102
- trap(:INT) do
103
- s.shutdown
104
- end
105
- s.start
data/examples/serve.db DELETED
Binary file
data/examples/tepee/start DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'webrick/httpserver'
3
- s = WEBrick::HTTPServer.new(:BindAddress => '0.0.0.0', :Port => 3000)
4
- s.mount("/", WEBrick::HTTPServlet::CGIHandler, "tepee.rb")
5
- trap( :INT ) { s.shutdown }
6
- s.start