Module: Hirb

Defined in:
lib/hirb.rb,
lib/hirb/menu.rb,
lib/hirb/util.rb,
lib/hirb/view.rb,
lib/hirb/pager.rb,
lib/hirb/views.rb,
lib/hirb/string.rb,
lib/hirb/console.rb,
lib/hirb/helpers.rb,
lib/hirb/version.rb,
lib/hirb/formatter.rb,
lib/hirb/dynamic_view.rb,
lib/hirb/helpers/table.rb,
lib/hirb/import_object.rb

Overview

Most of Hirb’s functionality is in Hirb::View. For a tutorial on configuring and creating views see Hirb::View. For a tutorial on dynamic views see Hirb::DynamicView.

Config Files

Hirb can have multiple config files defined by config_files(). These config files have the following top level keys:

:output

This hash is used by the formatter object. See Hirb::Formatter.config for its format.

:width

Width of the terminal/console. Defaults to Hirb::View::DEFAULT_WIDTH or possibly autodetected when Hirb is enabled.

:height

Height of the terminal/console. Defaults to Hirb::View::DEFAULT_HEIGHT or possibly autodetected when Hirb is enabled.

:formatter

Boolean which determines if the formatter is enabled. Defaults to true.

:pager

Boolean which determines if the pager is enabled. Defaults to true.

:pager_command

Command to be used for paging. Command can have options after it i.e. ‘less -r’. Defaults to common pagers i.e. less and more if detected.

:ignore_errors

Boolean which ignores internal view errors and continues with original view (i.e. #inspect for irb). Defaults to false.

Defined Under Namespace

Modules: Console, DynamicView, Helpers, ObjectMethods, String, Util, View, Views Classes: Formatter, Menu, Pager

Constant Summary collapse

VERSION =
'0.6.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config(reload = false) ⇒ Object

Returns the value of attribute config.



34
35
36
# File 'lib/hirb.rb', line 34

def config
  @config
end

.config_filesObject

Array of config files which are merged sequentially to produce config. Defaults to config/hirb.yml and ~/.hirb_yml



58
59
60
# File 'lib/hirb.rb', line 58

def config_files
  @config_files
end

Class Method Details

.add_dynamic_view(view, options, &block) ⇒ Object

Adds views. See Hirb::DynamicView.add for details.



52
53
54
# File 'lib/hirb.rb', line 52

def add_dynamic_view(view, options, &block)
  DynamicView.add(view, options, &block)
end

.add_view(view, options, &block) ⇒ Object

Adds views. See Hirb::View.add for details.



47
48
49
# File 'lib/hirb.rb', line 47

def add_view(view, options, &block)
  View.add(view, options, &block)
end

.default_config_filesObject

:stopdoc:



63
64
65
66
# File 'lib/hirb.rb', line 63

def default_config_files
  [File.join(Util.find_home, ".hirb.yml")] +
    (File.exists?('config/hirb.yml') ? ['config/hirb.yml'] : [])
end

.disableObject

Disables view functionality. See Hirb::View.disable for details.



42
43
44
# File 'lib/hirb.rb', line 42

def disable
  View.disable
end

.enable(options = {}, &block) ⇒ Object

Enables view functionality. See Hirb::View.enable for details.



37
38
39
# File 'lib/hirb.rb', line 37

def enable(options={}, &block)
  View.enable(options, &block)
end

.read_config_file(file = config_file) ⇒ Object



68
69
70
# File 'lib/hirb.rb', line 68

def read_config_file(file=config_file)
  File.exists?(file) ? YAML::load_file(file) : {}
end