public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
A series of improvements:
* Include the correct init file (allowing Merb::Config)
* Move Merb:BootLoader::LoadInit into merb-core.rb
* Include GlobalHelpers in Merb::AbstractController
* Erubis benchmark
* Inflector benchmark
* Changes to the SpecHelper to support the new Config[:framework] system
wycats (author)
Mon Jan 21 12:30:05 -0800 2008
commit  3de67f9f7040ea224d7007b918f15e0a1f6a2bad
tree    42d846f4d2eeb3e9e846e5d37f24b5a104b11c28
parent  15e92cc88c9797ee5f7d5b482850080ae803c1fd
...
1
2
 
 
 
3
...
 
1
2
3
4
5
0
@@ -1 +1,3 @@
0
-test_log
0
\ No newline at end of file
0
+test_log
0
+pkg
0
+pkg/*
0
\ No newline at end of file
...
1
2
3
4
 
5
...
1
 
 
 
2
3
0
@@ -1,5 +1,3 @@
0
 #!/usr/bin/env ruby
0
-require 'rubygems'
0
-require 'merb'
0
-
0
+require "merb-core"
0
 Merb.start
...
23
24
25
 
 
 
 
 
 
 
 
 
26
27
28
...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -23,6 +23,15 @@ module Merb
0
     
0
     def start(argv=ARGV)
0
       Merb::Config.parse_args(argv)
0
+
0
+ if Merb::Config[:init_file]
0
+ require(Merb.root / Merb::Config[:init_file])
0
+ elsif File.exists?(Merb.dir_for(:config) / "merb_init")
0
+ require(Merb.dir_for(:config) / "merb_init")
0
+ elsif File.file?(Merb.dir_for(:application))
0
+ require(Merb.dir_for(:application))
0
+ end
0
+
0
       BootLoader.run
0
       case Merb::Config[:adapter]
0
       when "mongrel"
...
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
 
50
51
52
53
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
56
57
58
 
 
 
 
 
 
59
60
61
...
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
37
38
39
 
 
 
 
 
 
 
 
 
 
40
41
42
43
44
 
 
 
 
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
81
82
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
85
86
0
@@ -37,25 +37,37 @@ module Merb
0
   
0
 end
0
 
0
-class Merb::BootLoader::LoadInit < Merb::BootLoader
0
- def self.run
0
- if Merb::Config[:init_file]
0
- require Merb.root / Merb::Config[:init_file]
0
- elsif File.exists?(Merb.root / "config" / "merb_init.rb")
0
- require Merb.root / "config" / "merb_init"
0
- elsif File.exists?(Merb.root / "merb_init.rb")
0
- require Merb.root / "merb_init"
0
- elsif File.exists?(Merb.root / "application.rb")
0
- require Merb.root / "application"
0
+class Merb::BootLoader::BuildFramework < Merb::BootLoader
0
+ class << self
0
+ def run
0
+ build_framework
0
     end
0
- if File.exists?(Merb.root / "router.rb")
0
- require Merb.root / "router"
0
- elsif File.exists?(Merb.root / "config" / "router.rb")
0
- require Merb.root / "config" / "router.rb"
0
+
0
+ # This method should be overridden in merb_init.rb before Merb.start to set up a different
0
+ # framework structure
0
+ def build_framework
0
+ unless Merb::Config[:framework]
0
+ %w[view model controller helper mailer part].each do |component|
0
+ Merb.push_path(component.to_sym, Merb.root_path("app/#{component}s"))
0
+ end
0
+ Merb.push_path(:application, Merb.root_path("app/controllers/application.rb"))
0
+ Merb.push_path(:config, Merb.root_path("config"), "*.rb")
0
+ Merb.push_path(:lib, Merb.root_path("lib"), nil)
0
+ else
0
+ Merb::Config[:framework].each do |name, path|
0
+ Merb.push_path(name, Merb.root_path(path.first), path[1])
0
+ end
0
+ end
0
     end
0
   end
0
 end
0
 
0
+class Merb::BootLoader::LoadRouter < Merb::BootLoader
0
+ def self.run
0
+ require(Merb.dir_for(:config) / "router") if File.exists?(Merb.dir_for(:config) / "router")
0
+ end
0
+end
0
+
0
 class Merb::BootLoader::Environment < Merb::BootLoader
0
   def self.run
0
     Merb.environment = Merb::Config[:environment]
0
@@ -69,25 +81,6 @@ class Merb::BootLoader::Logger < Merb::BootLoader
0
   end
0
 end
0
 
0
-class Merb::BootLoader::BuildFramework < Merb::BootLoader
0
- class << self
0
- def run
0
- build_framework
0
- end
0
-
0
- # This method should be overridden in merb_init.rb before Merb.start to set up a different
0
- # framework structure
0
- def build_framework
0
- %w[view model controller helper mailer part].each do |component|
0
- Merb.push_path(component.to_sym, Merb.root_path("app/#{component}s"))
0
- end
0
- Merb.push_path(:application, Merb.root_path("app/controllers/application.rb"))
0
- Merb.push_path(:config, Merb.root_path("config"), "*.rb")
0
- Merb.push_path(:lib, Merb.root_path("lib"), nil)
0
- end
0
- end
0
-end
0
-
0
 class Merb::BootLoader::LoadPaths < Merb::BootLoader
0
   LOADED_CLASSES = {}
0
   
...
38
39
40
41
42
43
44
45
46
47
48
49
 
 
50
51
52
...
38
39
40
 
 
 
 
41
42
43
44
45
46
47
48
49
50
0
@@ -38,15 +38,13 @@ module Merb
0
       end
0
       
0
       def setup(settings = nil)
0
- if FileTest.exist? "#{defaults[:merb_root]}/framework"
0
- $LOAD_PATH.unshift( "#{defaults[:merb_root]}/framework" )
0
- end
0
-
0
         return @configuration =
0
         if settings
0
           defaults.merge(settings)
0
         elsif File.exists?("#{defaults[:merb_root]}/config/merb.yml")
0
           defaults.merge(YAML.load_file("#{defaults[:merb_root]}/config/merb.yml"))
0
+ elsif File.exists?("#{defaults[:merb_root]}/merb.yml")
0
+ defaults.merge(YAML.load_file("#{defaults[:merb_root]}/merb.yml"))
0
         else
0
           defaults.dup
0
         end
...
62
63
64
 
65
66
67
...
116
117
118
 
119
120
121
...
62
63
64
65
66
67
68
...
117
118
119
120
121
122
123
0
@@ -62,6 +62,7 @@
0
 class Merb::AbstractController
0
   include Merb::RenderMixin
0
   include Merb::InlineTemplates
0
+ include Merb::GlobalHelpers
0
   is_hookable
0
   
0
   class_inheritable_accessor :_before_filters, :_after_filters, :_template_root, :_layout
0
@@ -116,6 +117,7 @@ class Merb::AbstractController
0
     # The controller that is being inherited from Merb::AbstractController
0
     def inherited(klass)
0
       _abstract_subclasses << klass.to_s
0
+ klass.send(:include, Object.full_const_get("#{klass}Helper") rescue nil
0
       super
0
     end
0
     
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
0
@@ -0,0 +1,60 @@
0
+template = <<-HTML
0
+ <div>
0
+ <%= hello %>
0
+ <% [1,2,3,4,5,6,7,8,9,10].each do |i| %>
0
+ <%= i %>
0
+ <% end %>
0
+ </div>
0
+ <h3>Hello</h3>
0
+ <p>My name is testie McTesterson</p>
0
+
0
+ <div>
0
+ <%= hello %>
0
+ <% [1,2,3,4,5,6,7,8,9,10].each do |i| %>
0
+ <%= i %>
0
+ <% end %>
0
+ </div>
0
+ <h3>Hello</h3>
0
+ <p>My name is testie McTesterson</p>
0
+
0
+ <div>
0
+ <%= hello %>
0
+ <% [1,2,3,4,5,6,7,8,9,10].each do |i| %>
0
+ <%= i %>
0
+ <% end %>
0
+ </div>
0
+ <h3>Hello</h3>
0
+ <p>My name is testie McTesterson</p>
0
+
0
+ <div>
0
+ <%= hello %>
0
+ <% [1,2,3,4,5,6,7,8,9,10].each do |i| %>
0
+ <%= i %>
0
+ <% end %>
0
+ </div>
0
+ <h3>Hello</h3>
0
+ <p>My name is testie McTesterson</p>
0
+
0
+ <div>
0
+ <%= hello %>
0
+ <% [1,2,3,4,5,6,7,8,9,10].each do |i| %>
0
+ <%= i %>
0
+ <% end %>
0
+ </div>
0
+ <h3>Hello</h3>
0
+ <p>My name is testie McTesterson</p>
0
+HTML
0
+
0
+module Foo
0
+end
0
+
0
+require "benchmark"
0
+require "rubygems"
0
+require "erubis"
0
+TIMES = (ARGV[0] || 100_000).to_i
0
+
0
+Benchmark.bmbm do |x|
0
+ x.report("Compiling") do
0
+ TIMES.times { ::Erubis::Eruby.new(template).def_method(Foo, "template") }
0
+ end
0
+end
0
\ No newline at end of file
...
632
633
634
635
 
636
637
638
...
657
658
659
 
660
661
 
662
663
 
664
665
 
 
666
667
 
668
669
670
...
632
633
634
 
635
636
637
638
...
657
658
659
660
661
662
663
664
665
666
667
 
668
669
670
671
672
673
674
675
0
@@ -632,7 +632,7 @@ Benchmark.bmbm do |x|
0
     TIMES.times { "wives".english_singular }
0
   end
0
   
0
- x.report("Rails wife => wives") do
0
+ x.report("Rails wives => wife") do
0
     TIMES.times { "wives".singularize }
0
   end
0
   
0
@@ -657,13 +657,18 @@ end
0
 # user system total real
0
 # English boy => boys 1.310000 0.000000 1.310000 ( 1.332678)
0
 # Rails boy => boys 2.830000 0.000000 2.830000 ( 2.846847)
0
+#
0
 # English boys => boy 1.540000 0.010000 1.550000 ( 1.576141)
0
 # Rails boy => boys 3.140000 0.010000 3.150000 ( 3.201089)
0
+#
0
 # English wife => wives 0.250000 0.010000 0.260000 ( 0.261200)
0
 # Rails wife => wives 2.150000 0.010000 2.160000 ( 2.199219)
0
+#
0
 # English wives => wife 0.250000 0.000000 0.250000 ( 0.264623)
0
-# Rails wife => wives 3.130000 0.020000 3.150000 ( 3.192153)
0
+# Rails wives => wife 3.130000 0.020000 3.150000 ( 3.192153)
0
+#
0
 # English dwarf => dwarves 1.120000 0.000000 1.120000 ( 1.159888)
0
 # Rails dwarf => dwarves 2.150000 0.010000 2.160000 ( 2.329601)
0
+#
0
 # English dwarves => dwarf 1.060000 0.010000 1.070000 ( 1.338925)
0
 # Rails dwarves => dwarf 2.900000 0.020000 2.920000 ( 2.931470)
0
\ No newline at end of file
...
4
5
6
7
 
 
 
8
9
10
...
4
5
6
 
7
8
9
10
11
12
0
@@ -4,7 +4,9 @@ require File.join(__DIR__, "..", "..", "spec_helper")
0
 require File.join(__DIR__, "controllers", "filters")
0
 require File.join(__DIR__, "controllers", "render")
0
 
0
-Merb::BootLoader::Templates.run
0
+Merb::Config[:framework] = {}
0
+
0
+Merb::BootLoader.run
0
 
0
 module Merb::Test::Behaviors
0
   def dispatch_should_make_body(klass, body, action = :index)

Comments

    No one has commented yet.