Class: FileWatch::Settings
- Inherits:
-
Object
- Object
- FileWatch::Settings
- Defined in:
- lib/filewatch/settings.rb
Instance Attribute Summary collapse
-
#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.
-
#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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/filewatch/settings.rb', line 20 def initialize defaults = { :delimiter => "\n", :file_chunk_size => FILE_READ_SIZE, :max_active => 4095, :file_chunk_count => FIXNUM_MAX, :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
#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 |
#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
.days_to_seconds(days) ⇒ Object
16 17 18 |
# File 'lib/filewatch/settings.rb', line 16 def self.days_to_seconds(days) (24 * 3600) * days.to_f end |
.from_options(opts) ⇒ Object
12 13 14 |
# File 'lib/filewatch/settings.rb', line 12 def self.(opts) new.(opts) end |
Instance Method Details
#add_options(opts) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/filewatch/settings.rb', line 38 def (opts) @opts.update(opts) self.max_open_files = @opts[:max_active] @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] @sincedb_write_interval = @opts[:sincedb_write_interval] @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 = self.class.days_to_seconds(@opts.fetch(:sincedb_clean_after, 14)) @file_sort_by = @opts[:file_sort_by] @file_sort_direction = @opts[:file_sort_direction] self end |
#max_open_files=(value) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/filewatch/settings.rb', line 60 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 |