Class: PDFWalker::Walker::Config
- Inherits:
-
Object
- Object
- PDFWalker::Walker::Config
- Defined in:
- lib/pdfwalker/config.rb
Constant Summary collapse
- DEFAULT_CONFIG_FILE =
"#{File.("~")}/.pdfwalker.conf.yml"- DEFAULT_CONFIG =
{ "Debug" => { "Profiling" => false, "ProfilingOutputDir" => "prof", "Verbosity" => Origami::Parser::VERBOSE_TRACE, "IgnoreFileHeader" => true }, "UI" => { "LastOpenedDocuments" => [] } }
- NLOG_RECENT_FILES =
5
Instance Method Summary collapse
- #ignore_header? ⇒ Boolean
-
#initialize(configfile = DEFAULT_CONFIG_FILE) ⇒ Config
constructor
A new instance of Config.
- #last_opened_file(filepath) ⇒ Object
- #profile? ⇒ Boolean
- #profile_output_dir ⇒ Object
- #recent_files(n = NLOG_RECENT_FILES) ⇒ Object
- #save ⇒ Object
- #set_ignore_header(bool) ⇒ Object
- #set_profiling(bool) ⇒ Object
- #set_verbosity(level) ⇒ Object
- #verbosity ⇒ Object
Constructor Details
#initialize(configfile = DEFAULT_CONFIG_FILE) ⇒ Config
Returns a new instance of Config.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pdfwalker/config.rb', line 47 def initialize(configfile = DEFAULT_CONFIG_FILE) begin @conf = YAML.load(File.open(configfile)) rescue @conf = DEFAULT_CONFIG ensure @filename = configfile set_missing_values end end |
Instance Method Details
#ignore_header? ⇒ Boolean
87 88 89 |
# File 'lib/pdfwalker/config.rb', line 87 def ignore_header? @conf["Debug"]['IgnoreFileHeader'] end |
#last_opened_file(filepath) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/pdfwalker/config.rb', line 58 def last_opened_file(filepath) @conf["UI"]['LastOpenedDocuments'].push(filepath).uniq! @conf["UI"]['LastOpenedDocuments'].delete_at(0) while @conf["UI"]['LastOpenedDocuments'].size > NLOG_RECENT_FILES save end |
#profile? ⇒ Boolean
74 75 76 |
# File 'lib/pdfwalker/config.rb', line 74 def profile? @conf["Debug"]['Profiling'] end |
#profile_output_dir ⇒ Object
78 79 80 |
# File 'lib/pdfwalker/config.rb', line 78 def profile_output_dir @conf["Debug"]['ProfilingOutputDir'] end |
#recent_files(n = NLOG_RECENT_FILES) ⇒ Object
65 66 67 |
# File 'lib/pdfwalker/config.rb', line 65 def recent_files(n = NLOG_RECENT_FILES) @conf["UI"]['LastOpenedDocuments'].last(n).reverse end |
#save ⇒ Object
100 101 102 |
# File 'lib/pdfwalker/config.rb', line 100 def save File.open(@filename, "w").write(@conf.to_yaml) end |
#set_ignore_header(bool) ⇒ Object
82 83 84 85 |
# File 'lib/pdfwalker/config.rb', line 82 def set_ignore_header(bool) @conf["Debug"]['IgnoreFileHeader'] = bool save end |
#set_profiling(bool) ⇒ Object
69 70 71 72 |
# File 'lib/pdfwalker/config.rb', line 69 def set_profiling(bool) @conf["Debug"]['Profiling'] = bool save end |
#set_verbosity(level) ⇒ Object
91 92 93 94 |
# File 'lib/pdfwalker/config.rb', line 91 def set_verbosity(level) @conf["Debug"]['Verbosity'] = level save end |
#verbosity ⇒ Object
96 97 98 |
# File 'lib/pdfwalker/config.rb', line 96 def verbosity @conf["Debug"]['Verbosity'] end |