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.
-
#relative_path_dirname ⇒ Object
Returns the value of attribute relative_path_dirname.
-
#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_gemfile? ⇒ Boolean
- #file_is_a_gemfile_lock? ⇒ Boolean
- #file_is_a_handler? ⇒ Boolean
- #file_is_opal_main? ⇒ 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
- #to_h ⇒ Object
Methods included from Logger
Constructor Details
#initialize(type:, full_path:, listened_directory:) ⇒ ListenerEvent
Returns a new instance of ListenerEvent.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/faastruby/local/listeners/listener.rb', line 59 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) @relative_path_dirname = File.dirname(@relative_path) @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.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def dirname @dirname end |
#filename ⇒ Object
Returns the value of attribute filename.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def filename @filename end |
#full_path ⇒ Object
Returns the value of attribute full_path.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def full_path @full_path end |
#listened_directory ⇒ Object
Returns the value of attribute listened_directory.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def listened_directory @listened_directory end |
#relative_path ⇒ Object
Returns the value of attribute relative_path.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def relative_path @relative_path end |
#relative_path_dirname ⇒ Object
Returns the value of attribute relative_path_dirname.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 def relative_path_dirname @relative_path_dirname end |
#type ⇒ Object
Returns the value of attribute type.
58 59 60 |
# File 'lib/faastruby/local/listeners/listener.rb', line 58 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
119 120 121 122 |
# File 'lib/faastruby/local/listeners/listener.rb', line 119 def added? debug __method__ @type == :added end |
#file_is_a_function_config? ⇒ Boolean
105 106 107 108 |
# File 'lib/faastruby/local/listeners/listener.rb', line 105 def file_is_a_function_config? debug __method__ filename == 'faastruby.yml' end |
#file_is_a_gemfile? ⇒ Boolean
90 91 92 93 |
# File 'lib/faastruby/local/listeners/listener.rb', line 90 def file_is_a_gemfile? debug __method__ filename == 'Gemfile' end |
#file_is_a_gemfile_lock? ⇒ Boolean
95 96 97 98 |
# File 'lib/faastruby/local/listeners/listener.rb', line 95 def file_is_a_gemfile_lock? debug __method__ filename == 'Gemfile.lock' end |
#file_is_a_handler? ⇒ Boolean
100 101 102 103 |
# File 'lib/faastruby/local/listeners/listener.rb', line 100 def file_is_a_handler? debug __method__ filename.match(/^handler\.(rb|cr)$/) end |
#file_is_opal_main? ⇒ Boolean
110 111 112 |
# File 'lib/faastruby/local/listeners/listener.rb', line 110 def file_is_opal_main? filename == 'main.rb' end |
#function_created? ⇒ Boolean
85 86 87 88 |
# File 'lib/faastruby/local/listeners/listener.rb', line 85 def function_created? debug __method__ added? && filename.match(/^handler\.(rb|cr)$/) end |
#modified? ⇒ Boolean
124 125 126 127 |
# File 'lib/faastruby/local/listeners/listener.rb', line 124 def modified? debug __method__ @type == :modified end |
#relative_path_for(full_path) ⇒ Object
134 135 136 137 138 |
# File 'lib/faastruby/local/listeners/listener.rb', line 134 def relative_path_for(full_path) debug "relative_path_for(#{full_path.inspect})" full_path.slice!("#{@listened_directory}/") full_path end |
#removed? ⇒ Boolean
129 130 131 132 |
# File 'lib/faastruby/local/listeners/listener.rb', line 129 def removed? debug __method__ @type == :removed end |
#to_h ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/faastruby/local/listeners/listener.rb', line 73 def to_h { listened_directory: @listened_directory, full_path: @full_path, relative_path: @relative_path, relative_path_dirname: @relative_path_dirname, filename: @filename, dirname: @dirname, type: @type } end |