terminal-file-picker 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +11 -3
- data/lib/terminal-file-picker/file_browser_model.rb +2 -2
- data/lib/terminal-file-picker/file_picker.rb +0 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af483ed650624caf3dc074f752cf63a969826b3da2f86b340071adcc6bc2329b
|
4
|
+
data.tar.gz: 9e63b9d7878d86f96827b3fc4f267ba3e07fa81049c30a76d8c63b49dfad2e9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd35ad0a76eba5eb98693d7360ad2f783efb2b1306ee2509f8850b9679fc54c25b6a3462d9cf3bdc27398b2b8c1d6ce0b972cf80e11b0e69f4b4c91a1cb609b
|
7
|
+
data.tar.gz: cf4fffc39d5e39ffcb8a8b8026f3de032e5a4487776afe732b957de5207838d705323c827a86242c86d42c8b0b9a4afff922506adeea034db2d13ab373304078
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 ilkutkutlar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ The gem is useful when your program needs to accept a file path as input and you
|
|
10
10
|
|
11
11
|
The gem does not rely on the Curses library and instead uses the [TTY toolkit](https://github.com/piotrmurach/tty), which has cross platform support and support for many types of terminals/terminal emulators. Therefore this gem should also have the same level of support.
|
12
12
|
|
13
|
-
|
13
|
+
## Installation
|
14
14
|
|
15
15
|
```rb
|
16
16
|
gem install 'terminal-file-picker'
|
@@ -22,9 +22,11 @@ or add it to your project's `Gemfile`:
|
|
22
22
|
gem 'terminal-file-picker'
|
23
23
|
```
|
24
24
|
|
25
|
-
|
25
|
+
## Simple Usage
|
26
26
|
|
27
27
|
```rb
|
28
|
+
require 'terminal-file-picker'
|
29
|
+
|
28
30
|
# Only required argument is the "root path". The user will
|
29
31
|
# start navigating from the root path once file picker is invoked.
|
30
32
|
# Root path can be either absolute or relative.
|
@@ -39,7 +41,7 @@ picker = FilePicker.new('.')
|
|
39
41
|
puts(picker.pick_file)
|
40
42
|
```
|
41
43
|
|
42
|
-
|
44
|
+
## Options
|
43
45
|
|
44
46
|
There are some options to customise the look and feel of the file picker (all options do have default values, so all are optional)
|
45
47
|
|
@@ -89,3 +91,9 @@ You can change the date and time format of date modified and time modified colum
|
|
89
91
|
```rb
|
90
92
|
FilePicker.new('.', date_format: '%d-%m-%Y', time_format: '%H.%m')
|
91
93
|
```
|
94
|
+
|
95
|
+
## Development
|
96
|
+
|
97
|
+
- Officially, this gem supports Ruby versions >= 2.0.0 and such a Ruby version should be used during development as well.
|
98
|
+
- Tests are written with [Rspec](https://github.com/rspec/rspec), version ~3.9. Run the tests on terminal with `rspec` in the project directory (need to install rspec first).
|
99
|
+
- [Rubocop](https://github.com/rubocop-hq/rubocop) version ~0.8.2 is used to check for use of best practices and standard styling. Run Rubocop on the terminal with `rubocop` in the project directory (need to install Rubocop first). Currently, there are a couple of failing Rubocop checks which will be fixed soon.
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pry'
|
2
|
-
|
3
1
|
# Functions related to retrieving and formatting
|
4
2
|
# information related to directories and their contents.
|
5
3
|
class FileBrowserModel
|
@@ -35,6 +33,8 @@ class FileBrowserModel
|
|
35
33
|
# Order files such that '.' and '..' come before
|
36
34
|
# all the other files.
|
37
35
|
def order_files(files)
|
36
|
+
# Pre-sort files.
|
37
|
+
files.sort!{|a,b| a[0]<=>b[0]}
|
38
38
|
# Put "." and ".." at the start
|
39
39
|
groups = files.group_by do |f|
|
40
40
|
if f.first == './' || f.first == '../'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-file-picker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilkut Kutlar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -101,8 +101,11 @@ email:
|
|
101
101
|
- ilkutkutlar@gmail.com
|
102
102
|
executables: []
|
103
103
|
extensions: []
|
104
|
-
extra_rdoc_files:
|
104
|
+
extra_rdoc_files:
|
105
|
+
- README.md
|
106
|
+
- LICENSE
|
105
107
|
files:
|
108
|
+
- LICENSE
|
106
109
|
- README.md
|
107
110
|
- lib/terminal-file-picker.rb
|
108
111
|
- lib/terminal-file-picker/file_browser_model.rb
|
@@ -129,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
132
|
- !ruby/object:Gem::Version
|
130
133
|
version: '0'
|
131
134
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.3.5
|
133
136
|
signing_key:
|
134
137
|
specification_version: 4
|
135
138
|
summary: Interactive terminal file picker
|