mack 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/bin/mack +1 -0
- data/bin/templates/config/initializers/gems.rb.template +12 -0
- data/bin/templates/test/test_helper.rb.template +16 -0
- data/lib/core_extensions/kernel.rb +5 -0
- data/lib/initialization/initializer.rb +7 -1
- data/lib/sea_level/controller_base.rb +14 -2
- data/lib/sea_level/filter.rb +18 -1
- data/lib/tasks/gem_tasks.rake +34 -0
- data/lib/utils/gem_manager.rb +79 -0
- metadata +24 -22
- data/tasks/gem_helper.rb +0 -48
- data/tasks/gem_tasks.rake +0 -93
data/CHANGELOG
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
+
===0.4.2
|
2
|
+
* Added config/initializers directory. All files in this directory will be required at start up time.
|
3
|
+
* Gems can now be required simply using the initializers/gems.rb file and the require_gems method.
|
4
|
+
* Added gems:list and gems:install rake tasks. The gems:list task will list any gems being required for the application. The gems:install task will install all the gems being required for the application.
|
5
|
+
* Filters in controllers can now be inherited from parent controller classes.
|
6
|
+
* gem: mack_ruby_core_extensions 0.1.5
|
7
|
+
* gem: thing 0.7.1
|
8
|
+
|
1
9
|
===0.4.1
|
2
10
|
* Improved testing support.
|
11
|
+
* Added assigns support to testing. This is allows for pulling instance variables that were set in a controller to tests.
|
3
12
|
* Added ability to do 'session' based tests.
|
4
13
|
* Added assert_difference method.
|
5
14
|
* Added ability to set/remove cookies before requests are made.
|
data/bin/mack
CHANGED
@@ -36,6 +36,7 @@ create_dir(File.join(app, "app", "models"))
|
|
36
36
|
create_dir(File.join(app, "app", "views", "default"))
|
37
37
|
create_dir(File.join(app, "app", "views", "layouts"))
|
38
38
|
create_dir(File.join(app, "config", "app_config"))
|
39
|
+
create_dir(File.join(app, "config", "initializers"))
|
39
40
|
create_dir(File.join(app, "lib", "tasks"))
|
40
41
|
create_dir(File.join(app, "log"))
|
41
42
|
create_dir(File.join(app, "public", "images"))
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Using this file you can add gems dependencies to your application.
|
2
|
+
# gem_name, options
|
3
|
+
# gem_name is the name of the gem you want to add.
|
4
|
+
# :version, optional, is the version of the gem you want to use.
|
5
|
+
# :libs, optional, is an array of files you want to require.
|
6
|
+
# :source, options, is the source you want to use to install a particular gem.
|
7
|
+
require_gems do |gem|
|
8
|
+
# examples:
|
9
|
+
# gem.add :redgreen, :version => "1.2.2", :libs => :redgreen
|
10
|
+
# gem.add :termios
|
11
|
+
# gem.add :rubyzip, :source => "http://gems.rubyforge.org"
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "test/unit"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
ENV["MACK_ENV"] = "test"
|
6
|
+
|
7
|
+
# load the mack framework:
|
8
|
+
gem 'mack'
|
9
|
+
require 'mack'
|
10
|
+
|
11
|
+
# place common methods, assertions, and other type things in this file so
|
12
|
+
# other tests will have access to them.
|
13
|
+
|
14
|
+
class Test::Unit::TestCase
|
15
|
+
|
16
|
+
end
|
@@ -57,7 +57,13 @@ unless Object.const_defined?("MACK_INITIALIZED")
|
|
57
57
|
# set up application stuff:
|
58
58
|
|
59
59
|
# set up routes:
|
60
|
-
require File.join(
|
60
|
+
require File.join(MACK_CONFIG, "routes")
|
61
|
+
|
62
|
+
# set up initializers:
|
63
|
+
Dir.glob(File.join(MACK_CONFIG, "initializers", "**/*.rb")) do |d|
|
64
|
+
require d
|
65
|
+
end
|
66
|
+
Mack::Utils::GemManager.instance.do_requires
|
61
67
|
|
62
68
|
# require 'plugins':
|
63
69
|
require File.join(File.dirname(__FILE__), "initializers", "plugins.rb")
|
@@ -320,11 +320,23 @@ module Mack
|
|
320
320
|
end
|
321
321
|
|
322
322
|
def add_filter(type, meth, options) # :nodoc:
|
323
|
-
controller_filters[type.to_sym] << Mack::Controller::Filter.new(meth, options)
|
323
|
+
controller_filters[type.to_sym] << Mack::Controller::Filter.new(meth, self, options)
|
324
324
|
end
|
325
325
|
|
326
326
|
def controller_filters # :nodoc:
|
327
|
-
|
327
|
+
unless @controller_filters
|
328
|
+
@controller_filters = {:before => [], :after => [], :after_render => []}
|
329
|
+
# inherit filters from the superclass, if any, to this parent
|
330
|
+
sc = self.superclass
|
331
|
+
if sc.class_is_a?(Mack::Controller::Base)
|
332
|
+
ch = sc.controller_filters
|
333
|
+
[:before, :after, :after_render].each do |v|
|
334
|
+
@controller_filters[v] << ch[v]
|
335
|
+
@controller_filters[v].flatten!
|
336
|
+
@controller_filters[v].uniq!
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
328
340
|
@controller_filters
|
329
341
|
end
|
330
342
|
|
data/lib/sea_level/filter.rb
CHANGED
@@ -33,9 +33,10 @@ module Mack
|
|
33
33
|
attr_reader :filter_method
|
34
34
|
attr_reader :action_list
|
35
35
|
|
36
|
-
def initialize(filter_method, action_list = {})
|
36
|
+
def initialize(filter_method, klass, action_list = {})
|
37
37
|
@filter_method = filter_method
|
38
38
|
clean_action_list(action_list)
|
39
|
+
@klass = klass
|
39
40
|
end
|
40
41
|
|
41
42
|
def run?(action)
|
@@ -47,6 +48,22 @@ module Mack
|
|
47
48
|
end
|
48
49
|
return false
|
49
50
|
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
"#{@klass}.#{filter_method}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(other)
|
57
|
+
self.to_s == other.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def eql?(other)
|
61
|
+
self.to_s == other.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def hash
|
65
|
+
self.to_s.hash
|
66
|
+
end
|
50
67
|
|
51
68
|
private
|
52
69
|
def clean_action_list(action_list)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
namespace :gems do
|
2
|
+
|
3
|
+
desc "lists all the gem required for this application."
|
4
|
+
task :list => :setup do
|
5
|
+
Mack::Utils::GemManager.instance.required_gem_list.each do |g|
|
6
|
+
puts g
|
7
|
+
end
|
8
|
+
end # list
|
9
|
+
|
10
|
+
desc "installs the gems needed for this application."
|
11
|
+
task :install => :setup do
|
12
|
+
runner = Gem::GemRunner.new
|
13
|
+
Mack::Utils::GemManager.instance.required_gem_list.each do |g|
|
14
|
+
params = ["install", g.name.to_s]
|
15
|
+
params << "--version=#{g.version}" if g.version?
|
16
|
+
params << "--source=#{g.source}" if g.source?
|
17
|
+
runner.run(params)
|
18
|
+
end
|
19
|
+
end # install
|
20
|
+
|
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", "gems")
|
29
|
+
require 'rubygems'
|
30
|
+
require 'rubygems/gem_runner'
|
31
|
+
Gem.manage_gems
|
32
|
+
end
|
33
|
+
|
34
|
+
end # gem
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Mack
|
2
|
+
module Utils
|
3
|
+
# This class is used to add gems to your application in an easy to use way.
|
4
|
+
#
|
5
|
+
# require_gems do |gem|
|
6
|
+
# gem.add :redgreen, :version => "1.2.2", :libs => :redgreen
|
7
|
+
# gem.add :termios
|
8
|
+
# gem.add "rubyzip", :source => "http:// gems.rubyforge.org"
|
9
|
+
# end
|
10
|
+
class GemManager
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
attr_accessor :required_gem_list
|
14
|
+
|
15
|
+
def initialize # :nodoc:
|
16
|
+
@required_gem_list = []
|
17
|
+
end
|
18
|
+
|
19
|
+
# Adds a new gem to the system. This does NOT actually require the gem
|
20
|
+
# or any of it's 'libs'. You need to call the do_requires method to actually
|
21
|
+
# require any of the 'libs' defined for this gem.
|
22
|
+
#
|
23
|
+
# Options:
|
24
|
+
# * <code>:source => "http:// gems.rubyforge.org"</code>
|
25
|
+
# * <code>:version => "1.2.3"</code>
|
26
|
+
# * <code>:libs => "file" or :libs => ["file1", "file2"]</code>
|
27
|
+
def add(name, options = {})
|
28
|
+
@required_gem_list << Mack::Utils::GemManager::GemObject.new(name, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Requires the gem and any libs that you've specified.
|
32
|
+
def do_requires
|
33
|
+
@required_gem_list.each do |g|
|
34
|
+
if g.version?
|
35
|
+
gem(g.name, g.version)
|
36
|
+
else
|
37
|
+
gem(g.name)
|
38
|
+
end
|
39
|
+
g.libs.each {|l| require l.to_s} if g.libs?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
class GemObject # :nodoc:
|
45
|
+
attr_accessor :name
|
46
|
+
attr_accessor :version
|
47
|
+
attr_accessor :libs
|
48
|
+
attr_accessor :source
|
49
|
+
|
50
|
+
def initialize(name, options = {})
|
51
|
+
self.name = name
|
52
|
+
self.version = options[:version]
|
53
|
+
self.libs = [options[:libs]].flatten.compact
|
54
|
+
self.source = options[:source]
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_s
|
58
|
+
t = self.name.to_s
|
59
|
+
t << "-#{self.version}" if self.version?
|
60
|
+
t.downcase
|
61
|
+
end
|
62
|
+
|
63
|
+
def libs?
|
64
|
+
!self.libs.empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
def version?
|
68
|
+
!self.version.blank?
|
69
|
+
end
|
70
|
+
|
71
|
+
def source?
|
72
|
+
!self.source.blank?
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end # GemManager
|
78
|
+
end # Utils
|
79
|
+
end # Mack
|
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.4.
|
4
|
+
version: 0.4.2
|
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-
|
12
|
+
date: 2008-04-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - "="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 0.1.
|
31
|
+
version: 0.1.5
|
32
32
|
version:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: application_configuration
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.7.
|
67
|
+
version: 0.7.1
|
68
68
|
version:
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: builder
|
@@ -95,22 +95,6 @@ extra_rdoc_files:
|
|
95
95
|
- CHANGELOG
|
96
96
|
files:
|
97
97
|
- README
|
98
|
-
- bin/templates/app/controllers/default_controller.rb.template
|
99
|
-
- bin/templates/app/helpers/application_helper.rb.template
|
100
|
-
- bin/templates/app/views/default/index.html.erb.template
|
101
|
-
- bin/templates/app/views/layouts/application.html.erb.template
|
102
|
-
- bin/templates/config/app_config/default.yml.template
|
103
|
-
- bin/templates/config/app_config/development.yml.template
|
104
|
-
- bin/templates/config/app_config/production.yml.template
|
105
|
-
- bin/templates/config/app_config/test.yml.template
|
106
|
-
- bin/templates/config/boot.rb.template
|
107
|
-
- bin/templates/config/database.yml.template
|
108
|
-
- bin/templates/config/routes.rb.template
|
109
|
-
- bin/templates/config/thin.ru.template
|
110
|
-
- bin/templates/config/thin.yml.template
|
111
|
-
- bin/templates/public/favicon.ico
|
112
|
-
- bin/templates/public/stylesheets/scaffold.css.template
|
113
|
-
- bin/templates/Rakefile.template
|
114
98
|
- lib/core_extensions/kernel.rb
|
115
99
|
- lib/core_extensions/string.rb
|
116
100
|
- lib/distributed/errors/errors.rb
|
@@ -159,6 +143,7 @@ files:
|
|
159
143
|
- lib/sea_level/session.rb
|
160
144
|
- lib/sea_level/view_binder.rb
|
161
145
|
- lib/tasks/cachetastic_tasks.rake
|
146
|
+
- lib/tasks/gem_tasks.rake
|
162
147
|
- lib/tasks/log_tasks.rake
|
163
148
|
- lib/tasks/mack_dump_tasks.rake
|
164
149
|
- lib/tasks/mack_server_tasks.rake
|
@@ -170,10 +155,27 @@ files:
|
|
170
155
|
- lib/test_extensions/test_helpers.rb
|
171
156
|
- lib/utils/crypt/default_worker.rb
|
172
157
|
- lib/utils/crypt/keeper.rb
|
158
|
+
- lib/utils/gem_manager.rb
|
173
159
|
- lib/utils/html.rb
|
174
160
|
- lib/utils/server.rb
|
175
|
-
-
|
176
|
-
-
|
161
|
+
- bin/templates/app/controllers/default_controller.rb.template
|
162
|
+
- bin/templates/app/helpers/application_helper.rb.template
|
163
|
+
- bin/templates/app/views/default/index.html.erb.template
|
164
|
+
- bin/templates/app/views/layouts/application.html.erb.template
|
165
|
+
- bin/templates/config/app_config/default.yml.template
|
166
|
+
- bin/templates/config/app_config/development.yml.template
|
167
|
+
- bin/templates/config/app_config/production.yml.template
|
168
|
+
- bin/templates/config/app_config/test.yml.template
|
169
|
+
- bin/templates/config/boot.rb.template
|
170
|
+
- bin/templates/config/database.yml.template
|
171
|
+
- bin/templates/config/initializers/gems.rb.template
|
172
|
+
- bin/templates/config/routes.rb.template
|
173
|
+
- bin/templates/config/thin.ru.template
|
174
|
+
- bin/templates/config/thin.yml.template
|
175
|
+
- bin/templates/public/favicon.ico
|
176
|
+
- bin/templates/public/stylesheets/scaffold.css.template
|
177
|
+
- bin/templates/Rakefile.template
|
178
|
+
- bin/templates/test/test_helper.rb.template
|
177
179
|
- CHANGELOG
|
178
180
|
has_rdoc: true
|
179
181
|
homepage: http://www.mackframework.com
|
data/tasks/gem_helper.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
class GemHelper # :nodoc:
|
2
|
-
include Singleton
|
3
|
-
|
4
|
-
attr_accessor :project
|
5
|
-
attr_accessor :package
|
6
|
-
attr_accessor :gem_name
|
7
|
-
attr_accessor :version
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
self.project = "magrathea"
|
11
|
-
self.package = "mack"
|
12
|
-
self.gem_name = "mack"
|
13
|
-
self.version = "0.4.1"
|
14
|
-
end
|
15
|
-
|
16
|
-
def gem_name_with_version
|
17
|
-
"#{self.gem_name}-#{self.version}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def full_gem_name
|
21
|
-
"#{self.gem_name_with_version}.gem"
|
22
|
-
end
|
23
|
-
|
24
|
-
def release
|
25
|
-
begin
|
26
|
-
rf = RubyForge.new
|
27
|
-
rf.login
|
28
|
-
begin
|
29
|
-
rf.add_release(self.project, self.package, self.version, File.join("pkg", full_gem_name))
|
30
|
-
rescue Exception => e
|
31
|
-
if e.message.match("Invalid package_id") || e.message.match("no <package_id> configured for")
|
32
|
-
puts "You need to create the package!"
|
33
|
-
rf.create_package(self.project, self.package)
|
34
|
-
rf.add_release(self.project, self.package, self.version, File.join("pkg", full_gem_name))
|
35
|
-
else
|
36
|
-
raise e
|
37
|
-
end
|
38
|
-
end
|
39
|
-
rescue Exception => e
|
40
|
-
puts e
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def install
|
45
|
-
puts `sudo gem install #{File.join("pkg", full_gem_name)}`
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/tasks/gem_tasks.rake
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/gempackagetask'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'find'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
require 'rubyforge'
|
9
|
-
require 'rubygems'
|
10
|
-
require 'rubygems/gem_runner'
|
11
|
-
require 'singleton'
|
12
|
-
|
13
|
-
require 'tasks/gem_helper'
|
14
|
-
|
15
|
-
namespace :gem do
|
16
|
-
|
17
|
-
namespace :package do
|
18
|
-
|
19
|
-
desc "Package up the mack gem."
|
20
|
-
task :mack do |t|
|
21
|
-
pwd = FileUtils.pwd
|
22
|
-
gh = GemHelper.instance
|
23
|
-
FileUtils.rm_rf("#{pwd}/pkg", :verbose => true)
|
24
|
-
gem_spec = Gem::Specification.new do |s|
|
25
|
-
s.name = gh.gem_name
|
26
|
-
s.version = gh.version
|
27
|
-
s.summary = "Mack is a powerful, yet simple, web application framework."
|
28
|
-
s.description = %{
|
29
|
-
Mack is a powerful, yet simple, web application framework.
|
30
|
-
It takes some cues from the likes of Rails and Merb, so it's not entirely unfamiliar.
|
31
|
-
Mack hopes to provide developers a great framework for building, and deploying, portal and
|
32
|
-
distributed applications.
|
33
|
-
}
|
34
|
-
s.author = "markbates"
|
35
|
-
s.email = "mark@mackframework.com"
|
36
|
-
s.homepage = "http://www.mackframework.com"
|
37
|
-
s.has_rdoc = true
|
38
|
-
s.extra_rdoc_files = ["README", "CHANGELOG"]
|
39
|
-
s.files = FileList["README", "**/*.*"].exclude("pkg/").exclude("test/").exclude("tasks/private").exclude("doc")
|
40
|
-
s.require_paths << '.'
|
41
|
-
s.require_paths << 'bin'
|
42
|
-
s.require_paths << 'lib'
|
43
|
-
|
44
|
-
s.bindir = "bin"
|
45
|
-
s.executables << "mack"
|
46
|
-
|
47
|
-
s.rdoc_options << '--title' << 'Mack' << '--main' << 'README' << '--line-numbers' << "--inline-source"
|
48
|
-
|
49
|
-
s.add_dependency("rack", "0.3.0")
|
50
|
-
s.add_dependency("mack_ruby_core_extensions", "0.1.4")
|
51
|
-
s.add_dependency("application_configuration", "1.2.1")
|
52
|
-
s.add_dependency("cachetastic", "1.4.2")
|
53
|
-
s.add_dependency("log4r", "1.0.5")
|
54
|
-
s.add_dependency("thin", "0.7.0")
|
55
|
-
s.add_dependency("builder", "2.1.2")
|
56
|
-
s.add_dependency("crypt", "1.1.4")
|
57
|
-
|
58
|
-
|
59
|
-
s.rubyforge_project = gh.project
|
60
|
-
end
|
61
|
-
Rake::GemPackageTask.new(gem_spec) do |pkg|
|
62
|
-
pkg.package_dir = "#{pwd}/pkg"
|
63
|
-
pkg.need_zip = false
|
64
|
-
pkg.need_tar = false
|
65
|
-
end
|
66
|
-
Rake::Task["package"].invoke
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
namespace :install do
|
72
|
-
|
73
|
-
desc "Package up and install the mack gem."
|
74
|
-
task :mack => "gem:package:mack" do |t|
|
75
|
-
GemHelper.instance.install
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
namespace :release do
|
81
|
-
|
82
|
-
desc "Package up, install, and release the mack gem."
|
83
|
-
task :mack => ["gem:install:mack"] do |t|
|
84
|
-
GemHelper.instance.release
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
alias_task :pack, "gem:package:mack"
|
92
|
-
alias_task :install, "gem:install:mack"
|
93
|
-
alias_task :release, "gem:release:mack"
|