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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 942988b83ec5c05fed5f15e87869dd0f20044db8
4
- data.tar.gz: 57bc680b81ffe4f7650b1200d0aa21a8579be60a
3
+ metadata.gz: 4df742a4e266803053eb20282142c87567501744
4
+ data.tar.gz: 83bfefce4bd634feb3c2b9d7bc5e862361333235
5
5
  SHA512:
6
- metadata.gz: eec00863e1a07aa333d71a66139773d7f198efcfa137e6aa57607d619431854a2850e54e7ae59c8e1dbbc28f9bd887969f36aef584d703bb0830a345e1540bb9
7
- data.tar.gz: 3129461e852e4a830e7dcf0dd097c32e017fa4e99541ed76f1bb9670025575a6ec9f3570ad9390a397f6ca733a051b5349d0865a5103656a0bf22be5948e4f7c
6
+ metadata.gz: 5cbb89bf23f4c6c1a2f1ef0cfe0c252a2434422b181ae6d693929626b7ca6410c31b593904f424253bb81f23437facbfda4b272ff04af91d4f15350d09287735
7
+ data.tar.gz: c043719cf3ccda997839c3e97a5cf0813c5ac032ecdf251bbb657471f7a3d1854da0a3a8c61599e3ba73edbb9184735c6fc98980aa7b698d5820de7e5d90e4cc
@@ -13,13 +13,26 @@ require 'open3'
13
13
  # =======================================================================
14
14
 
15
15
  module NRSER
16
- def self.git_root from
17
- path = Pathname.new( from ).expand_path
18
- path = path.dirname unless path.directory?
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: path.to_s
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
@@ -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
@@ -18,7 +18,7 @@ module NRSER
18
18
  #
19
19
  # @return [String]
20
20
  #
21
- VERSION = "0.2.0.pre.1"
21
+ VERSION = "0.2.0.pre.2"
22
22
 
23
23
 
24
24
  module Version
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hamster