Class: FileWatch::Settings
- Inherits:
-
Object
- Object
- FileWatch::Settings
- Defined in:
- lib/filewatch/settings.rb
Instance Attribute Summary collapse
-
#check_archive_validity ⇒ Object
readonly
Returns the value of attribute check_archive_validity.
-
#close_older ⇒ Object
readonly
Returns the value of attribute close_older.
-
#delimiter ⇒ Object
readonly
Returns the value of attribute delimiter.
-
#delimiter_byte_size ⇒ Object
readonly
Returns the value of attribute delimiter_byte_size.
-
#discover_interval ⇒ Object
readonly
Returns the value of attribute discover_interval.
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#exit_after_read ⇒ Object
readonly
Returns the value of attribute exit_after_read.
-
#file_chunk_count ⇒ Object
readonly
Returns the value of attribute file_chunk_count.
-
#file_chunk_size ⇒ Object
readonly
Returns the value of attribute file_chunk_size.
-
#file_sort_by ⇒ Object
readonly
Returns the value of attribute file_sort_by.
-
#file_sort_direction ⇒ Object
readonly
Returns the value of attribute file_sort_direction.
-
#ignore_older ⇒ Object
readonly
Returns the value of attribute ignore_older.
-
#lastwarn_max_files ⇒ Object
readonly
Returns the value of attribute lastwarn_max_files.
-
#max_active ⇒ Object
readonly
Returns the value of attribute max_active.
-
#max_warn_msg ⇒ Object
readonly
Returns the value of attribute max_warn_msg.
-
#sincedb_expiry_duration ⇒ Object
readonly
Returns the value of attribute sincedb_expiry_duration.
-
#sincedb_path ⇒ Object
readonly
Returns the value of attribute sincedb_path.
-
#sincedb_write_interval ⇒ Object
readonly
Returns the value of attribute sincedb_write_interval.
-
#start_new_files_at ⇒ Object
readonly
Returns the value of attribute start_new_files_at.
-
#stat_interval ⇒ Object
readonly
Returns the value of attribute stat_interval.
Class Method Summary collapse
Instance Method Summary collapse
- #add_options(opts) ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #max_open_files=(value) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/filewatch/settings.rb', line 18 def initialize defaults = { :delimiter => "\n", :file_chunk_size => FILE_READ_SIZE, :max_open_files => 4095, :file_chunk_count => MAX_ITERATIONS, :sincedb_clean_after => 14, :exclude => [], :stat_interval => 1, :discover_interval => 5, :file_sort_by => "last_modified", :file_sort_direction => "asc", } @opts = {} @lastwarn_max_files = 0 (defaults) end |
Instance Attribute Details
#check_archive_validity ⇒ Object (readonly)
Returns the value of attribute check_archive_validity.
12 13 14 |
# File 'lib/filewatch/settings.rb', line 12 def check_archive_validity @check_archive_validity end |
#close_older ⇒ Object (readonly)
Returns the value of attribute close_older.
5 6 7 |
# File 'lib/filewatch/settings.rb', line 5 def close_older @close_older end |
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
5 6 7 |
# File 'lib/filewatch/settings.rb', line 5 def delimiter @delimiter end |
#delimiter_byte_size ⇒ Object (readonly)
Returns the value of attribute delimiter_byte_size.
5 6 7 |
# File 'lib/filewatch/settings.rb', line 5 def delimiter_byte_size @delimiter_byte_size end |
#discover_interval ⇒ Object (readonly)
Returns the value of attribute discover_interval.
7 8 9 |
# File 'lib/filewatch/settings.rb', line 7 def discover_interval @discover_interval end |
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
8 9 10 |
# File 'lib/filewatch/settings.rb', line 8 def exclude @exclude end |
#exit_after_read ⇒ Object (readonly)
Returns the value of attribute exit_after_read.
11 12 13 |
# File 'lib/filewatch/settings.rb', line 11 def exit_after_read @exit_after_read end |
#file_chunk_count ⇒ Object (readonly)
Returns the value of attribute file_chunk_count.
8 9 10 |
# File 'lib/filewatch/settings.rb', line 8 def file_chunk_count @file_chunk_count end |
#file_chunk_size ⇒ Object (readonly)
Returns the value of attribute file_chunk_size.
8 9 10 |
# File 'lib/filewatch/settings.rb', line 8 def file_chunk_size @file_chunk_size end |
#file_sort_by ⇒ Object (readonly)
Returns the value of attribute file_sort_by.
10 11 12 |
# File 'lib/filewatch/settings.rb', line 10 def file_sort_by @file_sort_by end |
#file_sort_direction ⇒ Object (readonly)
Returns the value of attribute file_sort_direction.
10 11 12 |
# File 'lib/filewatch/settings.rb', line 10 def file_sort_direction @file_sort_direction end |
#ignore_older ⇒ Object (readonly)
Returns the value of attribute ignore_older.
5 6 7 |
# File 'lib/filewatch/settings.rb', line 5 def ignore_older @ignore_older end |
#lastwarn_max_files ⇒ Object (readonly)
Returns the value of attribute lastwarn_max_files.
6 7 8 |
# File 'lib/filewatch/settings.rb', line 6 def lastwarn_max_files @lastwarn_max_files end |
#max_active ⇒ Object (readonly)
Returns the value of attribute max_active.
6 7 8 |
# File 'lib/filewatch/settings.rb', line 6 def max_active @max_active end |
#max_warn_msg ⇒ Object (readonly)
Returns the value of attribute max_warn_msg.
6 7 8 |
# File 'lib/filewatch/settings.rb', line 6 def max_warn_msg @max_warn_msg end |
#sincedb_expiry_duration ⇒ Object (readonly)
Returns the value of attribute sincedb_expiry_duration.
9 10 11 |
# File 'lib/filewatch/settings.rb', line 9 def sincedb_expiry_duration @sincedb_expiry_duration end |
#sincedb_path ⇒ Object (readonly)
Returns the value of attribute sincedb_path.
9 10 11 |
# File 'lib/filewatch/settings.rb', line 9 def sincedb_path @sincedb_path end |
#sincedb_write_interval ⇒ Object (readonly)
Returns the value of attribute sincedb_write_interval.
7 8 9 |
# File 'lib/filewatch/settings.rb', line 7 def sincedb_write_interval @sincedb_write_interval end |
#start_new_files_at ⇒ Object (readonly)
Returns the value of attribute start_new_files_at.
8 9 10 |
# File 'lib/filewatch/settings.rb', line 8 def start_new_files_at @start_new_files_at end |
#stat_interval ⇒ Object (readonly)
Returns the value of attribute stat_interval.
7 8 9 |
# File 'lib/filewatch/settings.rb', line 7 def stat_interval @stat_interval end |
Class Method Details
.from_options(opts) ⇒ Object
14 15 16 |
# File 'lib/filewatch/settings.rb', line 14 def self.(opts) new.(opts) end |
Instance Method Details
#add_options(opts) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/filewatch/settings.rb', line 36 def (opts) @opts.update(opts) self.max_open_files = @opts[:max_open_files] @delimiter = @opts[:delimiter] @delimiter_byte_size = @delimiter.bytesize @file_chunk_size = @opts[:file_chunk_size] @close_older = @opts[:close_older] @ignore_older = @opts[:ignore_older] @stat_interval = @opts[:stat_interval] @discover_interval = @opts[:discover_interval] @exclude = Array(@opts[:exclude]) @start_new_files_at = @opts[:start_new_files_at] @file_chunk_count = @opts[:file_chunk_count] @sincedb_path = @opts[:sincedb_path] @sincedb_write_interval = @opts[:sincedb_write_interval] @sincedb_expiry_duration = @opts.fetch(:sincedb_clean_after) @file_sort_by = @opts[:file_sort_by] @file_sort_direction = @opts[:file_sort_direction] @exit_after_read = @opts[:exit_after_read] @check_archive_validity = @opts[:check_archive_validity] self end |
#max_open_files=(value) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/filewatch/settings.rb', line 59 def max_open_files=(value) val = value.to_i val = 4095 if value.nil? || val <= 0 @max_warn_msg = "Reached open files limit: #{val}, set by the 'max_open_files' option or default" @max_active = val end |