diff --git a/README.rdoc b/README.rdoc index ee999fb2c..b5c97675d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,15 @@ +== (Padrino Admin TwitterBootstrap 2.1) +* Slim, Haml, Erb engine +* Remove all locale, now only English +* Remove all unused helper +* Padrino-Modal: rack-flash and delete function into modal :D +* highlights error field +* Automatic replace true or false with relative image (list.slim, list.haml, list.erb) +* Breadcrumbs +* Automatic time_ago_in_words when column model is created_at or updated_at +* Migrate function for MiniRecord +* tag_icon helper + = Padrino Padrino is the godfather of Sinatra. Follow us on @@ -88,4 +100,4 @@ The individual Padrino sub-gems also contain README's which outlines their funct == Copyright -Copyright (c) 2011 Padrino. See LICENSE for details. +Copyright (c) 2012 Padrino. See LICENSE for details. diff --git a/padrino-admin/lib/padrino-admin.rb b/padrino-admin/lib/padrino-admin.rb index ee83ec834..deff4c384 100644 --- a/padrino-admin/lib/padrino-admin.rb +++ b/padrino-admin/lib/padrino-admin.rb @@ -21,11 +21,6 @@ module Admin; end # String.send(:include, Padrino::Admin::Utils::Crypt) -## -# Load our Padrino::Admin locales -# -I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-admin/locale/**/*.yml"] - ## # Now we need to add admin generators to padrino-gen # diff --git a/padrino-admin/padrino-admin.gemspec b/padrino-admin/padrino-admin.gemspec old mode 100755 new mode 100644 diff --git a/padrino-cache/padrino-cache.gemspec b/padrino-cache/padrino-cache.gemspec old mode 100755 new mode 100644 diff --git a/padrino-core/padrino-core.gemspec b/padrino-core/padrino-core.gemspec old mode 100755 new mode 100644 diff --git a/padrino-gen/lib/padrino-gen/generators/actions.rb b/padrino-gen/lib/padrino-gen/generators/actions.rb index 9b75d721d..46066f559 100644 --- a/padrino-gen/lib/padrino-gen/generators/actions.rb +++ b/padrino-gen/lib/padrino-gen/generators/actions.rb @@ -270,11 +270,11 @@ def require_dependencies(*gem_names) # @api public def insert_into_gemfile(name, options={}) after_pattern = options[:group] ? "#{options[:group].to_s.capitalize} requirements\n" : "Component requirements\n" - version = options.delete(:version) - gem_options = options.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join(", ") - write_option = gem_options.present? ? ", #{gem_options}" : "" - write_version = version.present? ? ", #{version.inspect}" : "" - include_text = "gem '#{name}'"<< write_version << write_option << "\n" + version = options.delete(:version) + gem_options = options.map { |k, v| ":#{k} => '#{v.to_s}'" }.join(", ") + write_option = gem_options.present? ? ", #{gem_options}" : '' + write_version = version.present? ? ", '#{version.to_s}'" : '' + include_text = "gem '#{name}'" << write_version << write_option << "\n" inject_into_file('Gemfile', include_text, :after => after_pattern) end @@ -351,14 +351,14 @@ def test? # # @api public def tiny? - File.exist?(destination_root("app/controllers.rb")) + File.exist?(destination_root('app/controllers.rb')) end # Run the bundler # # @api semipublic def run_bundler - say "Bundling application dependencies using bundler...", :yellow + say 'Bundling application dependencies using bundler...', :yellow in_root { run 'bundle install' } end @@ -418,12 +418,12 @@ def check_app_existence(app) # # @api private def app_skeleton(app, tiny=false) - directory("app/", destination_root(app)) + directory('app/', destination_root(app)) if tiny # generate tiny structure - template "templates/controller.rb.tt", destination_root(app, "controllers.rb") - template "templates/helper.rb.tt", destination_root(app, "helpers.rb") + template 'templates/controller.rb.tt', destination_root(app, 'controllers.rb') + template 'templates/helper.rb.tt', destination_root(app, 'helpers.rb') @short_name = 'notifier' - template "templates/mailer.rb.tt", destination_root(app, "mailers.rb") + template 'templates/mailer.rb.tt', destination_root(app, 'mailers.rb') else # generate standard folders empty_directory destination_root(app, 'controllers') empty_directory destination_root(app, 'helpers') diff --git a/padrino-gen/lib/padrino-gen/generators/app.rb b/padrino-gen/lib/padrino-gen/generators/app.rb index 17f9b447e..5757b1583 100644 --- a/padrino-gen/lib/padrino-gen/generators/app.rb +++ b/padrino-gen/lib/padrino-gen/generators/app.rb @@ -19,12 +19,10 @@ def self.banner; "padrino-gen project [name]"; end include Padrino::Generators::Actions desc "Description:\n\n\tpadrino-gen app generates a new Padrino application" - - argument :name, :desc => "The name of your padrino application" - - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string + argument :name, :desc => 'The name of your padrino application' + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string class_option :destroy, :aliases => '-d', :default => false, :type => :boolean - class_option :tiny, :desc => "Generate tiny app skeleton", :aliases => '-i', :default => false, :type => :boolean + class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean # Show help if no argv given require_arguments! @@ -34,24 +32,24 @@ def self.banner; "padrino-gen project [name]"; end # @api private def create_app self.destination_root = options[:root] - @app_name = name.gsub(/\W/, "_").underscore.camelize + @app_name = name.gsub(/\W/, '_').underscore.camelize if in_app_root? self.behavior = :revoke if options[:destroy] app_skeleton(@app_name.downcase, options[:tiny]) empty_directory destination_root("public/#{@app_name.downcase}") - append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"#{@app_name}\").to(\"/#{@app_name.downcase}\")" + append_file destination_root('config/apps.rb'), "\nPadrino.mount('#{@app_name}').to('/#{@app_name.downcase}')" return if self.behavior == :revoke say - say "="*65, :green + say '=' * 65, :green say "Your #{@app_name} application has been installed." - say "="*65, :green + say '='*65, :green say "This application has been mounted to /#{@app_name.downcase}" - say "You can configure a different path by editing 'config/apps.rb" - say "="*65, :green + say "You can configure a different path by editing 'config/apps.rb'" + say '=' * 65, :green say else - say "You are not at the root of a Padrino application! (config/boot.rb not found)" + say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end # App diff --git a/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt b/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt index fe3769d0a..d1b3dd1b3 100644 --- a/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt +++ b/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt @@ -27,10 +27,10 @@ class <%= @app_name %> < Padrino::Application # set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development) # set :show_exceptions, true # Shows a stack trace in browser (default for development) # set :logging, true # Logging in STDOUT for development and file for production (default only for development) - # set :public_folder, "foo/bar" # Location for static assets (default root/public) + # set :public_folder, 'foo/bar' # Location for static assets (default root/public) # set :reload, false # Reload application files (default in development) - # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder') - # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales) + # set :default_builder, 'foo' # Set a custom form builder (default 'StandardFormBuilder') + # set :locale_path, 'bar' # Set path for I18n translations (default your_app/locales) # disable :sessions # Disabled sessions by default (enable if needed) # disable :flash # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined) # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application) diff --git a/padrino-gen/lib/padrino-gen/generators/cli.rb b/padrino-gen/lib/padrino-gen/generators/cli.rb index cd9549eea..28dda4565 100644 --- a/padrino-gen/lib/padrino-gen/generators/cli.rb +++ b/padrino-gen/lib/padrino-gen/generators/cli.rb @@ -20,8 +20,8 @@ class Cli < Thor::Group # @api private def load_boot begin - ENV['PADRINO_LOG_LEVEL'] ||= "test" - ENV['BUNDLE_GEMFILE'] = File.join(options[:root], "Gemfile") if options[:root] + ENV['PADRINO_LOG_LEVEL'] ||= 'test' + ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root] boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb' if File.exist?(boot) require File.expand_path(boot) @@ -47,7 +47,7 @@ def setup generator_class = Padrino::Generators.mappings[generator_kind] if generator_class - args = ARGV.empty? && generator_class.require_arguments? ? ["-h"] : ARGV + args = ARGV.empty? && generator_class.require_arguments? ? ['-h'] : ARGV generator_class.start(args) else puts "Please specify generator to use (#{Padrino::Generators.mappings.keys.join(", ")})" diff --git a/padrino-gen/lib/padrino-gen/generators/controller.rb b/padrino-gen/lib/padrino-gen/generators/controller.rb index 285b3b829..57617b0ed 100644 --- a/padrino-gen/lib/padrino-gen/generators/controller.rb +++ b/padrino-gen/lib/padrino-gen/generators/controller.rb @@ -20,11 +20,11 @@ def self.banner; "padrino-gen controller [name]"; end desc "Description:\n\n\tpadrino-gen controller generates a new Padrino controller" - argument :name, :desc => "The name of your padrino controller" - argument :fields, :desc => "The fields for the controller", :type => :array, :default => [] - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string - class_option :app, :desc => "The application destination path", :aliases => '-a', :default => "/app", :type => :string - class_option :destroy, :aliases => '-d', :default => false, :type => :boolean + argument :name, :desc => 'The name of your padrino controller' + argument :fields, :desc => 'The fields for the controller', :default => [], :type => :array + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string + class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string + class_option :destroy, :aliases => '-d', :default => false, :type => :boolean # Show help if no argv given require_arguments! @@ -37,17 +37,17 @@ def create_controller if in_app_root? app = options[:app] check_app_existence(app) - @app_name = fetch_app_name(app) - @actions = controller_actions(fields) + @app_name = fetch_app_name(app) + @actions = controller_actions(fields) @controller = name.to_s.underscore self.behavior = :revoke if options[:destroy] - template "templates/controller.rb.tt", destination_root(app, "controllers", "#{name.to_s.underscore}.rb") - template "templates/helper.rb.tt", destination_root(app, "helpers", "#{name.to_s.underscore}_helper.rb") + template 'templates/controller.rb.tt', destination_root(app, 'controllers', "#{name.to_s.underscore}.rb") + template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb") empty_directory destination_root(app, "/views/#{name.to_s.underscore}") include_component_module_for(:test) generate_controller_test(name) if test? else - say "You are not at the root of a Padrino application! (config/boot.rb not found)" + say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end # Controller diff --git a/padrino-gen/lib/padrino-gen/generators/mailer.rb b/padrino-gen/lib/padrino-gen/generators/mailer.rb index 491409006..fd331c616 100644 --- a/padrino-gen/lib/padrino-gen/generators/mailer.rb +++ b/padrino-gen/lib/padrino-gen/generators/mailer.rb @@ -11,7 +11,7 @@ class Mailer < Thor::Group # Define the source template root def self.source_root; File.expand_path(File.dirname(__FILE__)); end # Defines the banner for this CLI generator - def self.banner; "padrino-gen mailer [name]"; end + def self.banner; 'padrino-gen mailer [name]'; end # Include related modules include Thor::Actions @@ -20,11 +20,11 @@ def self.banner; "padrino-gen mailer [name]"; end desc "Description:\n\n\tpadrino-gen mailer generates a new Padrino mailer" - argument :name, :desc => "The name of your padrino mailer" - argument :actions, :desc => "The delivery actions to add to your mailer", :type => :array, :default => [] - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string - class_option :app, :desc => "The application destination path", :aliases => '-a', :default => "/app", :type => :string - class_option :destroy, :aliases => '-d', :default => false, :type => :boolean + argument :name, :desc => 'The name of your padrino mailer' + argument :actions, :desc => 'The delivery actions to add to your mailer', :type => :array, :default => [] + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string + class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string + class_option :destroy, :aliases => '-d', :default => false, :type => :boolean # Show help if no argv given require_arguments! @@ -45,7 +45,7 @@ def create_mailer template "templates/mailer.rb.tt", destination_root(app, 'mailers', "#{@mailer_basename}.rb") empty_directory destination_root(app, 'views', 'mailers', @mailer_basename) else - say "You are not at the root of a Padrino application! (config/boot.rb not found)" + say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end # Mailer diff --git a/padrino-gen/lib/padrino-gen/generators/migration.rb b/padrino-gen/lib/padrino-gen/generators/migration.rb index 656350348..8c9f3ba73 100644 --- a/padrino-gen/lib/padrino-gen/generators/migration.rb +++ b/padrino-gen/lib/padrino-gen/generators/migration.rb @@ -20,9 +20,9 @@ def self.banner; "padrino-gen migration [name] [fields]"; end desc "Description:\n\n\tpadrino-gen migration generates a new migration file" - argument :name, :desc => "The name of your padrino migration" - argument :columns, :desc => "The columns for the migration", :type => :array, :default => [] - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string + argument :name, :desc => 'The name of your padrino migration' + argument :columns, :desc => 'The columns for the migration', :type => :array, :default => [] + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string class_option :destroy, :aliases => '-d', :default => false, :type => :boolean # Show help if no argv given @@ -36,11 +36,11 @@ def create_migration if include_component_module_for(:orm) create_migration_file(name, name, columns) else - say "<= You need an ORM adapter for run this generator. Sorry!" + say '<= You need an ORM adapter for run this generator. Sorry!' raise SystemExit end else - say "You are not at the root of a Padrino application! (config/boot.rb not found)" + say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end # Migration diff --git a/padrino-gen/lib/padrino-gen/generators/model.rb b/padrino-gen/lib/padrino-gen/generators/model.rb index 5e19c4df3..db4ca79de 100644 --- a/padrino-gen/lib/padrino-gen/generators/model.rb +++ b/padrino-gen/lib/padrino-gen/generators/model.rb @@ -20,12 +20,12 @@ def self.banner; "padrino-gen model [name] [fields]"; end desc "Description:\n\n\tpadrino-gen model generates a new model and migration files" - argument :name, :desc => "The name of your padrino model" - argument :fields, :desc => "The fields for the model", :type => :array, :default => [] - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string - class_option :app, :desc => "The application destination path", :aliases => '-a', :default => ".", :type => :string + argument :name, :desc => 'The name of your padrino model' + argument :fields, :desc => 'The fields for the model', :type => :array, :default => [] + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string + class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '.', :type => :string class_option :destroy, :aliases => '-d', :default => false, :type => :boolean - class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean + class_option :skip_migration, :aliases => '-s', :default => false, :type => :boolean # Show help if no argv given require_arguments! @@ -40,7 +40,7 @@ def create_model check_app_existence(app) self.behavior = :revoke if options[:destroy] if invalids = invalid_fields(fields) - say "Invalid field name:", :red + say 'Invalid field name:', :red say " #{invalids.join(", ")}" return end @@ -54,7 +54,7 @@ def create_model generate_model_test(name) if test? create_model_migration(migration_name, name, fields) unless options[:skip_migration] else - say "You are not at the root of a Padrino application! (config/boot.rb not found)" + say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end # Model diff --git a/padrino-gen/lib/padrino-gen/generators/project.rb b/padrino-gen/lib/padrino-gen/generators/project.rb index ed106cd64..5dee757d6 100644 --- a/padrino-gen/lib/padrino-gen/generators/project.rb +++ b/padrino-gen/lib/padrino-gen/generators/project.rb @@ -24,23 +24,23 @@ def self.banner; "padrino-gen project [name] [options]"; end desc "Description:\n\n\tpadrino-gen project generates a new Padrino project" - argument :name, :desc => "The name of your padrino project" + argument :name, :desc => 'The name of your padrino project' - class_option :app , :desc => "The application name", :aliases => '-n', :default => nil, :type => :string - class_option :bundle, :desc => "Run bundle install", :aliases => '-b', :default => false, :type => :boolean - class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string - class_option :dev, :desc => "Use padrino from a git checkout", :default => false, :type => :boolean - class_option :tiny, :desc => "Generate tiny app skeleton", :aliases => '-i', :default => false, :type => :boolean - class_option :adapter, :desc => "SQL adapter for ORM (sqlite, mysql, mysql2, postgres)", :aliases => '-a', :default => "sqlite", :type => :string - class_option :template, :desc => "Generate project from template", :aliases => '-p', :default => nil, :type => :string + class_option :app , :desc => 'The application name', :aliases => '-n', :default => nil, :type => :string + class_option :bundle, :desc => 'Run bundle install', :aliases => '-b', :default => false, :type => :boolean + class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string + class_option :dev, :desc => 'Use padrino from a git checkout', :default => false, :type => :boolean + class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean + class_option :adapter, :desc => 'SQL adapter for ORM (sqlite, mysql, mysql2, postgres)', :aliases => '-a', :default => 'sqlite', :type => :string + class_option :template, :desc => 'Generate project from template', :aliases => '-p', :default => nil, :type => :string # Definitions for the available customizable components - component_option :orm, "database engine", :aliases => '-d', :choices => [:activerecord, :mini_record, :datamapper, :mongomapper, :mongoid, :sequel, :couchrest, :ohm, :mongomatic, :ripple], :default => :none - component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec, :shoulda, :cucumber, :bacon, :testspec, :riot, :minitest], :default => :none - component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr], :default => :none - component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools, :extcore, :dojo], :default => :none - component_option :renderer, "template engine", :aliases => '-e', :choices => [:haml, :erb, :liquid, :slim], :default => :haml - component_option :stylesheet, "stylesheet engine", :aliases => '-c', :choices => [:less, :sass, :compass, :scss], :default => :none + component_option :orm, 'database engine', :aliases => '-d', :choices => [:activerecord, :mini_record, :datamapper, :mongomapper, :mongoid, :sequel, :couchrest, :ohm, :mongomatic, :ripple], :default => :none + component_option :test, 'testing framework', :aliases => '-t', :choices => [:rspec, :shoulda, :cucumber, :bacon, :testspec, :riot, :minitest], :default => :none + component_option :mock, 'mocking library', :aliases => '-m', :choices => [:mocha, :rr], :default => :none + component_option :script, 'javascript library', :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools, :extcore, :dojo], :default => :none + component_option :renderer, 'template engine', :aliases => '-e', :choices => [:haml, :erb, :liquid, :slim], :default => :haml + component_option :stylesheet, 'stylesheet engine', :aliases => '-c', :choices => [:less, :sass, :compass, :scss], :default => :none # Show help if no argv given require_arguments! @@ -50,19 +50,19 @@ def self.banner; "padrino-gen project [name] [options]"; end # @api private def setup_project valid_constant?(options[:app] || name) - @app_name = (options[:app] || name).gsub(/\W/, "_").underscore.camelize + @app_name = (options[:app] || name).gsub(/\W/, '_').underscore.camelize self.destination_root = File.join(options[:root], name) if options[:template] # Run the template to create project execute_runner(:template, options[:template]) else # generate project without template - directory("project/", destination_root) - empty_directory destination_root("public/images") - empty_directory destination_root("public/javascripts") - empty_directory destination_root("public/stylesheets") - empty_directory destination_root("tmp") + directory('project/', destination_root) + empty_directory destination_root('public/images') + empty_directory destination_root('public/javascripts') + empty_directory destination_root('public/stylesheets') + empty_directory destination_root('tmp') store_component_config('.components') app_skeleton('app', options[:tiny]) - template "templates/Gemfile.tt", destination_root("Gemfile") + template 'templates/Gemfile.tt', destination_root('Gemfile') end end @@ -93,9 +93,9 @@ def bundle_dependencies # @api private def finish_message say - say "="*65, :green + say '=' * 65, :green say "#{name} is ready for development!", :green - say "="*65, :green + say '=' * 65, :green say "$ cd #{options[:root]}/#{name}" say "$ bundle" unless options[:bundle] say "="*65, :green diff --git a/padrino-gen/lib/padrino-gen/generators/project/config.ru b/padrino-gen/lib/padrino-gen/generators/project/config.ru old mode 100755 new mode 100644 diff --git a/padrino-gen/lib/padrino-gen/generators/project/config/apps.rb.tt b/padrino-gen/lib/padrino-gen/generators/project/config/apps.rb.tt index 3902891f0..eeb60bc72 100644 --- a/padrino-gen/lib/padrino-gen/generators/project/config/apps.rb.tt +++ b/padrino-gen/lib/padrino-gen/generators/project/config/apps.rb.tt @@ -2,15 +2,15 @@ # This file mounts each app in the Padrino project to a specified sub-uri. # You can mount additional applications using any of these commands below: # -# Padrino.mount("blog").to('/blog') -# Padrino.mount("blog", :app_class => "BlogApp").to('/blog') -# Padrino.mount("blog", :app_file => "path/to/blog/app.rb").to('/blog') +# Padrino.mount('blog').to('/blog') +# Padrino.mount('blog', :app_class => 'BlogApp').to('/blog') +# Padrino.mount('blog', :app_file => 'path/to/blog/app.rb').to('/blog') # # You can also map apps to a specified host: # -# Padrino.mount("Admin").host("admin.example.org") -# Padrino.mount("WebSite").host(/.*\.?example.org/) -# Padrino.mount("Foo").to("/foo").host("bar.example.org") +# Padrino.mount('Admin').host('admin.example.org') +# Padrino.mount('WebSite').host(/.*\.?example.org/) +# Padrino.mount('Foo').to('/foo').host('bar.example.org') # # Note 1: Mounted apps (by default) should be placed into the project root at '/app_name'. # Note 2: If you use the host matching remember to respect the order of the rules. @@ -18,7 +18,7 @@ # By default, this file mounts the primary app which was generated with this project. # However, the mounted app can be modified as needed: # -# Padrino.mount("AppName", :app_file => "path/to/file", :app_class => "BlogApp").to('/') +# Padrino.mount('AppName', :app_file => 'path/to/file', :app_class => 'BlogApp').to('/') # ## @@ -31,4 +31,4 @@ Padrino.configure_apps do end # Mounts the core application for this project -Padrino.mount(<%= @app_name.inspect %>).to('/') +Padrino.mount('<%= @app_name.to_s %>').to('/') diff --git a/padrino-gen/lib/padrino-gen/generators/templates/controller.rb.tt b/padrino-gen/lib/padrino-gen/generators/templates/controller.rb.tt index c93e5cce6..52a9dd650 100644 --- a/padrino-gen/lib/padrino-gen/generators/templates/controller.rb.tt +++ b/padrino-gen/lib/padrino-gen/generators/templates/controller.rb.tt @@ -1,22 +1,21 @@ <%= @app_name %>.controllers <%= ":#{@controller}" if @controller %> do - # get :index, :map => "/foo/bar" do - # session[:foo] = "bar" + # get :index, :map => '/foo/bar' do + # session[:foo] = 'bar' # render 'index' # end - # get :sample, :map => "/sample/url", :provides => [:any, :js] do + # get :sample, :map => '/sample/url', :provides => [:any, :js] do # case content_type # when :js then ... # else ... # end # get :foo, :with => :id do - # "Maps to url '/foo/#{params[:id]}'" + # 'Maps to url '/foo/#{params[:id]}'' # end - # get "/example" do - # "Hello world!" + # get '/example' do + # 'Hello world!' # end - - <%= @actions %> + <%= "\n#{@actions}" %> end diff --git a/padrino-gen/lib/padrino-gen/padrino-tasks/minirecord.rb b/padrino-gen/lib/padrino-gen/padrino-tasks/minirecord.rb new file mode 100644 index 000000000..0e9b73a66 --- /dev/null +++ b/padrino-gen/lib/padrino-gen/padrino-tasks/minirecord.rb @@ -0,0 +1,13 @@ +if defined?(MiniRecord) + namespace :mr do + desc "Auto migration of database" + task :migrate => :environment do + Dir["models/*.rb"].each do |file_path| + basename = File.basename(file_path, File.extname(file_path)) + clazz = basename.camelize.constantize + clazz.auto_upgrade! if clazz.ancestors.include?(ActiveRecord::Base) + end + puts "<= mr:migrate executed" + end + end +end diff --git a/padrino-gen/padrino-gen.gemspec b/padrino-gen/padrino-gen.gemspec old mode 100755 new mode 100644 diff --git a/padrino-gen/test/test_app_generator.rb b/padrino-gen/test/test_app_generator.rb index fdc036fae..3bcca28fe 100644 --- a/padrino-gen/test/test_app_generator.rb +++ b/padrino-gen/test/test_app_generator.rb @@ -28,7 +28,7 @@ def teardown assert_file_exists("#{@apptmp}/sample_project/demo/views") assert_file_exists("#{@apptmp}/sample_project/demo/views/layouts") assert_dir_exists("#{@apptmp}/sample_project/public/demo") - assert_match_in_file('Padrino.mount("Demo").to("/demo")', "#{@apptmp}/sample_project/config/apps.rb") + assert_match_in_file("Padrino.mount('Demo').to('/demo')", "#{@apptmp}/sample_project/config/apps.rb") assert_match_in_file('class Demo < Padrino::Application', "#{@apptmp}/sample_project/demo/app.rb") assert_match_in_file(/Padrino.configure_apps do/, "#{@apptmp}/sample_project/config/apps.rb") assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb") diff --git a/padrino-gen/test/test_project_generator.rb b/padrino-gen/test/test_project_generator.rb index b31daa235..42d1060e5 100644 --- a/padrino-gen/test/test_project_generator.rb +++ b/padrino-gen/test/test_project_generator.rb @@ -16,7 +16,7 @@ def teardown capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") } assert_file_exists("#{@apptmp}/sample_project") assert_match_in_file(/class SampleProject < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb") - assert_match_in_file(/Padrino.mount\("SampleProject"\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb") + assert_match_in_file(/Padrino.mount\('SampleProject'\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb") assert_file_exists("#{@apptmp}/sample_project/config/boot.rb") assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico") assert_dir_exists("#{@apptmp}/sample_project/public/images") @@ -30,11 +30,11 @@ def teardown capture_io { generate(:project, 'project.com', "--root=#{@apptmp}") } assert_file_exists("#{@apptmp}/project.com") assert_match_in_file(/class ProjectCom < Padrino::Application/, "#{@apptmp}/project.com/app/app.rb") - assert_match_in_file(/Padrino.mount\("ProjectCom"\).to\('\/'\)/, "#{@apptmp}/project.com/config/apps.rb") + assert_match_in_file(/Padrino.mount\('ProjectCom'\).to\('\/'\)/, "#{@apptmp}/project.com/config/apps.rb") capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/project.com") } assert_file_exists("#{@apptmp}/project.com/wsdci2011") assert_match_in_file(/class WsDci2011 < Padrino::Application/, "#{@apptmp}/project.com/wsdci2011/app.rb") - assert_match_in_file(/Padrino.mount\("WsDci2011"\).to\("\/wsdci2011"\)/, "#{@apptmp}/project.com/config/apps.rb") + assert_match_in_file(/Padrino.mount\('WsDci2011'\).to\('\/wsdci2011'\)/, "#{@apptmp}/project.com/config/apps.rb") end should "raise an Error when given invalid constant names" do @@ -52,7 +52,7 @@ def teardown capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') } assert_file_exists("#{@apptmp}/sample_project") assert_match_in_file(/class BaseApp < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb") - assert_match_in_file(/Padrino.mount\("BaseApp"\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb") + assert_match_in_file(/Padrino.mount\('BaseApp'\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb") assert_file_exists("#{@apptmp}/sample_project/config/boot.rb") assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico") end @@ -67,7 +67,6 @@ def teardown assert_dir_exists("#{@apptmp}/sample_project/public/images") assert_dir_exists("#{@apptmp}/sample_project/public/javascripts") assert_dir_exists("#{@apptmp}/sample_project/public/stylesheets") - # assert_dir_exists("#{@apptmp}/sample_project/app/views/layouts") assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/app/mailers.rb") assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers") assert_no_file_exists("#{@apptmp}/sample_project/demo/controllers") @@ -86,7 +85,7 @@ def teardown should "place app specific names into correct files" do capture_io { generate(:project, 'warepedia', "--root=#{@apptmp}", '--script=none') } assert_match_in_file(/class Warepedia < Padrino::Application/m, "#{@apptmp}/warepedia/app/app.rb") - assert_match_in_file(/Padrino.mount\("Warepedia"\).to\('\/'\)/m, "#{@apptmp}/warepedia/config/apps.rb") + assert_match_in_file(/Padrino.mount\('Warepedia'\).to\('\/'\)/m, "#{@apptmp}/warepedia/config/apps.rb") end should "store and apply session_secret" do @@ -210,7 +209,7 @@ def teardown should "properly generate default" do out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') } assert_match(/applying.*?activerecord.*?orm/, out) - assert_match_in_file(/gem 'activerecord', :require => "active_record"/, "#{@apptmp}/project.com/Gemfile") + assert_match_in_file(/gem 'activerecord', :require => 'active_record'/, "#{@apptmp}/project.com/Gemfile") assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile") assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb") assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb") @@ -297,10 +296,10 @@ def teardown out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') } assert_match(/applying.*?mongoid.*?orm/, out) if RUBY_VERSION >= '1.9' - assert_match_in_file(/gem 'mongoid', ">=3.0"/, "#{@apptmp}/project.com/Gemfile") + assert_match_in_file(/gem 'mongoid', '>=3.0'/, "#{@apptmp}/project.com/Gemfile") assert_match_in_file(/Mongoid::Config.sessions/, "#{@apptmp}/project.com/config/database.rb") else - assert_match_in_file(/gem 'mongoid', "~>2.0"/, "#{@apptmp}/project.com/Gemfile") + assert_match_in_file(/gem 'mongoid', '~>2.0'"/, "#{@apptmp}/project.com/Gemfile") assert_match_in_file(/Mongoid.database/, "#{@apptmp}/project.com/config/database.rb") end assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile") @@ -423,8 +422,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=bacon', '--script=none') } assert_match(/applying.*?bacon.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'bacon'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/Bacon::Context/, "#{@apptmp}/sample_project/test/test_config.rb") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb") @@ -437,8 +436,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--script=none') } assert_match(/applying.*?riot.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'riot'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb") @@ -454,8 +453,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') } assert_match(/applying.*?rspec.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb") assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb") @@ -468,8 +467,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=shoulda', '--script=none') } assert_match(/applying.*?shoulda.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'shoulda'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb") assert_match_in_file(/Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb") @@ -482,8 +481,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') } assert_match(/applying.*?minitest.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb") @@ -498,12 +497,12 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testspec', '--script=none') } assert_match(/applying.*?testspec.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/gem 'test-spec'.*?:require => "test\/spec"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/gem 'test-spec'.*?:require => 'test\/spec'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb") assert_match_in_file(/Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb") - assert_match_in_file(/gem 'test-spec'.*?:require => "test\/spec"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/gem 'test-spec'.*?:require => 'test\/spec'/, "#{@apptmp}/sample_project/Gemfile") assert_file_exists("#{@apptmp}/sample_project/test/test.rake") assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake") assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake") @@ -513,8 +512,8 @@ def teardown out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=cucumber', '--script=none') } assert_match(/applying.*?cucumber.*?test/, out) assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile") - assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile") + assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/gem 'cucumber'/, "#{@apptmp}/sample_project/Gemfile") assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb") diff --git a/padrino-mailer/padrino-mailer.gemspec b/padrino-mailer/padrino-mailer.gemspec old mode 100755 new mode 100644 diff --git a/padrino/padrino.gemspec b/padrino/padrino.gemspec old mode 100755 new mode 100644