merb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/README +68 -58
  2. data/Rakefile +7 -6
  3. data/TODO +18 -0
  4. data/bin/merb +2 -2
  5. data/doc/rdoc/classes/Hash.html +148 -0
  6. data/doc/rdoc/classes/Merb/Config.html +161 -0
  7. data/doc/rdoc/classes/Merb/Controller.html +488 -0
  8. data/doc/rdoc/classes/Merb/RouteMatcher.html +354 -0
  9. data/doc/rdoc/classes/Merb/Server.html +288 -0
  10. data/doc/rdoc/classes/Merb.html +143 -0
  11. data/doc/rdoc/classes/MerbHandler.html +404 -0
  12. data/doc/rdoc/classes/MerbHash.html +457 -0
  13. data/doc/rdoc/classes/Noroutefound.html +172 -0
  14. data/doc/rdoc/classes/Object.html +149 -0
  15. data/doc/rdoc/classes/String.html +200 -0
  16. data/doc/rdoc/classes/Symbol.html +172 -0
  17. data/doc/rdoc/created.rid +1 -0
  18. data/doc/rdoc/files/LICENSE.html +129 -0
  19. data/doc/rdoc/files/README.html +330 -0
  20. data/doc/rdoc/files/TODO.html +154 -0
  21. data/doc/rdoc/files/lib/merb/merb_controller_rb.html +101 -0
  22. data/doc/rdoc/files/lib/merb/merb_daemon_rb.html +113 -0
  23. data/doc/rdoc/files/lib/merb/merb_handler_rb.html +108 -0
  24. data/doc/rdoc/files/lib/merb/merb_router_rb.html +101 -0
  25. data/doc/rdoc/files/lib/merb/merb_utils_rb.html +101 -0
  26. data/doc/rdoc/files/lib/merb/noroutefound_rb.html +101 -0
  27. data/doc/rdoc/files/lib/merb_config_rb.html +101 -0
  28. data/doc/rdoc/files/lib/merb_rb.html +112 -0
  29. data/doc/rdoc/fr_class_index.html +38 -0
  30. data/doc/rdoc/fr_file_index.html +38 -0
  31. data/doc/rdoc/fr_method_index.html +78 -0
  32. data/doc/rdoc/index.html +24 -0
  33. data/doc/rdoc/rdoc-style.css +208 -0
  34. data/examples/sample_app/{app → dist/app}/controllers/posts.rb +8 -8
  35. data/examples/sample_app/{app → dist/app}/controllers/test.rb +8 -5
  36. data/examples/sample_app/{app → dist/app}/controllers/upload.rb +13 -5
  37. data/examples/sample_app/dist/app/models/post.rb +13 -0
  38. data/examples/sample_app/dist/app/views/layout/application.rhtml +6 -0
  39. data/examples/sample_app/dist/app/views/layout/foo.rhtml +6 -0
  40. data/examples/sample_app/dist/app/views/layout/posts.rhtml +6 -0
  41. data/examples/sample_app/{app → dist/app}/views/posts/list.rhtml +1 -7
  42. data/examples/sample_app/{app → dist/app}/views/posts/new.rhtml +1 -7
  43. data/examples/sample_app/{app → dist/app}/views/posts/show.rhtml +1 -8
  44. data/examples/sample_app/dist/app/views/test/foo.rhtml +2 -0
  45. data/examples/sample_app/{app → dist/app}/views/test/hello.rhtml +1 -8
  46. data/examples/sample_app/{app → dist/app}/views/upload/start.rhtml +0 -8
  47. data/examples/sample_app/{app → dist/app}/views/upload/upload.rhtml +0 -0
  48. data/examples/sample_app/{conf → dist/conf}/merb_init.rb +5 -2
  49. data/examples/sample_app/{conf → dist/conf}/router.rb +6 -8
  50. data/examples/sample_app/test/test_helper.rb +1 -0
  51. data/examples/skeleton/dist/conf/merb_init.rb +21 -0
  52. data/examples/skeleton/dist/conf/router.rb +23 -0
  53. data/examples/skeleton/test/test_helper.rb +1 -0
  54. data/lib/merb/merb_controller.rb +54 -15
  55. data/lib/merb/merb_daemon.rb +35 -20
  56. data/lib/merb/merb_handler.rb +49 -38
  57. data/lib/merb/merb_router.rb +25 -28
  58. data/lib/merb/merb_utils.rb +98 -9
  59. data/{examples/sample_app/app/controllers → lib/merb}/noroutefound.rb +1 -1
  60. data/lib/merb.rb +4 -4
  61. data/lib/merb_config.rb +1 -1
  62. data/test/unit/route_matcher_test.rb +12 -31
  63. metadata +109 -28
  64. data/examples/sample_app/app/models/post.rb +0 -2
  65. data/examples/sample_app/app/views/test/foo.rhtml +0 -6
data/README CHANGED
@@ -1,10 +1,8 @@
1
- <html><body>
2
- <pre>
3
1
  Copyright (c) 2006 Ezra Zygmuntowicz
4
2
 
5
3
  Merb. Mongrel+Erb
6
4
 
7
- Little bitty lightweight ruby app server. FOr when you really need performance
5
+ Little bitty lightweight ruby app server. For when you really need performance
8
6
  for simple dynamic pages.
9
7
 
10
8
  **Sample APP included**
@@ -14,9 +12,9 @@ Unpack the gem and grab the sample app
14
12
  $ gem unpack merb
15
13
 
16
14
  cd merb*
17
- cd examples/smaple_app
15
+ cd examples/sample_app
18
16
 
19
- $ merb start -t
17
+ $ merb
20
18
 
21
19
  then the sample app will be running on port 4000 in the foreground.
22
20
  you can go to a few urls:
@@ -28,7 +26,7 @@ http://localhost:4000/foo/123/baz/12234345
28
26
 
29
27
  **FEATURES** 1. Mongrel handler built in that parses incoming requests
30
28
  including multipart uploads and post as well as ?query=strings. Puts the
31
- params into @params and the cookies into @cookies when it instantiates your
29
+ params into params and the cookies into cookies when it instantiates your
32
30
  controller class.
33
31
 
34
32
  2. New RouteMatcher and route compiler. Reads your route definition and compiles
@@ -36,61 +34,45 @@ a method on the fly that will match the request path against each route and do t
36
34
  right thing. So the following routes:
37
35
 
38
36
  Merb::RouteMatcher.prepare do |r|
39
- r.add '/foo/:bar/baz/:id', :class => 'Test', :method => 'foo'
40
- r.add '/hey/:there/you/:guys', :class => 'Test', :method => 'hello'
41
- r.add '/:class/:method/:id', {}
42
- r.add '/:class/:method', {}
43
- r.add '.*', {:class => 'NoRouteFound', :method => 'noroute'}
37
+ r.add '/foo/:bar/baz/:id', :controller => 'Test', :action => 'foo'
38
+ r.add '/:controller/:action/:id'
39
+ r.add '/bar/:*rest', :controller => 'Test', :action => 'glob'
44
40
  end
45
41
 
46
42
  Will be compiled and defined as a method with this lambda as the body:
47
43
 
48
44
  lambda{|path|
49
- if Regexp.new('/foo/(.+)/baz/(.+)') =~ path
45
+ case path
46
+ when Regexp.new('/foo/([^/;.,?]+)/baz/([^/;.,?]+)')
50
47
  @sections[:bar] = $1
51
48
  @sections[:id] = $2
52
- return {:class=>"Test", :method=>"foo"}.merge(@sections)
49
+ return {:controller=>"Test", :action=>"foo"}.merge(@sections)
50
+ when /\A\/([^\/;.,?]+)(?:\/?\Z|\/([^\/;.,?]+)\/?)(?:\/?\Z|\/([^\/;.,?]+)\/?)\Z/
51
+ @sections[:controller] = $1
52
+ @sections[:action] = $2 || 'index'
53
+ @sections[:id] = $3 || nil
54
+ return @sections
55
+ when Regexp.new('/bar/([^;.,?]+)')
56
+ @sections[:rest] = $1
57
+ return {:controller=>"Test", :action=>"glob"}.merge(@sections)
58
+ else
59
+ return {:controller=>'Noroutefound', :action=>'noroute'}
53
60
  end
54
-
55
- if Regexp.new('/hey/(.+)/you/(.+)') =~ path
56
- @sections[:there] = $1
57
- @sections[:guys] = $2
58
- return {:class=>"Test", :method=>"hello"}.merge(@sections)
59
- end
60
-
61
- if Regexp.new('/(.+)/(.+)/(.+)') =~ path
62
- @sections[:class] = $1
63
- @sections[:method] = $2
64
- @sections[:id] = $3
65
- return {}.merge(@sections)
66
- end
67
-
68
- if Regexp.new('/(.+)/(.+)') =~ path
69
- @sections[:class] = $1
70
- @sections[:method] = $2
71
- return {}.merge(@sections)
72
- end
73
-
74
- if Regexp.new('.*') =~ path
75
- return {:class=>"NoRouteFound", :method=>"noroute"}.merge(@sections)
76
- end
77
-
78
- return default_route
79
61
  }
80
62
 
81
63
  3. Simple controller classes with built in render method and template handling
82
- with instance vars available in the views automatically.
64
+ with instance vars available in the views automatically. Merb also supports
65
+ layouts. It will look for a layout named after your controller class first and
66
+ then fall back to application.rhtml if no layout exists named after your controller.
67
+ You can use render_no_layout or do layout :none right before you render
83
68
 
84
- class Test < Merb::Controller
85
- template_dir :test
86
69
 
87
- def hello(args)
88
- # args is a hash of the remaining templated
89
- # parameters from the url matched in routing.
90
- # @params and @cookies are avaialable here. string
70
+ class Test < Merb::Controller
71
+ def hello
72
+ # params, headers and cookies are available here. string
91
73
  # keys and not symbols just yet.
92
74
  # Assign the parameter to an instance variable
93
- @name = args[:name]
75
+ @name = params[:name]
94
76
  render
95
77
  end
96
78
  end
@@ -100,19 +82,23 @@ end
100
82
  <title>Hello, <%= @name %></title>
101
83
  </head>
102
84
  <body>
103
- <h1><%= @params.inspect %></h1>
104
- <h1><%= @cookies.inspect %></h1>
105
- <% 5.times do %>
106
- <h1>Hello, <%= @name %>!</h1>
107
- <% end %>
85
+ <%= @layout_content %>
108
86
  </body>
109
87
  </html>
110
88
 
89
+
90
+ <h1><%= params.inspect %></h1>
91
+ <h1><%= cookies.inspect %></h1>
92
+ <% 5.times do %>
93
+ <h1>Hello, <%= @name %>!</h1>
94
+ <% end %>
95
+
96
+
111
97
  4. the server. right now you add your routes in
112
98
  the appdir/conf/router.rb file. So by default it runs on port 4000
113
99
 
114
100
  $ cd /path/to/your/merb/app
115
- $ merb start
101
+ $ merb
116
102
 
117
103
  5. File uploads. This is the thing that Merb was written for. Rails doesn't allow
118
104
  multiple concurrent file uploads at once without blocking an entire rails backend
@@ -122,14 +108,38 @@ form. There is a very simple upload controller example that handles this upload.
122
108
  When a file is uploaded with Merb, it gets put in a Tempfile. So you just want to
123
109
  copy it to the right place on the filesystem.
124
110
 
125
- def upload(args)
126
- puts @params[:file].inspect
111
+ def upload
112
+ puts params[:file].inspect
127
113
 
128
- FileUtils.mv @params[:file][:tempfile].path, MERB_ROOT+"/uploads/#{@params[:file][:filename]}"
114
+ FileUtils.mv params[:file][:tempfile].path, MERB_ROOT+"/uploads/#{params[:file][:filename]}"
129
115
 
130
116
  render
131
117
  end
132
- </pre>
133
- </body>
134
- </html>
135
118
 
119
+
120
+ 6. Merb app layout. A Merb app contains everything it needs to run in production in the
121
+ MERB_ROOT/dist directory. So for deployment you only need to deploy the dist dir. This
122
+ keeps your test code and development plugins separate from your main app and lets you
123
+ not deploy them to the live server. You deal with two things with this setup, MERB_ROOT
124
+ and DIST_ROOT. MERB_ROOT is the root of the whole tree. And DISTROOT is MERB_ROOT+/dist
125
+ You will cd into MERB_ROOT to run the merb command line. ANd when you deploy live you
126
+ will put the dist dir into another empty MERB_ROOT on the production server.
127
+
128
+ skeleton_app
129
+ Rakefile
130
+ README
131
+ scripts
132
+ test
133
+ fixtures
134
+ spec
135
+ unit
136
+ plugins
137
+ dist
138
+ app
139
+ controllers
140
+ models
141
+ views
142
+ conf
143
+ lib
144
+ public
145
+ plugins
data/Rakefile CHANGED
@@ -7,11 +7,11 @@ require 'fileutils'
7
7
  include FileUtils
8
8
 
9
9
  NAME = "merb"
10
- VERS = "0.0.3"
10
+ VERS = "0.0.4"
11
11
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
12
12
  RDOC_OPTS = ['--quiet', '--title', "Merb Documentation",
13
13
  "--opname", "index.html",
14
- "--line-numbers",
14
+ "--line-numbers", 'TODO',
15
15
  "--main", "README",
16
16
  "--inline-source"]
17
17
 
@@ -26,7 +26,7 @@ Rake::RDocTask.new do |rdoc|
26
26
  rdoc.options += RDOC_OPTS
27
27
  rdoc.main = "README"
28
28
  rdoc.title = "Merb Documentation"
29
- rdoc.rdoc_files.add ['README', 'LICENSE', 'lib/*.rb']
29
+ rdoc.rdoc_files.add ['README', 'LICENSE', 'TODO', 'lib/**/*.rb']
30
30
  end
31
31
 
32
32
  spec = Gem::Specification.new do |s|
@@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
34
34
  s.version = VERS
35
35
  s.platform = Gem::Platform::RUBY
36
36
  s.has_rdoc = true
37
- s.extra_rdoc_files = ["README", "LICENSE"]
37
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
38
38
  s.rdoc_options += RDOC_OPTS +
39
39
  ['--exclude', '^(app|uploads)']
40
40
  s.summary = "Merb == Mongrel + Erb. Pocket rocket web framework."
@@ -45,9 +45,10 @@ spec = Gem::Specification.new do |s|
45
45
  s.executables = ['merb']
46
46
 
47
47
  s.add_dependency('mongrel')
48
+ s.add_dependency('erubis')
48
49
  s.required_ruby_version = '>= 1.8.4'
49
50
 
50
- s.files = %w(LICENSE README Rakefile) + Dir.glob("{app,bin,doc,test,lib,examples}/**/*")
51
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{app,bin,doc,test,lib,examples}/**/*")
51
52
 
52
53
  s.require_path = "lib"
53
54
  s.bindir = "bin"
@@ -69,7 +70,7 @@ end
69
70
 
70
71
  task :doc_rforge do
71
72
  sh %{rake doc}
72
- sh %{scp -r doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
73
+ sh %{scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
73
74
  end
74
75
 
75
76
  desc 'Run unit tests'
data/TODO ADDED
@@ -0,0 +1,18 @@
1
+ [TODO]
2
+ * Irb Console **DONE**
3
+ * Migrations
4
+ * Helpers
5
+ * config file
6
+ * merg args and params **DONE**
7
+ * session
8
+ ** AR
9
+ ** DRb
10
+ * Rails integration
11
+ * Mongoose ?
12
+ * Text backend?
13
+ * plugins support(rails plugins too?)
14
+ * Layouts
15
+ * auto template_dir
16
+ * before/after filters
17
+ * merbjs
18
+ * testing
data/bin/merb CHANGED
@@ -3,5 +3,5 @@ require 'rubygems'
3
3
  require 'merb'
4
4
  #require 'merb_daemon'
5
5
  require 'merb_config'
6
-
7
- Merb::Server.run.join
6
+ DEBUG=true
7
+ Merb::Server.run
@@ -0,0 +1,148 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Hash</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Hash</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/merb/merb_utils_rb.html">
59
+ lib/merb/merb_utils.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+
84
+
85
+ </div>
86
+
87
+ <div id="method-list">
88
+ <h3 class="section-bar">Methods</h3>
89
+
90
+ <div class="name-list">
91
+ <a href="#M000008">with_indifferent_access</a>&nbsp;&nbsp;
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <!-- if includes -->
99
+
100
+ <div id="section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Instance methods</h3>
112
+
113
+ <div id="method-M000008" class="method-detail">
114
+ <a name="M000008"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000008" class="method-signature">
118
+ <span class="method-name">with_indifferent_access</span><span class="method-args">()</span>
119
+ </a>
120
+ </div>
121
+
122
+ <div class="method-description">
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000008-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/merb/merb_utils.rb, line 38</span>
128
+ 38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_indifferent_access</span>
129
+ 39: <span class="ruby-constant">MerbHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
130
+ 40: <span class="ruby-keyword kw">end</span>
131
+ </pre>
132
+ </div>
133
+ </div>
134
+ </div>
135
+
136
+
137
+ </div>
138
+
139
+
140
+ </div>
141
+
142
+
143
+ <div id="validator-badges">
144
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
145
+ </div>
146
+
147
+ </body>
148
+ </html>
@@ -0,0 +1,161 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Merb::Config</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Merb::Config</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/merb_config_rb.html">
59
+ lib/merb_config.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="../Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+
84
+
85
+ </div>
86
+
87
+ <div id="method-list">
88
+ <h3 class="section-bar">Methods</h3>
89
+
90
+ <div class="name-list">
91
+ <a href="#M000035">setup</a>&nbsp;&nbsp;
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <!-- if includes -->
99
+
100
+ <div id="section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Class methods</h3>
112
+
113
+ <div id="method-M000035" class="method-detail">
114
+ <a name="M000035"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000035" class="method-signature">
118
+ <span class="method-name">setup</span><span class="method-args">()</span>
119
+ </a>
120
+ </div>
121
+
122
+ <div class="method-description">
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000035-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/merb_config.rb, line 5</span>
128
+ 5: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">setup</span>
129
+ 6: <span class="ruby-identifier">defaults</span> = {
130
+ 7: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;0.0.0.0&quot;</span>,
131
+ 8: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;4000&quot;</span>,
132
+ 9: <span class="ruby-identifier">:allow_reloading</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
133
+ 10: <span class="ruby-identifier">:merb_root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
134
+ 11: }
135
+ 12:
136
+ 13: <span class="ruby-keyword kw">begin</span>
137
+ 14: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;#{defaults[:merb_root]}/dist/conf/merb.yml&quot;</span>)).<span class="ruby-identifier">result</span>))
138
+ 15: <span class="ruby-keyword kw">rescue</span>
139
+ 16: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>
140
+ 17: <span class="ruby-keyword kw">end</span>
141
+ 18:
142
+ 19: <span class="ruby-identifier">options</span>
143
+ 20: <span class="ruby-keyword kw">end</span>
144
+ </pre>
145
+ </div>
146
+ </div>
147
+ </div>
148
+
149
+
150
+ </div>
151
+
152
+
153
+ </div>
154
+
155
+
156
+ <div id="validator-badges">
157
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
158
+ </div>
159
+
160
+ </body>
161
+ </html>