walk_up 0.0.8 → 1.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/walk_up.rb +23 -0
  3. metadata +3 -3
  4. data/main/main.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3030968711207d64b5fdf48b10902b6716899841fe70c16218143d6d103fde58
4
- data.tar.gz: 8ebb3853f559f7a144dc40fe97a34ba64bea4805d2354af7f85b49d0bcaef3e5
3
+ metadata.gz: b7b8adaff0ebe4f2e7082e7d5ed6df7178c7a28868a729cf925b0fd148d25b72
4
+ data.tar.gz: 6759b28f721367610eb6b811ef81f0b0495543cd01c6ecbd5cf364d93f026179
5
5
  SHA512:
6
- metadata.gz: 16b7534a9a53a2ab2162bca9413840d3656397f1927a7c90e8e2b1f117d6554c3106b6c4ed7cc867d6ea4da8548b6567e2112dae792a1e03bec79fc47a809787
7
- data.tar.gz: 0b59bab6e4af53a6b7f38b869c0483c550b2f5bd5af1365f79664094bbec5b5390bfe402f695053e55adaa022b6c3f7153af7e2089c7b1b8c3abab9b09a54114
6
+ metadata.gz: 9ceb117b845c01730d5cc125d17a168f471e46058ee8c944de541349a3fad49b0ed7787e5ea611b70c53941502a61e14962853c0452d8cc07ca0995fcfd6dea2
7
+ data.tar.gz: 525887940580607a18e60d033915ca478295762ac595a135d8cb7c8bd15ab91c3fbd2f179c556cb24db521b787a411421aa4c1eb000b9d048795131f5fd6e802
data/lib/walk_up.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require "pathname"
3
+
4
+ def walk_up_until(file_to_find, start_path=nil)
5
+ here = start_path || Dir.pwd
6
+ # if absolute
7
+ if not Pathname.new(here).absolute?
8
+ here = File.join(Dir.pwd, here)
9
+ end
10
+ loop do
11
+ check_path = File.join(here, file_to_find)
12
+ if File.exist?(check_path)
13
+ return check_path
14
+ end
15
+ # reached the top
16
+ if here == File.dirname(here)
17
+ return nil
18
+ # else go up one and try again
19
+ else
20
+ here = File.dirname(here)
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: walk_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Hykin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email:
@@ -18,7 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - LICENSE.md
20
20
  - README.md
21
- - main/main.rb
21
+ - lib/walk_up.rb
22
22
  homepage: https://github.com/jeff-hykin/walk_up.git
23
23
  licenses:
24
24
  - MIT
data/main/main.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- puts "You found main!"