mack 0.7.1.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/CHANGELOG +32 -0
  2. data/bin/gem_load_path.rb +1 -1
  3. data/bin/mackery +0 -1
  4. data/bin/mackery-server +5 -1
  5. data/lib/mack/assets/asset_helpers.rb +51 -0
  6. data/lib/mack/assets/assets_mgr.rb +165 -0
  7. data/lib/mack/controller/controller.rb +4 -4
  8. data/lib/mack/controller/cookie_jar.rb +1 -1
  9. data/lib/mack/controller/request.rb +13 -3
  10. data/lib/mack/controller/response.rb +12 -0
  11. data/lib/mack/core_extensions/kernel.rb +69 -0
  12. data/lib/mack/core_extensions/symbol.rb +4 -0
  13. data/lib/mack/errors/errors.rb +5 -1
  14. data/lib/mack/generators/controller_generator/manifest.yml +2 -2
  15. data/lib/mack/generators/controller_helper_generator/manifest.yml +2 -2
  16. data/lib/mack/generators/mack_application_generator/manifest.yml +10 -2
  17. data/lib/mack/generators/mack_application_generator/templates/config/{app_config/default.yml.template → configatron/default.rb.template} +10 -15
  18. data/lib/mack/generators/mack_application_generator/templates/config/{app_config/development.yml.template → configatron/development.rb.template} +1 -1
  19. data/lib/mack/generators/mack_application_generator/templates/config/{app_config/production.yml.template → configatron/production.rb.template} +0 -0
  20. data/lib/mack/generators/mack_application_generator/templates/config/{app_config/test.yml.template → configatron/test.rb.template} +1 -1
  21. data/lib/mack/generators/mack_application_generator/templates/public/404.html.template +15 -0
  22. data/lib/mack/generators/mack_application_generator/templates/public/500.html.template +15 -0
  23. data/lib/mack/generators/view_helper_generator/manifest.yml +2 -2
  24. data/lib/mack/initialization/application.rb +9 -5
  25. data/lib/mack/initialization/boot_loader.rb +2 -104
  26. data/lib/mack/initialization/configuration.rb +72 -69
  27. data/lib/mack/initialization/console.rb +1 -1
  28. data/lib/mack/initialization/helpers.rb +1 -6
  29. data/lib/mack/initialization/logging/basic_layout.rb +14 -0
  30. data/lib/mack/initialization/logging/color_layout.rb +23 -0
  31. data/lib/mack/initialization/logging/filter.rb +45 -0
  32. data/lib/mack/initialization/logging.rb +33 -89
  33. data/lib/mack/initialization/plugins.rb +1 -1
  34. data/lib/mack/rendering/engine/builder.rb +3 -0
  35. data/lib/mack/rendering/engine/erubis.rb +28 -16
  36. data/lib/mack/rendering/type/file_base.rb +1 -1
  37. data/lib/mack/rendering/type/url.rb +3 -3
  38. data/lib/mack/rendering/view_template.rb +4 -7
  39. data/lib/mack/routing/resource_proxy.rb +33 -0
  40. data/lib/mack/routing/route_map.rb +122 -288
  41. data/lib/mack/routing/route_object.rb +88 -0
  42. data/lib/mack/routing/routes.rb +169 -0
  43. data/lib/mack/routing/urls.rb +39 -5
  44. data/lib/mack/runner.rb +65 -32
  45. data/lib/mack/runner_helpers/request_logger.rb +3 -3
  46. data/lib/mack/runner_helpers/session.rb +4 -4
  47. data/lib/mack/sessions/cookie_session_store.rb +3 -3
  48. data/lib/mack/sessions/session.rb +1 -1
  49. data/lib/mack/sessions/session_store_base.rb +1 -1
  50. data/lib/mack/tasks/gem_tasks.rake +156 -1
  51. data/lib/mack/tasks/mack_dump_tasks.rake +1 -1
  52. data/lib/mack/tasks/mack_update_tasks.rake +85 -1
  53. data/lib/mack/tasks/rake_rules.rake +6 -0
  54. data/lib/mack/tasks/test_tasks.rake +4 -4
  55. data/lib/mack/testing/helpers.rb +13 -6
  56. data/lib/mack/testing/rspec.rb +27 -9
  57. data/lib/mack/testing/test_case.rb +1 -1
  58. data/lib/mack/utils/ansi/ansi_color.rb +4 -1
  59. data/lib/mack/utils/forgery_detector.rb +3 -3
  60. data/lib/mack/utils/http_status_codes.rb +19 -0
  61. data/lib/mack/utils/http_status_codes.yml +55 -0
  62. data/lib/mack/utils/paths.rb +32 -32
  63. data/lib/mack/utils/reloader.rb +60 -0
  64. data/lib/mack/utils/server.rb +3 -3
  65. data/lib/mack/version.rb +1 -1
  66. data/lib/mack/view_helpers/all_helpers.rb +7 -0
  67. data/lib/mack/view_helpers/date_time_helpers.rb +16 -10
  68. data/lib/mack/view_helpers/form_helpers.rb +1 -1
  69. data/lib/mack/view_helpers/html_helpers.rb +22 -1
  70. data/lib/mack/view_helpers/link_helpers.rb +51 -10
  71. data/lib/mack/view_helpers/string_helpers.rb +1 -1
  72. data/lib/mack.rb +0 -1
  73. data/lib/mack_core.rb +8 -8
  74. data/lib/mack_tasks.rb +1 -1
  75. metadata +27 -15
  76. data/lib/mack/view_helpers/asset_helpers.rb +0 -50
@@ -3,18 +3,24 @@ module Mack
3
3
  module FormHelpers
4
4
 
5
5
  MONTHS = [["January", 1], ["February", 2], ["March", 3], ["April", 4], ["May", 5], ["June", 6], ["July", 7], ["August", 8],
6
- ["September", 9], ["October", 10], ["November", 11], ["December", 12]]
7
- DAYS = []
8
- 1.upto(31) do |m|
9
- DAYS << [(m < 10 ? "0#{m}" : m), m]
6
+ ["September", 9], ["October", 10], ["November", 11], ["December", 12]] unless defined?(MONTHS)
7
+ unless defined?(DAYS)
8
+ DAYS = []
9
+ 1.upto(31) do |m|
10
+ DAYS << [(m < 10 ? "0#{m}" : m), m]
11
+ end
10
12
  end
11
- HOURS = []
12
- 1.upto(24) do |h|
13
- HOURS << [(h < 10 ? "0#{h}" : h), h]
13
+ unless defined?(HOURS)
14
+ HOURS = []
15
+ 1.upto(24) do |h|
16
+ HOURS << [(h < 10 ? "0#{h}" : h), h]
17
+ end
14
18
  end
15
- MINUTES = []
16
- 1.upto(59) do |m|
17
- MINUTES << [(m < 10 ? "0#{m}" : m), m]
19
+ unless defined?(MINUTES)
20
+ MINUTES = []
21
+ 1.upto(59) do |m|
22
+ MINUTES << [(m < 10 ? "0#{m}" : m), m]
23
+ end
18
24
  end
19
25
 
20
26
  # This will create a series of select boxes that compromise a time object. By default boxes will be
@@ -44,7 +44,7 @@ module Mack
44
44
  end
45
45
  concat("<form#{build_options(options)}>\n", block.binding)
46
46
  concat(meth, block.binding) unless meth.blank?
47
- concat(form_authenticity_field, block.binding) if !app_config.mack.disable_forgery_detector
47
+ concat(form_authenticity_field, block.binding) unless configatron.mack.disable_forgery_detector
48
48
  yield
49
49
  concat("\n</form>", block.binding)
50
50
  # content_tag(:form, options, &block)
@@ -1,7 +1,7 @@
1
1
  module Mack
2
2
  module ViewHelpers # :nodoc:
3
3
  module HtmlHelpers
4
-
4
+
5
5
  # Builds an HTML tag.
6
6
  #
7
7
  # Examples:
@@ -28,6 +28,7 @@ module Mack
28
28
 
29
29
  # Builds a HTML image tag.
30
30
  def img(image_src, options = {})
31
+ image_src = "#{get_resource_root(image_src)}#{image_src}?#{configatron.mack.assets.stamp}"
31
32
  non_content_tag(:img, {:src => image_src}.merge(options))
32
33
  end
33
34
 
@@ -37,6 +38,18 @@ module Mack
37
38
  "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"#{url}\">"
38
39
  end
39
40
 
41
+ def google_analytics(id)
42
+ %{
43
+ <script type="text/javascript">
44
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
45
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
46
+ </script>
47
+ <script type="text/javascript">
48
+ var pageTracker = _gat._getTracker("#{id}");
49
+ pageTracker._trackPageview();
50
+ </script>}.strip
51
+ end
52
+
40
53
  private
41
54
  def build_options(options)
42
55
  if options[:disabled]
@@ -49,6 +62,14 @@ module Mack
49
62
  opts
50
63
  end
51
64
 
65
+ def get_resource_root(resource)
66
+ path = ""
67
+ path = "#{configatron.mack.distributed.site_domain}" unless configatron.mack.distributed.site_domain.nil?
68
+ path = Mack::Assets::Helpers.instance.asset_hosts(resource) if path.empty?
69
+ return path
70
+ end
71
+
72
+
52
73
  end # HtmlHelpers
53
74
  end # ViewHelpers
54
75
  end # Mack
@@ -47,6 +47,25 @@ module Mack
47
47
  a(link_text, options)
48
48
  end
49
49
 
50
+ # If the current page matches the link requested, then it will only return the text.
51
+ # If the current page does not match the link requested then link_to is call.
52
+ def link_unless_current(text, link = text, options = {})
53
+ link_to_unless((link == request.fullpath), text, link, options)
54
+ end
55
+
56
+ # Only creates a link if the expression is true, otherwise, it passes back the text.
57
+ def link_to_if(expr, text, link = text, options = {})
58
+ if expr
59
+ return link_to(text, link, options)
60
+ end
61
+ return text
62
+ end
63
+
64
+ # Only creates a link unless the expression is true, otherwise, it passes back the text.
65
+ def link_to_unless(expr, text, link = text, options = {})
66
+ link_to_if(!expr, text, link, options)
67
+ end
68
+
50
69
  # Used in views to create href links. It takes link_text, url, and a Hash that gets added
51
70
  # to the href as options.
52
71
  #
@@ -122,14 +141,15 @@ module Mack
122
141
  #
123
142
  # If distributed_site_domain is specified, it will be used.
124
143
  #
125
- def javascript(files)
144
+ def javascript(files, options = {})
126
145
  files = [files].flatten
127
-
146
+ files = resolve_bundle('javascripts', files)
147
+
128
148
  link = ""
129
149
  files.each do |name|
130
150
  file_name = !name.to_s.end_with?(".js") ? "#{name}.js" : "#{name}"
131
151
  resource = "/javascripts/#{file_name}"
132
- link += "<script src=\"#{get_resource_root(resource)}#{resource}?#{Time.now.to_i}\" type=\"text/javascript\"></script>\n"
152
+ link += "<script src=\"#{get_resource_root(resource)}#{resource}?#{configatron.mack.assets.stamp}\" type=\"text/javascript\"></script>\n"
133
153
  end
134
154
  return link
135
155
  end
@@ -148,26 +168,47 @@ module Mack
148
168
  #
149
169
  def stylesheet(files, options = {})
150
170
  files = [files].flatten
171
+ files = resolve_bundle('stylesheets', files)
151
172
  options = {:media => 'screen', :rel => 'stylesheet', :type => 'text/css'}.merge(options)
152
173
 
153
174
  link = ""
154
175
  files.each do |name|
155
176
  file_name = !name.to_s.end_with?(".css") ? "#{name}.css" : "#{name}"
156
177
  resource = "/stylesheets/#{file_name}"
157
- link += "<link href=\"#{get_resource_root(resource)}#{resource}\" media=\"#{options[:media]}\" rel=\"#{options[:rel]}\" type=\"#{options[:type]}\" />\n"
178
+ link += "<link href=\"#{get_resource_root(resource)}#{resource}?#{configatron.mack.assets.stamp}\" media=\"#{options[:media]}\" rel=\"#{options[:rel]}\" type=\"#{options[:type]}\" />\n"
158
179
  end
159
180
 
160
181
  return link
161
182
  end
162
183
 
163
- private
164
- def get_resource_root(resource)
165
- path = ""
166
- path = "#{app_config.mack.distributed_site_domain}" if app_config.mack.distributed_site_domain
167
- path = Mack::AssetHelpers.instance.asset_hosts(resource) if path.empty?
168
- return path
184
+ def assets_bundle(names)
185
+ names = [names].flatten
186
+ names.collect { |s| s.to_s }
187
+ arr = []
188
+ names.each do |name|
189
+ arr << javascript(name) if assets_mgr.has_group?(name, :javascripts)
190
+ arr << stylesheet(name) if assets_mgr.has_group?(name, :stylesheets)
191
+ end
192
+ return arr.join("\n")
169
193
  end
170
194
 
195
+ private
196
+
197
+ def resolve_bundle(asset_type, sources)
198
+ groups = assets_mgr.groups_by_asset_type(asset_type)
199
+ sources.collect! { |s| s.to_s }
200
+ groups.collect! { |s| s.to_s }
201
+
202
+ groups.each do |group|
203
+ if sources.include?(group)
204
+ sources = sources[0..(sources.index(group))] +
205
+ assets_mgr.send(asset_type, group) +
206
+ sources[(sources.index(group) + 1)..sources.length]
207
+ sources.delete(group)
208
+ end
209
+ end
210
+ return sources
211
+ end
171
212
  end # LinkHelpers
172
213
  end # ViewHelpers
173
214
  end # Mack
@@ -56,7 +56,7 @@ module Mack
56
56
  end
57
57
  end
58
58
 
59
- alias_method :s, :sanitize_html
59
+ alias_instance_method :sanitize_html, :s
60
60
 
61
61
  end # StringHelpers
62
62
  end # ViewHelpers
data/lib/mack.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # require the core classes:
2
2
 
3
3
  # puts "Loading mack from: #{File.dirname(__FILE__)}"
4
-
5
4
  require File.join(File.dirname(__FILE__), 'mack_core')
6
5
 
7
6
  # load the environment:
data/lib/mack_core.rb CHANGED
@@ -3,8 +3,7 @@ require 'rack'
3
3
  require 'digest'
4
4
  require 'mack-facets'
5
5
  require 'mack-encryption'
6
- require 'application_configuration'
7
- require 'cachetastic'
6
+ require 'configatron'
8
7
  require 'fileutils'
9
8
  require 'log4r'
10
9
  require 'singleton'
@@ -18,7 +17,8 @@ require 'erb'
18
17
  require 'genosaurus'
19
18
  require 'net/http'
20
19
  require 'pp'
21
- require 'test/unit'
20
+ require 'test/unit'
21
+ require 'thread'
22
22
  begin
23
23
  # just in case people don't have it installed.
24
24
  require 'ruby-debug'
@@ -40,19 +40,19 @@ boot_load(:paths) do
40
40
  end
41
41
 
42
42
  boot_load(:gems) do
43
- Mack.logger.debug "Initializing custom gems..." unless app_config.log.disable_initialization_logging
43
+ Mack.logger.debug "Initializing custom gems..." unless configatron.mack.log.disable_initialization_logging
44
44
  load Mack::Paths.initializers("gems.rb")
45
45
  Mack::Utils::GemManager.instance.do_requires
46
46
  end
47
47
 
48
48
  boot_load(:core_classes) do
49
- Mack.logger.debug "Initializing core classes..." unless app_config.log.disable_initialization_logging
49
+ Mack.logger.debug "Initializing core classes..." unless configatron.mack.log.disable_initialization_logging
50
50
  # Require all the necessary files to make Mack actually work!
51
- lib_dirs = ["errors", "core_extensions", "utils", "sessions", "runner_helpers", "routing", "view_helpers", "rendering", "controller", "tasks", "initialization/server", "generators", "distributed"]
51
+ lib_dirs = ["assets", "errors", "core_extensions", "utils", "sessions", "runner_helpers", "routing", "view_helpers", "rendering", "controller", "tasks", "initialization/server", "generators", "distributed"]
52
52
  lib_dirs << "testing"# if Mack.env == "test"
53
53
  lib_dirs.each do |dir|
54
54
  dir_globs = Dir.glob(File.join(File.dirname(__FILE__), "mack", dir, "**/*.rb"))
55
- dir_globs.each do |d|
55
+ dir_globs.sort.each do |d|
56
56
  require d unless d.match(/console/)
57
57
  end
58
58
  end
@@ -63,7 +63,7 @@ boot_load(:runner) do
63
63
  end
64
64
 
65
65
  boot_load(:load_mack_core, :version, :paths, :configuration, :logging, :core_classes, :gems) do
66
- Mack.logger.debug "Initialization of Mack Core finished." unless app_config.log.disable_initialization_logging
66
+ Mack.logger.debug "Initialization of Mack Core finished." unless configatron.mack.log.disable_initialization_logging
67
67
  end
68
68
 
69
69
  Mack::BootLoader.run(:load_mack_core)
data/lib/mack_tasks.rb CHANGED
@@ -4,7 +4,7 @@ require 'rake/rdoctask'
4
4
  require 'fileutils'
5
5
  require 'rubygems'
6
6
  require 'mack-facets'
7
- require 'application_configuration'
7
+ require 'configatron'
8
8
 
9
9
  fl = File.join(File.dirname(__FILE__), 'mack')
10
10
 
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.7.1.1
4
+ version: 0.8.0
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-09-14 00:00:00 -04:00
12
+ date: 2008-10-06 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,27 +30,27 @@ dependencies:
30
30
  requirements:
31
31
  - - "="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.1.1
33
+ version: 0.8.0
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: application_configuration
36
+ name: configatron
37
37
  type: :runtime
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.5.3
43
+ version: 2.1.4
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
- name: log4r
46
+ name: logging
47
47
  type: :runtime
48
48
  version_requirement:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.0.5
53
+ version: 0.9.4
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thin
@@ -60,7 +60,7 @@ dependencies:
60
60
  requirements:
61
61
  - - "="
62
62
  - !ruby/object:Gem::Version
63
- version: 0.8.2
63
+ version: 1.0.0
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: builder
@@ -120,7 +120,7 @@ dependencies:
120
120
  requirements:
121
121
  - - "="
122
122
  - !ruby/object:Gem::Version
123
- version: 1.1.4
123
+ version: 1.1.8
124
124
  version:
125
125
  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.
126
126
  email: mark@mackframework.com
@@ -136,6 +136,8 @@ extra_rdoc_files:
136
136
  - CHANGELOG
137
137
  files:
138
138
  - README
139
+ - lib/mack/assets/asset_helpers.rb
140
+ - lib/mack/assets/assets_mgr.rb
139
141
  - lib/mack/controller/all_helpers.rb
140
142
  - lib/mack/controller/controller.rb
141
143
  - lib/mack/controller/cookie_jar.rb
@@ -164,15 +166,17 @@ files:
164
166
  - lib/mack/generators/mack_application_generator/templates/app/helpers/views/application_helper.rb.template
165
167
  - lib/mack/generators/mack_application_generator/templates/app/views/default/index.html.erb.template
166
168
  - lib/mack/generators/mack_application_generator/templates/app/views/layouts/application.html.erb.template
167
- - lib/mack/generators/mack_application_generator/templates/config/app_config/default.yml.template
168
- - lib/mack/generators/mack_application_generator/templates/config/app_config/development.yml.template
169
- - lib/mack/generators/mack_application_generator/templates/config/app_config/production.yml.template
170
- - lib/mack/generators/mack_application_generator/templates/config/app_config/test.yml.template
169
+ - lib/mack/generators/mack_application_generator/templates/config/configatron/default.rb.template
170
+ - lib/mack/generators/mack_application_generator/templates/config/configatron/development.rb.template
171
+ - lib/mack/generators/mack_application_generator/templates/config/configatron/production.rb.template
172
+ - lib/mack/generators/mack_application_generator/templates/config/configatron/test.rb.template
171
173
  - lib/mack/generators/mack_application_generator/templates/config/database.yml.template
172
174
  - lib/mack/generators/mack_application_generator/templates/config/initializers/gems.rb.template
173
175
  - lib/mack/generators/mack_application_generator/templates/config/initializers/inflections.rb.template
174
176
  - lib/mack/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template
175
177
  - lib/mack/generators/mack_application_generator/templates/config/routes.rb.template
178
+ - lib/mack/generators/mack_application_generator/templates/public/404.html.template
179
+ - lib/mack/generators/mack_application_generator/templates/public/500.html.template
176
180
  - lib/mack/generators/mack_application_generator/templates/public/favicon.ico.template
177
181
  - lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template
178
182
  - lib/mack/generators/mack_application_generator/templates/Rakefile.template
@@ -204,6 +208,9 @@ files:
204
208
  - lib/mack/initialization/console.rb
205
209
  - lib/mack/initialization/environment.rb
206
210
  - lib/mack/initialization/helpers.rb
211
+ - lib/mack/initialization/logging/basic_layout.rb
212
+ - lib/mack/initialization/logging/color_layout.rb
213
+ - lib/mack/initialization/logging/filter.rb
207
214
  - lib/mack/initialization/logging.rb
208
215
  - lib/mack/initialization/plugins.rb
209
216
  - lib/mack/initialization/server/simple_server.rb
@@ -223,7 +230,10 @@ files:
223
230
  - lib/mack/rendering/type/url.rb
224
231
  - lib/mack/rendering/type/xml.rb
225
232
  - lib/mack/rendering/view_template.rb
233
+ - lib/mack/routing/resource_proxy.rb
226
234
  - lib/mack/routing/route_map.rb
235
+ - lib/mack/routing/route_object.rb
236
+ - lib/mack/routing/routes.rb
227
237
  - lib/mack/routing/urls.rb
228
238
  - lib/mack/runner.rb
229
239
  - lib/mack/runner_helpers/base.rb
@@ -255,13 +265,15 @@ files:
255
265
  - lib/mack/utils/content_length_handler.rb
256
266
  - lib/mack/utils/forgery_detector.rb
257
267
  - lib/mack/utils/gem_manager.rb
268
+ - lib/mack/utils/http_status_codes.rb
269
+ - lib/mack/utils/http_status_codes.yml
258
270
  - lib/mack/utils/mime_types.rb
259
271
  - lib/mack/utils/mime_types.yml
260
272
  - lib/mack/utils/paths.rb
273
+ - lib/mack/utils/reloader.rb
261
274
  - lib/mack/utils/server.rb
262
275
  - lib/mack/version.rb
263
276
  - lib/mack/view_helpers/all_helpers.rb
264
- - lib/mack/view_helpers/asset_helpers.rb
265
277
  - lib/mack/view_helpers/date_time_helpers.rb
266
278
  - lib/mack/view_helpers/form_helpers.rb
267
279
  - lib/mack/view_helpers/html_helpers.rb
@@ -305,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
317
  requirements: []
306
318
 
307
319
  rubyforge_project: magrathea
308
- rubygems_version: 1.2.0
320
+ rubygems_version: 1.3.0
309
321
  signing_key:
310
322
  specification_version: 2
311
323
  summary: Mack is a powerful, yet simple, web application framework.
@@ -1,50 +0,0 @@
1
- module Mack
2
- class AssetHelpers # :nodoc:
3
- include Singleton
4
-
5
- #
6
- # Set the asset hosts for this app. It supports the following format:
7
- # - plain string: the string literal will be considered as the asset hosts (e.g. 'http://assets.foo.com')
8
- # - formatted string: to support asset host distribution (e.g. 'http://asset%d.foo.com')
9
- # - a proc object: to support custom asset hosts generation (e.g. Proc.new { |source| 'assets.foo.com' }
10
- #
11
- # The max number of distribution can be set from app_config's asset_hosts_max_distribution.
12
- # The default value is 4
13
- #
14
- def asset_hosts=(host)
15
- @hosts = host
16
- end
17
-
18
- #
19
- # Return the max number of asset hosts distribution
20
- #
21
- def max_distribution
22
- return app_config.asset_hosts_max_distribution.to_i || 4
23
- end
24
-
25
- #
26
- # Return the asset hosts for this application.
27
- #
28
- def asset_hosts(source = '')
29
- ret_val = ''
30
-
31
- # if no explicit asset_host setting, then use the one defined in app_config (if exists)
32
- host = @hosts || app_config.asset_hosts
33
- host = '' if host.nil?
34
-
35
- if host.kind_of?(Proc)
36
- ret_val = host.call(source)
37
- else
38
- ret_val = sprintf(host, rand(max_distribution))
39
- end
40
- return ret_val
41
- end
42
-
43
- #
44
- # Clear previously set configuration for asset hosts
45
- #
46
- def reset!
47
- @hosts = nil
48
- end
49
- end
50
- end