Sha256: 2a091e97595b3e15457b75b6cfb4cc8d278f2b0d865d86776f3ebc3fc41d1dfe

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module Alf
  module Shell
    class Alfrc < Support::Config

      # Path to be put in $LOAD_PATH before executing alf
      option :load_paths, Array, []

      # Libraries to require before executing alf
      option :requires, Array, []

      # Default renderer to use for outputting relations
      option :default_renderer, Class, ->{ $stdout.tty? ? Renderer::Text : Renderer::Rash }

      # Float format to use
      option :float_format, String, "%.3f"

      # Pretty print in console mode?
      option :pretty, Boolean, ->{ $stdout.tty? }

      # The adapter to use by default
      option :adapter, Object, ->{ Path.pwd } 

      # The database to use by default
      option :database, Database, ->{ Database.new(adapter) }

      # The viewpoint to use by default
      option :viewpoint, Module, ->{ Viewpoint::NATIVE }

      # If `path` is provided, evaluates the content of the file on this
      # instance. Also, if a block is passed, yields it with self. Return
      # self in any case.
      def alfrc(path = nil)
        ::Kernel.eval(Path(path).read, binding, path.to_s) if path
        yield(self) if block_given?
        self
      end

    end # class Alfrc
  end # module Shell
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-shell-0.14.0 lib/alf/shell/alfrc.rb