Sha256: e3e1ccc52f84b7826a9ac0525e228a904ec68f669f1fda9a78502fac2dc95f6c

Contents?: true

Size: 1.4 KB

Versions: 30

Compression:

Stored size: 1.4 KB

Contents

module Padrino
  module Module
    attr_accessor :root

    ##
    # Register this module as being loaded from a gem. This automatically
    # sets the root and therefore the dependency paths correctly.
    #
    # @param [String] name
    #   The name of the gem. Has to be the name as stated in the gemspec.
    #
    # @returns the gems root.
    def gem!(name)
      self.root = Padrino.gem(name, self)
    end

    ##
    # Helper method for file references within a Padrino module.
    #
    # @param [Array<String>] args
    #   The directories to join to {Module.root}.
    #
    # @return [String]
    #   The absolute path.
    #
    # @example
    #   module MyModule
    #     extend Padrino::Module
    #     gem! 'my_gem'
    #   end
    #   Module.root!
    def root(*args)
      File.expand_path(File.join(@root, *args))
    end

    ##
    # Returns the list of path globs to load as dependencies.
    # Appends custom dependency patterns to the be loaded for Padrino.
    #
    # @return [Array<String>]
    #   The dependency paths.
    #
    # @example
    #   module MyModule
    #     extend Padrino::Module
    #     gem! 'my_gem'
    #   end
    #
    #   Module.dependency_paths << "#{MyModule.root}/uploaders/*.rb"
    #
    def dependency_paths
      [
        "#{root}/lib/**/*.rb", "#{root}/shared/lib/**/*.rb",
        "#{root}/models/**/*.rb", "#{root}/shared/models/**/*.rb"
      ]
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
padrino-core-0.12.9 lib/padrino-core/module.rb
padrino-core-0.13.3.4 lib/padrino-core/module.rb
padrino-core-0.14.0.rc1 lib/padrino-core/module.rb
padrino-core-0.13.3.3 lib/padrino-core/module.rb
padrino-core-0.13.3.2 lib/padrino-core/module.rb
padrino-core-0.12.8.1 lib/padrino-core/module.rb
padrino-core-0.13.3.1 lib/padrino-core/module.rb
padrino-core-0.13.3 lib/padrino-core/module.rb
padrino-core-0.12.8 lib/padrino-core/module.rb
padrino-core-0.12.7 lib/padrino-core/module.rb
padrino-core-0.12.6 lib/padrino-core/module.rb
padrino-core-0.13.2 lib/padrino-core/module.rb
padrino-core-0.13.1 lib/padrino-core/module.rb
padrino-core-0.13.1.beta1 lib/padrino-core/module.rb
padrino-core-0.13.0 lib/padrino-core/module.rb
padrino-core-0.13.0.beta3 lib/padrino-core/module.rb
padrino-core-0.13.0.beta2 lib/padrino-core/module.rb
padrino-core-0.12.5 lib/padrino-core/module.rb
padrino-core-0.13.0.beta1 lib/padrino-core/module.rb
padrino-core-0.12.4 lib/padrino-core/module.rb