mack 0.4.7 → 0.5.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 +21 -2
- data/README +1 -4
- data/bin/mack +2 -2
- data/lib/errors/errors.rb +1 -10
- data/lib/generators/mack_application_generator/manifest.yml +5 -1
- data/lib/generators/mack_application_generator/templates/config/database.yml.template +45 -1
- data/lib/generators/mack_application_generator/templates/test/test_helper.rb.template +1 -1
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %> → %=@plugin_name%}/init.rb.template +0 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %>/lib/<%= @plugin_name %>.rb.template → %=@plugin_name%/lib/%=@plugin_name%.rb.template} +0 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %>/lib/tasks/<%= @plugin_name %>_tasks.rake.template → %=@plugin_name%/lib/tasks/%=@plugin_name%_tasks.rake.template} +0 -0
- data/lib/initialization/configuration.rb +28 -6
- data/lib/initialization/console.rb +2 -0
- data/lib/initialization/initializer.rb +23 -36
- data/lib/initialization/initializers/logging.rb +2 -2
- data/lib/initialization/initializers/orm_support.rb +4 -63
- data/lib/initialization/initializers/plugins.rb +1 -1
- data/lib/initialization/server/simple_server.rb +0 -2
- data/lib/mack.rb +2 -2
- data/lib/mack_tasks.rb +6 -0
- data/lib/rendering/base.rb +1 -1
- data/lib/rendering/classes/action.rb +1 -1
- data/lib/rendering/classes/public.rb +1 -1
- data/lib/rendering/classes/url.rb +1 -0
- data/lib/rendering/classes/xml.rb +1 -1
- data/lib/sea_level/controller_base.rb +19 -10
- data/lib/sea_level/helpers/view_helpers/html_helpers.rb +96 -11
- data/lib/sea_level/helpers/view_helpers/string_helpers.rb +22 -0
- data/lib/sea_level/uploaded_file.rb +1 -0
- data/lib/sea_level/view_binder.rb +14 -11
- data/lib/tasks/cachetastic_tasks.rake +11 -11
- data/lib/tasks/mack_server_tasks.rake +3 -3
- data/lib/tasks/mack_tasks.rake +2 -5
- data/lib/tasks/rake_rules.rake +1 -2
- data/lib/tasks/test_tasks.rake +22 -1
- data/lib/test_extensions/test_case.rb +50 -0
- data/lib/test_extensions/test_helpers.rb +22 -5
- metadata +30 -30
- data/lib/generators/genosaurus_helpers.rb +0 -38
- data/lib/generators/migration_generator/migration_generator.rb +0 -67
- data/lib/generators/migration_generator/templates/db/migrations/<%=@migration_name%>.rb.template +0 -31
- data/lib/generators/model_column.rb +0 -55
- data/lib/generators/model_generator/manifest.yml +0 -11
- data/lib/generators/model_generator/model_generator.rb +0 -93
- data/lib/generators/model_generator/templates/active_record.rb.template +0 -2
- data/lib/generators/model_generator/templates/data_mapper.rb.template +0 -11
- data/lib/generators/model_generator/templates/test.rb.template +0 -9
- data/lib/generators/scaffold_generator/manifest.yml +0 -31
- data/lib/generators/scaffold_generator/scaffold_generator.rb +0 -43
- data/lib/generators/scaffold_generator/templates/generic/app/controllers/controller.rb.template +0 -50
- data/lib/generators/scaffold_generator/templates/generic/app/views/edit.html.erb.template +0 -20
- data/lib/generators/scaffold_generator/templates/generic/app/views/index.html.erb.template +0 -41
- data/lib/generators/scaffold_generator/templates/generic/app/views/new.html.erb.template +0 -19
- data/lib/generators/scaffold_generator/templates/generic/app/views/show.html.erb.template +0 -12
- data/lib/generators/scaffold_generator/templates/no_orm/controller.rb.template +0 -38
- data/lib/generators/scaffold_generator/templates/test.rb.template +0 -9
- data/lib/sea_level/helpers/view_helpers/orm_helpers.rb +0 -87
- data/lib/tasks/db_tasks.rake +0 -94
- data/lib/utils/html.rb +0 -104
data/lib/tasks/db_tasks.rake
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
namespace :db do
|
2
|
-
|
3
|
-
desc "Migrate the database through scripts in db/migrations"
|
4
|
-
task :migrate => "db:schema:create" do
|
5
|
-
migration_files.each do |migration|
|
6
|
-
require migration
|
7
|
-
migration = File.basename(migration, ".rb")
|
8
|
-
m_number = migration_number(migration)
|
9
|
-
if m_number > @schema_info.version
|
10
|
-
migration_name(migration).camelcase.constantize.up
|
11
|
-
@schema_info.version += 1
|
12
|
-
@schema_info.save
|
13
|
-
end
|
14
|
-
end # each
|
15
|
-
end # migrate
|
16
|
-
|
17
|
-
desc "Rolls the schema back to the previous version. Specify the number of steps with STEP=n"
|
18
|
-
task :rollback => ["db:schema:create", "db:abort_if_pending_migrations"] do
|
19
|
-
migrations = migration_files.reverse
|
20
|
-
(ENV["STEP"] || 1).to_i.times do |step|
|
21
|
-
migration = migrations[step]
|
22
|
-
require migration
|
23
|
-
migration = File.basename(migration, ".rb")
|
24
|
-
m_number = migration_number(migration)
|
25
|
-
if m_number == @schema_info.version
|
26
|
-
migration_name(migration).camelcase.constantize.down
|
27
|
-
@schema_info.version -= 1
|
28
|
-
@schema_info.save
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end # rollback
|
33
|
-
|
34
|
-
desc "Raises an error if there are pending migrations"
|
35
|
-
task :abort_if_pending_migrations do
|
36
|
-
migrations = migration_files.reverse
|
37
|
-
return if migrations.empty?
|
38
|
-
migration = migrations.first
|
39
|
-
migration = File.basename(migration, ".rb")
|
40
|
-
m_number = migration_number(migration)
|
41
|
-
if m_number > @schema_info.version
|
42
|
-
raise Mack::Errors::UnrunMigrations.new(m_number - @schema_info.version)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Displays the current schema version of your database"
|
47
|
-
task :version => "db:schema:create" do
|
48
|
-
puts "\nYour database is currently at version: #{@schema_info.version}\n"
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
namespace :schema do
|
53
|
-
|
54
|
-
task :create => "mack:environment" do
|
55
|
-
if using_data_mapper?
|
56
|
-
require 'data_mapper/migration'
|
57
|
-
unless DmSchemaInfo.table.exists?
|
58
|
-
DmSchemaInfo.table.create!
|
59
|
-
DmSchemaInfo.create(:version => 0)
|
60
|
-
end
|
61
|
-
@schema_info = DmSchemaInfo.first
|
62
|
-
elsif using_active_record?
|
63
|
-
require 'active_record/migration'
|
64
|
-
class CreateArSchemaInfo < ActiveRecord::Migration # :nodoc:
|
65
|
-
def self.up
|
66
|
-
create_table :schema_info do |t|
|
67
|
-
t.column :version, :integer, :default => 0
|
68
|
-
end
|
69
|
-
end # up
|
70
|
-
end # CreateArSchemaInfo
|
71
|
-
unless ArSchemaInfo.table_exists?
|
72
|
-
CreateArSchemaInfo.up
|
73
|
-
ArSchemaInfo.create(:version => 0)
|
74
|
-
end
|
75
|
-
@schema_info = ArSchemaInfo.find(:first)
|
76
|
-
end
|
77
|
-
end # create
|
78
|
-
|
79
|
-
end # schema
|
80
|
-
|
81
|
-
|
82
|
-
def migration_files
|
83
|
-
Dir.glob(File.join(MACK_ROOT, "db", "migrations", "*.rb"))
|
84
|
-
end
|
85
|
-
|
86
|
-
def migration_number(migration)
|
87
|
-
migration.match(/(^\d+)/).captures.last.to_i
|
88
|
-
end
|
89
|
-
|
90
|
-
def migration_name(migration)
|
91
|
-
migration.match(/^\d+_(.+)/).captures.last
|
92
|
-
end
|
93
|
-
|
94
|
-
end # db
|
data/lib/utils/html.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
module Mack
|
2
|
-
module Utils
|
3
|
-
# Useful utilities for dealing with HTML.
|
4
|
-
class Html
|
5
|
-
|
6
|
-
class << self
|
7
|
-
|
8
|
-
# Used in views to create href links. It takes link_text, url, and a Hash that gets added
|
9
|
-
# to the href as options.
|
10
|
-
#
|
11
|
-
# Examples:
|
12
|
-
# Mack::Utils::Html.href("http://www.mackframework.com") # => <a href="http://www.mackframework.com">http://www.mackframework.com</a>
|
13
|
-
# Mack::Utils::Html.href("Mack", "http://www.mackframework.com") # => <a href="http://www.mackframework.com">Mack</a>
|
14
|
-
# Mack::Utils::Html.href("Mack", "http://www.mackframework.com", :target => "_blank") # => <a href="http://www.mackframework.com" target="_blank">Mack</a>
|
15
|
-
# Mack::Utils::Html.href("Mack", "http://www.mackframework.com", :target => "_blank", :rel => :nofollow) # => <a href="http://www.mackframework.com" target="_blank" rel="nofollow">Mack</a>
|
16
|
-
# If you pass in :method as an option it will be a JavaScript form that will post to the specified link with the
|
17
|
-
# methd specified.
|
18
|
-
# Mack::Utils::Html.href("Mack", "http://www.mackframework.com", :method => :delete)
|
19
|
-
# If you use the :method option you can also pass in a :confirm option. The :confirm option will generate a
|
20
|
-
# javascript confirmation window. If 'OK' is selected the the form will submit. If 'cancel' is selected, then
|
21
|
-
# nothing will happen. This is extremely useful for 'delete' type of links.
|
22
|
-
# Mack::Utils::Html.href("Mack", "http://www.mackframework.com", :method => :delete, :confirm => "Are you sure?")
|
23
|
-
def href(link_text, url = link_text, html_options = {})
|
24
|
-
if html_options[:method]
|
25
|
-
meth = nil
|
26
|
-
confirm = nil
|
27
|
-
|
28
|
-
meth = %{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', '_method'); s.setAttribute('value', '#{html_options[:method]}'); f.appendChild(s);f.submit()}
|
29
|
-
html_options.delete(:method)
|
30
|
-
|
31
|
-
if html_options[:confirm]
|
32
|
-
confirm = %{if (confirm('#{html_options[:confirm]}'))}
|
33
|
-
html_options.delete(:confirm)
|
34
|
-
end
|
35
|
-
|
36
|
-
html_options[:onclick] = (confirm ? (confirm + " { ") : "") << meth << (confirm ? (" } ") : "") << ";return false;"
|
37
|
-
end
|
38
|
-
|
39
|
-
html = "<a href=" << '"' << url
|
40
|
-
html << '"'
|
41
|
-
html << " " << html_options.join("%s=\"%s\"", " ") unless html_options.empty?
|
42
|
-
html << ">" << link_text
|
43
|
-
html << "</a>"
|
44
|
-
html
|
45
|
-
end
|
46
|
-
|
47
|
-
alias_method :a, :href
|
48
|
-
|
49
|
-
# A wrapper to generate an auto discovery tag so browsers no the page contains an RSS feed.
|
50
|
-
#
|
51
|
-
# Example:
|
52
|
-
# <%= Mack::Utils::Html.rss(posts_index_url(:format => :xml)) %>
|
53
|
-
def rss(url)
|
54
|
-
"<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"#{url}\">"
|
55
|
-
end
|
56
|
-
|
57
|
-
# Wraps the content_tag method.
|
58
|
-
#
|
59
|
-
# Examples:
|
60
|
-
# Mack::Utils::Html.b("hello") # => <b>hello</b>
|
61
|
-
# Mack::Utils::Html.div("hello world!", :class => :foo)) # => <div class="foo">hello world!</div>
|
62
|
-
def method_missing(sym, *args)
|
63
|
-
ags = args.parse_splat_args
|
64
|
-
|
65
|
-
tag = sym
|
66
|
-
content = nil
|
67
|
-
options = {}
|
68
|
-
|
69
|
-
if ags.is_a?(Array)
|
70
|
-
content = ags[0] if ags[0].is_a?(String)
|
71
|
-
options = ags[1] if ags[1].is_a?(Hash)
|
72
|
-
elsif ags.is_a?(String)
|
73
|
-
content = ags
|
74
|
-
elsif ags.is_a?(Hash)
|
75
|
-
options = ags
|
76
|
-
end
|
77
|
-
|
78
|
-
content = yield if block_given?
|
79
|
-
|
80
|
-
content_tag(tag, content, options)
|
81
|
-
end
|
82
|
-
|
83
|
-
# Builds an HTML tag.
|
84
|
-
#
|
85
|
-
# Examples:
|
86
|
-
# content_tag(:b, "hello") # => <b>hello</b>
|
87
|
-
# content_tag("div", "hello world!", :class => :foo) # => <div class="foo">hello world!</div>
|
88
|
-
def content_tag(tag, content, options = {})
|
89
|
-
html = "<#{tag} #{options.join("%s=\"%s\"", " ")}>#{content}</#{tag}>"
|
90
|
-
end
|
91
|
-
|
92
|
-
# Builds a HTML image tag.
|
93
|
-
#
|
94
|
-
def image_tag(image_src, options = {})
|
95
|
-
html = "<img src=\"#{image_src}\""
|
96
|
-
html << " " << options.join("%s=\"%s\"", " ") unless options.empty?
|
97
|
-
html << ">"
|
98
|
-
end
|
99
|
-
|
100
|
-
end # self
|
101
|
-
|
102
|
-
end # Html
|
103
|
-
end # Utils
|
104
|
-
end # Mack
|