nrser 0.2.0.pre.1 → 0.2.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nrser/functions/git.rb +19 -5
- data/lib/nrser/functions/path.rb +23 -0
- data/lib/nrser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4df742a4e266803053eb20282142c87567501744
|
4
|
+
data.tar.gz: 83bfefce4bd634feb3c2b9d7bc5e862361333235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cbb89bf23f4c6c1a2f1ef0cfe0c252a2434422b181ae6d693929626b7ca6410c31b593904f424253bb81f23437facbfda4b272ff04af91d4f15350d09287735
|
7
|
+
data.tar.gz: c043719cf3ccda997839c3e97a5cf0813c5ac032ecdf251bbb657471f7a3d1854da0a3a8c61599e3ba73edbb9184735c6fc98980aa7b698d5820de7e5d90e4cc
|
data/lib/nrser/functions/git.rb
CHANGED
@@ -13,13 +13,26 @@ require 'open3'
|
|
13
13
|
# =======================================================================
|
14
14
|
|
15
15
|
module NRSER
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# Get the absolute path to the root directory of the Git repo that
|
17
|
+
# `path` is in.
|
18
|
+
#
|
19
|
+
# @note
|
20
|
+
# In submodules, this will return the root of the submodule, **NOT**
|
21
|
+
# of the top-level repo.
|
22
|
+
#
|
23
|
+
# @param [String | Pathname] path
|
24
|
+
# Path in Git repo that you want to find the root of.
|
25
|
+
#
|
26
|
+
# Accepts relative and user (`~/...`) paths.
|
27
|
+
#
|
28
|
+
# @return [Pathname]
|
29
|
+
#
|
30
|
+
def self.git_root path = Pathname.getwd
|
31
|
+
dir = dir_from path
|
19
32
|
|
20
33
|
out, err, status = Open3.capture3 \
|
21
34
|
'git rev-parse --show-toplevel',
|
22
|
-
chdir:
|
35
|
+
chdir: dir.to_s
|
23
36
|
|
24
37
|
if status != 0
|
25
38
|
message = \
|
@@ -29,6 +42,7 @@ module NRSER
|
|
29
42
|
raise SystemCallError.new message, status.exitstatus
|
30
43
|
end
|
31
44
|
|
32
|
-
out.chomp
|
45
|
+
Pathname.new out.chomp
|
33
46
|
end
|
47
|
+
|
34
48
|
end
|
data/lib/nrser/functions/path.rb
CHANGED
@@ -12,6 +12,29 @@ module NRSER
|
|
12
12
|
end
|
13
13
|
|
14
14
|
|
15
|
+
# Get the directory for a path - if the path is a directory, it's returned
|
16
|
+
# (converted to a {Pathname}). It's not a directory, it's {Pathname#dirname}
|
17
|
+
# will be returned.
|
18
|
+
#
|
19
|
+
# Expands the path (so that `~` paths work).
|
20
|
+
#
|
21
|
+
# @param [String | Pathname] path
|
22
|
+
# File or directory path.
|
23
|
+
#
|
24
|
+
# @return [Pathname]
|
25
|
+
# Absolute directory path.
|
26
|
+
#
|
27
|
+
def self.dir_from path
|
28
|
+
pn = pn_from( path ).expand_path
|
29
|
+
|
30
|
+
if pn.directory?
|
31
|
+
pn
|
32
|
+
else
|
33
|
+
pn.dirname
|
34
|
+
end
|
35
|
+
end # .dir_from
|
36
|
+
|
37
|
+
|
15
38
|
# @todo Document glob? method.
|
16
39
|
#
|
17
40
|
# @param [type] arg_name
|
data/lib/nrser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nrser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.pre.
|
4
|
+
version: 0.2.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hamster
|