mack 0.6.0.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +45 -0
- data/bin/mack +8 -3
- data/lib/mack.rb +2 -57
- data/lib/mack/controller/all_helpers.rb +14 -0
- data/lib/{controller → mack/controller}/controller.rb +7 -1
- data/lib/{controller → mack/controller}/cookie_jar.rb +0 -0
- data/lib/{controller → mack/controller}/filter.rb +0 -0
- data/lib/{controller → mack/controller}/request.rb +0 -0
- data/lib/{controller → mack/controller}/response.rb +0 -0
- data/lib/{controller → mack/controller}/session.rb +0 -0
- data/lib/{controller → mack/controller}/uploaded_file.rb +0 -0
- data/lib/{core_extensions → mack/core_extensions}/kernel.rb +0 -0
- data/lib/{core_extensions → mack/core_extensions}/string.rb +0 -0
- data/lib/{distributed → mack/distributed}/errors/errors.rb +0 -0
- data/lib/{distributed → mack/distributed}/routing/urls.rb +10 -1
- data/lib/{distributed → mack/distributed}/utils/rinda.rb +0 -0
- data/lib/{errors → mack/errors}/errors.rb +4 -0
- data/lib/{generators → mack/generators}/mack_application_generator/mack_application_generator.rb +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/manifest.yml +0 -0
- data/lib/mack/generators/mack_application_generator/templates/Rakefile.template +6 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/app/controllers/default_controller.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/app/helpers/controllers/default_controller_helper.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/app/helpers/views/application_helper.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/app/views/default/index.html.erb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/app/views/layouts/application.html.erb.template +0 -0
- data/lib/mack/generators/mack_application_generator/templates/config/app_config/default.yml.template +11 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/app_config/development.yml.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/app_config/production.yml.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/app_config/test.yml.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/database.yml.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/initializers/gems.rb.template +3 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/initializers/mime_types.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/config/routes.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/public/favicon.ico.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/public/stylesheets/scaffold.css.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/test/functional/default_controller_spec.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/test/functional/default_controller_test.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/test/spec.opts.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/test/spec_helper.rb.template +0 -0
- data/lib/{generators → mack/generators}/mack_application_generator/templates/test/test_helper.rb.template +0 -0
- data/lib/{generators → mack/generators}/plugin_generator/plugin_generator.rb +0 -0
- data/lib/{generators → mack/generators}/plugin_generator/templates/vendor/plugins/%=@plugin_name%/init.rb.template +0 -0
- data/lib/{generators → mack/generators}/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/%=@plugin_name%.rb.template +0 -0
- data/lib/{generators → mack/generators}/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/tasks/%=@plugin_name%_tasks.rake.template +0 -0
- data/lib/{initialization → mack/initialization}/application.rb +6 -6
- data/lib/{initialization → mack/initialization}/configuration.rb +7 -2
- data/lib/{initialization → mack/initialization}/console.rb +1 -1
- data/lib/{initialization → mack/initialization}/helpers.rb +1 -1
- data/lib/{initialization → mack/initialization}/logging.rb +25 -0
- data/lib/mack/initialization/orm_support.rb +20 -0
- data/lib/{initialization → mack/initialization}/plugins.rb +0 -0
- data/lib/{initialization → mack/initialization}/server/simple_server.rb +0 -0
- data/lib/{rendering → mack/rendering}/engine/base.rb +0 -0
- data/lib/{rendering → mack/rendering}/engine/builder.rb +0 -0
- data/lib/{rendering → mack/rendering}/engine/erubis.rb +0 -0
- data/lib/{rendering → mack/rendering}/engine/registry.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/action.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/base.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/file_base.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/inline.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/layout.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/partial.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/public.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/template.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/text.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/url.rb +0 -0
- data/lib/{rendering → mack/rendering}/type/xml.rb +0 -0
- data/lib/{rendering → mack/rendering}/view_template.rb +0 -0
- data/lib/{routing → mack/routing}/route_map.rb +1 -7
- data/lib/{routing → mack/routing}/urls.rb +0 -0
- data/lib/mack/runner.rb +121 -0
- data/lib/mack/runner_helpers/base.rb +13 -0
- data/lib/mack/runner_helpers/registry.rb +13 -0
- data/lib/mack/runner_helpers/request_logger.rb +32 -0
- data/lib/mack/runner_helpers/session.rb +41 -0
- data/lib/{tasks → mack/tasks}/cachetastic_tasks.rake +0 -11
- data/lib/{tasks → mack/tasks}/gem_tasks.rake +3 -17
- data/lib/{tasks → mack/tasks}/generator_tasks.rake +1 -1
- data/lib/{tasks → mack/tasks}/log_tasks.rake +0 -0
- data/lib/{tasks → mack/tasks}/mack_dump_tasks.rake +0 -0
- data/lib/{tasks → mack/tasks}/mack_ring_server_tasks.rake +0 -0
- data/lib/{tasks → mack/tasks}/mack_server_tasks.rake +0 -0
- data/lib/{tasks → mack/tasks}/mack_tasks.rake +1 -2
- data/lib/{tasks → mack/tasks}/mack_update_tasks.rake +0 -0
- data/lib/{tasks → mack/tasks}/rake_helpers.rb +0 -0
- data/lib/{tasks → mack/tasks}/rake_rules.rake +1 -5
- data/lib/{tasks → mack/tasks}/test_tasks.rake +18 -8
- data/lib/mack/tasks/tmp_tasks.rake +8 -0
- data/lib/{testing → mack/testing}/helpers.rb +1 -1
- data/lib/{testing → mack/testing}/response.rb +0 -0
- data/lib/{testing → mack/testing}/rspec.rb +3 -2
- data/lib/{testing → mack/testing}/test_assertions.rb +0 -0
- data/lib/{testing → mack/testing}/test_case.rb +0 -0
- data/lib/mack/utils/ansi/ansi_color.rb +22 -0
- data/lib/{utils → mack/utils}/crypt/default_worker.rb +0 -0
- data/lib/{utils → mack/utils}/crypt/keeper.rb +0 -0
- data/lib/{utils → mack/utils}/gem_manager.rb +10 -5
- data/lib/{utils → mack/utils}/mime_types.rb +0 -0
- data/lib/{utils → mack/utils}/mime_types.yml +2 -1
- data/lib/{utils → mack/utils}/server.rb +11 -5
- data/lib/mack/view_helpers/all_helpers.rb +16 -0
- data/lib/{view_helpers → mack/view_helpers}/html_helpers.rb +1 -1
- data/lib/{view_helpers → mack/view_helpers}/string_helpers.rb +1 -1
- data/lib/mack_app.rb +19 -0
- data/lib/mack_core.rb +52 -0
- data/lib/mack_tasks.rb +16 -1
- metadata +118 -98
- data/lib/generators/mack_application_generator/templates/Rakefile.template +0 -10
- data/lib/generators/mack_application_generator/templates/config/app_config/default.yml.template +0 -6
- data/lib/initialization/orm_support.rb +0 -10
- data/lib/runner.rb +0 -172
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Mack
|
2
2
|
|
3
3
|
module Routes
|
4
|
+
include Extlib::Hook
|
4
5
|
|
5
6
|
# This method yields up Mack::Routes::RouteMap and allows for the creation of routes in the system.
|
6
7
|
#
|
@@ -11,13 +12,6 @@ module Mack
|
|
11
12
|
Mack::Rendering::ViewTemplate,
|
12
13
|
Test::Unit::TestCase,
|
13
14
|
Mack::Distributed::Routes::Urls)
|
14
|
-
if app_config.mack.use_distributed_routes
|
15
|
-
raise Mack::Distributed::Errors::ApplicationNameUndefined.new if app_config.mack.distributed_app_name.nil?
|
16
|
-
|
17
|
-
d_urls = Mack::Distributed::Routes::Urls.new(app_config.mack.distributed_site_domain)
|
18
|
-
d_urls.put
|
19
|
-
end
|
20
|
-
# puts "Finished compiling routes: #{Mack::Routes::RouteMap.instance.routes_list.inspect}"
|
21
15
|
end
|
22
16
|
|
23
17
|
# Routes are the back bone of the Mack framework. They are used to map incoming urls to controllers.
|
File without changes
|
data/lib/mack/runner.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'routing', 'urls')
|
2
|
+
module Mack
|
3
|
+
# This is the heart and soul of the Mack framework! This class interfaces with the Rack framework.
|
4
|
+
# It handles all the dispatching back and forth between the Rack framework and a Mack application.
|
5
|
+
class Runner
|
6
|
+
include Extlib::Hook
|
7
|
+
include Mack::Routes::Urls
|
8
|
+
|
9
|
+
attr_reader :response # :nodoc:
|
10
|
+
attr_reader :request # :nodoc:
|
11
|
+
attr_reader :cookies # :nodoc:
|
12
|
+
attr_reader :runner_helpers # :nodoc:
|
13
|
+
|
14
|
+
# This method needs to be defined as part of the Rack framework. As is noted for the Mack::Runner
|
15
|
+
# class, this is where the center of the Mack framework lies.
|
16
|
+
def call(env)
|
17
|
+
begin
|
18
|
+
setup(env)
|
19
|
+
begin
|
20
|
+
route = Mack::Routes::RouteMap.instance.get_route_from_request(self.request)
|
21
|
+
if route[:redirect_to]
|
22
|
+
# because the route is specified to be a redirect, let's do that:
|
23
|
+
redirect_to(route)
|
24
|
+
else
|
25
|
+
self.request.all_params[:original_controller] = route[:controller]
|
26
|
+
self.request.all_params[:original_action] = route[:action]
|
27
|
+
run_controller(route)
|
28
|
+
end
|
29
|
+
# rescue Mack::Errors::ResourceNotFound, Mack::Errors::UndefinedRoute => e
|
30
|
+
# return try_to_find_resource(env, e)
|
31
|
+
rescue Exception => e
|
32
|
+
route = Mack::Routes::RouteMap.instance.get_route_from_error(e.class)
|
33
|
+
unless route.nil?
|
34
|
+
run_controller(route, e)
|
35
|
+
else
|
36
|
+
if e.class == Mack::Errors::ResourceNotFound || e.class == Mack::Errors::UndefinedRoute
|
37
|
+
return try_to_find_resource(env, e)
|
38
|
+
else
|
39
|
+
raise e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
teardown
|
44
|
+
rescue Exception => e
|
45
|
+
Mack.logger.error(e)
|
46
|
+
raise e
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#private
|
51
|
+
def run_controller(route, e = nil)
|
52
|
+
# let's handle a normal request:
|
53
|
+
begin
|
54
|
+
cont = "#{route[:controller].to_s.camelcase}Controller".constantize
|
55
|
+
rescue NameError => e
|
56
|
+
raise Mack::Errors::ResourceNotFound.new(self.request.path_info)
|
57
|
+
end
|
58
|
+
self.request.all_params[:controller] = route[:controller]
|
59
|
+
self.request.all_params[:action] = route[:action]
|
60
|
+
self.request.instance_variable_set("@params_controller", nil)
|
61
|
+
self.request.instance_variable_set("@params_action", nil)
|
62
|
+
|
63
|
+
c = cont.new
|
64
|
+
c.configure_controller(self.request, self.response, self.cookies)
|
65
|
+
c.caught_exception = e unless e.nil?
|
66
|
+
|
67
|
+
self.response.controller = c
|
68
|
+
self.response.write(c.run)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Setup the request, response, cookies, session, etc...
|
72
|
+
# yield up, and then clean things up afterwards.
|
73
|
+
def setup(env)
|
74
|
+
@request = Mack::Request.new(env)
|
75
|
+
@response = Mack::Response.new
|
76
|
+
@cookies = Mack::CookieJar.new(self.request, self.response)
|
77
|
+
@runner_helpers = []
|
78
|
+
Mack::RunnerHelpers::Registry.registered_items.each do |helper|
|
79
|
+
help = helper.new
|
80
|
+
help.start(self.request, self.response, self.cookies)
|
81
|
+
@runner_helpers << help
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def teardown
|
86
|
+
self.runner_helpers.reverse.each do |help|
|
87
|
+
help.complete(self.request, self.response, self.cookies)
|
88
|
+
end
|
89
|
+
self.response.finish
|
90
|
+
end
|
91
|
+
|
92
|
+
def try_to_find_resource(env, exception)
|
93
|
+
env = env.dup
|
94
|
+
# we can't find a route for this, so let's try and see if it's in the public directory:
|
95
|
+
if File.extname(env["PATH_INFO"]).blank?
|
96
|
+
env["PATH_INFO"] << ".html"
|
97
|
+
end
|
98
|
+
if File.exists?(File.join(Mack.root, "public", env["PATH_INFO"]))
|
99
|
+
return Rack::File.new(File.join(Mack.root, "public")).call(env)
|
100
|
+
else
|
101
|
+
raise exception
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# This will redirect the request to the specified url. A default status of
|
106
|
+
# 302, Moved Temporarily, is set if no status is specified. A simple HTML
|
107
|
+
# page is rendered in case the redirect does not occur.
|
108
|
+
def redirect_to(route)
|
109
|
+
status = route[:status] || 302
|
110
|
+
url = route[:redirect_to]
|
111
|
+
options = self.request.all_params
|
112
|
+
options.merge!(route)
|
113
|
+
options - [:controller, :action, :redirect_to, :method, :status, :format]
|
114
|
+
url = url_for_pattern(url, options)
|
115
|
+
self.response.status = status
|
116
|
+
self.response[:location] = url
|
117
|
+
self.response.write(redirect_html(self.request.path_info, url, status))
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "request_logger")
|
2
|
+
require File.join(File.dirname(__FILE__), "session")
|
3
|
+
module Mack
|
4
|
+
module RunnerHelpers
|
5
|
+
class Registry < Mack::Utils::RegistryList
|
6
|
+
|
7
|
+
def initial_state
|
8
|
+
[Mack::RunnerHelpers::RequestLogger, Mack::RunnerHelpers::Session]
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "base")
|
2
|
+
module Mack
|
3
|
+
module RunnerHelpers # :nodoc:
|
4
|
+
class RequestLogger < Mack::RunnerHelpers::Base
|
5
|
+
|
6
|
+
attr_reader :start_time
|
7
|
+
attr_reader :end_time
|
8
|
+
attr_reader :total_time
|
9
|
+
attr_reader :requests_per_second
|
10
|
+
|
11
|
+
def start(request, response, cookies)
|
12
|
+
@start_time = Time.now
|
13
|
+
end
|
14
|
+
|
15
|
+
def complete(request, response, cookies)
|
16
|
+
@end_time = Time.now
|
17
|
+
@total_time = @end_time - @start_time
|
18
|
+
@requests_per_second = (1 / @total_time).round
|
19
|
+
if app_config.log.detailed_requests
|
20
|
+
msg = "\n\t[#{request.request_method.upcase}] '#{request.path_info}'\n"
|
21
|
+
msg << "\tSession ID: #{request.session.id}\n" if app_config.mack.use_sessions
|
22
|
+
msg << "\tParameters: #{request.all_params}\n"
|
23
|
+
msg << Mack::Utils::Ansi::Color.wrap(app_config.log.completed_color, "\tCompleted in #{@total_time} (#{@requests_per_second} reqs/sec) | #{response.status} [#{request.full_host}]")
|
24
|
+
else
|
25
|
+
msg = "[#{request.request_method.upcase}] '#{request.path_info}' (#{total_time})"
|
26
|
+
end
|
27
|
+
Mack.logger.info(msg)
|
28
|
+
end
|
29
|
+
|
30
|
+
end # RequestLogger
|
31
|
+
end # RunnerHelpers
|
32
|
+
end # Mack
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "base")
|
2
|
+
module Mack
|
3
|
+
module RunnerHelpers # :nodoc:
|
4
|
+
class Session < Mack::RunnerHelpers::Base
|
5
|
+
|
6
|
+
attr_accessor :sess_id
|
7
|
+
|
8
|
+
def start(request, response, cookies)
|
9
|
+
if app_config.mack.use_sessions
|
10
|
+
sess_id = cookies[app_config.mack.session_id]
|
11
|
+
unless sess_id
|
12
|
+
sess_id = create_new_session(request, response, cookies)
|
13
|
+
else
|
14
|
+
sess = Cachetastic::Caches::MackSessionCache.get(sess_id)
|
15
|
+
if sess
|
16
|
+
request.session = sess
|
17
|
+
else
|
18
|
+
# we couldn't find it in the store, so we need to create it:
|
19
|
+
sess_id = create_new_session(request, response, cookies)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete(request, response, cookies)
|
26
|
+
Cachetastic::Caches::MackSessionCache.set(sess_id, request.session) if app_config.mack.use_sessions
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def create_new_session(request, response, cookies)
|
31
|
+
id = String.randomize(40).downcase
|
32
|
+
cookies[app_config.mack.session_id] = {:value => id, :expires => nil}
|
33
|
+
sess = Mack::Session.new(id)
|
34
|
+
request.session = sess
|
35
|
+
Cachetastic::Caches::MackSessionCache.set(id, sess)
|
36
|
+
id
|
37
|
+
end
|
38
|
+
|
39
|
+
end # Session
|
40
|
+
end # RunnerHelpers
|
41
|
+
end # Mack
|
@@ -55,15 +55,4 @@ namespace :cachetastic do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
# namespace :page_cache do
|
59
|
-
#
|
60
|
-
# desc "Expires the page cache."
|
61
|
-
# task :expire_all => :environment do
|
62
|
-
# running_time do("Cachetastic::Caches::PageCache.expire_all")
|
63
|
-
# Cachetastic::Caches::PageCache.expire_all
|
64
|
-
# end
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# end
|
68
|
-
|
69
58
|
end
|
@@ -1,34 +1,20 @@
|
|
1
1
|
namespace :gems do
|
2
2
|
|
3
3
|
desc "lists all the gem required for this application."
|
4
|
-
task :list
|
4
|
+
task :list do
|
5
5
|
Mack::Utils::GemManager.instance.required_gem_list.each do |g|
|
6
6
|
puts g
|
7
7
|
end
|
8
8
|
end # list
|
9
9
|
|
10
10
|
desc "installs the gems needed for this application."
|
11
|
-
task :install
|
12
|
-
runner = Gem::GemRunner.new
|
11
|
+
task :install do
|
13
12
|
Mack::Utils::GemManager.instance.required_gem_list.each do |g|
|
14
13
|
params = ["install", g.name.to_s]
|
15
14
|
params << "--version=#{g.version}" if g.version?
|
16
15
|
params << "--source=#{g.source}" if g.source?
|
17
|
-
|
16
|
+
sh "gem #{params.join(" ")}"
|
18
17
|
end
|
19
18
|
end # install
|
20
19
|
|
21
|
-
private
|
22
|
-
task :setup do
|
23
|
-
gem 'mack'
|
24
|
-
require 'core_extensions/kernel'
|
25
|
-
require 'utils/gem_manager'
|
26
|
-
gem 'mack_ruby_core_extensions'
|
27
|
-
require 'mack_ruby_core_extensions'
|
28
|
-
require File.join(FileUtils.pwd, "config", "initializers", "gems")
|
29
|
-
require 'rubygems'
|
30
|
-
require 'rubygems/gem_runner'
|
31
|
-
Gem.manage_gems
|
32
|
-
end
|
33
|
-
|
34
20
|
end # gem
|
@@ -7,7 +7,7 @@ namespace :generator do
|
|
7
7
|
g = g.constantize
|
8
8
|
if g.respond_to?(:superclass) && g.superclass == Genosaurus
|
9
9
|
list << g.name
|
10
|
-
list << "\n\t" << "rake generate:#{g.name.underscore}\n"
|
10
|
+
list << "\n\t" << "rake generate:#{g.name.underscore.gsub("_generator", '')}\n"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
list << "\n\n"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,14 +2,13 @@ namespace :mack do
|
|
2
2
|
|
3
3
|
desc "Loads the Mack environment. Default is development."
|
4
4
|
task :environment do
|
5
|
-
require File.join(File.dirname(__FILE__), '..', 'mack')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', "..", 'mack')
|
6
6
|
end # environment
|
7
7
|
|
8
8
|
desc "Loads an irb console allow you full access to the application w/o a browser."
|
9
9
|
task :console do
|
10
10
|
libs = []
|
11
11
|
libs << "-r irb/completion"
|
12
|
-
# libs << "-r #{File.join(File.dirname(__FILE__), '..', 'mack')}"
|
13
12
|
libs << "-r #{File.join(File.dirname(__FILE__), '..', 'initialization', 'console')}"
|
14
13
|
exec "irb #{libs.join(" ")} --simple-prompt"
|
15
14
|
end # console
|
File without changes
|
File without changes
|
@@ -2,7 +2,7 @@ require 'rake'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'spec'
|
4
4
|
require 'spec/rake/spectask'
|
5
|
-
|
5
|
+
require 'fileutils'
|
6
6
|
namespace :test do
|
7
7
|
|
8
8
|
task :setup do
|
@@ -25,14 +25,12 @@ namespace :test do
|
|
25
25
|
task :stats do |t|
|
26
26
|
ENV["MACK_ENV"] = "test"
|
27
27
|
Rake::Task["mack:environment"].invoke
|
28
|
+
Rake::Task["test:setup"].invoke
|
28
29
|
x = `rcov test/**/*_#{app_config.mack.testing_framework == "rspec" ? "spec" : "test"}.rb -T --no-html -x Rakefile,config\/`
|
29
|
-
@print = false
|
30
30
|
x.each do |line|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
@print = true
|
35
|
-
end
|
31
|
+
case line
|
32
|
+
when /^\+[\+\-]*\+$/, /^\|.*\|$/, /\d+\sLines\s+\d+\sLOC/
|
33
|
+
puts line
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -41,6 +39,7 @@ namespace :test do
|
|
41
39
|
task :coverage do |t|
|
42
40
|
ENV["MACK_ENV"] = "test"
|
43
41
|
Rake::Task["mack:environment"].invoke
|
42
|
+
Rake::Task["test:setup"].invoke
|
44
43
|
`rcov test/**/*_#{app_config.mack.testing_framework == "rspec" ? "spec" : "test"}.rb -x Rakefile,config\/`
|
45
44
|
`open coverage/index.html`
|
46
45
|
end
|
@@ -55,7 +54,18 @@ namespace :test do
|
|
55
54
|
|
56
55
|
end
|
57
56
|
|
57
|
+
task :default do
|
58
|
+
require 'application_configuration'
|
59
|
+
app_config.load_file(File.join(FileUtils.pwd, "config", "app_config", "default.yml"))
|
60
|
+
app_config.load_file(File.join(FileUtils.pwd, "config", "app_config", "test.yml"))
|
61
|
+
tf = "rspec"
|
62
|
+
begin
|
63
|
+
tf = app_config.mack.testing_framework
|
64
|
+
rescue Exception => e
|
65
|
+
end
|
66
|
+
Rake::Task["test:setup"].invoke
|
67
|
+
Rake::Task["test:#{tf}"].invoke
|
68
|
+
end
|
58
69
|
|
59
|
-
alias_task :default, ["test:setup", "test:rspec"]
|
60
70
|
alias_task :stats, "test:stats"
|
61
71
|
alias_task :coverage, "test:coverage"
|