padrino-core 0.10.2 → 0.10.3
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/.document +3 -3
- data/.yardopts +1 -0
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.rdoc +2 -2
- data/lib/padrino-core/application/rendering.rb +79 -26
- data/lib/padrino-core/application/routing.rb +215 -127
- data/lib/padrino-core/application/showexceptions.rb +2 -1
- data/lib/padrino-core/application.rb +67 -57
- data/lib/padrino-core/caller.rb +10 -4
- data/lib/padrino-core/command.rb +11 -0
- data/lib/padrino-core/loader.rb +52 -24
- data/lib/padrino-core/locale/cs.yml +4 -1
- data/lib/padrino-core/locale/da.yml +4 -1
- data/lib/padrino-core/locale/de.yml +4 -1
- data/lib/padrino-core/locale/en.yml +4 -1
- data/lib/padrino-core/locale/es.yml +4 -1
- data/lib/padrino-core/locale/fr.yml +4 -1
- data/lib/padrino-core/locale/hu.yml +4 -1
- data/lib/padrino-core/locale/it.yml +4 -1
- data/lib/padrino-core/locale/ja.yml +4 -1
- data/lib/padrino-core/locale/lv.yml +34 -0
- data/lib/padrino-core/locale/nl.yml +4 -1
- data/lib/padrino-core/locale/no.yml +4 -1
- data/lib/padrino-core/locale/pl.yml +4 -1
- data/lib/padrino-core/locale/pt_br.yml +4 -1
- data/lib/padrino-core/locale/ru.yml +4 -1
- data/lib/padrino-core/locale/tr.yml +4 -1
- data/lib/padrino-core/locale/uk.yml +4 -1
- data/lib/padrino-core/locale/zh_cn.yml +4 -1
- data/lib/padrino-core/locale/zh_tw.yml +4 -1
- data/lib/padrino-core/logger.rb +119 -128
- data/lib/padrino-core/mounter.rb +46 -14
- data/lib/padrino-core/reloader.rb +5 -3
- data/lib/padrino-core/router.rb +30 -11
- data/lib/padrino-core/server.rb +14 -5
- data/lib/padrino-core/support_lite.rb +54 -20
- data/lib/padrino-core/tasks.rb +1 -3
- data/lib/padrino-core/version.rb +8 -4
- data/lib/padrino-core.rb +58 -11
- data/padrino-core.gemspec +1 -1
- data/test/fixtures/apps/simple.rb +1 -1
- data/test/helper.rb +4 -24
- data/test/mini_shoulda.rb +45 -0
- data/test/test_application.rb +19 -18
- data/test/test_core.rb +2 -2
- data/test/test_dependencies.rb +5 -5
- data/test/test_filters.rb +2 -1
- data/test/test_locale.rb +1 -1
- data/test/test_logger.rb +1 -1
- data/test/test_mounter.rb +26 -25
- data/test/test_reloader_complex.rb +5 -3
- data/test/test_reloader_simple.rb +6 -5
- data/test/test_rendering.rb +8 -5
- data/test/test_restful_routing.rb +1 -1
- data/test/test_router.rb +1 -1
- data/test/test_routing.rb +33 -12
- metadata +13 -9
| @@ -1,7 +1,8 @@ | |
| 1 1 | 
             
            module Padrino
         | 
| 2 2 | 
             
              ##
         | 
| 3 | 
            -
              # This module extend Sinatra::ShowExceptions adding Padrino as "Framework"
         | 
| 3 | 
            +
              # This module extend Sinatra::ShowExceptions adding Padrino as "Framework".
         | 
| 4 4 | 
             
              #
         | 
| 5 | 
            +
              # @private
         | 
| 5 6 | 
             
              class ShowExceptions < Sinatra::ShowExceptions
         | 
| 6 7 | 
             
                private
         | 
| 7 8 | 
             
                  def frame_class(frame)
         | 
| @@ -7,7 +7,17 @@ module Padrino | |
| 7 7 | 
             
              # These subclassed applications can be easily mounted into other Padrino applications as well.
         | 
| 8 8 | 
             
              #
         | 
| 9 9 | 
             
              class Application < Sinatra::Base
         | 
| 10 | 
            -
                 | 
| 10 | 
            +
                # Support for advanced routing, controllers, url_for
         | 
| 11 | 
            +
                register Padrino::Routing
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                ##
         | 
| 14 | 
            +
                # Returns the logger for this application.
         | 
| 15 | 
            +
                #
         | 
| 16 | 
            +
                # @return [Padrino::Logger] Logger associated with this app.
         | 
| 17 | 
            +
                #
         | 
| 18 | 
            +
                def logger
         | 
| 19 | 
            +
                  Padrino.logger
         | 
| 20 | 
            +
                end
         | 
| 11 21 |  | 
| 12 22 | 
             
                class << self
         | 
| 13 23 |  | 
| @@ -25,29 +35,15 @@ module Padrino | |
| 25 35 | 
             
                    super(base) # Loading the subclass inherited method
         | 
| 26 36 | 
             
                  end
         | 
| 27 37 |  | 
| 28 | 
            -
                  ##
         | 
| 29 | 
            -
                  # Hooks into when a new instance of the application is created
         | 
| 30 | 
            -
                  # This is used because putting the configuration into inherited doesn't
         | 
| 31 | 
            -
                  # take into account overwritten app settings inside subclassed definitions
         | 
| 32 | 
            -
                  # Only performs the setup first time application is initialized.
         | 
| 33 | 
            -
                  #
         | 
| 34 | 
            -
                  def new(*args, &bk)
         | 
| 35 | 
            -
                    setup_application!
         | 
| 36 | 
            -
                    logging, logging_was = false, logging
         | 
| 37 | 
            -
                    show_exceptions, show_exceptions_was = false, show_exceptions
         | 
| 38 | 
            -
                    super(*args, &bk)
         | 
| 39 | 
            -
                  ensure
         | 
| 40 | 
            -
                    logging, show_exceptions = logging_was, show_exceptions_was
         | 
| 41 | 
            -
                  end
         | 
| 42 | 
            -
             | 
| 43 38 | 
             
                  ##
         | 
| 44 39 | 
             
                  # Reloads the application files from all defined load paths
         | 
| 45 40 | 
             
                  #
         | 
| 46 41 | 
             
                  # This method is used from our Padrino Reloader during development mode
         | 
| 47 42 | 
             
                  # in order to reload the source files.
         | 
| 48 43 | 
             
                  #
         | 
| 49 | 
            -
                  #  | 
| 44 | 
            +
                  # @return [TrueClass]
         | 
| 50 45 | 
             
                  #
         | 
| 46 | 
            +
                  # @example
         | 
| 51 47 | 
             
                  #   MyApp.reload!
         | 
| 52 48 | 
             
                  #
         | 
| 53 49 | 
             
                  def reload!
         | 
| @@ -56,31 +52,32 @@ module Padrino | |
| 56 52 | 
             
                    reset! # Reset sinatra app
         | 
| 57 53 | 
             
                    reset_router! # Reset all routes
         | 
| 58 54 | 
             
                    Padrino.require_dependencies(self.app_file, :force => true) # Reload the app file
         | 
| 59 | 
            -
                    register_initializers # Reload our middlewares
         | 
| 60 55 | 
             
                    require_dependencies # Reload dependencies
         | 
| 61 | 
            -
                    default_filters! | 
| 62 | 
            -
                    default_routes! | 
| 63 | 
            -
                    default_errors! | 
| 56 | 
            +
                    default_filters!     # Reload filters
         | 
| 57 | 
            +
                    default_routes!      # Reload default routes
         | 
| 58 | 
            +
                    default_errors!      # Reload our errors
         | 
| 64 59 | 
             
                    I18n.reload! if defined?(I18n) # Reload also our translations
         | 
| 60 | 
            +
                    true
         | 
| 65 61 | 
             
                  end
         | 
| 66 62 |  | 
| 67 63 | 
             
                  ##
         | 
| 68 64 | 
             
                  # Resets application routes to only routes not defined by the user
         | 
| 69 65 | 
             
                  #
         | 
| 70 | 
            -
                  #  | 
| 66 | 
            +
                  # @return [TrueClass]
         | 
| 71 67 | 
             
                  #
         | 
| 68 | 
            +
                  # @example
         | 
| 72 69 | 
             
                  #   MyApp.reset_routes!
         | 
| 73 70 | 
             
                  #
         | 
| 74 71 | 
             
                  def reset_routes!
         | 
| 75 72 | 
             
                    reset_router!
         | 
| 76 73 | 
             
                    default_routes!
         | 
| 74 | 
            +
                    true
         | 
| 77 75 | 
             
                  end
         | 
| 78 76 |  | 
| 79 77 | 
             
                  ##
         | 
| 80 78 | 
             
                  # Returns the routes of our app.
         | 
| 81 79 | 
             
                  #
         | 
| 82 | 
            -
                  #  | 
| 83 | 
            -
                  #
         | 
| 80 | 
            +
                  # @example
         | 
| 84 81 | 
             
                  #   MyApp.routes
         | 
| 85 82 | 
             
                  #
         | 
| 86 83 | 
             
                  def routes
         | 
| @@ -91,11 +88,11 @@ module Padrino | |
| 91 88 | 
             
                  # Setup the application by registering initializers, load paths and logger
         | 
| 92 89 | 
             
                  # Invoked automatically when an application is first instantiated
         | 
| 93 90 | 
             
                  #
         | 
| 91 | 
            +
                  # @return [TrueClass]
         | 
| 92 | 
            +
                  #
         | 
| 94 93 | 
             
                  def setup_application!
         | 
| 95 94 | 
             
                    return if @_configured
         | 
| 96 | 
            -
                    self.register_initializers
         | 
| 97 95 | 
             
                    self.require_dependencies
         | 
| 98 | 
            -
                    self.disable :logging # We need do that as default because Sinatra use commonlogger.
         | 
| 99 96 | 
             
                    self.default_filters!
         | 
| 100 97 | 
             
                    self.default_routes!
         | 
| 101 98 | 
             
                    self.default_errors!
         | 
| @@ -104,12 +101,15 @@ module Padrino | |
| 104 101 | 
             
                      I18n.reload!
         | 
| 105 102 | 
             
                    end
         | 
| 106 103 | 
             
                    @_configured = true
         | 
| 104 | 
            +
                    @_configured
         | 
| 107 105 | 
             
                  end
         | 
| 108 106 |  | 
| 109 107 | 
             
                  ##
         | 
| 110 108 | 
             
                  # Run the Padrino app as a self-hosted server using
         | 
| 111 109 | 
             
                  # Thin, Mongrel or WEBrick (in that order)
         | 
| 112 110 | 
             
                  #
         | 
| 111 | 
            +
                  # @see Padrino::Server#start
         | 
| 112 | 
            +
                  #
         | 
| 113 113 | 
             
                  def run!(options={})
         | 
| 114 114 | 
             
                    return unless Padrino.load!
         | 
| 115 115 | 
             
                    Padrino.mount(self.to_s).to("/")
         | 
| @@ -117,7 +117,8 @@ module Padrino | |
| 117 117 | 
             
                  end
         | 
| 118 118 |  | 
| 119 119 | 
             
                  ##
         | 
| 120 | 
            -
                  #  | 
| 120 | 
            +
                  # @return [Array]
         | 
| 121 | 
            +
                  #   directory that need to be added to +$LOAD_PATHS+ from this application
         | 
| 121 122 | 
             
                  #
         | 
| 122 123 | 
             
                  def load_paths
         | 
| 123 124 | 
             
                    @_load_paths ||= %w(models lib mailers controllers helpers).map { |path| File.join(self.root, path) }
         | 
| @@ -127,7 +128,10 @@ module Padrino | |
| 127 128 | 
             
                  # Returns default list of path globs to load as dependencies
         | 
| 128 129 | 
             
                  # Appends custom dependency patterns to the be loaded for your Application
         | 
| 129 130 | 
             
                  #
         | 
| 130 | 
            -
                  #  | 
| 131 | 
            +
                  # @return [Array]
         | 
| 132 | 
            +
                  #   list of path globs to load as dependencies
         | 
| 133 | 
            +
                  #
         | 
| 134 | 
            +
                  # @example
         | 
| 131 135 | 
             
                  #   MyApp.dependencies << "#{Padrino.root}/uploaders/**/*.rb"
         | 
| 132 136 | 
             
                  #   MyApp.dependencies << Padrino.root('other_app', 'controllers.rb')
         | 
| 133 137 | 
             
                  #
         | 
| @@ -143,12 +147,13 @@ module Padrino | |
| 143 147 | 
             
                  #
         | 
| 144 148 | 
             
                  # By default we look for files:
         | 
| 145 149 | 
             
                  #
         | 
| 150 | 
            +
                  #   # List of default files that we are looking for:
         | 
| 146 151 | 
             
                  #   yourapp/models.rb
         | 
| 147 152 | 
             
                  #   yourapp/models/**/*.rb
         | 
| 148 153 | 
             
                  #   yourapp/lib.rb
         | 
| 149 154 | 
             
                  #   yourapp/lib/**/*.rb
         | 
| 150 155 | 
             
                  #
         | 
| 151 | 
            -
                  #  | 
| 156 | 
            +
                  # @example Adding a custom perequisite
         | 
| 152 157 | 
             
                  #   MyApp.prerequisites << Padrino.root('my_app', 'custom_model.rb')
         | 
| 153 158 | 
             
                  #
         | 
| 154 159 | 
             
                  def prerequisites
         | 
| @@ -167,14 +172,15 @@ module Padrino | |
| 167 172 | 
             
                      set :logging, Proc.new { development? }
         | 
| 168 173 | 
             
                      set :method_override, true
         | 
| 169 174 | 
             
                      set :sessions, false
         | 
| 170 | 
            -
                      set : | 
| 175 | 
            +
                      set :public_folder, Proc.new { Padrino.root('public', uri_root) }
         | 
| 171 176 | 
             
                      set :views, Proc.new { File.join(root,   "views") }
         | 
| 172 177 | 
             
                      set :images_path, Proc.new { File.join(public, "images") }
         | 
| 178 | 
            +
                      set :protection, false
         | 
| 173 179 | 
             
                      # Padrino specific
         | 
| 174 180 | 
             
                      set :uri_root, "/"
         | 
| 175 181 | 
             
                      set :app_name, self.to_s.underscore.to_sym
         | 
| 176 182 | 
             
                      set :default_builder, 'StandardFormBuilder'
         | 
| 177 | 
            -
                      set :flash, defined?(Rack::Flash)
         | 
| 183 | 
            +
                      set :flash, defined?(Sinatra::Flash) || defined?(Rack::Flash)
         | 
| 178 184 | 
             
                      set :authentication, false
         | 
| 179 185 | 
             
                      # Padrino locale
         | 
| 180 186 | 
             
                      set :locale_path, Proc.new { Dir[File.join(self.root, "/locale/**/*.{rb,yml}")] }
         | 
| @@ -222,16 +228,6 @@ module Padrino | |
| 222 228 | 
             
                      end
         | 
| 223 229 | 
             
                    end
         | 
| 224 230 |  | 
| 225 | 
            -
                    ##
         | 
| 226 | 
            -
                    # Requires the Padrino middleware
         | 
| 227 | 
            -
                    #
         | 
| 228 | 
            -
                    def register_initializers
         | 
| 229 | 
            -
                      use Padrino::ShowExceptions         if show_exceptions?
         | 
| 230 | 
            -
                      use Padrino::Logger::Rack, uri_root if Padrino.logger && logging?
         | 
| 231 | 
            -
                      use Padrino::Reloader::Rack         if reload?
         | 
| 232 | 
            -
                      use Rack::Flash, :sweep => true     if flash?
         | 
| 233 | 
            -
                    end
         | 
| 234 | 
            -
             | 
| 235 231 | 
             
                    ##
         | 
| 236 232 | 
             
                    # Requires all files within the application load paths
         | 
| 237 233 | 
             
                    #
         | 
| @@ -239,22 +235,36 @@ module Padrino | |
| 239 235 | 
             
                      Padrino.set_load_paths(*load_paths)
         | 
| 240 236 | 
             
                      Padrino.require_dependencies(dependencies, :force => true)
         | 
| 241 237 | 
             
                    end
         | 
| 242 | 
            -
                end # self
         | 
| 243 238 |  | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
                       | 
| 250 | 
            -
             | 
| 251 | 
            -
                       | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 239 | 
            +
                  private
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                    # Overrides the default middleware for Sinatra based on Padrino conventions
         | 
| 242 | 
            +
                    # Also initializes the application after setting up the middleware
         | 
| 243 | 
            +
                    def setup_default_middleware(builder)
         | 
| 244 | 
            +
                      setup_sessions builder
         | 
| 245 | 
            +
                      setup_flash builder
         | 
| 246 | 
            +
                      builder.use Padrino::ShowExceptions         if show_exceptions?
         | 
| 247 | 
            +
                      builder.use Padrino::Logger::Rack, uri_root if Padrino.logger && logging?
         | 
| 248 | 
            +
                      builder.use Padrino::Reloader::Rack         if reload?
         | 
| 249 | 
            +
                      builder.use Rack::MethodOverride            if method_override?
         | 
| 250 | 
            +
                      builder.use Rack::Head
         | 
| 251 | 
            +
                      setup_protection builder
         | 
| 252 | 
            +
                      setup_application!
         | 
| 253 | 
            +
                    end
         | 
| 254 | 
            +
             | 
| 255 | 
            +
                     # TODO Remove this in a few versions (rack-flash deprecation)
         | 
| 256 | 
            +
                     # Move register Sinatra::Flash into setup_default_middleware
         | 
| 257 | 
            +
                     # Initializes flash using sinatra-flash or rack-flash
         | 
| 258 | 
            +
                    def setup_flash(builder)
         | 
| 259 | 
            +
                      register Sinatra::Flash if flash? && defined?(Sinatra::Flash)
         | 
| 260 | 
            +
                      if defined?(Rack::Flash) && !defined?(Sinatra::Flash)
         | 
| 261 | 
            +
                        logger.warn %Q{
         | 
| 262 | 
            +
                          [Deprecation] In Gemfile, 'rack-flash' should be replaced with 'sinatra-flash'!
         | 
| 263 | 
            +
                          Rack-Flash is not compatible with later versions of Rack and should be replaced.
         | 
| 264 | 
            +
                        }
         | 
| 265 | 
            +
                        builder.use Rack::Flash, :sweep => true     if flash?
         | 
| 266 | 
            +
                      end
         | 
| 267 | 
            +
                    end
         | 
| 268 | 
            +
                end # self
         | 
| 259 269 | 
             
              end # Application
         | 
| 260 270 | 
             
            end # Padrino
         | 
    
        data/lib/padrino-core/caller.rb
    CHANGED
    
    | @@ -20,22 +20,28 @@ module Padrino | |
| 20 20 | 
             
              ] unless defined?(PADRINO_IGNORE_CALLERS)
         | 
| 21 21 |  | 
| 22 22 | 
             
              ##
         | 
| 23 | 
            -
              # Add rubinius (and hopefully other VM  | 
| 23 | 
            +
              # Add rubinius (and hopefully other VM implementations) ignore patterns ...
         | 
| 24 24 | 
             
              #
         | 
| 25 25 | 
             
              PADRINO_IGNORE_CALLERS.concat(RUBY_IGNORE_CALLERS) if defined?(RUBY_IGNORE_CALLERS)
         | 
| 26 26 |  | 
| 27 27 | 
             
              private
         | 
| 28 28 | 
             
                ##
         | 
| 29 | 
            -
                #  | 
| 29 | 
            +
                # The filename for the file that is the direct caller (first caller).
         | 
| 30 | 
            +
                #
         | 
| 31 | 
            +
                # @return [String]
         | 
| 32 | 
            +
                #   The file the caller method exists in.
         | 
| 30 33 | 
             
                #
         | 
| 31 34 | 
             
                def self.first_caller
         | 
| 32 35 | 
             
                  caller_files.first
         | 
| 33 36 | 
             
                end
         | 
| 34 37 |  | 
| 35 | 
            -
                 | 
| 36 | 
            -
                # Like Kernel#caller but excluding certain magic entries and without
         | 
| 38 | 
            +
                #
         | 
| 39 | 
            +
                # Like +Kernel#caller+ but excluding certain magic entries and without
         | 
| 37 40 | 
             
                # line / method information; the resulting array contains filenames only.
         | 
| 38 41 | 
             
                #
         | 
| 42 | 
            +
                # @return [Array<String>]
         | 
| 43 | 
            +
                #   The files of the calling methods.
         | 
| 44 | 
            +
                #
         | 
| 39 45 | 
             
                def self.caller_files
         | 
| 40 46 | 
             
                  caller(1).
         | 
| 41 47 | 
             
                    map    { |line| line.split(/:(?=\d|in )/)[0,2] }.
         | 
    
        data/lib/padrino-core/command.rb
    CHANGED
    
    | @@ -5,6 +5,14 @@ module Padrino | |
| 5 5 | 
             
              # This method return the correct location of padrino bin or
         | 
| 6 6 | 
             
              # exec it using Kernel#system with the given args
         | 
| 7 7 | 
             
              #
         | 
| 8 | 
            +
              # @param [Array] args
         | 
| 9 | 
            +
              #   command or commands to execute
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              # @return [Boolean]
         | 
| 12 | 
            +
              #
         | 
| 13 | 
            +
              # @example
         | 
| 14 | 
            +
              #   Padrino.bin('start', '-e production')
         | 
| 15 | 
            +
              #
         | 
| 8 16 | 
             
              def self.bin(*args)
         | 
| 9 17 | 
             
                @_padrino_bin ||= [self.ruby_command, File.expand_path("../../../bin/padrino", __FILE__)]
         | 
| 10 18 | 
             
                args.empty? ? @_padrino_bin : system(args.unshift(@_padrino_bin).join(" "))
         | 
| @@ -14,6 +22,9 @@ module Padrino | |
| 14 22 | 
             
              # Return the path to the ruby interpreter taking into account multiple
         | 
| 15 23 | 
             
              # installations and windows extensions.
         | 
| 16 24 | 
             
              #
         | 
| 25 | 
            +
              # @return [String]
         | 
| 26 | 
            +
              #   path to ruby bin executable
         | 
| 27 | 
            +
              #
         | 
| 17 28 | 
             
              def self.ruby_command
         | 
| 18 29 | 
             
                @ruby_command ||= begin
         | 
| 19 30 | 
             
                  ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
         | 
    
        data/lib/padrino-core/loader.rb
    CHANGED
    
    | @@ -1,16 +1,19 @@ | |
| 1 1 | 
             
            module Padrino
         | 
| 2 2 | 
             
              class << self
         | 
| 3 | 
            -
             | 
| 4 3 | 
             
                ##
         | 
| 5 | 
            -
                # Hooks to be called before a load/reload
         | 
| 4 | 
            +
                # Hooks to be called before a load/reload.
         | 
| 5 | 
            +
                #
         | 
| 6 | 
            +
                # @yield []
         | 
| 7 | 
            +
                #   The given block will be called before Padrino was loaded/reloaded.
         | 
| 6 8 | 
             
                #
         | 
| 7 | 
            -
                #  | 
| 9 | 
            +
                # @return [Array<Proc>]
         | 
| 10 | 
            +
                #   The load/reload before hooks.
         | 
| 8 11 | 
             
                #
         | 
| 12 | 
            +
                # @example
         | 
| 9 13 | 
             
                #   before_load do
         | 
| 10 14 | 
             
                #     pre_initialize_something
         | 
| 11 15 | 
             
                #   end
         | 
| 12 16 | 
             
                #
         | 
| 13 | 
            -
                #
         | 
| 14 17 | 
             
                def before_load(&block)
         | 
| 15 18 | 
             
                  @_before_load ||= []
         | 
| 16 19 | 
             
                  @_before_load << block if block_given?
         | 
| @@ -18,15 +21,19 @@ module Padrino | |
| 18 21 | 
             
                end
         | 
| 19 22 |  | 
| 20 23 | 
             
                ##
         | 
| 21 | 
            -
                # Hooks to be called after a load/reload
         | 
| 24 | 
            +
                # Hooks to be called after a load/reload.
         | 
| 22 25 | 
             
                #
         | 
| 23 | 
            -
                #  | 
| 26 | 
            +
                # @yield []
         | 
| 27 | 
            +
                #   The given block will be called after Padrino was loaded/reloaded.
         | 
| 24 28 | 
             
                #
         | 
| 29 | 
            +
                # @return [Array<Proc>]
         | 
| 30 | 
            +
                #   The load/reload hooks.
         | 
| 31 | 
            +
                #
         | 
| 32 | 
            +
                # @example
         | 
| 25 33 | 
             
                #   after_load do
         | 
| 26 34 | 
             
                #     DataMapper.finalize
         | 
| 27 35 | 
             
                #   end
         | 
| 28 36 | 
             
                #
         | 
| 29 | 
            -
                #
         | 
| 30 37 | 
             
                def after_load(&block)
         | 
| 31 38 | 
             
                  @_after_load ||= []
         | 
| 32 39 | 
             
                  @_after_load << block if block_given?
         | 
| @@ -34,7 +41,10 @@ module Padrino | |
| 34 41 | 
             
                end
         | 
| 35 42 |  | 
| 36 43 | 
             
                ##
         | 
| 37 | 
            -
                #  | 
| 44 | 
            +
                # The used +$LOAD_PATHS+ from Padrino.
         | 
| 45 | 
            +
                #
         | 
| 46 | 
            +
                # @return [Array<String>]
         | 
| 47 | 
            +
                #   The load paths used by Padrino.
         | 
| 38 48 | 
             
                #
         | 
| 39 49 | 
             
                def load_paths
         | 
| 40 50 | 
             
                  @_load_paths_was = %w(lib models shared).map { |path| Padrino.root(path) }
         | 
| @@ -42,7 +52,11 @@ module Padrino | |
| 42 52 | 
             
                end
         | 
| 43 53 |  | 
| 44 54 | 
             
                ##
         | 
| 45 | 
            -
                # Requires necessary dependencies as well as application files from root | 
| 55 | 
            +
                # Requires necessary dependencies as well as application files from root
         | 
| 56 | 
            +
                # lib and models.
         | 
| 57 | 
            +
                #
         | 
| 58 | 
            +
                # @return [Boolean]
         | 
| 59 | 
            +
                #   returns true if Padrino is not already bootstraped otherwise else.
         | 
| 46 60 | 
             
                #
         | 
| 47 61 | 
             
                def load!
         | 
| 48 62 | 
             
                  return false if loaded?
         | 
| @@ -60,7 +74,9 @@ module Padrino | |
| 60 74 | 
             
                end
         | 
| 61 75 |  | 
| 62 76 | 
             
                ##
         | 
| 63 | 
            -
                # Clear the padrino env
         | 
| 77 | 
            +
                # Clear the padrino env.
         | 
| 78 | 
            +
                #
         | 
| 79 | 
            +
                # @return [NilClass]
         | 
| 64 80 | 
             
                #
         | 
| 65 81 | 
             
                def clear!
         | 
| 66 82 | 
             
                  Padrino.clear_middleware!
         | 
| @@ -75,7 +91,7 @@ module Padrino | |
| 75 91 | 
             
                end
         | 
| 76 92 |  | 
| 77 93 | 
             
                ##
         | 
| 78 | 
            -
                # Method for reloading required applications and their files
         | 
| 94 | 
            +
                # Method for reloading required applications and their files.
         | 
| 79 95 | 
             
                #
         | 
| 80 96 | 
             
                def reload!
         | 
| 81 97 | 
             
                  Padrino.before_load.each(&:call) # Run before hooks
         | 
| @@ -84,14 +100,18 @@ module Padrino | |
| 84 100 | 
             
                end
         | 
| 85 101 |  | 
| 86 102 | 
             
                ##
         | 
| 87 | 
            -
                # This adds the ablity to instantiate Padrino.load! after | 
| 103 | 
            +
                # This adds the ablity to instantiate {Padrino.load!} after
         | 
| 104 | 
            +
                # {Padrino::Application} definition.
         | 
| 88 105 | 
             
                #
         | 
| 89 106 | 
             
                def called_from
         | 
| 90 107 | 
             
                  @_called_from || first_caller
         | 
| 91 108 | 
             
                end
         | 
| 92 109 |  | 
| 93 110 | 
             
                ##
         | 
| 94 | 
            -
                #  | 
| 111 | 
            +
                # Determines whether Padrino was loaded with {Padrino.load!}.
         | 
| 112 | 
            +
                #
         | 
| 113 | 
            +
                # @return [Boolean]
         | 
| 114 | 
            +
                #   Specifies whether Padrino was loaded.
         | 
| 95 115 | 
             
                #
         | 
| 96 116 | 
             
                def loaded?
         | 
| 97 117 | 
             
                  Thread.current[:padrino_loaded]
         | 
| @@ -102,21 +122,23 @@ module Padrino | |
| 102 122 | 
             
                # If you use this method we can perform correctly a Padrino.reload!
         | 
| 103 123 | 
             
                # Another good thing that this method are dependency check, for example:
         | 
| 104 124 | 
             
                #
         | 
| 105 | 
            -
                #   models
         | 
| 106 | 
            -
                # | 
| 107 | 
            -
                # | 
| 125 | 
            +
                #   # models
         | 
| 126 | 
            +
                #   #  \-- a.rb => require something of b.rb
         | 
| 127 | 
            +
                #   #  \-- b.rb
         | 
| 108 128 | 
             
                #
         | 
| 109 129 | 
             
                # In the example above if we do:
         | 
| 110 130 | 
             
                #
         | 
| 111 131 | 
             
                #   Dir["/models/*.rb"].each { |r| require r }
         | 
| 112 132 | 
             
                #
         | 
| 113 | 
            -
                # we get an error, because we try to require first a.rb that need | 
| 133 | 
            +
                # we get an error, because we try to require first +a.rb+ that need
         | 
| 134 | 
            +
                # _something_ of +b.rb+.
         | 
| 114 135 | 
             
                #
         | 
| 115 | 
            -
                # With  | 
| 136 | 
            +
                # With this method we don't have this problem.
         | 
| 116 137 | 
             
                #
         | 
| 117 | 
            -
                #  | 
| 138 | 
            +
                # @param [Array<String>] paths
         | 
| 139 | 
            +
                #   The paths to require.
         | 
| 118 140 | 
             
                #
         | 
| 119 | 
            -
                # | 
| 141 | 
            +
                # @example For require all our app libs we need to do:
         | 
| 120 142 | 
             
                #   require_dependencies("#{Padrino.root}/lib/**/*.rb")
         | 
| 121 143 | 
             
                #
         | 
| 122 144 | 
             
                def require_dependencies(*paths)
         | 
| @@ -158,10 +180,13 @@ module Padrino | |
| 158 180 |  | 
| 159 181 | 
             
                ##
         | 
| 160 182 | 
             
                # Returns default list of path globs to load as dependencies
         | 
| 161 | 
            -
                # Appends custom dependency patterns to the be loaded for Padrino
         | 
| 183 | 
            +
                # Appends custom dependency patterns to the be loaded for Padrino.
         | 
| 162 184 | 
             
                #
         | 
| 163 | 
            -
                #  | 
| 164 | 
            -
                # | 
| 185 | 
            +
                # @return [Array<String>]
         | 
| 186 | 
            +
                #   The dependencey paths.
         | 
| 187 | 
            +
                #
         | 
| 188 | 
            +
                # @example
         | 
| 189 | 
            +
                #   Padrino.dependency_paths << "#{Padrino.root}/uploaders/*.rb"
         | 
| 165 190 | 
             
                #
         | 
| 166 191 | 
             
                def dependency_paths
         | 
| 167 192 | 
             
                  @_dependency_paths_was = [
         | 
| @@ -172,7 +197,10 @@ module Padrino | |
| 172 197 | 
             
                end
         | 
| 173 198 |  | 
| 174 199 | 
             
                ##
         | 
| 175 | 
            -
                # Concat to  | 
| 200 | 
            +
                # Concat to +$LOAD_PATH+ the given paths.
         | 
| 201 | 
            +
                #
         | 
| 202 | 
            +
                # @param [Array<String>] paths
         | 
| 203 | 
            +
                #   The paths to concat.
         | 
| 176 204 | 
             
                #
         | 
| 177 205 | 
             
                def set_load_paths(*paths)
         | 
| 178 206 | 
             
                  $:.concat(paths); load_paths.concat(paths)
         | 
| @@ -13,7 +13,10 @@ cs: | |
| 13 13 | 
             
                abbr_day_names: [Ne, Po, Út, St, Čt, Pá, So]
         | 
| 14 14 | 
             
                month_names: [~, Leden, Únor, Březen, Duben, Květen, Červen, Červenec, Srpen, Září, Říjen, Listopad, Prosinec]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Led, Úno, Bře, Dub, Kvě, Čvn, Čvc, Srp, Zář, Říj, Lis, Pro]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ da: | |
| 13 13 | 
             
                abbr_day_names: [sø, ma, ti, 'on', to, fr, lø]
         | 
| 14 14 | 
             
                month_names: [~, januar, februar, marts, april, maj, juni, juli, august, september, oktober, november, december]
         | 
| 15 15 | 
             
                abbr_month_names: [~, jan, feb, mar, apr, maj, jun, jul, aug, sep, okt, nov, dec]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ de: | |
| 13 13 | 
             
                abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa]
         | 
| 14 14 | 
             
                month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ en: | |
| 13 13 | 
             
                abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
         | 
| 14 14 | 
             
                month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - year
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - day
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ es: | |
| 13 13 | 
             
                abbr_day_names: [Dom, Lun, Mar, Mie, Jue, Vie, Sab]
         | 
| 14 14 | 
             
                month_names: [~, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Ene, Feb, Mar, Abr, May, Jun, Jul, Ago, Sep, Oct, Nov, Dic]
         | 
| 16 | 
            -
                order:  | 
| 16 | 
            +
                order: 
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ fr: | |
| 13 13 | 
             
                abbr_day_names: [Lun, Mar, Mer, Jeu, Ven, Sam, Dim]
         | 
| 14 14 | 
             
                month_names: [~, Janvier, Février, Mars, Avril, Mai, Juin, Juillet, Août, Septembre, Octobre, Novembre, Décembre]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Jan, Fev, Mar, Avr, Mai, Jui, Jui, Aou, Sep, Oct, Nov, Dec]
         | 
| 16 | 
            -
                order:  | 
| 16 | 
            +
                order: 
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ hu: | |
| 13 13 | 
             
                abbr_day_names: [vas, hét, kedd, sze, csüt, pén, szo]
         | 
| 14 14 | 
             
                month_names: [~, január, február, március, április, május, június, július, augusztus, szeptember, oktober, november, december]
         | 
| 15 15 | 
             
                abbr_month_names: [~, jan, febr, márc, ápr, máj, jún, júl, aug, szept, okt, nov, dec]
         | 
| 16 | 
            -
                order:  | 
| 16 | 
            +
                order: 
         | 
| 17 | 
            +
                  - year
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - day
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ it: | |
| 13 13 | 
             
                abbr_day_names: [Dom, Lun, Mar, Mer, Gio, Ven, Sab]
         | 
| 14 14 | 
             
                month_names: [~, Gennaio, Febbraio, Marzo, Aprile, Maggio, Giugno, Luglio, Agosto, Settembre, Ottobre, Novembre, Dicembre]
         | 
| 15 15 | 
             
                abbr_month_names: [~, Gen, Feb, Mar, Apr, Mag, Giu, Lug, Ago, Set, Ott, Nov, Dic]
         | 
| 16 | 
            -
                order:  | 
| 16 | 
            +
                order: 
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ ja: | |
| 13 13 | 
             
                abbr_day_names: [日, 月, 火, 水, 木, 金, 土]
         | 
| 14 14 | 
             
                month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月]
         | 
| 15 15 | 
             
                abbr_month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月]
         | 
| 16 | 
            -
                order:  | 
| 16 | 
            +
                order: 
         | 
| 17 | 
            +
                  - year
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - day
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            lv:
         | 
| 2 | 
            +
              date:
         | 
| 3 | 
            +
                formats:
         | 
| 4 | 
            +
                  # Use the strftime parameters for formats.
         | 
| 5 | 
            +
                  # When no format has been given, it uses default.
         | 
| 6 | 
            +
                  # You can provide other formats here if you like!
         | 
| 7 | 
            +
                  default: "%d.%m.%Y."
         | 
| 8 | 
            +
                  short: "%e. %B"
         | 
| 9 | 
            +
                  long: "%Y. gada %e. %B"
         | 
| 10 | 
            +
                  only_day: "%e"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                day_names: [Svētdiena, Pirmdiena, Otrdiena, Trešdiena, Ceturtdiena, Piektdiena, Sestdiena]
         | 
| 13 | 
            +
                abbr_day_names: [Sv, P, O, T, C, P, S]
         | 
| 14 | 
            +
                month_names: [~, Janvāris, Februāris, Marts, Aprīlis, Maijs, Jūnijs, Jūlijs, Augusts, Septembris, Oktobris, Novembris, Decembris]
         | 
| 15 | 
            +
                abbr_month_names: [~, Janv, Febr, Marts, Apr, Maijs, Jūn, Jūl, Aug, Sept, Okt, Nov, Dec]
         | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              time:
         | 
| 22 | 
            +
                formats:
         | 
| 23 | 
            +
                  default: "%Y. gada %e. %B, %H:%M"
         | 
| 24 | 
            +
                  short: "%d.%m.%Y., %H:%M"
         | 
| 25 | 
            +
                  long: "%Y. gada %e. %B, %H:%M:%S"
         | 
| 26 | 
            +
                am: "priekšpusdiena"
         | 
| 27 | 
            +
                pm: "pēcpusdiena"
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            # Used in array.to_sentence.
         | 
| 30 | 
            +
              support:
         | 
| 31 | 
            +
                array:
         | 
| 32 | 
            +
                  words_connector: ", "
         | 
| 33 | 
            +
                  two_words_connector: " un "
         | 
| 34 | 
            +
                  last_word_connector: ", un "
         | 
| @@ -13,7 +13,10 @@ nl: | |
| 13 13 | 
             
                abbr_day_names: [zo, ma, di, wo, do, vr, za]
         | 
| 14 14 | 
             
                month_names: [~, januari, februari, maart, april, mei, juni, juli, augustus, september, oktober, november]
         | 
| 15 15 | 
             
                abbr_month_names: [~, jan, feb, maa, apr, mei, jun, jul, aug, sep, okt, nov, dec]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ | |
| 13 13 | 
             
                abbr_day_names: [sø, ma, ti, 'on', to, fr, lø]
         | 
| 14 14 | 
             
                month_names: [~, januar, februar, mars, april, mai, juni, juli, august, september, oktober, november, desember]
         | 
| 15 15 | 
             
                abbr_month_names: [~, jan, feb, mar, apr, maj, jun, jul, aug, sep, okt, nov, des]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - day
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - year
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         | 
| @@ -13,7 +13,10 @@ pl: | |
| 13 13 | 
             
                abbr_day_names: [nie, pon, wto, śro, czw, pia, sob]
         | 
| 14 14 | 
             
                month_names: [~, Styczeń, Luty, Marzec, Kwiecień, Maj, Czerwiec, Lipiec, Sierpień, Wrzesień, Październik, Listopad, Grudzień]
         | 
| 15 15 | 
             
                abbr_month_names: [~, sty, lut, mar, kwi, maj, cze, lip, sie, wrz, paź, lis, gru]
         | 
| 16 | 
            -
                order: | 
| 16 | 
            +
                order:
         | 
| 17 | 
            +
                  - year
         | 
| 18 | 
            +
                  - month
         | 
| 19 | 
            +
                  - day
         | 
| 17 20 |  | 
| 18 21 | 
             
              time:
         | 
| 19 22 | 
             
                formats:
         |