Class: Insup::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/insup/tracker.rb

Direct Known Subclasses

GitTracker, SimpleTracker

Defined Under Namespace

Classes: GitTracker, SimpleTracker

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Tracker



13
14
15
16
# File 'lib/insup/tracker.rb', line 13

def initialize(config = nil)
  @config = config
  @path = Dir.getwd
end

Class Method Details

.find_tracker(tracker_alias) ⇒ Object



9
10
11
# File 'lib/insup/tracker.rb', line 9

def self.find_tracker(tracker_alias)
  @@trackers[tracker_alias.to_sym]
end

.tracker(tracker_alias) ⇒ Object



4
5
6
7
# File 'lib/insup/tracker.rb', line 4

def self.tracker(tracker_alias)
  @@trackers ||= {}
  @@trackers[tracker_alias] = self
end

Instance Method Details

#all_filesObject

Lists ALL files in the tracked locations whether they are ignored or not



19
20
21
22
23
24
25
26
# File 'lib/insup/tracker.rb', line 19

def all_files
  locations = tracked_locations
  locations.map do |loc|
    loc_pat = File.join(loc, '**/*')
    Dir.glob(loc_pat, File::FNM_DOTMATCH)
      .select{|e| File.file?(e)}
  end.flatten
end

#changesObject



38
39
40
41
42
43
44
# File 'lib/insup/tracker.rb', line 38

def changes
  res = raw_changes.select do |x|
    tracked_locations.any? do |loc|
      !ignore_matcher.matched?(x.path) && File.fnmatch(File.join(loc,'/*'), x.path)
    end
  end
end

#ignored_filesObject

Lists ALL tracked files in the tracked locations i. e. all files but ignored



34
35
36
# File 'lib/insup/tracker.rb', line 34

def ignored_files
  all_files.select{|f| ignore_matcher.matched?(f)}
end

#tracked_filesObject

Lists ALL tracked files in the tracked locations i. e. all files but ignored



29
30
31
# File 'lib/insup/tracker.rb', line 29

def tracked_files
  all_files.reject{|f| ignore_matcher.matched?(f)}
end