mack 0.8.0.101 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CHANGELOG +29 -0
  2. data/bin/mackery-console +6 -5
  3. data/bin/mackery-server +23 -7
  4. data/lib/mack.rb +0 -3
  5. data/lib/mack/application.rb +161 -0
  6. data/lib/mack/assets/asset_helpers.rb +8 -0
  7. data/lib/mack/assets/assets_mgr.rb +0 -10
  8. data/lib/mack/boot/app.rb +46 -0
  9. data/lib/mack/boot/assets.rb +10 -0
  10. data/lib/mack/boot/configuration.rb +87 -0
  11. data/lib/mack/boot/console.rb +36 -0
  12. data/lib/mack/boot/core.rb +21 -0
  13. data/lib/mack/boot/environment.rb +22 -0
  14. data/lib/mack/boot/extensions.rb +13 -0
  15. data/lib/mack/boot/gem_tasks.rb +20 -0
  16. data/lib/mack/boot/gems.rb +18 -0
  17. data/lib/mack/boot/hello.rb +11 -0
  18. data/lib/mack/{initialization → boot}/helpers.rb +8 -3
  19. data/lib/mack/boot/initializers.rb +17 -0
  20. data/lib/mack/boot/lib.rb +19 -0
  21. data/lib/mack/{initialization → boot}/logging.rb +16 -9
  22. data/lib/mack/{initialization → boot}/logging/basic_layout.rb +0 -0
  23. data/lib/mack/{initialization → boot}/logging/color_layout.rb +1 -1
  24. data/lib/mack/{initialization → boot}/logging/filter.rb +0 -0
  25. data/lib/mack/boot/paths.rb +234 -0
  26. data/lib/mack/boot/plugins.rb +26 -0
  27. data/lib/mack/boot/portlets.rb +20 -0
  28. data/lib/mack/boot/routes.rb +15 -0
  29. data/lib/mack/boot/version.rb +7 -0
  30. data/lib/mack/controller/request.rb +5 -2
  31. data/lib/mack/controller/uploaded_file.rb +4 -0
  32. data/lib/mack/core_extensions/kernel.rb +26 -0
  33. data/lib/mack/core_extensions/object.rb +16 -0
  34. data/lib/mack/generators/mack_application_generator/manifest.yml +5 -3
  35. data/lib/mack/generators/mack_application_generator/templates/config/initializers/portlets.rb.template +9 -0
  36. data/lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template +4 -0
  37. data/lib/mack/generators/portlet_generator/portlet_generator.rb +2 -0
  38. data/lib/mack/generators/portlet_generator/templates/README.template +3 -0
  39. data/lib/mack/generators/portlet_generator/templates/portlet_config/portlet.spec.template +28 -0
  40. data/lib/mack/portlets/manager.rb +27 -0
  41. data/lib/mack/portlets/portlet.rb +93 -0
  42. data/lib/mack/portlets/unpacker.rb +34 -0
  43. data/lib/mack/rendering/engine/erubis.rb +2 -2
  44. data/lib/mack/rendering/type/file_base.rb +8 -4
  45. data/lib/mack/rendering/type/public.rb +4 -2
  46. data/lib/mack/routing/resource_proxy.rb +30 -4
  47. data/lib/mack/routing/route_map.rb +28 -15
  48. data/lib/mack/routing/route_object.rb +57 -24
  49. data/lib/mack/routing/urls.rb +12 -2
  50. data/lib/mack/runner.rb +6 -154
  51. data/lib/mack/sessions/cookie_session_store.rb +2 -1
  52. data/lib/mack/tasks/mack_dump_tasks.rake +62 -18
  53. data/lib/mack/tasks/mack_tasks.rake +1 -15
  54. data/lib/mack/tasks/portlet_tasks.rake +33 -0
  55. data/lib/mack/tasks/rake_rules.rake +6 -0
  56. data/lib/mack/tasks/test_tasks.rake +4 -6
  57. data/lib/mack/testing/helpers.rb +12 -4
  58. data/lib/mack/utils/server.rb +7 -1
  59. data/lib/mack/utils/static.rb +19 -0
  60. data/lib/mack/version.rb +1 -1
  61. data/lib/mack/view_helpers/all_helpers.rb +0 -8
  62. data/lib/mack/view_helpers/date_time_helpers.rb +18 -12
  63. data/lib/mack/view_helpers/form_helpers.rb +9 -0
  64. data/lib/mack/view_helpers/html_helpers.rb +18 -7
  65. data/lib/mack/view_helpers/link_helpers.rb +2 -1
  66. data/lib/mack/view_helpers/object_helpers.rb +1 -1
  67. data/lib/mack_app.rb +26 -14
  68. data/lib/mack_core.rb +50 -39
  69. data/lib/mack_tasks.rb +46 -19
  70. metadata +37 -18
  71. data/lib/mack/initialization/application.rb +0 -53
  72. data/lib/mack/initialization/boot_loader.rb +0 -72
  73. data/lib/mack/initialization/configuration.rb +0 -101
  74. data/lib/mack/initialization/console.rb +0 -29
  75. data/lib/mack/initialization/environment.rb +0 -16
  76. data/lib/mack/initialization/plugins.rb +0 -16
  77. data/lib/mack/initialization/server/simple_server.rb +0 -19
  78. data/lib/mack/tasks/mack_server_tasks.rake +0 -24
  79. data/lib/mack/utils/paths.rb +0 -154
@@ -0,0 +1,36 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ # This file gets loaded when you run:
6
+ # rake console
7
+ # It loads the following classes to make using the application via the console easier:
8
+ #
9
+ # * Mack::TestHelpers
10
+ # * Mack::Routes::Urls
11
+
12
+ fl = File.join_from_here('..')
13
+
14
+ require File.join(fl, "..", "..", "bin", "gem_load_path.rb")
15
+
16
+ require File.join(fl, "..", "mack.rb")
17
+
18
+ require File.join(fl, "testing", "helpers.rb")
19
+
20
+ # self.send(:include, Mack::TestHelpers)
21
+ self.send(:include, Mack::Routes::Urls)
22
+
23
+ # When using the Mack console if you edit any files
24
+ # you can reload them in the console using this method
25
+ # without having to exit the console and start again.
26
+ def reload!
27
+ ivar_cache("_rack_reloader") do
28
+ Mack::Reloader.new(nil)
29
+ end.reload!
30
+ end
31
+
32
+ # Prevent AutoRunner from getting executed when user exits out of console
33
+ Test::Unit.run = true
34
+
35
+
36
+ end
@@ -0,0 +1,21 @@
1
+ run_once do
2
+
3
+ require File.join_from_here('configuration.rb')
4
+ require File.join_from_here('logging.rb')
5
+
6
+ init_message('core')
7
+
8
+ # Require all the necessary files to make Mack actually work!
9
+ lib_dirs = ["assets", "errors", "core_extensions", "utils", "sessions", "runner_helpers", "routing", "view_helpers", "rendering", "controller", "tasks", "initialization/server", "generators"]
10
+ lib_dirs << "testing"# if Mack.env == "test"
11
+ lib_dirs.each do |dir|
12
+ dir_globs = Dir.glob(File.join_from_here("..", dir, "**/*.rb"))
13
+ dir_globs.sort.each do |d|
14
+ # puts File.expand_path(d)
15
+ require File.expand_path(d) unless d.match(/console/)
16
+ end
17
+ end
18
+
19
+ require File.join_from_here('..', 'runner.rb')
20
+
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ module Mack
6
+ # Allows hook methods for the loading of the environment.
7
+ module Environment
8
+ include Extlib::Hook
9
+
10
+ # Requires the Mack application classes only once.
11
+ # This is the method you want to add 'hooks' on for
12
+ # application load setup.
13
+ def self.load
14
+ ivar_cache do
15
+ require File.join_from_here("..", "..", "mack_app")
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,13 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ require File.join_from_here('paths.rb')
6
+
7
+ Dir.glob(File.join_from_here('..', 'core_extensions', '**/*.rb')).each do |d|
8
+ d = File.expand_path(d)
9
+ # puts d
10
+ require d
11
+ end
12
+
13
+ end
@@ -0,0 +1,20 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ require File.join_from_here('configuration.rb')
6
+ require File.join_from_here('logging.rb')
7
+ require File.join_from_here('extensions.rb')
8
+
9
+ init_message('custom gem Rake tasks')
10
+
11
+ require File.join_from_here('..', 'utils', 'gem_manager.rb')
12
+
13
+ Mack.search_path(:initializers).each do |path|
14
+ f = File.join(path, 'gems.rb')
15
+ require f if File.exists?(f)
16
+ end
17
+
18
+ Mack::Utils::GemManager.instance.do_task_requires
19
+
20
+ end
@@ -0,0 +1,18 @@
1
+ run_once do
2
+
3
+ require File.join_from_here('configuration.rb')
4
+ require File.join_from_here('logging.rb')
5
+ require File.join_from_here('extensions.rb')
6
+
7
+ init_message('custom gems')
8
+
9
+ require File.join_from_here('..', 'utils', 'gem_manager.rb')
10
+
11
+ Mack.search_path(:initializers).each do |path|
12
+ f = File.join(path, 'gems.rb')
13
+ require f if File.exists?(f)
14
+ end
15
+
16
+ Mack::Utils::GemManager.instance.do_requires
17
+
18
+ end
@@ -0,0 +1,11 @@
1
+ run_once do
2
+
3
+ require File.join_from_here('logging.rb')
4
+ require File.join_from_here('version.rb')
5
+
6
+ Mack.reset_logger!
7
+
8
+ Mack.logger.debug "Mack root: #{Mack.root}"
9
+ Mack.logger.debug "Mack version: #{Mack::VERSION}"
10
+ Mack.logger.debug "Starting application in #{Mack.env} mode."
11
+ end
@@ -1,6 +1,10 @@
1
- boot_load(:helpers, :logging) do
2
- # Include ApplicationHelper into all controllers:
3
- Mack.logger.debug "Initializing helpers..." unless configatron.mack.log.disable_initialization_logging
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ require File.join_from_here('app')
6
+
7
+ init_message('helpers')
4
8
 
5
9
  module Mack
6
10
  module ControllerHelpers # :nodoc:
@@ -25,4 +29,5 @@ boot_load(:helpers, :logging) do
25
29
  h = "Mack::ViewHelpers::#{cont}".constantize
26
30
  Mack::Rendering::ViewTemplate.send(:include, h)
27
31
  end
32
+
28
33
  end
@@ -0,0 +1,17 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ require File.join_from_here('core')
6
+
7
+ init_message('initializers')
8
+
9
+ Mack.search_path(:initializers).each do |path|
10
+ Dir.glob(File.join(path, '**/*.rb')).each do |d|
11
+ d = File.expand_path(d)
12
+ # puts d
13
+ require d
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,19 @@
1
+ require 'mack-facets'
2
+
3
+ run_once do
4
+
5
+ require File.join_from_here('core.rb')
6
+ require File.join_from_here('gems.rb')
7
+ require File.join_from_here('plugins.rb')
8
+
9
+ init_message('lib')
10
+
11
+ Mack.search_path(:lib).each do |path|
12
+ Dir.glob(File.join(path, "**/*.rb")).each do |d|
13
+ d = File.expand_path(d)
14
+ # puts d
15
+ require d
16
+ end
17
+ end
18
+
19
+ end
@@ -1,10 +1,19 @@
1
- boot_load(:logging, :configuration) do
1
+ require 'rubygems'
2
+ require 'mack-facets'
3
+
4
+ run_once do
5
+
6
+ require File.join_from_here('configuration.rb')
2
7
 
8
+ # init_message('logging')
9
+
10
+ gem 'logging'
3
11
  require 'logging'
4
- require File.join(File.dirname(__FILE__), "..", "utils", "ansi", "ansi_color")
5
- require File.join(File.dirname(__FILE__), 'logging', 'filter')
6
- require File.join(File.dirname(__FILE__), 'logging', 'basic_layout')
7
- require File.join(File.dirname(__FILE__), 'logging', 'color_layout')
12
+
13
+ require File.join_from_here("..", "utils", "ansi", "ansi_color.rb")
14
+ require File.join_from_here('logging', 'filter')
15
+ require File.join_from_here('logging', 'basic_layout.rb')
16
+ require File.join_from_here('logging', 'color_layout.rb')
8
17
 
9
18
  module Logging # :nodoc:
10
19
 
@@ -50,8 +59,6 @@ boot_load(:logging, :configuration) do
50
59
 
51
60
  end # Mack
52
61
 
53
- unless Mack.logger
54
- Mack.reset_logger!
55
- end
62
+ Mack.reset_logger!
56
63
 
57
- end # boot_load
64
+ end # run_once
@@ -5,7 +5,7 @@ module Mack
5
5
 
6
6
  def format(event)
7
7
  message = super(event)
8
- if message.match(/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP)/)
8
+ if message.match(/(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP)/)
9
9
  return Mack::Utils::Ansi::Color.wrap(configatron.mack.log.colors.db, message)
10
10
  else
11
11
  color = configatron.mack.log.colors.retrieve(event.level_name.downcase.to_sym, nil)
@@ -0,0 +1,234 @@
1
+ require 'fileutils'
2
+ run_once do
3
+
4
+ module Mack
5
+
6
+ # Returns the root of the current Mack application
7
+ def self.root
8
+ ENV["MACK_ROOT"] ||= FileUtils.pwd
9
+ end
10
+
11
+ # Returns the environment of the current Mack application
12
+ def self.env
13
+ ENV["MACK_ENV"] ||= "development"
14
+ end
15
+
16
+ # Returns true/false based on whether the specified environment
17
+ # is the current environment
18
+ def self.env?(env)
19
+ self.env == env.to_s
20
+ end
21
+
22
+ def self.base_path(key)
23
+ if $__mack_base_path.nil?
24
+ $__mack_base_path = {}
25
+ end
26
+ path = Mack.root
27
+ path = $__mack_base_path[key.to_sym] if $__mack_base_path.has_key?(key.to_sym)
28
+ path
29
+ end
30
+
31
+ def self.set_base_path(key, value = "")
32
+ if $__mack_base_path.nil?
33
+ $__mack_base_path = {}
34
+ end
35
+ return if key == :local
36
+ Mack.logger.warn "Base path for #{key} will be overwritten with #{value}" if $__mack_base_path.has_key?(key.to_sym)
37
+ $__mack_base_path[key.to_sym] = value
38
+ end
39
+
40
+ def self.search_path(key, mack_paths_value = true)
41
+ if $__mack_search_path.nil?
42
+ $__mack_search_path = {}
43
+ end
44
+ paths = ($__mack_search_path[key.to_sym] ||= []).dup
45
+ paths << Mack::Paths.send(key) if Mack::Paths.methods.include?(key.to_s) && mack_paths_value
46
+ paths.flatten.uniq
47
+ end
48
+
49
+ def self.search_path_local_first(key)
50
+ paths = []
51
+ paths << Mack::Paths.send(key) if Mack::Paths.methods.include?(key.to_s)
52
+ paths << self.search_path(key, false)
53
+ paths.flatten.uniq
54
+ end
55
+
56
+ def self.add_search_path(key, path)
57
+ if $__mack_search_path.nil?
58
+ $__mack_search_path = {}
59
+ end
60
+ paths = ($__mack_search_path[key.to_sym] ||= [])
61
+ paths << File.expand_path(path)
62
+ $__mack_search_path[key.to_sym] = paths
63
+ end
64
+
65
+ module Paths
66
+
67
+ # <MACK_PROJECT_ROOT>
68
+ def self.root(*files)
69
+ File.expand_path(File.join(Mack.root, *files))
70
+ end
71
+
72
+ # <MACK_PROJECT_ROOT>/public
73
+ def self.public(*files)
74
+ Mack::Paths.root("public", *files)
75
+ end
76
+
77
+ # <MACK_PROJECT_ROOT>/public/images
78
+ def self.images(*files)
79
+ Mack::Paths.public("images", *files)
80
+ end
81
+
82
+ # <MACK_PROJECT_ROOT>/public/javascripts
83
+ def self.javascripts(*files)
84
+ Mack::Paths.public("javascripts", *files)
85
+ end
86
+
87
+ # <MACK_PROJECT_ROOT>/public/stylesheets
88
+ def self.stylesheets(*files)
89
+ Mack::Paths.public("stylesheets", *files)
90
+ end
91
+
92
+ # <MACK_PROJECT_ROOT>/app
93
+ def self.app(*files)
94
+ Mack::Paths.root("app", *files)
95
+ end
96
+
97
+ # <MACK_PROJECT_ROOT>/log
98
+ def self.log(*files)
99
+ Mack::Paths.root("log", *files)
100
+ end
101
+
102
+ # <MACK_PROJECT_ROOT>/test
103
+ def self.test(*files)
104
+ Mack::Paths.root("test", *files)
105
+ end
106
+
107
+ # <MACK_PROJECT_ROOT>/tmp
108
+ def self.tmp(*files)
109
+ Mack::Paths.root("tmp", *files)
110
+ end
111
+
112
+ # <MACK_PROJECT_ROOT>/test/models
113
+ def self.model_tests(*files)
114
+ Mack::Paths.test("models", *files)
115
+ end
116
+
117
+ # <MACK_PROJECT_ROOT>/test/controllers
118
+ def self.controller_tests(*files)
119
+ Mack::Paths.test("controllers", *files)
120
+ end
121
+
122
+ def self.test_helpers(*files)
123
+ Mack::Paths.test("helpers", *files)
124
+ end
125
+
126
+ # <MACK_PROJECT_ROOT>/test/helpers/controllers
127
+ def self.controller_helper_tests(*files)
128
+ Mack::Paths.test_helpers("controllers", *files)
129
+ end
130
+
131
+ # <MACK_PROJECT_ROOT>/test/helpers/views
132
+ def self.view_helper_tests(*files)
133
+ Mack::Paths.test_helpers("views", *files)
134
+ end
135
+
136
+ # <MACK_PROJECT_ROOT>/app/views
137
+ def self.views(*files)
138
+ Mack::Paths.app("views", *files)
139
+ end
140
+
141
+ # <MACK_PROJECT_ROOT>/app/views/layouts
142
+ def self.layouts(*files)
143
+ Mack::Paths.views("layouts", *files)
144
+ end
145
+
146
+ # <MACK_PROJECT_ROOT>/app/controllers
147
+ def self.controllers(*files)
148
+ Mack::Paths.app("controllers", *files)
149
+ end
150
+
151
+ # <MACK_PROJECT_ROOT>/app/models
152
+ def self.models(*files)
153
+ Mack::Paths.app("models", *files)
154
+ end
155
+
156
+ # <MACK_PROJECT_ROOT>/app/helpers
157
+ def self.helpers(*files)
158
+ Mack::Paths.app("helpers", *files)
159
+ end
160
+
161
+ # <MACK_PROJECT_ROOT>/app/helpers/controllers
162
+ def self.controller_helpers(*files)
163
+ Mack::Paths.helpers("controllers", *files)
164
+ end
165
+
166
+ # <MACK_PROJECT_ROOT>/app/helpers/views
167
+ def self.view_helpers(*files)
168
+ Mack::Paths.helpers("views", *files)
169
+ end
170
+
171
+ # <MACK_PROJECT_ROOT>/lib
172
+ def self.lib(*files)
173
+ Mack::Paths.root("lib", *files)
174
+ end
175
+
176
+ # <MACK_PROJECT_ROOT>/lib/tasks
177
+ def self.tasks(*files)
178
+ Mack::Paths.lib("tasks", *files)
179
+ end
180
+
181
+ # <MACK_PROJECT_ROOT>/db
182
+ def self.db(*files)
183
+ Mack::Paths.root("db", *files)
184
+ end
185
+
186
+ # <MACK_PROJECT_ROOT>/db/migrations
187
+ def self.migrations(*files)
188
+ Mack::Paths.db("migrations", *files)
189
+ end
190
+
191
+ # <MACK_PROJECT_ROOT>/config
192
+ def self.config(*files)
193
+ Mack::Paths.root("config", *files)
194
+ end
195
+
196
+ # <MACK_PROJECT_ROOT>/config/configatron
197
+ def self.configatron(*files)
198
+ Mack::Paths.config("configatron", *files)
199
+ end
200
+
201
+ # <MACK_PROJECT_ROOT>/config/initializers
202
+ def self.initializers(*files)
203
+ Mack::Paths.config("initializers", *files)
204
+ end
205
+
206
+ # <MACK_PROJECT_ROOT>/vendor
207
+ def self.vendor(*files)
208
+ Mack::Paths.root("vendor", *files)
209
+ end
210
+
211
+ # <MACK_PROJECT_ROOT>/vendor/plugins
212
+ def self.plugins(*files)
213
+ Mack::Paths.vendor("plugins", *files)
214
+ end
215
+
216
+ # <MACK_PROJECT_ROOT>/tmp/portlet_package
217
+ def self.portlet_package(*files)
218
+ Mack::Paths.tmp('portlet_package', *files)
219
+ end
220
+
221
+ # <MACK_PROJECT_ROOT>/portlet_config
222
+ def self.portlet_config(*files)
223
+ Mack::Paths.root('portlet_config', *files)
224
+ end
225
+
226
+ # <MACK_PROJECT_ROOT>/bin
227
+ def self.bin(*files)
228
+ Mack::Paths.root('bin', *files)
229
+ end
230
+
231
+ end # Paths
232
+ end # Mack
233
+
234
+ end # run_once