thorero-gen 0.9.4

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.
Files changed (152) hide show
  1. data/LICENSE +20 -0
  2. data/README +21 -0
  3. data/Rakefile +65 -0
  4. data/TODO +13 -0
  5. data/bin/merb-gen +10 -0
  6. data/lib/merb-gen.rb +37 -0
  7. data/lib/merb-gen/controller.rb +69 -0
  8. data/lib/merb-gen/freezer.rb +19 -0
  9. data/lib/merb-gen/generator.rb +55 -0
  10. data/lib/merb-gen/helper.rb +53 -0
  11. data/lib/merb-gen/merb.rb +27 -0
  12. data/lib/merb-gen/merb/merb_flat.rb +31 -0
  13. data/lib/merb-gen/merb/merb_full.rb +35 -0
  14. data/lib/merb-gen/merb/merb_very_flat.rb +33 -0
  15. data/lib/merb-gen/merb_plugin.rb +33 -0
  16. data/lib/merb-gen/migration.rb +69 -0
  17. data/lib/merb-gen/model.rb +67 -0
  18. data/lib/merb-gen/part_controller.rb +55 -0
  19. data/lib/merb-gen/resource.rb +32 -0
  20. data/lib/merb-gen/resource_controller.rb +91 -0
  21. data/lib/merb-gen/session_migration.rb +44 -0
  22. data/lib/merb-gen/slice.rb +25 -0
  23. data/lib/merb-gen/slice/full.rb +31 -0
  24. data/lib/merb-gen/slice/thin.rb +31 -0
  25. data/lib/merb-gen/slice/very_thin.rb +31 -0
  26. data/spec/controller_spec.rb +94 -0
  27. data/spec/merb_spec.rb +28 -0
  28. data/spec/migration_spec.rb +47 -0
  29. data/spec/model_spec.rb +95 -0
  30. data/spec/resource_controller_spec.rb +98 -0
  31. data/spec/spec_helper.rb +7 -0
  32. data/templates/application/merb/Rakefile +76 -0
  33. data/templates/application/merb/app/controllers/application.rb +2 -0
  34. data/templates/application/merb/app/controllers/exceptions.rb +13 -0
  35. data/templates/application/merb/app/helpers/global_helpers.rb +5 -0
  36. data/templates/application/merb/app/views/exceptions/internal_server_error.html.erb +216 -0
  37. data/templates/application/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  38. data/templates/application/merb/app/views/exceptions/not_found.html.erb +47 -0
  39. data/templates/application/merb/app/views/layout/application.html.erb +11 -0
  40. data/templates/application/merb/autotest/discover.rb +1 -0
  41. data/templates/application/merb/autotest/merb.rb +149 -0
  42. data/templates/application/merb/autotest/merb_rspec.rb +166 -0
  43. data/templates/application/merb/config/environments/development.rb +7 -0
  44. data/templates/application/merb/config/environments/production.rb +7 -0
  45. data/templates/application/merb/config/environments/rake.rb +7 -0
  46. data/templates/application/merb/config/environments/test.rb +6 -0
  47. data/templates/application/merb/config/init.rb +164 -0
  48. data/templates/application/merb/config/rack.rb +12 -0
  49. data/templates/application/merb/config/router.rb +35 -0
  50. data/templates/application/merb/public/images/merb.jpg +0 -0
  51. data/templates/application/merb/public/merb.fcgi +22 -0
  52. data/templates/application/merb/public/stylesheets/master.css +119 -0
  53. data/templates/application/merb/spec/spec.opts +0 -0
  54. data/templates/application/merb/spec/spec_helper.rb +13 -0
  55. data/templates/application/merb/test/test_helper.rb +14 -0
  56. data/templates/application/merb_flat/README.txt +10 -0
  57. data/templates/application/merb_flat/application.rb +15 -0
  58. data/templates/application/merb_flat/config/framework.rb +7 -0
  59. data/templates/application/merb_flat/config/init.rb +18 -0
  60. data/templates/application/merb_flat/views/foo.html.erb +3 -0
  61. data/templates/application/merb_plugin/LICENSE +20 -0
  62. data/templates/application/merb_plugin/README +4 -0
  63. data/templates/application/merb_plugin/Rakefile +59 -0
  64. data/templates/application/merb_plugin/TODO +5 -0
  65. data/templates/application/merb_plugin/lib/%base_name%.rb +18 -0
  66. data/templates/application/merb_plugin/lib/%base_name%/merbtasks.rb +6 -0
  67. data/templates/application/merb_plugin/spec/%base_name%_spec.rb +7 -0
  68. data/templates/application/merb_plugin/spec/spec_helper.rb +2 -0
  69. data/templates/application/merb_plugin/test/%base_name%_test.rb +0 -0
  70. data/templates/application/merb_plugin/test/test_helper.rb +2 -0
  71. data/templates/application/merb_very_flat/application.rbt +17 -0
  72. data/templates/application/slice/full/LICENSE +20 -0
  73. data/templates/application/slice/full/README +170 -0
  74. data/templates/application/slice/full/Rakefile +48 -0
  75. data/templates/application/slice/full/TODO +15 -0
  76. data/templates/application/slice/full/app/controllers/application.rb +5 -0
  77. data/templates/application/slice/full/app/controllers/main.rb +7 -0
  78. data/templates/application/slice/full/app/helpers/application_helper.rb +64 -0
  79. data/templates/application/slice/full/app/views/layout/%underscored_base_name%.html.erb +16 -0
  80. data/templates/application/slice/full/app/views/main/index.html.erb +1 -0
  81. data/templates/application/slice/full/lib/%base_name%.rb +78 -0
  82. data/templates/application/slice/full/lib/%base_name%/merbtasks.rb +166 -0
  83. data/templates/application/slice/full/lib/%base_name%/slicetasks.rb +18 -0
  84. data/templates/application/slice/full/public/javascripts/master.js +0 -0
  85. data/templates/application/slice/full/public/stylesheets/master.css +2 -0
  86. data/templates/application/slice/full/spec/%base_name%_spec.rb +130 -0
  87. data/templates/application/slice/full/spec/controllers/main_spec.rb +61 -0
  88. data/templates/application/slice/full/spec/spec_helper.rb +44 -0
  89. data/templates/application/slice/full/stubs/app/controllers/application.rb +2 -0
  90. data/templates/application/slice/full/stubs/app/controllers/main.rb +2 -0
  91. data/templates/application/slice/thin/LICENSE +20 -0
  92. data/templates/application/slice/thin/README +130 -0
  93. data/templates/application/slice/thin/Rakefile +46 -0
  94. data/templates/application/slice/thin/TODO +7 -0
  95. data/templates/application/slice/thin/application.rb +36 -0
  96. data/templates/application/slice/thin/lib/%base_name%.rb +93 -0
  97. data/templates/application/slice/thin/lib/%base_name%/merbtasks.rb +106 -0
  98. data/templates/application/slice/thin/lib/%base_name%/slicetasks.rb +18 -0
  99. data/templates/application/slice/thin/public/javascripts/master.js +0 -0
  100. data/templates/application/slice/thin/public/stylesheets/master.css +2 -0
  101. data/templates/application/slice/thin/stubs/application.rb +9 -0
  102. data/templates/application/slice/thin/views/layout/%underscored_base_name%.html.erb +16 -0
  103. data/templates/application/slice/thin/views/main/index.html.erb +1 -0
  104. data/templates/application/slice/very_thin/LICENSE +20 -0
  105. data/templates/application/slice/very_thin/README +110 -0
  106. data/templates/application/slice/very_thin/Rakefile +46 -0
  107. data/templates/application/slice/very_thin/TODO +7 -0
  108. data/templates/application/slice/very_thin/application.rb +36 -0
  109. data/templates/application/slice/very_thin/lib/%base_name%.rb +89 -0
  110. data/templates/application/slice/very_thin/lib/%base_name%/merbtasks.rb +106 -0
  111. data/templates/application/slice/very_thin/lib/%base_name%/slicetasks.rb +18 -0
  112. data/templates/component/controller/app/controllers/%file_name%.rb +11 -0
  113. data/templates/component/controller/app/views/%file_name%/index.html.erb +1 -0
  114. data/templates/component/controller/spec/controllers/%file_name%_spec.rb +7 -0
  115. data/templates/component/controller/test/controllers/%file_name%_test.rb +17 -0
  116. data/templates/component/freezer/script/frozen_merb +43 -0
  117. data/templates/component/helper/app/helpers/%file_name%_helper.rb +7 -0
  118. data/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +5 -0
  119. data/templates/component/migration/activerecord/schema/migrations/%file_name%.rb +19 -0
  120. data/templates/component/migration/datamapper/schema/migrations/%file_name%.rb +7 -0
  121. data/templates/component/migration/sequel/schema/migrations/%file_name%.rb +24 -0
  122. data/templates/component/model/activerecord/app/models/%file_name%.rb +2 -0
  123. data/templates/component/model/datamapper/app/models/%file_name%.rb +6 -0
  124. data/templates/component/model/none/app/models/%file_name%.rb +5 -0
  125. data/templates/component/model/rspec/spec/models/%file_name%_spec.rb +7 -0
  126. data/templates/component/model/sequel/app/models/%file_name%.rb +2 -0
  127. data/templates/component/model/test_unit/test/models/%file_name%_test.rb +9 -0
  128. data/templates/component/part_controller/app/parts/%file_name%_part.rb +9 -0
  129. data/templates/component/part_controller/app/parts/views/%file_name%_part/index.html.erb +3 -0
  130. data/templates/component/resource_controller/activerecord/app/controllers/%file_name%.rb +57 -0
  131. data/templates/component/resource_controller/activerecord/app/views/%file_name%/edit.html.erb +3 -0
  132. data/templates/component/resource_controller/activerecord/app/views/%file_name%/index.html.erb +3 -0
  133. data/templates/component/resource_controller/activerecord/app/views/%file_name%/new.html.erb +3 -0
  134. data/templates/component/resource_controller/activerecord/app/views/%file_name%/show.html.erb +3 -0
  135. data/templates/component/resource_controller/datamapper/app/controllers/%file_name%.rb +59 -0
  136. data/templates/component/resource_controller/datamapper/app/views/%file_name%/edit.html.erb +21 -0
  137. data/templates/component/resource_controller/datamapper/app/views/%file_name%/index.html.erb +24 -0
  138. data/templates/component/resource_controller/datamapper/app/views/%file_name%/new.html.erb +20 -0
  139. data/templates/component/resource_controller/datamapper/app/views/%file_name%/show.html.erb +14 -0
  140. data/templates/component/resource_controller/none/app/controllers/%file_name%.rb +36 -0
  141. data/templates/component/resource_controller/none/app/views/%file_name%/edit.html.erb +3 -0
  142. data/templates/component/resource_controller/none/app/views/%file_name%/index.html.erb +3 -0
  143. data/templates/component/resource_controller/none/app/views/%file_name%/new.html.erb +3 -0
  144. data/templates/component/resource_controller/none/app/views/%file_name%/show.html.erb +3 -0
  145. data/templates/component/resource_controller/sequel/app/controllers/%file_name%.rb +59 -0
  146. data/templates/component/resource_controller/sequel/app/views/%file_name%/edit.html.erb +3 -0
  147. data/templates/component/resource_controller/sequel/app/views/%file_name%/index.html.erb +3 -0
  148. data/templates/component/resource_controller/sequel/app/views/%file_name%/new.html.erb +3 -0
  149. data/templates/component/resource_controller/sequel/app/views/%file_name%/show.html.erb +3 -0
  150. data/templates/component/session_migration/activerecord/schema/migrations/%version%_sessions.rb +12 -0
  151. data/templates/component/session_migration/sequel/schema/migrations/%version%_sessions.rb +16 -0
  152. metadata +362 -0
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "merb" }
@@ -0,0 +1,149 @@
1
+ # Adapted from Autotest::Rails
2
+ require 'autotest'
3
+
4
+ class Autotest::Merb < Autotest
5
+
6
+ # +model_tests_dir+:: the directory to find model-centric tests
7
+ # +controller_tests_dir+:: the directory to find controller-centric tests
8
+ # +view_tests_dir+:: the directory to find view-centric tests
9
+ # +fixtures_dir+:: the directory to find fixtures in
10
+ attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir
11
+
12
+ def initialize
13
+ super
14
+
15
+ initialize_test_layout
16
+
17
+ # Ignore any happenings in these directories
18
+ add_exception %r%^\./(?:doc|log|public|tmp)%
19
+
20
+ # Ignore any mappings that Autotest may have already set up
21
+ clear_mappings
22
+
23
+ # Any changes to a file in the root of the 'lib' directory will run any
24
+ # model test with a corresponding name.
25
+ add_mapping %r%^lib\/.*\.rb% do |filename, _|
26
+ files_matching Regexp.new(["^#{model_test_for(filename)}$"])
27
+ end
28
+
29
+ # Any changes to a fixture will run corresponding view, controller and
30
+ # model tests
31
+ add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
32
+ [
33
+ model_test_for(m[1]),
34
+ controller_test_for(m[1]),
35
+ view_test_for(m[1])
36
+ ]
37
+ end
38
+
39
+ # Any change to a test or test will cause it to be run
40
+ add_mapping %r%^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
41
+ filename
42
+ end
43
+
44
+ # Any change to a model will cause it's corresponding test to be run
45
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
46
+ model_test_for(m[1])
47
+ end
48
+
49
+ # Any change to the global helper will result in all view and controller
50
+ # tests being run
51
+ add_mapping %r%^app/helpers/global_helpers.rb% do
52
+ files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
53
+ end
54
+
55
+ # Any change to a helper will run it's corresponding view and controller
56
+ # tests, unless the helper is the global helper. Changes to the global
57
+ # helper run all view and controller tests.
58
+ add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
59
+ if m[1] == "global" then
60
+ files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
61
+ else
62
+ [
63
+ view_test_for(m[1]),
64
+ controller_test_for(m[1])
65
+ ]
66
+ end
67
+ end
68
+
69
+ # Changes to views result in their corresponding view and controller test
70
+ # being run
71
+ add_mapping %r%^app/views/(.*)/% do |_, m|
72
+ [
73
+ view_test_for(m[1]),
74
+ controller_test_for(m[1])
75
+ ]
76
+ end
77
+
78
+ # Changes to a controller result in its corresponding test being run. If
79
+ # the controller is the exception or application controller, all
80
+ # controller tests are run.
81
+ add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
82
+ if ["application", "exception"].include?(m[1])
83
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
84
+ else
85
+ controller_test_for(m[1])
86
+ end
87
+ end
88
+
89
+ # If a change is made to the router, run all controller and view tests
90
+ add_mapping %r%^config/router.rb$% do # FIX
91
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
92
+ end
93
+
94
+ # If any of the major files governing the environment are altered, run
95
+ # everything
96
+ add_mapping %r%^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX
97
+ files_matching %r%^test/(unit|models|controllers|views|functional)/.*_test\.rb$%
98
+ end
99
+ end
100
+
101
+ private
102
+
103
+ # Determines the paths we can expect tests or specs to reside, as well as
104
+ # corresponding fixtures.
105
+ def initialize_test_layout
106
+ self.model_tests_dir = "test/unit"
107
+ self.controller_tests_dir = "test/functional"
108
+ self.view_tests_dir = "test/views"
109
+ self.fixtures_dir = "test/fixtures"
110
+ end
111
+
112
+ # Given a filename and the test type, this method will return the
113
+ # corresponding test's or spec's name.
114
+ #
115
+ # ==== Arguments
116
+ # +filename+<String>:: the file name of the model, view, or controller
117
+ # +kind_of_test+<Symbol>:: the type of test we that we should run
118
+ #
119
+ # ==== Returns
120
+ # String:: the name of the corresponding test or spec
121
+ #
122
+ # ==== Example
123
+ #
124
+ # > test_for("user", :model)
125
+ # => "user_test.rb"
126
+ # > test_for("login", :controller)
127
+ # => "login_controller_test.rb"
128
+ # > test_for("form", :view)
129
+ # => "form_view_spec.rb" # If you're running a RSpec-like suite
130
+ def test_for(filename, kind_of_test)
131
+ name = [filename]
132
+ name << kind_of_test.to_s if kind_of_test == :view
133
+ name << "test"
134
+ return name.join("_") + ".rb"
135
+ end
136
+
137
+ def model_test_for(filename)
138
+ [model_tests_dir, test_for(filename, :model)].join("/")
139
+ end
140
+
141
+ def controller_test_for(filename)
142
+ [controller_tests_dir, test_for(filename, :controller)].join("/")
143
+ end
144
+
145
+ def view_test_for(filename)
146
+ [view_tests_dir, test_for(filename, :view)].join("/")
147
+ end
148
+
149
+ end
@@ -0,0 +1,166 @@
1
+ # Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
2
+ require 'autotest'
3
+
4
+ class RspecCommandError < StandardError; end
5
+
6
+ # This class maps your application's structure so Autotest can understand what
7
+ # specs to run when files change.
8
+ #
9
+ # Fixtures are _not_ covered by this class. If you change a fixture file, you
10
+ # will have to run your spec suite manually, or, better yet, provide your own
11
+ # Autotest map explaining how your fixtures are set up.
12
+ class Autotest::MerbRspec < Autotest
13
+ def initialize
14
+ super
15
+
16
+ # Ignore any happenings in these directories
17
+ add_exception %r%^\./(?:doc|log|public|tmp)%
18
+
19
+ # Ignore SCM directories and custom Autotest mappings
20
+ %w[.svn .hg .git .autotest].each { |exception| add_exception(exception) }
21
+
22
+ # Ignore any mappings that Autotest may have already set up
23
+ clear_mappings
24
+
25
+ # Anything in /lib could have a spec anywhere, if at all. So, look for
26
+ # files with roughly the same name as the file in /lib
27
+ add_mapping %r%^lib\/(.*)\.rb% do |_, m|
28
+ files_matching %r%^spec\/#{m[1]}%
29
+ end
30
+
31
+ add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
32
+ all_specs
33
+ end
34
+
35
+ # Changing a spec will cause it to run itself
36
+ add_mapping %r%^spec/.*\.rb$% do |filename, _|
37
+ filename
38
+ end
39
+
40
+ # Any change to a model will cause it's corresponding test to be run
41
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
42
+ spec_for(m[1], 'model')
43
+ end
44
+
45
+ # Any change to global_helpers will result in all view and controller
46
+ # tests being run
47
+ add_mapping %r%^app/helpers/global_helpers\.rb% do
48
+ files_matching %r%^spec/(views|controllers|helpers)/.*_spec\.rb$%
49
+ end
50
+
51
+ # Any change to a helper will cause its spec to be run
52
+ add_mapping %r%^app/helpers/(.*)_helper(s)?\.rb% do |_, m|
53
+ spec_for(m[1], 'helper')
54
+ end
55
+
56
+ # Changes to a view cause its spec to be run
57
+ add_mapping %r%^app/views/(.*)/% do |_, m|
58
+ spec_for(m[1], 'view')
59
+ end
60
+
61
+ # Changes to a controller result in its corresponding spec being run. If
62
+ # the controller is the exception or application controller, all
63
+ # controller specs are run.
64
+ add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
65
+ if ["application", "exception"].include?(m[1])
66
+ files_matching %r%^spec/controllers/.*_spec\.rb$%
67
+ else
68
+ spec_for(m[1], 'controller')
69
+ end
70
+ end
71
+
72
+ # If a change is made to the router, run controller, view and helper specs
73
+ add_mapping %r%^config/router.rb$% do
74
+ files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
75
+ end
76
+
77
+ # If any of the major files governing the environment are altered, run
78
+ # everything
79
+ add_mapping %r%^config/(init|rack|environments/test).*\.rb|database\.yml% do
80
+ all_specs
81
+ end
82
+ end
83
+
84
+ def failed_results(results)
85
+ results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
86
+ end
87
+
88
+ def handle_results(results)
89
+ @failures = failed_results(results)
90
+ @files_to_test = consolidate_failures(@failures)
91
+ @files_to_test.empty? && !$TESTING ? hook(:green) : hook(:red)
92
+ @tainted = !@files_to_test.empty?
93
+ end
94
+
95
+ def consolidate_failures(failed)
96
+ filters = Hash.new { |h,k| h[k] = [] }
97
+ failed.each do |spec, failed_trace|
98
+ if f = test_files_for(failed).find { |f| f =~ /spec\// }
99
+ filters[f] << spec
100
+ break
101
+ end
102
+ end
103
+ filters
104
+ end
105
+
106
+ def make_test_cmd(specs_to_runs)
107
+ [
108
+ ruby,
109
+ "-S",
110
+ spec_command,
111
+ add_options_if_present,
112
+ files_to_test.keys.flatten.join(' ')
113
+ ].join(' ')
114
+ end
115
+
116
+ def add_options_if_present
117
+ File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
118
+ end
119
+
120
+ # Finds the proper spec command to use. Precendence is set in the
121
+ # lazily-evaluated method spec_commands. Alias + Override that in
122
+ # ~/.autotest to provide a different spec command then the default
123
+ # paths provided.
124
+ def spec_command(separator=File::ALT_SEPARATOR)
125
+ unless defined?(@spec_command)
126
+ @spec_command = spec_commands.find { |cmd| File.exists?(cmd) }
127
+
128
+ raise RspecCommandError, "No spec command could be found" unless @spec_command
129
+
130
+ @spec_command.gsub!(File::SEPARATOR, separator) if separator
131
+ end
132
+ @spec_command
133
+ end
134
+
135
+ # Autotest will look for spec commands in the following
136
+ # locations, in this order:
137
+ #
138
+ # * default spec bin/loader installed in Rubygems
139
+ # * any spec command found in PATH
140
+ def spec_commands
141
+ [File.join(Config::CONFIG['bindir'], 'spec'), 'spec']
142
+ end
143
+
144
+ private
145
+
146
+ # Runs +files_matching+ for all specs
147
+ def all_specs
148
+ files_matching %r%^spec/.*_spec\.rb$%
149
+ end
150
+
151
+ # Generates a path to some spec given its kind and the match from a mapping
152
+ #
153
+ # ==== Arguments
154
+ # match<String>:: the match from a mapping
155
+ # kind<String>:: the kind of spec that the match represents
156
+ #
157
+ # ==== Returns
158
+ # String
159
+ #
160
+ # ==== Example
161
+ # > spec_for('post', :view')
162
+ # => "spec/views/post_spec.rb"
163
+ def spec_for(match, kind)
164
+ File.join("spec", kind + 's', "#{match}_spec.rb")
165
+ end
166
+ end
@@ -0,0 +1,7 @@
1
+ Merb.logger.info("Loaded DEVELOPMENT Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:exception_details] = true
4
+ c[:reload_classes] = true
5
+ c[:reload_time] = 0.5
6
+ c[:log_auto_flush ] = true
7
+ }
@@ -0,0 +1,7 @@
1
+ Merb.logger.info("Loaded PRODUCTION Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:exception_details] = false
4
+ c[:reload_classes] = false
5
+ c[:log_level] = :error
6
+ c[:log_file] = Merb.log_path + "/production.log"
7
+ }
@@ -0,0 +1,7 @@
1
+ Merb.logger.info("Loaded RAKE Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:exception_details] = true
4
+ c[:reload_classes] = false
5
+ c[:log_auto_flush ] = true
6
+ c[:log_file] = Merb.log_path / 'merb_rake.log'
7
+ }
@@ -0,0 +1,6 @@
1
+ Merb.logger.info("Loaded TEST Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:testing] = true
4
+ c[:exception_details] = true
5
+ c[:log_auto_flush ] = true
6
+ }
@@ -0,0 +1,164 @@
1
+ #
2
+ # ==== Structure of Merb initializer
3
+ #
4
+ # 1. Load paths.
5
+ # 2. Dependencies configuration.
6
+ # 3. Libraries (ORM, testing tool, etc) you use.
7
+ # 4. Application-specific configuration.
8
+
9
+ #
10
+ # ==== Set up load paths
11
+ #
12
+
13
+ # Add the app's "gems" directory to the gem load path.
14
+ # Note that the gems directory must mirror the structure RubyGems uses for
15
+ # directories under which gems are kept.
16
+ #
17
+ # To conveniently set it up, use gem install -i <merb_app_root/gems>
18
+ # when installing gems. This will set up the structure under /gems
19
+ # automagically.
20
+ #
21
+ # An example:
22
+ #
23
+ # You want to bundle ActiveRecord and ActiveSupport with your Merb
24
+ # application to be deployment environment independent. To do so,
25
+ # install gems into merb_app_root/gems directory like this:
26
+ #
27
+ # gem install -i merb_app_root/gems activesupport-post-2.0.2.gem activerecord-post-2.0.2.gem
28
+ #
29
+ # Since RubyGems will search merb_app_root/gems for dependencies, order
30
+ # in the statement above is important: we need to install ActiveSupport which
31
+ # ActiveRecord depends on first.
32
+ #
33
+ # Remember that bundling of dependencies as gems with your application
34
+ # makes it independent of the environment it runs in and is a very
35
+ # good, encouraged practice to follow.
36
+ Gem.clear_paths
37
+ Gem.path.unshift(Merb.root / "gems")
38
+
39
+ # If you want modules and classes from libraries organized like
40
+ # merbapp/lib/magicwand/lib/magicwand.rb to autoload,
41
+ # uncomment this.
42
+ # Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
43
+
44
+ # ==== Dependencies
45
+
46
+ # These are some examples of how you might specify dependencies.
47
+ # Dependency loading is delayed to a later Merb app
48
+ # boot stage, but it may be important when
49
+ # another part of your configuration relies on libraries specified
50
+ # here.
51
+ #
52
+ # dependencies "RedCloth", "merb_helpers"
53
+ # OR
54
+ # dependency "RedCloth", "> 3.0"
55
+ # OR
56
+ # dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
57
+ Merb::BootLoader.after_app_loads do
58
+ # Add dependencies here that must load after the application loads:
59
+
60
+ # dependency "magic_admin" # this gem uses the app's model classes
61
+ end
62
+
63
+ #
64
+ # ==== Set up your ORM of choice
65
+ #
66
+
67
+ # Merb doesn't come with database support by default. You need
68
+ # an ORM plugin. Install one, and uncomment one of the following lines,
69
+ # if you need a database.
70
+
71
+ # Uncomment for DataMapper ORM
72
+ <%= "# " unless orm == :datamapper %>use_orm :datamapper
73
+
74
+ # Uncomment for ActiveRecord ORM
75
+ <%= "# " unless orm == :activerecord %>use_orm :activerecord
76
+
77
+ # Uncomment for Sequel ORM
78
+ <%= "# " unless orm == :sequel %>use_orm :sequel
79
+
80
+
81
+ #
82
+ # ==== Pick what you test with
83
+ #
84
+
85
+ # This defines which test framework the generators will use.
86
+ # RSpec is turned on by default.
87
+ #
88
+ # To use Test::Unit, you need to install the merb_test_unit gem.
89
+ # To use RSpec, you don't have to install any additional gems, since
90
+ # merb-core provides support for RSpec.
91
+ #
92
+ <%= "# " unless testing_framework == :test_unit %>use_test :test_unit
93
+ <%= "# " unless testing_framework == :rspec %>use_test :rspec
94
+
95
+ #
96
+ # ==== Set up your basic configuration
97
+ #
98
+
99
+ # IMPORTANT:
100
+ #
101
+ # early on Merb boot init file is not yet loaded.
102
+ # Thus setting PORT, PID FILE and ADAPTER using init file does not
103
+ # make sense and only can lead to confusion because default settings
104
+ # will be used instead.
105
+ #
106
+ # Please use command line options for them.
107
+ # See http://wiki.merbivore.com/pages/merb-core-boot-process
108
+ # if you want to know more.
109
+ Merb::Config.use do |c|
110
+
111
+ # Sets up a custom session id key which is used for the session persistence
112
+ # cookie name. If not specified, defaults to '_session_id'.
113
+ # c[:session_id_key] = '_session_id'
114
+
115
+ # The session_secret_key is only required for the cookie session store.
116
+ c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
117
+
118
+ # There are various options here, by default Merb comes with 'cookie',
119
+ # 'memory' or 'memcached'. You can of course use your favorite ORM
120
+ # instead: 'datamapper', 'sequel' or 'activerecord'.
121
+ c[:session_store] = 'cookie'
122
+ end
123
+
124
+
125
+ # ==== Tune your inflector
126
+
127
+ # To fine tune your inflector use the word, singular_word and plural_word
128
+ # methods of Language::English::Inflector module metaclass.
129
+ #
130
+ # Here we define erratum/errata exception case:
131
+ #
132
+ # Language::English::Inflector.word "erratum", "errata"
133
+ #
134
+ # In case singular and plural forms are the same omit
135
+ # second argument on call:
136
+ #
137
+ # Language::English::Inflector.word 'information'
138
+ #
139
+ # You can also define general, singularization and pluralization
140
+ # rules:
141
+ #
142
+ # Once the following rule is defined:
143
+ # Language::English::Inflector.rule 'y', 'ies'
144
+ #
145
+ # You can see the following results:
146
+ # irb> "fly".plural
147
+ # => flies
148
+ # irb> "cry".plural
149
+ # => cries
150
+ #
151
+ # Example for singularization rule:
152
+ #
153
+ # Language::English::Inflector.singular_rule 'o', 'oes'
154
+ #
155
+ # Works like this:
156
+ # irb> "heroes".singular
157
+ # => hero
158
+ #
159
+ # Example of pluralization rule:
160
+ # Language::English::Inflector.singular_rule 'fe', 'ves'
161
+ #
162
+ # And the result is:
163
+ # irb> "wife".plural
164
+ # => wives