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/console.rb,
lib/hirb/helpers.rb,
lib/hirb/formatter.rb,
lib/hirb/import_object.rb
Overview
Most of Hirb’s functionality currently resides in Hirb::View. For an in-depth tutorial on creating and configuring views see Hirb::Formatter. Hirb has an optional yaml config file defined by config_file(). This config file has 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 DEFAULT_WIDTH or possibly autodetected when Hirb is enabled.
- :height
-
Height of the terminal/console. Defaults to 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.
Defined Under Namespace
Modules: Console, Helpers, ObjectMethods, Util, View, Views Classes: Formatter, HashStruct, Menu, Pager
Class Method Summary collapse
- .config(reload = false) ⇒ Object
-
.config_file ⇒ Object
Default is config/hirb.yml or ~/hirb.yml in that order.
-
.config_file=(value) ⇒ Object
:stopdoc:.
-
.disable ⇒ Object
Disables view functionality.
-
.enable(options = {}, &block) ⇒ Object
Enables view functionality.
- .read_config_file(file = config_file) ⇒ Object
Class Method Details
.config(reload = false) ⇒ Object
51 52 53 |
# File 'lib/hirb.rb', line 51 def config(reload=false) @config = (@config.nil? || reload) ? read_config_file : @config end |
.config_file ⇒ Object
Default is config/hirb.yml or ~/hirb.yml in that order.
38 39 40 |
# File 'lib/hirb.rb', line 38 def config_file @config_file ||= File.exists?('config/hirb.yml') ? 'config/hirb.yml' : File.(File.join(ENV["HOME"],".hirb.yml")) end |
.config_file=(value) ⇒ Object
:stopdoc:
43 44 45 |
# File 'lib/hirb.rb', line 43 def config_file=(value) @config_file = value end |
.disable ⇒ Object
Disables view functionality. See Hirb::View.disable for details.
34 35 36 |
# File 'lib/hirb.rb', line 34 def disable View.disable end |
.enable(options = {}, &block) ⇒ Object
Enables view functionality. See Hirb::View.enable for details.
29 30 31 |
# File 'lib/hirb.rb', line 29 def enable(={}, &block) View.enable(, &block) end |
.read_config_file(file = config_file) ⇒ Object
47 48 49 |
# File 'lib/hirb.rb', line 47 def read_config_file(file=config_file) File.exists?(file) ? YAML::load_file(file) : {} end |