tty-prompt-files 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8e926771cdbb07ecd05984c8398d204d36c8e2633e90af325bf4f2eb6b2263c
4
- data.tar.gz: 400036a895ee673b560673f9086a405cf2b5d10a0b83a122804d6e0b68848c3a
3
+ metadata.gz: 636af1123ad9f1e4a01854b9d5d22c228a3606b49b953c8f8b5bfd7e83bd59ac
4
+ data.tar.gz: 0fd01831f754ba9fa4627c7de07ac061705535b2bdacf41407f974d73cf0f2af
5
5
  SHA512:
6
- metadata.gz: 576330ec6293696871efb6d707329b73f1c4497f7f1dda154cdeac3e909ea9e6e4c7708c190044f5c0a8508b191a8aaada9fb09917061954ce7d30bd678a9939
7
- data.tar.gz: 3b677a25f715cf4db500bb310b070d02c68f93a7687a8a98788a016eb2c6a7e5167778c3b2fcb933f48bbc888a57f07d7723964f02a8e2de765bc778a2a28f36
6
+ metadata.gz: 34d8e7b77e6678167986cf196354b3fae725968ce232d2952ddc1faaf65b4de992f4d44a623dcdcd12e9ce24175c9e212178c04bbe0bde246df20a2778c3ef10
7
+ data.tar.gz: c2a8e4d2d6827238223281bcd5cd90a352155e4e3f109a05e345ba2db7c63412bfd55e75d026288b4d0abe7d1799e205ca447e76b41066c6c9b2778459443bec
data/CHANGELOG.md CHANGED
@@ -3,3 +3,7 @@
3
3
  ## [0.1.0] - 2024-07-28
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.1.1] - 2024-08-11
8
+
9
+ - Fix `select_element_from_file_system` for non default location
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Files
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
data/lib/tty/files.rb CHANGED
@@ -1,21 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "files/version"
4
+ require "pry"
4
5
 
5
6
  module TTY
6
7
  class Prompt
7
8
  def select_element_from_file_system(pattern: "*", path: ".", text: "", options: {})
8
- elements = get_all_elements_from_path(pattern, path)
9
+ pathnames = get_pathnames_from_path(pattern, path)
9
10
 
10
- selected_element = self.select(text, elements)
11
+ file_names = pathnames.map do |pathname|
12
+ pathname.basename.to_s
13
+ end
11
14
 
12
- selected_element.realpath.to_path
15
+ selected_element = self.select(text, file_names)
16
+
17
+ get_selected_element_full_path(pathnames, selected_element)
13
18
  end
14
19
 
15
20
  private
16
21
 
17
- def get_all_elements_from_path(pattern, path)
18
- Pathname.glob(pattern, base: path)
22
+ def get_pathnames_from_path(pattern, path)
23
+ pathnames = Pathname.glob(path + "/" + pattern)
24
+
25
+ pathnames.map(&:realpath)
26
+ end
27
+
28
+ def get_selected_element_full_path(pathnames, selected_element)
29
+ selected_element_pathname = pathnames.find { |pathname| pathname.basename.to_s == selected_element }
30
+
31
+ selected_element_pathname.realpath.to_s
19
32
  end
20
33
  end
21
34
  end
@@ -29,10 +29,4 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_dependency "tty-prompt", "~> 0.23.1"
32
-
33
- # Uncomment to register a new dependency of your gem
34
- # spec.add_dependency "example-gem", "~> 1.0"
35
-
36
- # For more information and examples about making a new gem, check out our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-prompt-files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Set27
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-08 00:00:00.000000000 Z
11
+ date: 2024-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt