mack 0.7.1.1 → 0.8.0
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.
- 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
@@ -2,6 +2,24 @@ namespace :mack do
|
|
2
2
|
|
3
3
|
namespace :update do
|
4
4
|
|
5
|
+
desc "Convert application configuration yml file into Configatron file"
|
6
|
+
task :configuration do
|
7
|
+
file = ENV['FILE'] || ENV['file'] || File.join(Mack.root, "config", "app_config")
|
8
|
+
raise "Cannot find: #{file}" if !File.exists?(file)
|
9
|
+
if File.directory?(file)
|
10
|
+
Dir.glob(File.join(file, "**", "*.yml")).each do |f|
|
11
|
+
convert_config_file(f)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
raise "Cannot convert non-yml file: #{file}" if File.extname(file) != ".yml"
|
15
|
+
convert_config_file(file)
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "\nPlease note that you still have access to the pre-converted yml file(s)."
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
5
23
|
# desc "Renames thin.ru to rackup.ru and updates your thin.yml, if necessary."
|
6
24
|
# task :rackup do
|
7
25
|
# require 'fileutils'
|
@@ -22,5 +40,71 @@ namespace :mack do
|
|
22
40
|
end
|
23
41
|
|
24
42
|
end
|
43
|
+
# alias_task "mack:update", "mack:update:rackup"
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# ----- Helper methods for Configuration Updater -------- #
|
48
|
+
def convert_config_file(file)
|
49
|
+
print "Converting: #{File.basename(file)}..."
|
50
|
+
dest_file = file.gsub(".yml", ".rb").gsub('app_config', 'configatron')
|
51
|
+
bak_file = file
|
52
|
+
hash = YAML.load(File.read(file))
|
53
|
+
config_list = (hash) ? hash_to_configatron(hash) : []
|
54
|
+
data = ""
|
55
|
+
config_list.each do |line|
|
56
|
+
line = update_data(line)
|
57
|
+
data += (line + "\n")
|
58
|
+
end
|
59
|
+
FileUtils.mkdir_p(File.dirname(dest_file))
|
60
|
+
File.open(dest_file, "w") { |f| f.write(data.to_s) }
|
61
|
+
puts "done."
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_data(old_data)
|
65
|
+
updates = {
|
66
|
+
"configatron.mack.log_level" => "configatron.mack.log.level",
|
67
|
+
"configatron.run_remote_tests" => "configatron.mack.run_remote_tests",
|
68
|
+
"configatron.mack.log.db_color" => "configatron.mack.log.colors.db",
|
69
|
+
"configatron.mack.log.error_color" => "configatron.mack.log.colors.error",
|
70
|
+
"configatron.mack.log.completed_color" => "configatron.mack.log.colors.completed",
|
71
|
+
"configatron.base_language" => "configatron.mack.localization.base_language",
|
72
|
+
"configatron.supported_languages" => "configatron.mack.localization.supported_languages",
|
73
|
+
"configatron.char_encoding" => "configatron.mack.localization.char_encoding",
|
74
|
+
"configatron.dynamic_translation" => "configatron.mack.localization.dynamic_translation",
|
75
|
+
"configatron.content_expiry" => "configatron.mack.localization.content_expiry",
|
76
|
+
"configatron.mack.share_routes" => "configatron.mack.distributed.share_routes",
|
77
|
+
"configatron.mack.share_objects" => "configatron.mack.distributed.share_objects",
|
78
|
+
"configatron.mack.share_views" => "configatron.mack.distributed.share_views",
|
79
|
+
"configatron.mack.distributed_app_name" => "configatron.mack.distributed.app_name",
|
80
|
+
"configatron.mack.distributed_site_domain" => "configatron.mack.distributed.site_domain",
|
81
|
+
"configatron.mack.drb_timeout" => "configatron.mack.distributed.timeout"
|
82
|
+
}
|
83
|
+
|
84
|
+
key = old_data.split("=").first
|
85
|
+
if updates.has_key?(key)
|
86
|
+
return old_data.gsub(key, updates[key])
|
87
|
+
else
|
88
|
+
return old_data
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def cleanup_key(key)
|
93
|
+
if key.is_a?Symbol
|
94
|
+
mod_key = key.to_s.gsub("::", ".").to_sym
|
95
|
+
else
|
96
|
+
mod_key = key.gsub("::", ".")
|
97
|
+
end
|
98
|
+
end
|
25
99
|
|
26
|
-
|
100
|
+
def hash_to_configatron(hash, configs = [], current_config = "configatron")
|
101
|
+
hash.each_key do |key|
|
102
|
+
if hash[key].is_a?Hash
|
103
|
+
hash_to_configatron(hash[key], configs, (current_config + ".#{cleanup_key(key)}"))
|
104
|
+
else
|
105
|
+
configs << current_config + ".#{cleanup_key(key)} = #{hash[key].inspect}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
return configs
|
109
|
+
end
|
110
|
+
# ----- END:: Helper methods for Configuration Updater -------- #
|
@@ -30,4 +30,10 @@ rule /^generate:/ do |t|
|
|
30
30
|
Rake::Task["environment"].invoke
|
31
31
|
klass = "#{klass.camelcase}Generator"
|
32
32
|
gen = klass.constantize.run(ENV.to_hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
rule /^gems:freeze:/ do |t|
|
36
|
+
gem_name = t.name.gsub('gems:freeze:', '')
|
37
|
+
ENV['gem_name'] = gem_name
|
38
|
+
Rake::Task["gems:install_and_freeze"].invoke
|
33
39
|
end
|
@@ -13,7 +13,7 @@ namespace :test do
|
|
13
13
|
require File.join(File.dirname(__FILE__), '..', 'initialization', 'configuration')
|
14
14
|
Mack::BootLoader.run(:configuration)
|
15
15
|
t.libs << "test"
|
16
|
-
t.pattern =
|
16
|
+
t.pattern = configatron.mack.send("#{configatron.mack.testing_framework}_file_pattern")
|
17
17
|
t.verbose = true
|
18
18
|
end
|
19
19
|
|
@@ -22,7 +22,7 @@ namespace :test do
|
|
22
22
|
require File.join(File.dirname(__FILE__), '..', 'initialization', 'configuration')
|
23
23
|
Mack::BootLoader.run(:configuration)
|
24
24
|
t.spec_opts << '--options' << 'test/spec.opts' if File.exists?('test/spec.opts')
|
25
|
-
t.spec_files = Dir.glob(
|
25
|
+
t.spec_files = Dir.glob(configatron.mack.send("#{configatron.mack.testing_framework}_file_pattern"))
|
26
26
|
end
|
27
27
|
|
28
28
|
desc "Report code statistics (KLOCs, etc) from the application. Requires the rcov gem."
|
@@ -73,7 +73,7 @@ namespace :test do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
puts "Generating... please wait..."
|
76
|
-
res = `#{rcov} --html #{
|
76
|
+
res = `#{rcov} --html #{configatron.mack.send("#{configatron.mack.testing_framework}_file_pattern")}`
|
77
77
|
res
|
78
78
|
end
|
79
79
|
|
@@ -84,7 +84,7 @@ task :default do
|
|
84
84
|
Mack::BootLoader.run(:configuration)
|
85
85
|
tf = "rspec"
|
86
86
|
begin
|
87
|
-
tf =
|
87
|
+
tf = configatron.mack.testing_framework
|
88
88
|
rescue Exception => e
|
89
89
|
end
|
90
90
|
Rake::Task["test:setup"].invoke
|
data/lib/mack/testing/helpers.rb
CHANGED
@@ -12,6 +12,13 @@ if Mack.env == "test"
|
|
12
12
|
end # Session
|
13
13
|
end # RunnerHelpers
|
14
14
|
end # Mack
|
15
|
+
module Rack # :nodoc:
|
16
|
+
class MockRequest # :nodoc:
|
17
|
+
def method_missing(sym, *args)
|
18
|
+
@app.instance_variable_get("@app").instance_variable_get("@request").send(sym, *args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
15
22
|
end
|
16
23
|
#++
|
17
24
|
|
@@ -22,13 +29,13 @@ module Mack
|
|
22
29
|
# Temporarily changes the application configuration. Changes are reverted after
|
23
30
|
# the yield returns.
|
24
31
|
def temp_app_config(options = {})
|
25
|
-
|
26
|
-
|
27
|
-
|
32
|
+
configatron.temp(options) do
|
33
|
+
yield
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
def remote_test # :nodoc:
|
31
|
-
if (
|
38
|
+
if (configatron.mack.run_remote_tests)
|
32
39
|
yield
|
33
40
|
end
|
34
41
|
end
|
@@ -93,7 +100,7 @@ module Mack
|
|
93
100
|
sess = Mack::SessionStore.get($current_session_id, nil, nil, nil)
|
94
101
|
if sess.nil?
|
95
102
|
id = String.randomize(40).downcase
|
96
|
-
set_cookie(
|
103
|
+
set_cookie(configatron.mack.session_id, id)
|
97
104
|
sess = Mack::Session.new(id)
|
98
105
|
Mack::SessionStore.store.direct_set(id, sess)
|
99
106
|
$current_session_id = id
|
@@ -194,7 +201,7 @@ module Mack
|
|
194
201
|
spt = ck.split("=")
|
195
202
|
name = spt.first
|
196
203
|
value = spt.last
|
197
|
-
if name ==
|
204
|
+
if name == configatron.mack.session_id
|
198
205
|
value = nil unless @_mack_in_session
|
199
206
|
end
|
200
207
|
set_cookie(name, value)
|
data/lib/mack/testing/rspec.rb
CHANGED
@@ -7,16 +7,11 @@ module Spec # :nodoc:
|
|
7
7
|
include Mack::Routes::Urls
|
8
8
|
include Mack::Testing::Helpers
|
9
9
|
|
10
|
-
|
10
|
+
alias_instance_method :eval_block, :mack_eval_block
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
|
16
|
-
end
|
17
|
-
ensure
|
18
|
-
@_matcher_description = Spec::Matchers.generated_description
|
19
|
-
Spec::Matchers.clear_generated_description
|
12
|
+
def eval_block
|
13
|
+
in_session do
|
14
|
+
mack_eval_block
|
20
15
|
end
|
21
16
|
end
|
22
17
|
|
@@ -30,4 +25,27 @@ module Spec # :nodoc:
|
|
30
25
|
end
|
31
26
|
end # Matchers
|
32
27
|
|
28
|
+
# require 'spec/runner/formatter/base_text_formatter'
|
29
|
+
# module Runner # :nodoc:
|
30
|
+
# module Formatter # :nodoc:
|
31
|
+
# class BaseTextFormatter < BaseFormatter # :nodoc:
|
32
|
+
#
|
33
|
+
# def dump_pending
|
34
|
+
# unless @pending_examples.empty?
|
35
|
+
# @output.puts
|
36
|
+
# @output.puts yellow("Pending:")
|
37
|
+
# @pending_examples.each do |pending_example|
|
38
|
+
# @output.puts yellow("#{pending_example[0]} (#{pending_example[1]})")
|
39
|
+
# # @output.puts " Called from #{pending_example[2]}"
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# @output.flush
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# end # BaseTextFormatter
|
46
|
+
# end # Formatter
|
47
|
+
# end # Runner
|
48
|
+
|
33
49
|
end # Spec
|
50
|
+
|
51
|
+
|
@@ -8,7 +8,7 @@ module Test # :nodoc:
|
|
8
8
|
|
9
9
|
# Let's alias the run method in the class above us so we can create a new one here
|
10
10
|
# but still reference it.
|
11
|
-
|
11
|
+
alias_instance_method :run, :super_run # :nodoc:
|
12
12
|
|
13
13
|
# We need to wrap the run method so we can do things like
|
14
14
|
# run a cleanup method if it exists
|
@@ -5,7 +5,10 @@ module Mack
|
|
5
5
|
module Color
|
6
6
|
|
7
7
|
def self.wrap(color, string)
|
8
|
-
|
8
|
+
if configatron.mack.log.use_colors
|
9
|
+
return "\e[#{Mack::Utils::Ansi::ColorRegistry.registered_items[color.to_sym] || 0}m#{string}\e[0m"
|
10
|
+
end
|
11
|
+
return string
|
9
12
|
end
|
10
13
|
|
11
14
|
end # Color
|
@@ -127,9 +127,9 @@ module Mack
|
|
127
127
|
|
128
128
|
def valid_request? # :nodoc:
|
129
129
|
return true if !self.class.ignored_actions.empty? and self.skip_action?
|
130
|
-
return
|
130
|
+
return configatron.mack.disable_forgery_detector ||
|
131
131
|
self.skip_action? ||
|
132
|
-
request.params[:method] ==
|
132
|
+
request.params[:method].to_sym == :get ||
|
133
133
|
(request.params[:__authenticity_token] == authenticity_token)
|
134
134
|
end
|
135
135
|
|
@@ -142,7 +142,7 @@ module Mack
|
|
142
142
|
include Singleton
|
143
143
|
|
144
144
|
def dispense_token(key) # :nodoc:
|
145
|
-
salt =
|
145
|
+
salt = configatron.mack.retrieve(:request_authenticity_token_salt, "shh, it's a secret")
|
146
146
|
salt = "shh, it's a secret" if salt.empty?
|
147
147
|
string_to_hash = key.to_s + salt.to_s
|
148
148
|
Digest::SHA1.hexdigest(string_to_hash)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Mack
|
2
|
+
module Utils # :nodoc:
|
3
|
+
class HttpStatusCodes < Mack::Utils::RegistryMap
|
4
|
+
|
5
|
+
def initial_state
|
6
|
+
YAML.load(File.read(File.join(File.dirname(__FILE__), 'http_status_codes.yml')))
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def get(status)
|
12
|
+
self.registered_items[status.to_i] || 'UNKNOWN HTTP STATUS'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end # HttpStatusCodes
|
18
|
+
end # Utils
|
19
|
+
end # Mack
|
@@ -0,0 +1,55 @@
|
|
1
|
+
100: Continue
|
2
|
+
101: Switching Protocols
|
3
|
+
102: Processing
|
4
|
+
200: OK
|
5
|
+
201: Created
|
6
|
+
202: Accepted
|
7
|
+
203: Non-Authoritative Information
|
8
|
+
204: No Content
|
9
|
+
205: Reset Content
|
10
|
+
206: Partial Content
|
11
|
+
207: Multi-Status
|
12
|
+
300: Multiple Choices
|
13
|
+
301: Moved Permanently
|
14
|
+
302: Found
|
15
|
+
303: See Other
|
16
|
+
304: Not Modified
|
17
|
+
305: Use Proxy
|
18
|
+
306: Switch Proxy
|
19
|
+
307: Temporary Redirect
|
20
|
+
400: Bad Request
|
21
|
+
401: Unauthorized
|
22
|
+
402: Payment Required
|
23
|
+
403: Forbidden
|
24
|
+
404: Not Found
|
25
|
+
405: Method Not Allowed
|
26
|
+
406: Not Acceptable
|
27
|
+
407: Proxy Authentication Required
|
28
|
+
408: Request Timeout
|
29
|
+
409: Conflict
|
30
|
+
410: Gone
|
31
|
+
404: Not Found
|
32
|
+
411: Length Required
|
33
|
+
412: Precondition Failed
|
34
|
+
413: Request Entity Too Large
|
35
|
+
414: Request-URI Too Long
|
36
|
+
415: Unsupported Media Type
|
37
|
+
416: Requested Range Not Satisfiable
|
38
|
+
417: Expectation Failed
|
39
|
+
418: I'm a Teapot
|
40
|
+
422: Unprocessable Entity
|
41
|
+
423: Locked
|
42
|
+
424: Failed Dependency
|
43
|
+
425: Unordered Collection
|
44
|
+
426: Upgrade Required
|
45
|
+
449: Retry With
|
46
|
+
500: Internal Server Error
|
47
|
+
501: Not Implemented
|
48
|
+
502: Bad Gateway
|
49
|
+
503: Service Unavailable
|
50
|
+
504: Gateway Timeout
|
51
|
+
505: HTTP Version Not Supported
|
52
|
+
506: Variant Also Negotiates
|
53
|
+
507: Insufficient Storage
|
54
|
+
509: Bandwidth Limit Exceeded
|
55
|
+
510: Not Extended
|
data/lib/mack/utils/paths.rb
CHANGED
@@ -3,151 +3,151 @@ module Mack
|
|
3
3
|
|
4
4
|
# <MACK_PROJECT_ROOT>
|
5
5
|
def self.root(*files)
|
6
|
-
File.join(Mack.root, files)
|
6
|
+
File.join(Mack.root, *files)
|
7
7
|
end
|
8
8
|
|
9
9
|
# <MACK_PROJECT_ROOT>/public
|
10
10
|
def self.public(*files)
|
11
|
-
Mack::Paths.root("public", files)
|
11
|
+
Mack::Paths.root("public", *files)
|
12
12
|
end
|
13
13
|
|
14
14
|
# <MACK_PROJECT_ROOT>/public/images
|
15
15
|
def self.images(*files)
|
16
|
-
Mack::Paths.public("images", files)
|
16
|
+
Mack::Paths.public("images", *files)
|
17
17
|
end
|
18
18
|
|
19
19
|
# <MACK_PROJECT_ROOT>/public/javascripts
|
20
20
|
def self.javascripts(*files)
|
21
|
-
Mack::Paths.public("javascripts", files)
|
21
|
+
Mack::Paths.public("javascripts", *files)
|
22
22
|
end
|
23
23
|
|
24
24
|
# <MACK_PROJECT_ROOT>/public/stylesheets
|
25
25
|
def self.stylesheets(*files)
|
26
|
-
Mack::Paths.public("stylesheets", files)
|
26
|
+
Mack::Paths.public("stylesheets", *files)
|
27
27
|
end
|
28
28
|
|
29
29
|
# <MACK_PROJECT_ROOT>/app
|
30
30
|
def self.app(*files)
|
31
|
-
Mack::Paths.root("app", files)
|
31
|
+
Mack::Paths.root("app", *files)
|
32
32
|
end
|
33
33
|
|
34
34
|
# <MACK_PROJECT_ROOT>/log
|
35
35
|
def self.log(*files)
|
36
|
-
Mack::Paths.root("log", files)
|
36
|
+
Mack::Paths.root("log", *files)
|
37
37
|
end
|
38
38
|
|
39
39
|
# <MACK_PROJECT_ROOT>/test
|
40
40
|
def self.test(*files)
|
41
|
-
Mack::Paths.root("test", files)
|
41
|
+
Mack::Paths.root("test", *files)
|
42
42
|
end
|
43
43
|
|
44
44
|
# <MACK_PROJECT_ROOT>/tmp
|
45
45
|
def self.tmp(*files)
|
46
|
-
Mack::Paths.root("tmp", files)
|
46
|
+
Mack::Paths.root("tmp", *files)
|
47
47
|
end
|
48
48
|
|
49
49
|
# <MACK_PROJECT_ROOT>/test/models
|
50
50
|
def self.model_tests(*files)
|
51
|
-
Mack::Paths.test("models", files)
|
51
|
+
Mack::Paths.test("models", *files)
|
52
52
|
end
|
53
53
|
|
54
54
|
# <MACK_PROJECT_ROOT>/test/controllers
|
55
55
|
def self.controller_tests(*files)
|
56
|
-
Mack::Paths.test("controllers", files)
|
56
|
+
Mack::Paths.test("controllers", *files)
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.test_helpers(*files)
|
60
|
-
Mack::Paths.test("helpers", files)
|
60
|
+
Mack::Paths.test("helpers", *files)
|
61
61
|
end
|
62
62
|
|
63
63
|
# <MACK_PROJECT_ROOT>/test/helpers/controllers
|
64
64
|
def self.controller_helper_tests(*files)
|
65
|
-
Mack::Paths.test_helpers("controllers", files)
|
65
|
+
Mack::Paths.test_helpers("controllers", *files)
|
66
66
|
end
|
67
67
|
|
68
68
|
# <MACK_PROJECT_ROOT>/test/helpers/views
|
69
69
|
def self.view_helper_tests(*files)
|
70
|
-
Mack::Paths.test_helpers("views", files)
|
70
|
+
Mack::Paths.test_helpers("views", *files)
|
71
71
|
end
|
72
72
|
|
73
73
|
# <MACK_PROJECT_ROOT>/app/views
|
74
74
|
def self.views(*files)
|
75
|
-
Mack::Paths.app("views", files)
|
75
|
+
Mack::Paths.app("views", *files)
|
76
76
|
end
|
77
77
|
|
78
78
|
# <MACK_PROJECT_ROOT>/app/views/layouts
|
79
79
|
def self.layouts(*files)
|
80
|
-
Mack::Paths.views("layouts", files)
|
80
|
+
Mack::Paths.views("layouts", *files)
|
81
81
|
end
|
82
82
|
|
83
83
|
# <MACK_PROJECT_ROOT>/app/controllers
|
84
84
|
def self.controllers(*files)
|
85
|
-
Mack::Paths.app("controllers", files)
|
85
|
+
Mack::Paths.app("controllers", *files)
|
86
86
|
end
|
87
87
|
|
88
88
|
# <MACK_PROJECT_ROOT>/app/models
|
89
89
|
def self.models(*files)
|
90
|
-
Mack::Paths.app("models", files)
|
90
|
+
Mack::Paths.app("models", *files)
|
91
91
|
end
|
92
92
|
|
93
93
|
# <MACK_PROJECT_ROOT>/app/helpers
|
94
94
|
def self.helpers(*files)
|
95
|
-
Mack::Paths.app("helpers", files)
|
95
|
+
Mack::Paths.app("helpers", *files)
|
96
96
|
end
|
97
97
|
|
98
98
|
# <MACK_PROJECT_ROOT>/app/helpers/controllers
|
99
99
|
def self.controller_helpers(*files)
|
100
|
-
Mack::Paths.helpers("controllers", files)
|
100
|
+
Mack::Paths.helpers("controllers", *files)
|
101
101
|
end
|
102
102
|
|
103
103
|
# <MACK_PROJECT_ROOT>/app/helpers/views
|
104
104
|
def self.view_helpers(*files)
|
105
|
-
Mack::Paths.helpers("views", files)
|
105
|
+
Mack::Paths.helpers("views", *files)
|
106
106
|
end
|
107
107
|
|
108
108
|
# <MACK_PROJECT_ROOT>/lib
|
109
109
|
def self.lib(*files)
|
110
|
-
Mack::Paths.root("lib", files)
|
110
|
+
Mack::Paths.root("lib", *files)
|
111
111
|
end
|
112
112
|
|
113
113
|
# <MACK_PROJECT_ROOT>/lib/tasks
|
114
114
|
def self.tasks(*files)
|
115
|
-
Mack::Paths.lib("tasks", files)
|
115
|
+
Mack::Paths.lib("tasks", *files)
|
116
116
|
end
|
117
117
|
|
118
118
|
# <MACK_PROJECT_ROOT>/db
|
119
119
|
def self.db(*files)
|
120
|
-
Mack::Paths.root("db", files)
|
120
|
+
Mack::Paths.root("db", *files)
|
121
121
|
end
|
122
122
|
|
123
123
|
# <MACK_PROJECT_ROOT>/db/migrations
|
124
124
|
def self.migrations(*files)
|
125
|
-
Mack::Paths.db("migrations", files)
|
125
|
+
Mack::Paths.db("migrations", *files)
|
126
126
|
end
|
127
127
|
|
128
128
|
# <MACK_PROJECT_ROOT>/config
|
129
129
|
def self.config(*files)
|
130
|
-
Mack::Paths.root("config", files)
|
130
|
+
Mack::Paths.root("config", *files)
|
131
131
|
end
|
132
132
|
|
133
|
-
# <MACK_PROJECT_ROOT>/config/
|
134
|
-
def self.
|
135
|
-
Mack::Paths.config("
|
133
|
+
# <MACK_PROJECT_ROOT>/config/configatron
|
134
|
+
def self.configatron(*files)
|
135
|
+
Mack::Paths.config("configatron", *files)
|
136
136
|
end
|
137
137
|
|
138
138
|
# <MACK_PROJECT_ROOT>/config/initializers
|
139
139
|
def self.initializers(*files)
|
140
|
-
Mack::Paths.config("initializers", files)
|
140
|
+
Mack::Paths.config("initializers", *files)
|
141
141
|
end
|
142
142
|
|
143
143
|
# <MACK_PROJECT_ROOT>/vendor
|
144
144
|
def self.vendor(*files)
|
145
|
-
Mack::Paths.root("vendor", files)
|
145
|
+
Mack::Paths.root("vendor", *files)
|
146
146
|
end
|
147
147
|
|
148
148
|
# <MACK_PROJECT_ROOT>/vendor/plugins
|
149
149
|
def self.plugins(*files)
|
150
|
-
Mack::Paths.vendor("plugins", files)
|
150
|
+
Mack::Paths.vendor("plugins", *files)
|
151
151
|
end
|
152
152
|
|
153
153
|
end # Paths
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Mack
|
2
|
+
# Mack::Reloader checks on every request, but at most every +secs+
|
3
|
+
# seconds, if a file loaded changed, and reloads it, logging to
|
4
|
+
# Mack.logger.debug.
|
5
|
+
|
6
|
+
class Reloader
|
7
|
+
def initialize(app, secs = configatron.mack.reload_classes)
|
8
|
+
@app = app
|
9
|
+
@secs = secs # reload every @secs seconds max
|
10
|
+
@last = Time.now
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
if Time.now > @last + @secs
|
15
|
+
Thread.exclusive {
|
16
|
+
reload!
|
17
|
+
@last = Time.now
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
def reload!
|
25
|
+
need_reload = $LOADED_FEATURES.find_all { |loaded|
|
26
|
+
begin
|
27
|
+
if loaded =~ /\A[.\/]/ # absolute filename or 1.9
|
28
|
+
abs = loaded
|
29
|
+
else
|
30
|
+
if configatron.mack.deep_class_reload
|
31
|
+
abs = $LOAD_PATH.map { |path| ::File.join(path, loaded) }.find { |file| ::File.exist? file }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if abs
|
36
|
+
::File.mtime(abs) > @last - @secs rescue false
|
37
|
+
else
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
need_reload.each { |l|
|
44
|
+
$LOADED_FEATURES.delete l
|
45
|
+
}
|
46
|
+
|
47
|
+
need_reload.each { |to_load|
|
48
|
+
begin
|
49
|
+
if require to_load
|
50
|
+
Mack.logger.debug "#{self.class}: reloaded `#{to_load}'"
|
51
|
+
end
|
52
|
+
rescue LoadError, SyntaxError => e
|
53
|
+
raise e # Possibly ShowExceptions
|
54
|
+
end
|
55
|
+
}
|
56
|
+
need_reload
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/lib/mack/utils/server.rb
CHANGED
@@ -20,13 +20,13 @@ module Mack
|
|
20
20
|
# Any urls listed will go straight to the public directly and will not be served up via the app:
|
21
21
|
app = Rack::Static.new(app, :urls => ["/css", "/images", "/files", "/images", "/stylesheets", "/javascripts", "/media", "/favicon.ico"], :root => "public")
|
22
22
|
app = Mack::Utils::ContentLengthHandler.new(app)
|
23
|
-
app = Rack::Lint.new(app) if
|
23
|
+
app = Rack::Lint.new(app) if configatron.mack.use_lint
|
24
24
|
app = Rack::ShowStatus.new(app)
|
25
|
-
app = Rack::ShowExceptions.new(app) if
|
25
|
+
app = Rack::ShowExceptions.new(app) if configatron.mack.show_exceptions
|
26
26
|
app = Rack::Recursive.new(app)
|
27
27
|
|
28
28
|
# This will reload any edited classes if the cache_classes config setting is set to true.
|
29
|
-
app =
|
29
|
+
app = Mack::Reloader.new(app) unless configatron.mack.cache_classes
|
30
30
|
app
|
31
31
|
end
|
32
32
|
|
data/lib/mack/version.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
module Mack
|
2
2
|
module ViewHelpers # :nodoc:
|
3
|
+
|
4
|
+
def get_resource_root(resource)
|
5
|
+
path = ""
|
6
|
+
path = "#{configatron.mack.distributed.site_domain}" unless configatron.mack.distributed.site_domain.nil?
|
7
|
+
path = Mack::Assets::Helpers.instance.asset_hosts(resource) if path.empty?
|
8
|
+
return path
|
9
|
+
end
|
3
10
|
|
4
11
|
# Used to easily include all Mack::ViewHelpers. It will NOT include itself!
|
5
12
|
# This is primarily used to aid in testing view helpers.
|