Class: ORI::AutoConfig
Overview
Propose config defaults based on OS and environment.
Instance Attribute Summary collapse
-
#host_os ⇒ Object
Value of
RbConfig::Config["host_os"]
.
Instance Method Summary collapse
-
#color ⇒ Object
————————————— Defaults.
- #frontend ⇒ Object
-
#has_less? ⇒ Boolean
————————————— Accessors and pseudo-accessors.
-
#initialize(attrs = {}) ⇒ AutoConfig
constructor
A new instance of AutoConfig.
- #pager ⇒ Object
- #shell_escape ⇒ Object
- #unix? ⇒ Boolean
- #windows? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ AutoConfig
Returns a new instance of AutoConfig.
11 12 13 14 |
# File 'lib/ori/auto_config.rb', line 11 def initialize(attrs = {}) attrs.each {|k, v| send("#{k}=", v)} clear_cache end |
Instance Attribute Details
#host_os ⇒ Object
Value of RbConfig::Config["host_os"]
.
linux-gnu
mswin32
cygwin
9 10 11 |
# File 'lib/ori/auto_config.rb', line 9 def host_os @host_os end |
Instance Method Details
#color ⇒ Object
————————————— Defaults
46 47 48 |
# File 'lib/ori/auto_config.rb', line 46 def color @cache[:color] ||= unix?? true : false end |
#frontend ⇒ Object
50 51 52 |
# File 'lib/ori/auto_config.rb', line 50 def frontend @cache[:frontend] ||= unix?? "ri -T -f ansi %s" : "ri -T %s" end |
#has_less? ⇒ Boolean
————————————— Accessors and pseudo-accessors
18 19 20 21 22 23 |
# File 'lib/ori/auto_config.rb', line 18 def has_less? @cache[:has_less] ||= begin require_host_os !!@host_os.match(/cygwin|darwin|freebsd|gnu|linux/i) end end |
#pager ⇒ Object
54 55 56 |
# File 'lib/ori/auto_config.rb', line 54 def pager @cache[:pager] ||= has_less?? "less -R" : "more" end |
#shell_escape ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/ori/auto_config.rb', line 58 def shell_escape @cache[:shell_escape] ||= if unix? :unix elsif windows? :windows else nil end end |
#unix? ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/ori/auto_config.rb', line 30 def unix? @cache[:is_unix] ||= begin require_host_os !!@host_os.match(/cygwin|darwin|freebsd|gnu|linux|sunos|solaris/i) end end |
#windows? ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/ori/auto_config.rb', line 37 def windows? @cache[:is_windows] ||= begin require_host_os !!@host_os.match(/mswin|windows/i) end end |