module PUNK

Constants

Interface
Model
ROUTES

Public Class Methods

commands(target, scope = nil) click to toggle source
# File lib/punk/core/commands.rb, line 6
def self.commands(target, scope = nil)
  path = File.expand_path(File.join(__dir__, "..", "commands"))
  PUNK.profile_debug("commands", path: path) do
    Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
  end
  path = File.expand_path(File.join(PUNK.get.app.path, "commands"))
  PUNK.profile_debug("commands", path: path) do
    Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
  end
  case target
  when :commander
    require_relative "commander"
    Command.commander
  when :pry
    require_relative "pry"
    Command.pry
  when :spec
    Command.spec(scope)
  end
end
env() click to toggle source
# File lib/punk/core/env.rb, line 277
def self.env
  PUNK.get.env
end
init(task: "server", path: "./app", config: {}) click to toggle source
# File lib/punk.rb, line 19
def self.init(task: "server", path: "./app", config: {})
  require_relative "punk/core/interface"
  raise InternalServerError, "Cannot call PUNK.init multiple times!" if state != :included
  store.args = OpenStruct.new(
    task: task,
    path: path,
    config: config
  )
  store.state = :initialised
  Interface.bootstrap
  self
end
inject(*methods) click to toggle source
# File lib/punk/core/interface.rb, line 22
def self.inject(*methods)
  def_single_delegators :'PUNK::Interface', *methods
end
migration(&block) click to toggle source
# File lib/punk/startup/database.rb, line 43
def self.migration(&block)
  Sequel::MigrationDSL.create(&block)
end
profile_debug(name, **kwargs) { || ... } click to toggle source
# File lib/punk/core/logger.rb, line 13
def self.profile_debug(name, **kwargs)
  logger.debug "Started #{name}", kwargs.sanitize.inspect
  logger.measure_debug("Completed #{name}") { logger.tagged(name) { yield } }
end
profile_info(name, **kwargs) { || ... } click to toggle source
# File lib/punk/core/logger.rb, line 8
def self.profile_info(name, **kwargs)
  logger.info "Started #{name}", kwargs.sanitize.inspect
  logger.measure_info("Completed #{name}") { logger.tagged(name) { yield } }
end
profile_trace(name, **kwargs) { || ... } click to toggle source
# File lib/punk/core/logger.rb, line 18
def self.profile_trace(name, **kwargs)
  logger.trace "Started #{name}", kwargs.sanitize.inspect
  logger.measure_trace("Completed #{name}") { logger.tagged(name) { yield } }
end
require_all(path) click to toggle source
# File lib/punk/core/exec.rb, line 4
def self.require_all(path)
  path = File.expand_path(path)
  PUNK.profile_debug("require_all", path: path) do
    if PUNK.get.app.reloadable?
      PUNK.loader.require(path)
    else
      Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
    end
  end
end
route(name, &block) click to toggle source
# File lib/punk/core/app.rb, line 16
def self.route(name, &block)
  PUNK.profile_info("route", path: name) do
    PUNK::App.route(name) do |r|
      r.scope.instance_exec(&block)
    end
  end
end
task() click to toggle source
# File lib/punk/core/env.rb, line 281
def self.task
  PUNK.get.task
end
version() click to toggle source
# File lib/punk/core/version.rb, line 4
def self.version
  File.read(File.join(__dir__, "..", "..", "..", "VERSION"))
end