Class: RubyPitaya::ApplicationFilesImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/core/application_files_importer.rb

Instance Method Summary collapse

Instance Method Details

#auto_reloadObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rubypitaya/core/application_files_importer.rb', line 24

def auto_reload
  require 'listen'

  app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]

  app_files_listener = Listen.to(*app_folder_paths,
                                  only: /\.rb$/,
                                  force_polling: true,
                                  latency: 0.25,
                                  wait_for_delay: 0.1) do |modified, added, removed|
    import_added_files(added)
    reload_modified_files(modified)
  end

  app_files_listener.start
end

#import(is_cheats_enabled) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubypitaya/core/application_files_importer.rb', line 7

def import(is_cheats_enabled)
  app_folder_paths = Path::Plugins::APP_FOLDER_PATHS + [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]

  gem_files = []

  app_folder_paths.each do |app_folder_path|
    gem_files += Dir.glob("#{app_folder_path}**/*.rb")
  end

  gem_files.select! { |a| !a[/.+app\/migrations.+/] }
  gem_files.select! { |a| !a[/.+_cheats.rb/] && !a[/.+_cheat.rb/] } unless is_cheats_enabled

  gem_files.each do |path|
    require path
  end
end