mack 0.5.0 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/CHANGELOG +19 -0
  2. data/bin/mack +3 -2
  3. data/bin/mack_ring_server +19 -1
  4. data/lib/{sea_level/controller_base.rb → controller/base.rb} +87 -128
  5. data/lib/{sea_level → controller}/cookie_jar.rb +3 -3
  6. data/lib/{sea_level → controller}/filter.rb +0 -0
  7. data/lib/{sea_level → controller}/request.rb +0 -0
  8. data/lib/{sea_level → controller}/response.rb +0 -0
  9. data/lib/{sea_level → controller}/session.rb +0 -0
  10. data/lib/{sea_level → controller}/uploaded_file.rb +0 -0
  11. data/lib/distributed/routing/urls.rb +1 -1
  12. data/lib/distributed/utils/rinda.rb +1 -1
  13. data/lib/errors/errors.rb +6 -4
  14. data/lib/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template +3 -0
  15. data/lib/generators/mack_application_generator/templates/public/favicon.ico.template +0 -0
  16. data/lib/initialization/configuration.rb +2 -1
  17. data/lib/initialization/console.rb +2 -2
  18. data/lib/initialization/{initializers/logging.rb → logging.rb} +0 -0
  19. data/lib/initialization/{initializers/orm_support.rb → orm_support.rb} +0 -0
  20. data/lib/initialization/{initializers/plugins.rb → plugins.rb} +0 -0
  21. data/lib/mack.rb +107 -131
  22. data/lib/mack_tasks.rb +1 -1
  23. data/lib/rendering/engine/base.rb +26 -0
  24. data/lib/rendering/engine/builder.rb +30 -0
  25. data/lib/rendering/engine/erubis.rb +67 -0
  26. data/lib/rendering/engine/haml.rb +18 -0
  27. data/lib/rendering/engine/markaby.rb +27 -0
  28. data/lib/rendering/engine/registry.rb +48 -0
  29. data/lib/rendering/type/action.rb +37 -0
  30. data/lib/rendering/type/base.rb +59 -0
  31. data/lib/rendering/type/file_base.rb +32 -0
  32. data/lib/rendering/type/inline.rb +26 -0
  33. data/lib/rendering/type/layout.rb +26 -0
  34. data/lib/rendering/type/partial.rb +40 -0
  35. data/lib/rendering/type/public.rb +29 -0
  36. data/lib/rendering/type/template.rb +22 -0
  37. data/lib/rendering/type/text.rb +17 -0
  38. data/lib/rendering/type/url.rb +120 -0
  39. data/lib/rendering/type/xml.rb +34 -0
  40. data/lib/rendering/view_template.rb +168 -0
  41. data/lib/routing/route_map.rb +20 -11
  42. data/lib/runner.rb +137 -0
  43. data/lib/utils/mime_types.rb +56 -0
  44. data/lib/utils/mime_types.yml +449 -0
  45. data/lib/{sea_level/helpers/view_helpers → view_helpers}/html_helpers.rb +0 -0
  46. data/lib/{sea_level/helpers/view_helpers → view_helpers}/string_helpers.rb +0 -0
  47. metadata +58 -29
  48. data/lib/initialization/initializer.rb +0 -110
  49. data/lib/rendering/base.rb +0 -62
  50. data/lib/rendering/classes/action.rb +0 -26
  51. data/lib/rendering/classes/partial.rb +0 -12
  52. data/lib/rendering/classes/public.rb +0 -13
  53. data/lib/rendering/classes/text.rb +0 -12
  54. data/lib/rendering/classes/url.rb +0 -59
  55. data/lib/rendering/classes/xml.rb +0 -24
  56. data/lib/sea_level/view_binder.rb +0 -88
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-06 00:00:00 -04:00
12
+ date: 2008-05-21 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - "="
30
30
  - !ruby/object:Gem::Version
31
- version: 0.1.23
31
+ version: 0.1.28
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: application_configuration
@@ -102,6 +102,24 @@ dependencies:
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.6.0
104
104
  version:
105
+ - !ruby/object:Gem::Dependency
106
+ name: markaby
107
+ version_requirement:
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.5.0
113
+ version:
114
+ - !ruby/object:Gem::Dependency
115
+ name: haml
116
+ version_requirement:
117
+ version_requirements: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "="
120
+ - !ruby/object:Gem::Version
121
+ version: 1.8.2
122
+ version:
105
123
  - !ruby/object:Gem::Dependency
106
124
  name: genosaurus
107
125
  version_requirement:
@@ -109,7 +127,7 @@ dependencies:
109
127
  requirements:
110
128
  - - "="
111
129
  - !ruby/object:Gem::Version
112
- version: 1.1.4
130
+ version: 1.1.8
113
131
  version:
114
132
  - !ruby/object:Gem::Dependency
115
133
  name: rcov
@@ -127,7 +145,7 @@ dependencies:
127
145
  requirements:
128
146
  - - "="
129
147
  - !ruby/object:Gem::Version
130
- version: 0.5.0
148
+ version: 0.5.5
131
149
  version:
132
150
  description: Mack is a powerful, yet simple, web application framework. It takes some cues from the likes of Rails and Merb, so it's not entirely unfamiliar. Mack hopes to provide developers a great framework for building, and deploying, portal and distributed applications.
133
151
  email: mark@mackframework.com
@@ -141,6 +159,13 @@ extra_rdoc_files:
141
159
  - CHANGELOG
142
160
  files:
143
161
  - README
162
+ - lib/controller/base.rb
163
+ - lib/controller/cookie_jar.rb
164
+ - lib/controller/filter.rb
165
+ - lib/controller/request.rb
166
+ - lib/controller/response.rb
167
+ - lib/controller/session.rb
168
+ - lib/controller/uploaded_file.rb
144
169
  - lib/core_extensions/kernel.rb
145
170
  - lib/core_extensions/string.rb
146
171
  - lib/distributed/errors/errors.rb
@@ -151,7 +176,6 @@ files:
151
176
  - lib/generators/mack_application_generator/manifest.yml
152
177
  - lib/generators/mack_application_generator/templates/app/controllers/default_controller.rb.template
153
178
  - lib/generators/mack_application_generator/templates/app/helpers/application_helper.rb.template
154
- - lib/generators/mack_application_generator/templates/app/models.template
155
179
  - lib/generators/mack_application_generator/templates/app/views/default/index.html.erb.template
156
180
  - lib/generators/mack_application_generator/templates/app/views/layouts/application.html.erb.template
157
181
  - lib/generators/mack_application_generator/templates/config/app_config/default.yml.template
@@ -160,6 +184,7 @@ files:
160
184
  - lib/generators/mack_application_generator/templates/config/app_config/test.yml.template
161
185
  - lib/generators/mack_application_generator/templates/config/database.yml.template
162
186
  - lib/generators/mack_application_generator/templates/config/initializers/gems.rb.template
187
+ - lib/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template
163
188
  - lib/generators/mack_application_generator/templates/config/routes.rb.template
164
189
  - lib/generators/mack_application_generator/templates/config/thin.ru.template
165
190
  - lib/generators/mack_application_generator/templates/config/thin.yml.template
@@ -174,35 +199,35 @@ files:
174
199
  - lib/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/init.rb.template
175
200
  - lib/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/%=@plugin_name%.rb.template
176
201
  - lib/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/tasks/%=@plugin_name%_tasks.rake.template
177
- - lib/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/tasks.template
178
202
  - lib/initialization/configuration.rb
179
203
  - lib/initialization/console.rb
180
- - lib/initialization/initializer.rb
181
- - lib/initialization/initializers/logging.rb
182
- - lib/initialization/initializers/orm_support.rb
183
- - lib/initialization/initializers/plugins.rb
204
+ - lib/initialization/logging.rb
205
+ - lib/initialization/orm_support.rb
206
+ - lib/initialization/plugins.rb
184
207
  - lib/initialization/server/simple_server.rb
185
208
  - lib/mack.rb
186
209
  - lib/mack_tasks.rb
187
- - lib/rendering/base.rb
188
- - lib/rendering/classes/action.rb
189
- - lib/rendering/classes/partial.rb
190
- - lib/rendering/classes/public.rb
191
- - lib/rendering/classes/text.rb
192
- - lib/rendering/classes/url.rb
193
- - lib/rendering/classes/xml.rb
210
+ - lib/rendering/engine/base.rb
211
+ - lib/rendering/engine/builder.rb
212
+ - lib/rendering/engine/erubis.rb
213
+ - lib/rendering/engine/haml.rb
214
+ - lib/rendering/engine/markaby.rb
215
+ - lib/rendering/engine/registry.rb
216
+ - lib/rendering/type/action.rb
217
+ - lib/rendering/type/base.rb
218
+ - lib/rendering/type/file_base.rb
219
+ - lib/rendering/type/inline.rb
220
+ - lib/rendering/type/layout.rb
221
+ - lib/rendering/type/partial.rb
222
+ - lib/rendering/type/public.rb
223
+ - lib/rendering/type/template.rb
224
+ - lib/rendering/type/text.rb
225
+ - lib/rendering/type/url.rb
226
+ - lib/rendering/type/xml.rb
227
+ - lib/rendering/view_template.rb
194
228
  - lib/routing/route_map.rb
195
229
  - lib/routing/urls.rb
196
- - lib/sea_level/controller_base.rb
197
- - lib/sea_level/cookie_jar.rb
198
- - lib/sea_level/filter.rb
199
- - lib/sea_level/helpers/view_helpers/html_helpers.rb
200
- - lib/sea_level/helpers/view_helpers/string_helpers.rb
201
- - lib/sea_level/request.rb
202
- - lib/sea_level/response.rb
203
- - lib/sea_level/session.rb
204
- - lib/sea_level/uploaded_file.rb
205
- - lib/sea_level/view_binder.rb
230
+ - lib/runner.rb
206
231
  - lib/tasks/cachetastic_tasks.rake
207
232
  - lib/tasks/gem_tasks.rake
208
233
  - lib/tasks/generator_tasks.rake
@@ -220,7 +245,11 @@ files:
220
245
  - lib/utils/crypt/default_worker.rb
221
246
  - lib/utils/crypt/keeper.rb
222
247
  - lib/utils/gem_manager.rb
248
+ - lib/utils/mime_types.rb
249
+ - lib/utils/mime_types.yml
223
250
  - lib/utils/server.rb
251
+ - lib/view_helpers/html_helpers.rb
252
+ - lib/view_helpers/string_helpers.rb
224
253
  - CHANGELOG
225
254
  has_rdoc: true
226
255
  homepage: http://www.mackframework.com
@@ -252,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
281
  requirements: []
253
282
 
254
283
  rubyforge_project: magrathea
255
- rubygems_version: 1.0.1
284
+ rubygems_version: 1.1.1
256
285
  signing_key:
257
286
  specification_version: 2
258
287
  summary: Mack is a powerful, yet simple, web application framework.
@@ -1,110 +0,0 @@
1
- require 'rubygems'
2
- require 'rack'
3
- require 'digest'
4
- require 'mack_ruby_core_extensions'
5
- require 'application_configuration'
6
- require 'cachetastic'
7
- require 'fileutils'
8
- require 'log4r'
9
- require 'crypt/rijndael'
10
- require 'singleton'
11
- require 'uri'
12
- require 'drb'
13
- require 'rinda/ring'
14
- require 'rinda/tuplespace'
15
- require 'builder'
16
- require 'erubis'
17
- require 'erb'
18
- require 'genosaurus'
19
-
20
- require File.join(File.dirname(__FILE__), "configuration.rb")
21
-
22
- unless Mack::Configuration.initialized
23
-
24
- puts "Starting application in #{Mack::Configuration.env} mode."
25
- puts "Mack root: #{Mack::Configuration.root}"
26
-
27
- require File.join(File.dirname(__FILE__), "initializers", "logging.rb")
28
-
29
- require File.join(File.dirname(__FILE__), "initializers", "orm_support.rb")
30
-
31
- fl = File.join(File.dirname(__FILE__), "..")
32
-
33
- # Require all the necessary files to make Mack actually work!
34
- ["distributed", "errors", "core_extensions", "utils", "test_extensions", "routing", "rendering", "sea_level", "tasks", "initialization/server", "generators"].each do |dir|
35
- dir_globs = Dir.glob(File.join(fl, dir, "**/*.rb"))
36
- dir_globs.each do |d|
37
- require d
38
- end
39
- end
40
-
41
-
42
-
43
- # ------------------------------------------------------------------------
44
-
45
- # set up application stuff:
46
-
47
- # set up routes:
48
- require File.join(Mack::Configuration.config_directory, "routes")
49
-
50
- # set up initializers:
51
- Dir.glob(File.join(Mack::Configuration.config_directory, "initializers", "**/*.rb")) do |d|
52
- require d
53
- end
54
- Mack::Utils::GemManager.instance.do_requires
55
-
56
- # require 'plugins':
57
- require File.join(File.dirname(__FILE__), "initializers", "plugins.rb")
58
-
59
- # make sure that default_controller is available to other controllers
60
- path = File.join(Mack::Configuration.app_directory, "controllers", "default_controller.rb")
61
- require path if File.exists?(path)
62
-
63
- # require 'app' files:
64
- Dir.glob(File.join(Mack::Configuration.app_directory, "**/*.rb")).each do |d|
65
- # puts "d: #{d}"
66
- begin
67
- require d
68
- rescue NameError => e
69
- if e.message.match("uninitialized constant")
70
- mod = e.message.gsub("uninitialized constant ", "")
71
- x =%{
72
- module ::#{mod}
73
- end
74
- }
75
- eval(x)
76
- require d
77
- else
78
- raise e
79
- end
80
- end
81
- end
82
-
83
- # require 'lib' files:
84
- Dir.glob(File.join(Mack::Configuration.lib_directory, "**/*.rb")).each do |d|
85
- require d
86
- end
87
-
88
-
89
- # ------------------------------------------------------------------------
90
-
91
- # Include ApplicationHelper into all controllers:
92
- if Object.const_defined?("ApplicationHelper")
93
- ApplicationHelper.include_safely_into(Mack::Controller::Base, Mack::ViewBinder)
94
- end
95
- # Find other Helpers and include them into their respective controllers.
96
- Object.constants.collect {|c| c if c.match(/Controller$/)}.compact.each do |cont|
97
- if Object.const_defined?("#{cont}Helper")
98
- h = "#{cont}Helper".constantize
99
- h.include_safely_into(cont, Mack::ViewBinder)
100
- end
101
- end
102
-
103
- # Find view level Helpers and include them into the Mack::ViewBinder
104
- Mack::ViewHelpers.constants.each do |cont|
105
- h = "Mack::ViewHelpers::#{cont}".constantize
106
- h.include_safely_into(Mack::ViewBinder)
107
- end
108
-
109
- Mack::Configuration.set(:initialized, "true") if Mack::Configuration.initialized.nil?
110
- end
@@ -1,62 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # This is the base class from which all rendering systems need to extend.
4
- #
5
- # Example:
6
- # class Mack::Rendering::Pdf < Mack::Rendering::Base
7
- # def render
8
- # # do work to render stuff as a PDF
9
- # end
10
- # end
11
- #
12
- # Now add this to the list of available render systems:
13
- # app_config.mack.rendering_systems << :pdf
14
- #
15
- # You should now be able to do this in your controller:
16
- #
17
- # class MyAwesomeController < Mack::Controller::Base
18
- # def pdf
19
- # render(:pdf => "my_pdf_template")
20
- # end
21
- # end
22
- class Base
23
-
24
- attr_accessor :view_binder # The Mack::ViewBinder that called this rendering system.
25
- attr_accessor :options # The options associated with this render call
26
-
27
- def initialize(view_binder, options)
28
- self.view_binder = view_binder
29
- self.options = {:parameters => {}}.merge(options)
30
- end
31
-
32
- # This is the only method that needs to be implemented by a rendering system.
33
- # It should return a String.
34
- needs_method :render
35
-
36
- # Maps to the view_binder's param method. See also Mack::ViewBinder params.
37
- def params(key)
38
- self.view_binder.params(key)
39
- end
40
-
41
- private
42
- # Used to render a file from disk.
43
- def render_file(f, options = {})
44
- options = {:is_partial => false, :ext => ".#{self.params(:format)}.erb", :dir => Mack::Configuration.views_directory}.merge(options)
45
- partial = f.to_s
46
- parts = partial.split("/")
47
- if parts.size == 1
48
- # it's local to this controller
49
- partial = "_" << partial if options[:is_partial]
50
- partial = File.join(options[:dir], self.view_binder.controller.controller_name, partial + options[:ext])
51
- else
52
- # it's elsewhere
53
- parts[parts.size - 1] = "_" << parts.last if options[:is_partial]
54
- partial = File.join(options[:dir], parts.join("/") + options[:ext])
55
- end
56
- raise Errno::ENOENT.new(partial) unless File.exists?(partial)
57
- return Mack::ViewBinder.render(File.open(partial).read, self.view_binder.controller, options)
58
- end
59
-
60
- end # Base
61
- end # Rendering
62
- end # Mack
@@ -1,26 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # Used when someone calls render(:action => "index")
4
- class Action < Base
5
-
6
- def render
7
- begin
8
- # Try to render the action:
9
- return render_file(options[:action], options)
10
- rescue Errno::ENOENT => e
11
- begin
12
- # If the action doesn't exist on disk, try to render it from the public directory:
13
- t = render_file(options[:action], {:dir => Mack::Configuration.public_directory, :ext => ".#{params(:format)}", :layout => false}.merge(options))
14
- # Because it's being served from public don't wrap a layout around it!
15
- # self.controller.instance_variable_get("@render_options").merge!({:layout => false})
16
- return t
17
- rescue Errno::ENOENT => ex
18
- end
19
- # Raise the original exception because something bad has happened!
20
- raise e
21
- end
22
- end
23
-
24
- end
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # Used when someone calls render(:partial => "latest_news")
4
- class Partial < Base
5
-
6
- def render
7
- render_file(options[:partial], {:is_partial => true}.merge(options))
8
- end
9
-
10
- end
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # Used when someone calls render(:public => "index")
4
- # This renders a file from the public directory.
5
- class Public < Base
6
-
7
- def render
8
- render_file(options[:public], {:dir => Mack::Configuration.public_directory, :ext => ".html", :layout => false}.merge(options))
9
- end
10
-
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # Used when someone calls render(:text => "Hello World!")
4
- class Text < Base
5
-
6
- def render
7
- Mack::ViewBinder.render(options[:text], self.view_binder.controller, options)
8
- end
9
-
10
- end
11
- end
12
- end
@@ -1,59 +0,0 @@
1
- require 'net/http'
2
- require File.join(File.dirname(__FILE__), "..", 'base')
3
- module Mack
4
- module Rendering
5
- # Used when someone calls render(:url => "http://www.mackframework.com")
6
- class Url < Base
7
-
8
- def render
9
- options = {:method => :get, :domain => app_config.mack.site_domain, :raise_exception => false}.merge(self.options)
10
- case options[:method]
11
- when :get
12
- do_render_url(options) do |uri, options|
13
- unless options[:parameters].empty?
14
- uri = uri.to_s
15
- uri << "?"
16
- options[:parameters].each_pair do |k,v|
17
- uri << URI.encode(k.to_s)
18
- uri << "="
19
- uri << URI.encode(v.to_s)
20
- uri << "&"
21
- end
22
- uri.gsub!(/&$/, "")
23
- uri = URI.parse(uri)
24
- end
25
- Net::HTTP.get_response(uri)
26
- end
27
- when :post
28
- do_render_url(options) do |uri, options|
29
- Net::HTTP.post_form(uri, options[:parameters] || {})
30
- end
31
- else
32
- raise Mack::Errors::UnsupportRenderUrlMethodType.new(options[:method])
33
- end
34
- end
35
-
36
- private
37
- def do_render_url(options)
38
- Timeout::timeout(app_config.mack.render_url_timeout || 5) do
39
- url = options[:url]
40
- unless url.match(/^[a-zA-Z]+:\/\//)
41
- url = File.join(options[:domain], options[:url])
42
- end
43
- uri = URI.parse(url)
44
- response = yield uri, options
45
- if response.code == "200"
46
- return response.body
47
- else
48
- if options[:raise_exception]
49
- raise Mack::Errors::UnsuccessfulRenderUrl.new(uri, response)
50
- else
51
- return ""
52
- end
53
- end
54
- end
55
- end
56
-
57
- end
58
- end
59
- end