Class: Astray::Repository

Inherits:
Object
  • Object
show all
Includes:
PathLike, Enumerable
Defined in:
lib/astray/repository.rb

Direct Known Subclasses

Astray::Rails::Repository

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathLike

#<=>, #hash, #inspect, #to_s

Constructor Details

#initialize(path, ignore: []) ⇒ Repository

Returns a new instance of Repository.

Raises:



10
11
12
13
14
# File 'lib/astray/repository.rb', line 10

def initialize(path, ignore: [])
  @path = Pathname.new(path).expand_path
  raise InvalidDirectory unless @path.directory?
  @ignore = Set.new(ignore.map { |i| Pathname.new(i) })
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/astray/repository.rb', line 16

def path
  @path
end

Instance Method Details

#&(other) ⇒ Object



27
28
29
30
# File 'lib/astray/repository.rb', line 27

def &(other)
  wanted = other.map(&:relative_path).to_set
  select { |file| wanted.include? file.relative_path }
end

#-(other) ⇒ Object



22
23
24
25
# File 'lib/astray/repository.rb', line 22

def -(other)
  unwanted = other.map(&:relative_path).to_set
  reject { |file| unwanted.include? file.relative_path }
end

#each(&block) ⇒ Object



18
19
20
# File 'lib/astray/repository.rb', line 18

def each(&block)
  files.each(&block)
end