arcanus 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arcanus/errors.rb +3 -2
- data/lib/arcanus/repo.rb +6 -28
- data/lib/arcanus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 888bf2081e42c456d9276d560543cce366fff384
|
4
|
+
data.tar.gz: e2ec43b0bf7fde05b039026e6c38122608a625ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f87f25ab4192c8223b65655e2daaa922ab7292c86690b948c08686bffc7c86cd52503762ef7af48264d3f15b621a3afc62776809c16d4fdbfd2b2a1bdf57a82
|
7
|
+
data.tar.gz: 74140896c221a1049e7ecd5437ec5b114100971cb26bf3a42f0ad742b368c7e03088a57f3f129b5fa3fb308207948382a7c6e0db65110dd4a1f553d078478322
|
data/lib/arcanus/errors.rb
CHANGED
@@ -27,8 +27,9 @@ module Arcanus::Errors
|
|
27
27
|
# Raised when invalid/non-existent command was used.
|
28
28
|
class CommandInvalidError < UsageError; end
|
29
29
|
|
30
|
-
# Raised when run in a directory not part of a
|
31
|
-
|
30
|
+
# Raised when run in a directory not part of a repository with Arcanus
|
31
|
+
# installed.
|
32
|
+
class InvalidArcanusRepoError < UsageError; end
|
32
33
|
|
33
34
|
# Raised when a key path corresponding to a non-existent key is specified.
|
34
35
|
class InvalidKeyPathError < UsageError; end
|
data/lib/arcanus/repo.rb
CHANGED
@@ -12,44 +12,22 @@ module Arcanus
|
|
12
12
|
# current working directory resides within.
|
13
13
|
#
|
14
14
|
# @return [String]
|
15
|
-
# @raise [Arcanus::Errors::
|
15
|
+
# @raise [Arcanus::Errors::InvalidArcanusRepoError] if the current directory
|
16
16
|
# doesn't reside within a git repository
|
17
17
|
def root
|
18
18
|
@root ||=
|
19
19
|
begin
|
20
|
-
|
20
|
+
arc_dir = Pathname.new(File.expand_path('.'))
|
21
21
|
.enum_for(:ascend)
|
22
22
|
.find do |path|
|
23
|
-
(path + '.
|
23
|
+
(path + '.arcanus').exist?
|
24
24
|
end
|
25
25
|
|
26
|
-
unless
|
27
|
-
raise Errors::
|
26
|
+
unless arc_dir
|
27
|
+
raise Errors::InvalidArcanusRepoError, 'no .arcanus directory found'
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns an absolute path to the .git directory for a repo.
|
35
|
-
#
|
36
|
-
# @return [String]
|
37
|
-
def git_dir
|
38
|
-
@git_dir ||=
|
39
|
-
begin
|
40
|
-
git_dir = File.expand_path('.git', root)
|
41
|
-
|
42
|
-
# .git could also be a file that contains the location of the git directory
|
43
|
-
unless File.directory?(git_dir)
|
44
|
-
git_dir = File.read(git_dir)[/^gitdir: (.*)$/, 1]
|
45
|
-
|
46
|
-
# Resolve relative paths
|
47
|
-
unless git_dir.start_with?('/')
|
48
|
-
git_dir = File.expand_path(git_dir, repo_dir)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
git_dir
|
30
|
+
arc_dir.to_s
|
53
31
|
end
|
54
32
|
end
|
55
33
|
|
data/lib/arcanus/version.rb
CHANGED