Class: Arcanus::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/arcanus/repo.rb

Overview

Exposes information about the current git repository.

Instance Method Summary collapse

Instance Method Details

#arcanus_dirObject


32
33
34
# File 'lib/arcanus/repo.rb', line 32

def arcanus_dir
  File.join(root, '.arcanus')
end

#chest_file_pathObject


40
41
42
# File 'lib/arcanus/repo.rb', line 40

def chest_file_path
  File.join(root, CHEST_FILE_PATH)
end

#gitignore_file_pathObject


36
37
38
# File 'lib/arcanus/repo.rb', line 36

def gitignore_file_path
  File.join(arcanus_dir, '.gitignore')
end

#has_chest_file?Boolean

Returns:

  • (Boolean)

44
45
46
# File 'lib/arcanus/repo.rb', line 44

def has_chest_file?
  File.exist?(chest_file_path)
end

#has_locked_key?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/arcanus/repo.rb', line 52

def has_locked_key?
  File.exist?(locked_key_path)
end

#has_unlocked_key?Boolean

Returns:

  • (Boolean)

60
61
62
# File 'lib/arcanus/repo.rb', line 60

def has_unlocked_key?
  File.exist?(unlocked_key_path)
end

#locked_key_pathObject


48
49
50
# File 'lib/arcanus/repo.rb', line 48

def locked_key_path
  File.join(root, LOCKED_KEY_PATH)
end

#rootString

Returns the absolute path to the root of the current repository the current working directory resides within.

Returns:

  • (String)

Raises:


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/arcanus/repo.rb', line 12

def root
  @root ||=
    begin
      arc_dir = Pathname.new(File.expand_path('.'))
                        .enum_for(:ascend)
                        .find do |path|
        # We check for .arcanus first since most repos will have that but
        # not necessarily have .git. However, when running `arcanus setup`,
        # the .arcanus directory won't exist yet, so check for .git
        (path + '.arcanus').exist? || (path + '.git').exist?
      end

      unless arc_dir
        raise Errors::InvalidArcanusRepoError, 'no .arcanus directory found'
      end

      arc_dir.to_s
    end
end

#unlocked_key_pathObject


56
57
58
# File 'lib/arcanus/repo.rb', line 56

def unlocked_key_path
  File.join(root, UNLOCKED_KEY_PATH)
end