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.
- data/CHANGELOG +32 -0
- data/bin/gem_load_path.rb +1 -1
- data/bin/mackery +0 -1
- data/bin/mackery-server +5 -1
- data/lib/mack/assets/asset_helpers.rb +51 -0
- data/lib/mack/assets/assets_mgr.rb +165 -0
- data/lib/mack/controller/controller.rb +4 -4
- data/lib/mack/controller/cookie_jar.rb +1 -1
- data/lib/mack/controller/request.rb +13 -3
- data/lib/mack/controller/response.rb +12 -0
- data/lib/mack/core_extensions/kernel.rb +69 -0
- data/lib/mack/core_extensions/symbol.rb +4 -0
- data/lib/mack/errors/errors.rb +5 -1
- data/lib/mack/generators/controller_generator/manifest.yml +2 -2
- data/lib/mack/generators/controller_helper_generator/manifest.yml +2 -2
- data/lib/mack/generators/mack_application_generator/manifest.yml +10 -2
- data/lib/mack/generators/mack_application_generator/templates/config/{app_config/default.yml.template → configatron/default.rb.template} +10 -15
- data/lib/mack/generators/mack_application_generator/templates/config/{app_config/development.yml.template → configatron/development.rb.template} +1 -1
- data/lib/mack/generators/mack_application_generator/templates/config/{app_config/production.yml.template → configatron/production.rb.template} +0 -0
- data/lib/mack/generators/mack_application_generator/templates/config/{app_config/test.yml.template → configatron/test.rb.template} +1 -1
- data/lib/mack/generators/mack_application_generator/templates/public/404.html.template +15 -0
- data/lib/mack/generators/mack_application_generator/templates/public/500.html.template +15 -0
- data/lib/mack/generators/view_helper_generator/manifest.yml +2 -2
- data/lib/mack/initialization/application.rb +9 -5
- data/lib/mack/initialization/boot_loader.rb +2 -104
- data/lib/mack/initialization/configuration.rb +72 -69
- data/lib/mack/initialization/console.rb +1 -1
- data/lib/mack/initialization/helpers.rb +1 -6
- data/lib/mack/initialization/logging/basic_layout.rb +14 -0
- data/lib/mack/initialization/logging/color_layout.rb +23 -0
- data/lib/mack/initialization/logging/filter.rb +45 -0
- data/lib/mack/initialization/logging.rb +33 -89
- data/lib/mack/initialization/plugins.rb +1 -1
- data/lib/mack/rendering/engine/builder.rb +3 -0
- data/lib/mack/rendering/engine/erubis.rb +28 -16
- data/lib/mack/rendering/type/file_base.rb +1 -1
- data/lib/mack/rendering/type/url.rb +3 -3
- data/lib/mack/rendering/view_template.rb +4 -7
- data/lib/mack/routing/resource_proxy.rb +33 -0
- data/lib/mack/routing/route_map.rb +122 -288
- data/lib/mack/routing/route_object.rb +88 -0
- data/lib/mack/routing/routes.rb +169 -0
- data/lib/mack/routing/urls.rb +39 -5
- data/lib/mack/runner.rb +65 -32
- data/lib/mack/runner_helpers/request_logger.rb +3 -3
- data/lib/mack/runner_helpers/session.rb +4 -4
- data/lib/mack/sessions/cookie_session_store.rb +3 -3
- data/lib/mack/sessions/session.rb +1 -1
- data/lib/mack/sessions/session_store_base.rb +1 -1
- data/lib/mack/tasks/gem_tasks.rake +156 -1
- data/lib/mack/tasks/mack_dump_tasks.rake +1 -1
- data/lib/mack/tasks/mack_update_tasks.rake +85 -1
- data/lib/mack/tasks/rake_rules.rake +6 -0
- data/lib/mack/tasks/test_tasks.rake +4 -4
- data/lib/mack/testing/helpers.rb +13 -6
- data/lib/mack/testing/rspec.rb +27 -9
- data/lib/mack/testing/test_case.rb +1 -1
- data/lib/mack/utils/ansi/ansi_color.rb +4 -1
- data/lib/mack/utils/forgery_detector.rb +3 -3
- data/lib/mack/utils/http_status_codes.rb +19 -0
- data/lib/mack/utils/http_status_codes.yml +55 -0
- data/lib/mack/utils/paths.rb +32 -32
- data/lib/mack/utils/reloader.rb +60 -0
- data/lib/mack/utils/server.rb +3 -3
- data/lib/mack/version.rb +1 -1
- data/lib/mack/view_helpers/all_helpers.rb +7 -0
- data/lib/mack/view_helpers/date_time_helpers.rb +16 -10
- data/lib/mack/view_helpers/form_helpers.rb +1 -1
- data/lib/mack/view_helpers/html_helpers.rb +22 -1
- data/lib/mack/view_helpers/link_helpers.rb +51 -10
- data/lib/mack/view_helpers/string_helpers.rb +1 -1
- data/lib/mack.rb +0 -1
- data/lib/mack_core.rb +8 -8
- data/lib/mack_tasks.rb +1 -1
- metadata +27 -15
- data/lib/mack/view_helpers/asset_helpers.rb +0 -50
data/CHANGELOG
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
=== 0.8.0
|
2
|
+
* [#187] Fixed: When an exception is raised, the request doesn't get 'logged'
|
3
|
+
* [#185] Fixed: .html is being appended to logged requests when there's a 404
|
4
|
+
* [#184] Request logging should also print the message of the status code
|
5
|
+
* [#183] Updates to asset mgr/host
|
6
|
+
* [#181] Content-type can now be set with calling render.
|
7
|
+
* [#179] When configatron.mack.show_exceptions is false you now either the public/404.html or public/500.html file.
|
8
|
+
* [#178] Added a configure parameter to turn off log coloring
|
9
|
+
* [#176] Added a Google Analytics helper.
|
10
|
+
* [#175] Generating urls should use host or scheme if defined
|
11
|
+
* [#171] Ability to extend resources in routes
|
12
|
+
* [#170] Regex support in routes
|
13
|
+
* [#169] Proc support for Routes
|
14
|
+
* [#168] Fixed ERB errors not being reported correctly.
|
15
|
+
* [#167] Rake task to convert app config yamls to configatron
|
16
|
+
* [#165] Asset Packager
|
17
|
+
* [#164] Response helper for 'attachments'
|
18
|
+
* [#159] Added link_unless_current and link_if helpers
|
19
|
+
* [#156] Added 'Wildcard' Routes support
|
20
|
+
* [#152] INCOMPATIBILITY NOTICE: Removed deprecated support for delivered_emails use delivered_notifiers instead.
|
21
|
+
* [#138] Added support for 'host' & 'scheme' parameters in routes
|
22
|
+
* [#135] Replaced log4r with logging gem.
|
23
|
+
* [#119] Freeze gems
|
24
|
+
* [#106] INCOMPATIBILITY NOTICE: Removed deprecated support for droute_url
|
25
|
+
* [#93] INCOMPATIBILITY NOTICE: Removed deprecated support for 'top' level ApplicationHelper
|
26
|
+
* [#23] INCOMPATIBILITY NOTICE: Removed support for application_configuration and added support for configatron
|
27
|
+
* gem: logging 0.9.4
|
28
|
+
* gem: thin 1.0.0
|
29
|
+
* gem: rspec 1.1.8
|
30
|
+
* gem: configatron 2.1.4
|
31
|
+
* gem: cachetastic 2.0.0
|
32
|
+
|
1
33
|
=== 0.7.1.1
|
2
34
|
* [#163] Fixed jQuery code is being generated with double quotes instead of single quotes
|
3
35
|
* [#162] Fixed View helpers for mack-javascript aren't being required
|
data/bin/gem_load_path.rb
CHANGED
@@ -5,7 +5,7 @@ vendor_path = File.join(FileUtils.pwd, 'vendor')
|
|
5
5
|
|
6
6
|
mack_path = File.join(vendor_path, 'framework', 'mack', 'lib')
|
7
7
|
mack_more_path = File.join(vendor_path, 'framework', 'mack-more')
|
8
|
-
|
8
|
+
gem_path = File.join(vendor_path, 'gems')
|
9
9
|
|
10
10
|
if File.exists?(mack_path)
|
11
11
|
$:.insert(0, File.expand_path(mack_path))
|
data/bin/mackery
CHANGED
data/bin/mackery-server
CHANGED
@@ -10,6 +10,11 @@ require 'rubygems'
|
|
10
10
|
require 'fileutils'
|
11
11
|
require 'thin'
|
12
12
|
|
13
|
+
module Rack
|
14
|
+
ADAPTERS[:mack] = 'config/configatron/default.rb' if ADAPTERS.is_a?(Hash)
|
15
|
+
ADAPTERS << [:mack, 'config/configatron/default.rb'] if ADAPTERS.is_a?(Array)
|
16
|
+
end
|
17
|
+
|
13
18
|
require 'mack'
|
14
19
|
|
15
20
|
handler = "thin"
|
@@ -30,7 +35,6 @@ if handler == "thin"
|
|
30
35
|
thin_opts << "start"
|
31
36
|
end
|
32
37
|
thin_opts << ARGV
|
33
|
-
# puts "thin_opts: #{thin_opts.flatten.inspect}"
|
34
38
|
Thin::Runner.new(thin_opts.flatten.reject{|a| a.match(/^_[\d\.]+_$/)}).run!
|
35
39
|
else
|
36
40
|
port = 3000
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Mack
|
2
|
+
module Assets
|
3
|
+
class Helpers # :nodoc:
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
#
|
7
|
+
# Set the asset hosts for this app. It supports the following format:
|
8
|
+
# - plain string: the string literal will be considered as the asset hosts (e.g. 'http://assets.foo.com')
|
9
|
+
# - formatted string: to support asset host distribution (e.g. 'http://asset%d.foo.com')
|
10
|
+
# - a proc object: to support custom asset hosts generation (e.g. Proc.new { |source| 'assets.foo.com' }
|
11
|
+
#
|
12
|
+
# The max number of distribution can be set from configatron.mack.assets.max_distribution.
|
13
|
+
# The default value is 4
|
14
|
+
#
|
15
|
+
def asset_hosts=(host)
|
16
|
+
@hosts = host
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Return the max number of asset hosts distribution
|
21
|
+
#
|
22
|
+
def max_distribution
|
23
|
+
return configatron.mack.assets.max_distribution
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Return the asset hosts for this application.
|
28
|
+
#
|
29
|
+
def asset_hosts(source = '')
|
30
|
+
ret_val = ''
|
31
|
+
|
32
|
+
# if no explicit asset_host setting, then use the one defined in configatron (if exists)
|
33
|
+
host = @hosts || (configatron.mack.assets.hosts.nil? ? '' : configatron.mack.assets.hosts)
|
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
|
51
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module Mack
|
2
|
+
module Assets
|
3
|
+
class Bundle # :nodoc:
|
4
|
+
attr_accessor :data
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def initialize(bundle_name)
|
8
|
+
self.name = bundle_name
|
9
|
+
self.data = {:javascripts => [], :stylesheets => []}
|
10
|
+
end
|
11
|
+
|
12
|
+
def assets(asset_type)
|
13
|
+
self.data[asset_type]
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Add javascript file(s) to the group/bundle
|
18
|
+
#
|
19
|
+
def add_js(files)
|
20
|
+
return add_data(files, :javascripts, '.js')
|
21
|
+
end
|
22
|
+
alias_method :javascript, :add_js
|
23
|
+
|
24
|
+
def remove_js(files)
|
25
|
+
files = [files].flatten
|
26
|
+
self.data[:javascripts] -= files
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Add stylesheet file(s) to the group/bundle
|
31
|
+
#
|
32
|
+
def add_css(files)
|
33
|
+
return add_data(files, :stylesheets, '.css')
|
34
|
+
end
|
35
|
+
alias_method :stylesheet, :add_css
|
36
|
+
|
37
|
+
def remove_css(files)
|
38
|
+
files = [files].flatten
|
39
|
+
self.data[:stylesheets] -= files
|
40
|
+
end
|
41
|
+
|
42
|
+
def reset!(type = :all)
|
43
|
+
if type == :all
|
44
|
+
self.data.keys.each do |key|
|
45
|
+
self.data[key].clear
|
46
|
+
end
|
47
|
+
else
|
48
|
+
self.data[type].clear if self.data[type]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def add_data(data, type, file_type)
|
54
|
+
data = [data].flatten
|
55
|
+
data.each do |elt|
|
56
|
+
elt = elt.to_s
|
57
|
+
elt += file_type if !elt.end_with?(file_type)
|
58
|
+
self.data[type.to_sym] << elt
|
59
|
+
end
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Like the name suggests, this object will manage
|
67
|
+
# assets (i.e. scripts and stylesheets) used in a mack application.
|
68
|
+
# Developer will be able to use the manager to create
|
69
|
+
# assets groups, and refer them later in the erb file.
|
70
|
+
# <br>
|
71
|
+
# There's a convenient method available, called assets_mgr.
|
72
|
+
# Application should use that method to create new bundle, and to access
|
73
|
+
# defined bundles.
|
74
|
+
# <br>
|
75
|
+
# Example:
|
76
|
+
# # This will create new bundle called foo
|
77
|
+
# assets_mgr.foo do |a|
|
78
|
+
# a.add_js "foo"
|
79
|
+
# a.add_css "bar"
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# Note that nested group is not supported.
|
83
|
+
#
|
84
|
+
class Manager
|
85
|
+
include Singleton
|
86
|
+
|
87
|
+
def initialize # :nodoc:
|
88
|
+
@bundles = {}
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Clear the defined assets
|
93
|
+
#
|
94
|
+
def reset!
|
95
|
+
@bundles.clear
|
96
|
+
end
|
97
|
+
|
98
|
+
def method_missing(sym, *args, &block) # :nodoc:
|
99
|
+
if @bundles.has_key?(sym.to_s)
|
100
|
+
bundle = @bundles[sym.to_s]
|
101
|
+
else
|
102
|
+
bundle = Mack::Assets::Bundle.new(sym.to_s)
|
103
|
+
@bundles[sym.to_s] = bundle
|
104
|
+
end
|
105
|
+
if block_given?
|
106
|
+
yield bundle
|
107
|
+
end
|
108
|
+
return bundle
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# return all groups defined for both javascript and stylesheets
|
113
|
+
#
|
114
|
+
def groups
|
115
|
+
@bundles.keys
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# Return all groups defined by specified asset type
|
120
|
+
#
|
121
|
+
# <i>Params:</i>
|
122
|
+
# type -- asset type (can be either :javascript or :stylesheet)
|
123
|
+
def groups_by_asset_type(type)
|
124
|
+
arr = []
|
125
|
+
groups.each do |group|
|
126
|
+
arr << group if !@bundles[group.to_s].assets(type.to_sym).empty?
|
127
|
+
end
|
128
|
+
return arr
|
129
|
+
end
|
130
|
+
|
131
|
+
def has_group?(group, asset_type = nil)
|
132
|
+
if asset_type
|
133
|
+
return groups_by_asset_type(asset_type).include?(group.to_s)
|
134
|
+
else
|
135
|
+
return groups.include?(group)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def assets(asset_type, group)
|
140
|
+
return nil if !@bundles.has_key?(group.to_s)
|
141
|
+
return @bundles[group.to_s].assets(asset_type)
|
142
|
+
end
|
143
|
+
|
144
|
+
def javascripts(group)
|
145
|
+
return assets(:javascripts, group)
|
146
|
+
end
|
147
|
+
|
148
|
+
def stylesheets(group)
|
149
|
+
return assets(:stylesheets, group)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
module Kernel
|
159
|
+
#
|
160
|
+
# Return the instance of the AssetManager class.
|
161
|
+
#
|
162
|
+
def assets_mgr
|
163
|
+
return Mack::Assets::Manager.instance
|
164
|
+
end
|
165
|
+
end
|
@@ -54,7 +54,7 @@ module Mack
|
|
54
54
|
run_filters(:before)
|
55
55
|
# check to see if this controller responds to this action.
|
56
56
|
# only run public methods!
|
57
|
-
if self.public_methods.include?(self.action_name)
|
57
|
+
if self.public_methods.include?(self.action_name.to_s)
|
58
58
|
# call the action and capture the results to a variable.
|
59
59
|
self.send(self.action_name)
|
60
60
|
else
|
@@ -260,9 +260,9 @@ module Mack
|
|
260
260
|
# end
|
261
261
|
def render(render_type = :action, render_value = self.action_name, options = {})
|
262
262
|
raise Mack::Errors::DoubleRender.new if render_performed?
|
263
|
-
response.status = options[:status]
|
264
|
-
options = {:
|
265
|
-
response[
|
263
|
+
response.status = options[:status] if options[:status]
|
264
|
+
options = {:layout => layout}.merge(options)
|
265
|
+
response.content_type = options[:content_type] if options[:content_type]
|
266
266
|
options.delete(:content_type)
|
267
267
|
@view_template = Mack::Rendering::ViewTemplate.new(render_type, render_value,
|
268
268
|
{:format => params[:format].to_sym, :controller => self}.merge(options))
|
@@ -43,7 +43,7 @@ module Mack
|
|
43
43
|
unless value.is_a?(Hash)
|
44
44
|
value = {:value => value}
|
45
45
|
end
|
46
|
-
value =
|
46
|
+
value = configatron.mack.cookie_values.to_hash.symbolize_keys.merge(value)
|
47
47
|
self.all_cookies[key] = value
|
48
48
|
self.response.set_cookie(key, value)
|
49
49
|
end
|
@@ -3,13 +3,18 @@ module Mack
|
|
3
3
|
class Request < Rack::Request
|
4
4
|
|
5
5
|
class Parameters < Hash # :nodoc:
|
6
|
-
|
6
|
+
alias_instance_method :[], :old_hash
|
7
|
+
alias_instance_method :store
|
7
8
|
def [](key)
|
8
9
|
data = old_hash(key.to_sym) || old_hash(key.to_s)
|
9
10
|
data = data.to_s if data.is_a?(Symbol)
|
10
11
|
return data
|
11
12
|
end
|
12
13
|
|
14
|
+
def []=(key, value)
|
15
|
+
_original_store(key.to_sym, value)
|
16
|
+
end
|
17
|
+
|
13
18
|
def to_s
|
14
19
|
s = self.inspect
|
15
20
|
Mack::Logging::Filter.list.each do |p|
|
@@ -27,7 +32,7 @@ module Mack
|
|
27
32
|
parse_params(rack_params)
|
28
33
|
end
|
29
34
|
|
30
|
-
|
35
|
+
alias_instance_method :params, :rack_params # :nodoc:
|
31
36
|
|
32
37
|
# Merges another Hash with the parameters for this request.
|
33
38
|
def merge_params(opts = {})
|
@@ -85,7 +90,12 @@ module Mack
|
|
85
90
|
@mack_params
|
86
91
|
end
|
87
92
|
|
88
|
-
|
93
|
+
def params=(p) # :nodoc:
|
94
|
+
@mack_params = Mack::Request::Parameters.new
|
95
|
+
parse_params(p)
|
96
|
+
end
|
97
|
+
|
98
|
+
alias_instance_method :params, :all_params
|
89
99
|
|
90
100
|
# Returns a Mack::Request::UploadedFile object.
|
91
101
|
def file(key)
|
@@ -9,5 +9,17 @@ module Mack
|
|
9
9
|
self.controller.instance_variable_get("@#{key}")
|
10
10
|
end
|
11
11
|
|
12
|
+
def attachment=(file_name)
|
13
|
+
self['Content-Disposition'] = "attachment; filename=#{file_name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def content_type=(type)
|
17
|
+
self['Content-Type'] = type
|
18
|
+
end
|
19
|
+
|
20
|
+
def content_type
|
21
|
+
self['Content-Type']
|
22
|
+
end
|
23
|
+
|
12
24
|
end
|
13
25
|
end
|
@@ -41,6 +41,75 @@ module Kernel
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
unless Module.const_defined?('GEM_MOD')
|
45
|
+
Module.const_set('GEM_MOD', 1)
|
46
|
+
|
47
|
+
alias_instance_method :gem, :old_gem
|
48
|
+
|
49
|
+
def gem(gem_name, *version_requirements)
|
50
|
+
vendor_path = File.join(Mack.root, 'vendor')
|
51
|
+
gem_path = File.join(vendor_path, 'gems')
|
52
|
+
|
53
|
+
# try to normalize the version requirement string
|
54
|
+
ver = version_requirements.to_s.strip
|
55
|
+
ver = "> 0.0.0" if ver == nil or ver.empty?
|
56
|
+
# if the version string starts with number, then prepend = to it (since the developer wants an exact match)
|
57
|
+
ver = "= " + ver if ver[0,1] != '=' and ver[0,1] != '>' and ver[0,1] != '<'
|
58
|
+
|
59
|
+
num = ver.match(/\d.+/).to_s
|
60
|
+
op = ver.delete(num).strip
|
61
|
+
op += "=" if op == '='
|
62
|
+
|
63
|
+
found_local_gem = false
|
64
|
+
|
65
|
+
Dir.glob(File.join(gem_path, "#{gem_name}*")).each_with_index do |file, i|
|
66
|
+
# all frozen gem has the pattern [gem_name]-[version]
|
67
|
+
next if !file.include?'-'
|
68
|
+
|
69
|
+
# make sure we're not loading gem with almost the same name, e.g. "#{gem_name}-foo_bar-0.89.1"
|
70
|
+
file_gem_name = file.match(/\D*-/).to_s
|
71
|
+
next if !file.starts_with?(file_gem_name)
|
72
|
+
|
73
|
+
# find the version number from the file name
|
74
|
+
file_ver = file.match(/\d.+/).to_s
|
75
|
+
|
76
|
+
# generate number comparison string that we can evaluate, to make sure that we
|
77
|
+
# pick the correct gem based on the requested version requirements
|
78
|
+
comparison = "'#{file_ver}' #{op} '#{num}'" # e.g.: "'0.8.0' > '0.0.0'"
|
79
|
+
|
80
|
+
# if we find the match (i.e. the comparison string checks out) then
|
81
|
+
# read the frozen spec file in that directory (so we can see what the require path is)
|
82
|
+
# and prepend the new require path(s) to the global search path.
|
83
|
+
# If we didn't find it, then continue to look (obviously)
|
84
|
+
if eval(comparison)
|
85
|
+
spec_file = File.join(file, 'spec.yaml')
|
86
|
+
|
87
|
+
if File.exists?(spec_file)
|
88
|
+
spec = YAML.load(File.read(spec_file))
|
89
|
+
else
|
90
|
+
spec = nil
|
91
|
+
end
|
92
|
+
|
93
|
+
if spec and spec.require_path
|
94
|
+
spec.require_path.each { |rp| $:.insert(0, File.expand_path(File.join(file, rp))) }
|
95
|
+
else
|
96
|
+
$:.insert(0, File.expand_path(file))
|
97
|
+
end
|
98
|
+
|
99
|
+
found_local_gem = true
|
100
|
+
break
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# if After going through the vendor/gems folder and we still didn't find
|
105
|
+
# any frozen gem that matched the criteria, then call the system's gem loader
|
106
|
+
if !found_local_gem
|
107
|
+
# puts "Loading installed gem: #{gem_name}"
|
108
|
+
old_gem(gem_name, *version_requirements)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
44
113
|
private
|
45
114
|
class DeprecatedRegistryList < Mack::Utils::RegistryList # :nodoc:
|
46
115
|
end
|
data/lib/mack/errors/errors.rb
CHANGED
@@ -56,7 +56,11 @@ module Mack
|
|
56
56
|
class UndefinedRoute < StandardError
|
57
57
|
# Takes a request object.
|
58
58
|
def initialize(req)
|
59
|
-
|
59
|
+
if req.is_a?(Mack::Request)
|
60
|
+
super("#{req.path_info}; #{req.request_method}")
|
61
|
+
else
|
62
|
+
super(req)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end # UndefinedRoute
|
62
66
|
|
@@ -5,12 +5,12 @@ controller_template:
|
|
5
5
|
views_migrations:
|
6
6
|
type: directory
|
7
7
|
output_path: <%= File.join("app", "views", @name_plural) %>
|
8
|
-
<% if
|
8
|
+
<% if configatron.mack.testing_framework.to_s == "test_case" -%>
|
9
9
|
test_template:
|
10
10
|
type: file
|
11
11
|
template_path: <%= File.join(templates_directory_path, "test", "controllers", "test_case.rb.template") %>
|
12
12
|
output_path: <%= File.join("test", "controllers", "#{@name_plural}_controller_test.rb") %>
|
13
|
-
<% elsif
|
13
|
+
<% elsif configatron.mack.testing_framework.to_s == "rspec" -%>
|
14
14
|
test_template:
|
15
15
|
type: file
|
16
16
|
template_path: <%= File.join(templates_directory_path, "test", "controllers", "rspec.rb.template") %>
|
@@ -2,12 +2,12 @@ helper_template:
|
|
2
2
|
type: file
|
3
3
|
template_path: <%= File.join(templates_directory_path, "app", "helpers", "controllers", "helper.rb.template") %>
|
4
4
|
output_path: <%= File.join("app", "helpers", "controllers", "#{@name_plural}_controller_helper.rb") %>
|
5
|
-
<% if
|
5
|
+
<% if configatron.mack.testing_framework.to_s == "test_case" -%>
|
6
6
|
helper_test_template:
|
7
7
|
type: file
|
8
8
|
template_path: <%= File.join(templates_directory_path, "test", "helpers", "controllers", "test_case.rb.template") %>
|
9
9
|
output_path: <%= File.join("test", "helpers", "controllers", "#{@name_plural}_controller_helper_test.rb") %>
|
10
|
-
<% elsif
|
10
|
+
<% elsif configatron.mack.testing_framework.to_s == "rspec" -%>
|
11
11
|
helper_test_template:
|
12
12
|
type: file
|
13
13
|
template_path: <%= File.join(templates_directory_path, "test", "helpers", "controllers", "rspec.rb.template") %>
|
@@ -22,8 +22,8 @@ application_layout:
|
|
22
22
|
<% ["default", "development", "production", "test"].each do |env| -%>
|
23
23
|
<%= env %>_yml:
|
24
24
|
type: file
|
25
|
-
template_path: <%= File.join(templates_directory_path, "config", "
|
26
|
-
output_path: <%= File.join(app_name, "config", "
|
25
|
+
template_path: <%= File.join(templates_directory_path, "config", "configatron", "#{env}.rb.template") %>
|
26
|
+
output_path: <%= File.join(app_name, "config", "configatron", "#{env}.rb") %>
|
27
27
|
<% end -%>
|
28
28
|
database_yml:
|
29
29
|
type: file
|
@@ -43,6 +43,14 @@ favicon:
|
|
43
43
|
type: file
|
44
44
|
template_path: <%= File.join(templates_directory_path, "public", "favicon.ico.template") %>
|
45
45
|
output_path: <%= File.join(app_name, "public", "favicon.ico") %>
|
46
|
+
404:
|
47
|
+
type: file
|
48
|
+
template_path: <%= File.join(templates_directory_path, "public", "404.html.template") %>
|
49
|
+
output_path: <%= File.join(app_name, "public", "404.html") %>
|
50
|
+
500:
|
51
|
+
type: file
|
52
|
+
template_path: <%= File.join(templates_directory_path, "public", "500.html.template") %>
|
53
|
+
output_path: <%= File.join(app_name, "public", "500.html") %>
|
46
54
|
scaffold_css:
|
47
55
|
type: file
|
48
56
|
template_path: <%= File.join(templates_directory_path, "public", "stylesheets", "scaffold.css.template") %>
|
@@ -6,29 +6,24 @@
|
|
6
6
|
#
|
7
7
|
# Configuration parameters can be used in your application like such:
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# configatron.<setting_name>
|
10
10
|
#
|
11
11
|
# Nested parameters can be defined using ::.
|
12
12
|
#
|
13
13
|
# Examples:
|
14
|
-
# default.
|
15
|
-
# default_time_limit: <%%= 15.minutes %>
|
16
|
-
# api
|
14
|
+
# default.rb:
|
15
|
+
# configatron.default_time_limit: <%%= 15.minutes %>
|
16
|
+
# configatron.api.timeout_limit: <%%= 15.seconds %>
|
17
17
|
#
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# configatron.default_time_limit # => 900
|
19
|
+
# configatron.api.timeout_limit # => 15
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
mack::session_id: _<%= @options["app"].downcase %>_session_id
|
25
|
-
|
26
|
-
mack::testing_framework: <%= @options["testing_framework"] %>
|
27
|
-
|
28
|
-
default_secret_key: <%= String.randomize(80) %>
|
21
|
+
configatron.mack.session_id = '_<%= @options["app"].downcase %>_session_id'
|
22
|
+
configatron.mack.testing_framework = '<%= @options["testing_framework"] %>'
|
23
|
+
configatron.default_secret_key = '<%= String.randomize(80) %>'
|
29
24
|
|
30
25
|
# Mack provides RJS support through mack-javascript gem.
|
31
26
|
# In order to have RJS support, you will need to perform the following steps:
|
32
27
|
# 1. Uncomment the code below, and make sure that the framework is the one you want to use
|
33
28
|
# 2. run: rake generate:javascript
|
34
|
-
# mack
|
29
|
+
# configatron.mack.js_framework = '<%= @options["js_framework"] %>'
|
@@ -1 +1 @@
|
|
1
|
-
# Any settings in here will override the settings in default.yml for the development environment.
|
1
|
+
# Any settings in here will override the settings in default.yml for the development environment.
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
# Any settings in here will override the settings in default.yml for the test environment.
|
1
|
+
# Any settings in here will override the settings in default.yml for the test environment.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Page Not Found! (404)</title>
|
4
|
+
<style>
|
5
|
+
body {
|
6
|
+
font-family: Verdana;
|
7
|
+
}
|
8
|
+
</style>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Page Not Found!</h1>
|
12
|
+
|
13
|
+
<p>We're sorry the page you have tried to access does not appear to exist. Please check the URL and try again.</p>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Server Error! (500)</title>
|
4
|
+
<style>
|
5
|
+
body {
|
6
|
+
font-family: Verdana;
|
7
|
+
}
|
8
|
+
</style>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Server Error!</h1>
|
12
|
+
|
13
|
+
<p>We're sorry there appears to be a problem. Please try back again later.</p>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -2,12 +2,12 @@ helper_template:
|
|
2
2
|
type: file
|
3
3
|
template_path: <%= File.join(templates_directory_path, "app", "helpers", "views", "helper.rb.template") %>
|
4
4
|
output_path: <%= File.join("app", "helpers", "views", "#{@name_singular}_helper.rb") %>
|
5
|
-
<% if
|
5
|
+
<% if configatron.mack.testing_framework.to_s == "test_case" -%>
|
6
6
|
helper_test_template:
|
7
7
|
type: file
|
8
8
|
template_path: <%= File.join(templates_directory_path, "test", "helpers", "views", "test_case.rb.template") %>
|
9
9
|
output_path: <%= File.join("test", "helpers", "views", "#{@name_singular}_helper_test.rb") %>
|
10
|
-
<% elsif
|
10
|
+
<% elsif configatron.mack.testing_framework.to_s == "rspec" -%>
|
11
11
|
helper_test_template:
|
12
12
|
type: file
|
13
13
|
template_path: <%= File.join(templates_directory_path, "test", "helpers", "views", "rspec.rb.template") %>
|