Class: XMigra::GitSpecifics::AttributesFile

Inherits:
Object
  • Object
show all
Defined in:
lib/xmigra/vcs_support/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(effect_root, access = :shared) ⇒ AttributesFile

Returns a new instance of AttributesFile.



14
15
16
17
# File 'lib/xmigra/vcs_support/git.rb', line 14

def initialize(effect_root, access=:shared)
  @effect_root = Pathname(effect_root)
  @access = access
end

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



19
20
21
# File 'lib/xmigra/vcs_support/git.rb', line 19

def access
  @access
end

#effect_rootObject (readonly)

Returns the value of attribute effect_root.



19
20
21
# File 'lib/xmigra/vcs_support/git.rb', line 19

def effect_root
  @effect_root
end

Instance Method Details

#descriptionObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xmigra/vcs_support/git.rb', line 38

def description
  "".tap do |result|
    result << "#{path_from(Pathname.pwd)}"
    
    chars = []
    
    if file_path.exist?
      chars << "exists"
    end
    
    case access
    when :local
      chars << "local"
    end
    
    unless chars.empty?
      result << " (#{chars.join(', ')})"
    end
  end
end

#file_pathObject



30
31
32
# File 'lib/xmigra/vcs_support/git.rb', line 30

def file_path
  @effect_root + file_relative_path
end

#file_relative_pathObject



21
22
23
24
25
26
27
28
# File 'lib/xmigra/vcs_support/git.rb', line 21

def file_relative_path
  case @access
  when :local
    Pathname('.git/info/attributes')
  else
    Pathname('.gitattributes')
  end
end

#open(*args, &blk) ⇒ Object



59
60
61
# File 'lib/xmigra/vcs_support/git.rb', line 59

def open(*args, &blk)
  file_path.open(*args, &blk)
end

#path_from(path) ⇒ Object



34
35
36
# File 'lib/xmigra/vcs_support/git.rb', line 34

def path_from(path)
  file_path.relative_path_from(Pathname(path))
end