mack 0.6.1.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/CHANGELOG +49 -3
  2. data/README +4 -4
  3. data/bin/mack +1 -2
  4. data/lib/mack/controller/controller.rb +1 -1
  5. data/lib/mack/controller/cookie_jar.rb +4 -0
  6. data/lib/mack/controller/request.rb +55 -3
  7. data/lib/mack/controller/session.rb +9 -0
  8. data/lib/mack/controller/tell.rb +13 -0
  9. data/lib/mack/core_extensions/kernel.rb +39 -11
  10. data/lib/mack/core_extensions/symbol.rb +107 -0
  11. data/lib/mack/generators/controller_generator/controller_generator.rb +64 -0
  12. data/lib/mack/generators/controller_generator/manifest.yml +18 -0
  13. data/lib/mack/generators/controller_generator/templates/app/controllers/controller.rb.template +7 -0
  14. data/lib/mack/generators/controller_generator/templates/test/controllers/rspec.rb.template +15 -0
  15. data/lib/mack/generators/controller_generator/templates/test/controllers/test_case.rb.template +15 -0
  16. data/lib/mack/generators/controller_helper_generator/controller_helper_generator.rb +16 -0
  17. data/lib/mack/generators/controller_helper_generator/manifest.yml +15 -0
  18. data/lib/mack/generators/controller_helper_generator/templates/app/helpers/controllers/helper.rb.template +7 -0
  19. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/rspec.rb.template +6 -0
  20. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/test_case.rb.template +10 -0
  21. data/lib/mack/generators/mack_application_generator/mack_application_generator.rb +1 -0
  22. data/lib/mack/generators/mack_application_generator/manifest.yml +26 -10
  23. data/lib/mack/generators/mack_application_generator/templates/Rakefile.template +1 -1
  24. data/lib/mack/generators/mack_application_generator/templates/app/controllers/default_controller.rb.template +7 -1
  25. data/lib/mack/generators/mack_application_generator/templates/app/helpers/controllers/default_controller_helper.rb.template +1 -1
  26. data/lib/mack/generators/mack_application_generator/templates/app/helpers/views/application_helper.rb.template +3 -0
  27. data/lib/mack/generators/mack_application_generator/templates/app/views/default/index.html.erb.template +60 -2
  28. data/lib/mack/generators/mack_application_generator/templates/app/views/layouts/application.html.erb.template +10 -2
  29. data/lib/mack/generators/mack_application_generator/templates/config/app_config/default.yml.template +21 -0
  30. data/lib/mack/generators/mack_application_generator/templates/config/app_config/development.yml.template +1 -0
  31. data/lib/mack/generators/mack_application_generator/templates/config/app_config/production.yml.template +1 -0
  32. data/lib/mack/generators/mack_application_generator/templates/config/app_config/test.yml.template +1 -0
  33. data/lib/mack/generators/mack_application_generator/templates/config/database.yml.template +24 -0
  34. data/lib/mack/generators/mack_application_generator/templates/config/initializers/inflections.rb.template +13 -0
  35. data/lib/mack/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template +1 -0
  36. data/lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template +125 -29
  37. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_spec.rb.template +2 -0
  38. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_test.rb.template +2 -0
  39. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_spec.rb.template +6 -0
  40. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_test.rb.template +10 -0
  41. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_spec.rb.template +6 -0
  42. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_test.rb.template +10 -0
  43. data/lib/mack/generators/view_helper_generator/manifest.yml +15 -0
  44. data/lib/mack/generators/view_helper_generator/templates/app/helpers/views/helper.rb.template +7 -0
  45. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/rspec.rb.template +6 -0
  46. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/test_case.rb.template +10 -0
  47. data/lib/mack/generators/view_helper_generator/view_helper_generator.rb +16 -0
  48. data/lib/mack/initialization/application.rb +6 -6
  49. data/lib/mack/initialization/configuration.rb +17 -9
  50. data/lib/mack/initialization/helpers.rb +3 -3
  51. data/lib/mack/initialization/logging.rb +30 -20
  52. data/lib/mack/rendering/view_template.rb +1 -0
  53. data/lib/mack/routing/route_map.rb +10 -12
  54. data/lib/mack/routing/urls.rb +0 -40
  55. data/lib/mack/runner.rb +7 -2
  56. data/lib/mack/runner_helpers/request_logger.rb +1 -1
  57. data/lib/mack/runner_helpers/session.rb +13 -6
  58. data/lib/mack/tasks/mack_dump_tasks.rake +1 -8
  59. data/lib/mack/tasks/mack_tasks.rake +1 -1
  60. data/lib/mack/tasks/test_tasks.rake +2 -2
  61. data/lib/mack/testing/file.rb +28 -0
  62. data/lib/mack/testing/helpers.rb +59 -4
  63. data/lib/mack/testing/rspec.rb +19 -7
  64. data/lib/mack/utils/mime_types.yml +1 -0
  65. data/lib/mack/utils/server.rb +1 -1
  66. data/lib/mack/version.rb +3 -0
  67. data/lib/mack/view_helpers/date_time_helpers.rb +106 -0
  68. data/lib/mack/view_helpers/form_helpers.rb +282 -0
  69. data/lib/mack/view_helpers/html_helpers.rb +4 -88
  70. data/lib/mack/view_helpers/link_helpers.rb +171 -0
  71. data/lib/mack/view_helpers/object_helpers.rb +14 -0
  72. data/lib/mack/view_helpers/string_helpers.rb +41 -0
  73. data/lib/mack_app.rb +1 -0
  74. data/lib/mack_core.rb +3 -7
  75. data/lib/mack_tasks.rb +8 -16
  76. metadata +36 -27
  77. data/bin/mack_ring_server +0 -33
  78. data/lib/mack/core_extensions/string.rb +0 -21
  79. data/lib/mack/distributed/errors/errors.rb +0 -27
  80. data/lib/mack/distributed/routing/urls.rb +0 -44
  81. data/lib/mack/distributed/utils/rinda.rb +0 -45
  82. data/lib/mack/initialization/orm_support.rb +0 -20
  83. data/lib/mack/tasks/mack_ring_server_tasks.rake +0 -33
  84. data/lib/mack/utils/crypt/default_worker.rb +0 -28
  85. data/lib/mack/utils/crypt/keeper.rb +0 -46
@@ -1,33 +0,0 @@
1
- #!/usr/local/bin/ruby
2
- require 'rubygems'
3
- require 'daemons'
4
- require 'rinda/ring'
5
- require 'rinda/tuplespace'
6
- require 'fileutils'
7
- require 'optparse'
8
- require 'optparse/time'
9
- require 'ostruct'
10
-
11
- options = OpenStruct.new
12
- opts = OptionParser.new do |opts|
13
- opts.banner = <<-BANNER
14
- Usage: mack_ring_server <command>
15
- Available commands are:
16
-
17
- - start
18
- - stop
19
- - restart
20
-
21
- BANNER
22
- end
23
-
24
- opts.parse!(ARGV)
25
-
26
- FileUtils.mkdir_p(File.join("tmp", "pids"))
27
-
28
- Daemons.run_proc('mack_ring_server', {:dir_mode => :normal, :dir => File.join("tmp", "pids"), :monitor => true, :multiple => false}) do
29
- puts 'Starting mack_ring_server...'
30
- DRb.start_service
31
- Rinda::RingServer.new(Rinda::TupleSpace.new)
32
- DRb.thread.join
33
- end
@@ -1,21 +0,0 @@
1
- class String
2
-
3
- # Maps to Kernel _encrypt
4
- #
5
- # Examples:
6
- # "Hello World".encrypt
7
- # "Hello World".encrypt(:my_crypt)
8
- def encrypt(worker = :default)
9
- _encrypt(self, worker)
10
- end
11
-
12
- # Maps to Kernel _decrypt
13
- #
14
- # Examples:
15
- # some_encrypted_string.decrypt
16
- # some_encrypted_string.decrypt(:my_crypt)
17
- def decrypt(worker = :default)
18
- _decrypt(self, worker)
19
- end
20
-
21
- end
@@ -1,27 +0,0 @@
1
- module Mack
2
- module Distributed # :nodoc:
3
- module Errors # :nodoc:
4
-
5
- # Raised when an unknown distributed application is referenced.
6
- class UnknownApplication < StandardError
7
- # Takes the application name.
8
- def initialize(app_name)
9
- super("APPLICATION: #{app_name} is not a known/registered distributed application.")
10
- end
11
- end
12
-
13
- # Raised when an unknown distributed route name for a distributed application is referenced.
14
- class UnknownRouteName < StandardError
15
- # Takes the application name and the route name.
16
- def initialize(app_name, route_name)
17
- super("ROUTE_NAME: #{route_name}, is not a known/registered distributed route name for application: #{app_name}.")
18
- end
19
- end
20
-
21
- # Raised when an application doesn't declare it's application name for use in a distributed system.
22
- class ApplicationNameUndefined < StandardError
23
- end
24
-
25
- end # Errors
26
- end # Distributed
27
- end # Mack
@@ -1,44 +0,0 @@
1
- module Mack
2
- module Distributed
3
- module Routes
4
- # A class used to house the Mack::Routes::Url module for distributed applications.
5
- # Functionally this class does nothing, but since you can't cache a module, a class is needed.
6
- class Urls
7
- include DRbUndumped
8
-
9
- def initialize(dsd) # :nodoc:
10
- @dsd = dsd
11
- end
12
-
13
- def put
14
- Mack::Distributed::Utils::Rinda.register_or_renew(:space => app_config.mack.distributed_app_name.to_sym,
15
- :klass_def => :distributed_routes,
16
- :object => self, :timeout => 0)
17
- end
18
-
19
- def run(meth, options)
20
- self.send(meth, options)
21
- end
22
-
23
- class << self
24
-
25
- def get(app_name)
26
- Mack::Distributed::Utils::Rinda.read(:space => app_name.to_sym, :klass_def => :distributed_routes)
27
- end
28
-
29
- end
30
-
31
- end # Urls
32
-
33
- end # Routes
34
- end # Distributed
35
- end # Mack
36
-
37
- Mack::Routes.after_class_method(:build) do
38
- if app_config.mack.use_distributed_routes
39
- raise Mack::Distributed::Errors::ApplicationNameUndefined.new if app_config.mack.distributed_app_name.nil?
40
-
41
- d_urls = Mack::Distributed::Routes::Urls.new(app_config.mack.distributed_site_domain)
42
- d_urls.put
43
- end
44
- end
@@ -1,45 +0,0 @@
1
- module Mack
2
- module Distributed
3
- module Utils
4
- module Rinda
5
-
6
- def self.register_or_renew(options = {})
7
- options = handle_options(options)
8
- ::DRb.start_service
9
- begin
10
- ring_server.take([options[:space], options[:klass_def], nil, nil], options[:timeout])
11
- rescue Exception => e
12
- # Mack.logger.error(e)
13
- end
14
- register(options)
15
- end
16
-
17
- def self.register(options = {})
18
- options = handle_options(options)
19
- ::DRb.start_service
20
- ring_server.write([options[:space],
21
- options[:klass_def],
22
- options[:object],
23
- options[:description]],
24
- ::Rinda::SimpleRenewer.new)
25
- end
26
-
27
- def self.ring_server
28
- rs = ::Rinda::RingFinger.primary
29
- rs
30
- end
31
-
32
- def self.read(options = {})
33
- options = handle_options(options)
34
- ring_server.read([options[:space], options[:klass_def], nil, options[:description]], options[:timeout])[2]
35
- end
36
-
37
- private
38
- def self.handle_options(options = {})
39
- {:space => :name, :klass_def => nil, :object => nil, :description => nil, :timeout => app_config.mack.drb_timeout}.merge(options)
40
- end
41
-
42
- end
43
- end
44
- end
45
- end
@@ -1,20 +0,0 @@
1
- # If the application explicitly says it doesn't want to use any orm,
2
- # then we're not going to initialize any default orm.
3
- # Note: this is initialization process only. By the default, application
4
- # generated by mack still have data_mapper as default.
5
- orm = app_config.orm
6
- unless orm.nil?
7
- Mack.logger.warn %{
8
- Please note that setting up orm in app_config has been deprecated, and will not be supported in future mack releases.
9
- Here's how to update your existing application:
10
- 1. Remove the line:
11
- orm: data_mapper
12
- from the app_config/default.yml file
13
- 2. In gems.rb, add the following line in the require_gems block:
14
- gem.add "mack-data_mapper", :libs => "mack-data_mapper"
15
- ** if you use active record, then change it to mack-active_record instead of mack-data_mapper
16
- }
17
- Mack.logger.debug "Initializing #{orm} orm..."
18
- require "mack-#{orm}"
19
- require "mack-#{orm}_tasks"
20
- end
@@ -1,33 +0,0 @@
1
- require 'rinda/ring'
2
- namespace :mack do
3
- namespace :ring_server do
4
-
5
- desc "Start the Rinda ring server"
6
- task :start do
7
- `mack_ring_server start`
8
- end
9
-
10
- desc "Stop the Rinda ring server"
11
- task :stop do
12
- `mack_ring_server stop`
13
- end
14
-
15
- namespace :services do
16
-
17
- desc "Lists all services on the ring server"
18
- task :list do
19
- DRb.start_service
20
- ring_server = Rinda::RingFinger.primary
21
- services = ring_server.read_all([nil, nil, nil, nil])
22
- puts "Services on #{ring_server.__drburi}"
23
- services.each do |service|
24
- puts "#{service[0]}: #{service[1]} on #{service[2].__drburi} - #{service[3]}"
25
- end
26
- end
27
-
28
- end # services
29
-
30
- end # ring_server
31
- end # mack
32
-
33
- alias_task "mack:ring_server:restart", "mack:ring_server:stop", "mack:ring_server:start"
@@ -1,28 +0,0 @@
1
- module Mack
2
- module Utils # :nodoc:
3
- module Crypt # :nodoc:
4
- # The default worker is one that is used when no other worker is specified or the
5
- # specified worker does not exist. It uses the Crypt::Rijndael library and get's
6
- # it's secret key from app_config.default_secret_key
7
- class DefaultWorker
8
-
9
- def initialize
10
- @aes_key = ::Crypt::Rijndael.new(app_config.default_secret_key || (String.randomize(40)))
11
- end
12
-
13
- # Encrypts a string using the Crypt::Rijndael library and the secret key found in
14
- # app_config.default_secret_key
15
- def encrypt(x)
16
- @aes_key.encrypt_string(x)
17
- end
18
-
19
- # Decrypts a string using the Crypt::Rijndael library and the secret key found in
20
- # app_config.default_secret_key
21
- def decrypt(x)
22
- @aes_key.decrypt_string(x)
23
- end
24
-
25
- end # DefaultWorker
26
- end # Crypt
27
- end # Utils
28
- end # Mack
@@ -1,46 +0,0 @@
1
- module Mack
2
- module Utils
3
- module Crypt
4
- # A singleton class that holds/manages all the workers for the system.
5
- #
6
- # A worker must be defined as Mack::Utils::Crypt::<name>Worker and must
7
- # define an encrypt(value) method and a decrypt(value) method.
8
- #
9
- # Example:
10
- # class Mack::Utils::Crypt::ReverseWorker
11
- # def encrypt(x)
12
- # x.reverse
13
- # end
14
- #
15
- # def decrypt(x)
16
- # x.reverse
17
- # end
18
- # end
19
- class Keeper
20
- include Singleton
21
-
22
- def initialize
23
- @crypt_workers_cache = {}
24
- end
25
-
26
- # Returns a worker object to handle the encrytion/decryption.
27
- # If the specified worker doesn't exist then Mack::Utils::Crypt::DefaultWorker
28
- # is returned.
29
- def worker(key = :default)
30
- worker = @crypt_workers_cache[key.to_sym]
31
- if worker.nil?
32
- worker_klass = key.to_s.camelcase + "Worker"
33
- if Mack::Utils::Crypt.const_defined?(worker_klass)
34
- worker = "Mack::Utils::Crypt::#{worker_klass}".constantize.new
35
- else
36
- worker = Mack::Utils::Crypt::DefaultWorker.new
37
- end
38
- @crypt_workers_cache[key.to_sym] = worker
39
- end
40
- worker
41
- end
42
-
43
- end # Keeper
44
- end # Crypt
45
- end # Utils
46
- end # Mack