git-root 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 894f2a98f7b7ef9977caa1aa493849ca50fb4d0e5730131d7e1b7f7c7c9d7d7f
4
+ data.tar.gz: 17aaf75e9017073549b60cd44040ef4047c6bb6b15c6f8f9ffb4621e2021097a
5
+ SHA512:
6
+ metadata.gz: 76dc8f6a56e726dd147dfef2785db2e6a331cbc27a87ff2b44741f608fe3b105f42d4e915ffd6bf64aa0c0bc1c6de6e298fae83540a143fefd0b14249c316ffe
7
+ data.tar.gz: e46f9657a65acb1871e0a26c5e42f3b2034363dc673c954bd5b7ba5e64b5b6ed3993660c4df24b3f3fc557552470027989c3c89d6e08d62893c01dcd6a15f7f0
data/LICENSE.md ADDED
@@ -0,0 +1,25 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright © `2009-2022` `Wolf Software`
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the “Software”), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ <p align="center">
2
+ <a href="https://github.com/DevelopersToolbox/">
3
+ <img src="https://cdn.wolfsoftware.com/assets/images/github/organisations/developerstoolbox/black-and-white-circle-256.png" alt="DevelopersToolbox logo" />
4
+ </a>
5
+ <br />
6
+ <a href="https://github.com/DevelopersToolbox/gitroot/actions/workflows/cicd-pipeline.yml">
7
+ <img src="https://img.shields.io/github/workflow/status/DevelopersToolbox/gitroot/CICD%20Pipeline/master?style=for-the-badge" alt="Github Build Status">
8
+ </a>
9
+ <a href="https://github.com/DevelopersToolbox/gitroot/releases/latest">
10
+ <img src="https://img.shields.io/github/v/release/DevelopersToolbox/gitroot?color=blue&label=Latest%20Release&style=for-the-badge" alt="Release">
11
+ </a>
12
+ <a href="https://github.com/DevelopersToolbox/gitroot/releases/latest">
13
+ <img src="https://img.shields.io/github/commits-since/DevelopersToolbox/gitroot/latest.svg?color=blue&style=for-the-badge" alt="Commits since release">
14
+ </a>
15
+ <br />
16
+ <a href=".github/CODE_OF_CONDUCT.md">
17
+ <img src="https://img.shields.io/badge/Code%20of%20Conduct-blue?style=for-the-badge" />
18
+ </a>
19
+ <a href=".github/CONTRIBUTING.md">
20
+ <img src="https://img.shields.io/badge/Contributing-blue?style=for-the-badge" />
21
+ </a>
22
+ <a href=".github/SECURITY.md">
23
+ <img src="https://img.shields.io/badge/Report%20Security%20Concern-blue?style=for-the-badge" />
24
+ </a>
25
+ <a href="https://github.com/DevelopersToolbox/gitroot/issues">
26
+ <img src="https://img.shields.io/badge/Get%20Support-blue?style=for-the-badge" />
27
+ </a>
28
+ <br />
29
+ <a href="https://wolfsoftware.com/">
30
+ <img src="https://img.shields.io/badge/Created%20by%20Wolf%20Software-blue?style=for-the-badge" />
31
+ </a>
32
+ </p>
33
+
34
+ ## Overview
35
+
@@ -0,0 +1,19 @@
1
+ class GitRoot
2
+ #
3
+ # Catch all - something bad happened but we don't know what
4
+ #
5
+ class UnknownError < StandardError
6
+ def initialize(msg = 'Something bad happen!')
7
+ super
8
+ end
9
+ end
10
+
11
+ #
12
+ # User supplied an invalid token (instead of a missing token)
13
+ #
14
+ class InvalidRepoError < StandardError
15
+ def initialize(msg = 'Invalid git repository')
16
+ super
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ class GitRoot
2
+ # Current major release.
3
+ MAJOR = 0
4
+
5
+ # Current minor release.
6
+ MINOR = 1
7
+
8
+ # Current patch level.
9
+ PATCH = 0
10
+
11
+ # Full release version.
12
+ VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
13
+ end
data/lib/git-root.rb ADDED
@@ -0,0 +1,33 @@
1
+ #
2
+ # stuff to go here
3
+ #
4
+
5
+ require 'pathname'
6
+
7
+ require_relative 'git-root/errors'
8
+ require_relative 'git-root/version'
9
+
10
+ #
11
+ # and here
12
+ #
13
+ class GitRoot
14
+ #
15
+ # Stuff
16
+ #
17
+
18
+ class << self
19
+ def path(base_path = Dir.getwd)
20
+ git_path_parts = Pathname(base_path).each_filename.to_a
21
+
22
+ while git_path_parts.count.positive?
23
+ git_root = "/#{git_path_parts.join('/')}"
24
+ git_path = "#{git_root}/.git"
25
+
26
+ return git_root if File.directory?(git_path)
27
+
28
+ git_path_parts.pop
29
+ end
30
+ raise InvalidRepoError.new
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-root
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tim Gurney aka Wolf
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rbs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.6.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.6.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: reek
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.36.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.36.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-packaging
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.2
97
+ description:
98
+ email:
99
+ - wolf@tgwolf.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - LICENSE.md
105
+ - README.md
106
+ - lib/git-root.rb
107
+ - lib/git-root/errors.rb
108
+ - lib/git-root/version.rb
109
+ homepage: https://github.com/DevelopersToolbox/git-root
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ rubygems_mfa_required: 'true'
114
+ homepage_uri: https://github.com/DevelopersToolbox/git-root
115
+ source_code_uri: https://github.com/DevelopersToolbox/git-root
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.6.0
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.3.7
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: A super simple gem to get the root directory for any given git repository
135
+ test_files: []