Method: Ruber::ProjectDirScanner#initialize

Defined in:
lib/ruber/project_dir_scanner.rb

#initialize(prj) ⇒ ProjectDirScanner

Returns a new instance of ProjectDirScanner.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ruber/project_dir_scanner.rb', line 37

def initialize prj
  super
  @project = prj
  #The /? at the end is there to avoid depending on whether Project#project_directory
  #returns a string ending with / or not
  @regexp = %r[^#{Regexp.quote @project.project_directory}/?]
  make_rules
  @watcher = KDE::DirWatch.new self do
    add_dir prj.project_directory, 
        KDE::DirWatch::WatchFiles | KDE::DirWatch::WatchSubDirs
  end
  @watcher.connect(SIGNAL('created(QString)')) do |f|
    emit file_added(f) if file_in_project? f
  end
  @watcher.connect(SIGNAL('deleted(QString)')) do |f|
    emit file_removed(f) if file_in_project? f
  end
  @project.connect(SIGNAL('option_changed(QString, QString)')) do |g, n|
    if g == 'general' and n == 'project_files'
      if @project[:general, :project_files] != @rules
        make_rules
        emit rules_changed
      end
    end
  end
  @watcher.start_scan false
end