Class: FaaStRuby::Local::ListenerEvent
- Inherits:
-
Object
- Object
- FaaStRuby::Local::ListenerEvent
- Includes:
- Logger
- Defined in:
- lib/faastruby/local/listeners/listener.rb
Instance Attribute Summary collapse
-
#dirname ⇒ Object
Returns the value of attribute dirname.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#full_path ⇒ Object
Returns the value of attribute full_path.
-
#listened_directory ⇒ Object
Returns the value of attribute listened_directory.
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#added? ⇒ Boolean
def file_was_just_added? debug __method__ Time.now.to_i - File.ctime(@full_path).to_i <= 1 end.
- #file_is_a_function_config? ⇒ Boolean
- #file_is_a_handler? ⇒ Boolean
- #function_created? ⇒ Boolean
-
#initialize(type:, full_path:, listened_directory:) ⇒ ListenerEvent
constructor
A new instance of ListenerEvent.
- #modified? ⇒ Boolean
- #relative_path_for(full_path) ⇒ Object
- #removed? ⇒ Boolean
Methods included from Logger
Constructor Details
#initialize(type:, full_path:, listened_directory:) ⇒ ListenerEvent
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 49 def initialize(type:, full_path:, listened_directory:) debug "initialize(type: #{type.inspect}, full_path: #{full_path.inspect}, listened_directory: #{listened_directory.inspect})" @listened_directory = listened_directory @full_path = full_path @relative_path = relative_path_for(@full_path.dup) @filename = File.basename(@full_path) @dirname = File.dirname(@full_path) @type = type debug "EVENT: #{@type}" debug "EVENT: #{@full_path}" end |
Instance Attribute Details
#dirname ⇒ Object
Returns the value of attribute dirname.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def dirname @dirname end |
#filename ⇒ Object
Returns the value of attribute filename.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def filename @filename end |
#full_path ⇒ Object
Returns the value of attribute full_path.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def full_path @full_path end |
#listened_directory ⇒ Object
Returns the value of attribute listened_directory.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def listened_directory @listened_directory end |
#relative_path ⇒ Object
Returns the value of attribute relative_path.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def relative_path @relative_path end |
#type ⇒ Object
Returns the value of attribute type.
48 49 50 |
# File 'lib/faastruby/local/listeners/listener.rb', line 48 def type @type end |
Instance Method Details
#added? ⇒ Boolean
def file_was_just_added?
debug __method__
Time.now.to_i - File.ctime(@full_path).to_i <= 1
end
82 83 84 85 |
# File 'lib/faastruby/local/listeners/listener.rb', line 82 def added? debug __method__ @type == :added end |
#file_is_a_function_config? ⇒ Boolean
72 73 74 75 |
# File 'lib/faastruby/local/listeners/listener.rb', line 72 def file_is_a_function_config? debug __method__ filename == 'faastruby.yml' end |
#file_is_a_handler? ⇒ Boolean
67 68 69 70 |
# File 'lib/faastruby/local/listeners/listener.rb', line 67 def file_is_a_handler? debug __method__ filename.match(/^handler\.(rb|cr)$/) end |
#function_created? ⇒ Boolean
62 63 64 65 |
# File 'lib/faastruby/local/listeners/listener.rb', line 62 def function_created? debug __method__ added? && filename.match(/^handler\.(rb|cr)$/) end |
#modified? ⇒ Boolean
87 88 89 90 |
# File 'lib/faastruby/local/listeners/listener.rb', line 87 def modified? debug __method__ @type == :modified end |
#relative_path_for(full_path) ⇒ Object
97 98 99 100 101 |
# File 'lib/faastruby/local/listeners/listener.rb', line 97 def relative_path_for(full_path) debug "relative_path_for(#{full_path.inspect})" full_path.slice!("#{@listened_directory}/") full_path end |
#removed? ⇒ Boolean
92 93 94 95 |
# File 'lib/faastruby/local/listeners/listener.rb', line 92 def removed? debug __method__ @type == :removed end |