attic-path 0.0.2 → 0.0.3
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.
- data/README.md +34 -20
- data/lib/attic-path/attic_path_commands.rb +4 -2
- data/lib/attic-path/attic_path_input.rb +72 -53
- metadata +7 -7
data/README.md
CHANGED
@@ -19,25 +19,31 @@ Options
|
|
19
19
|
There are a number of options you can use with Attic-Path
|
20
20
|
|
21
21
|
List of options:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
----------------
|
23
|
+
|
24
|
+
- submit: If set to true the user has to type the submit_command before being able to store the string.
|
25
|
+
- submit_command: Set the name for the submit command.
|
26
|
+
- no_blank: If you don't want the user to submit a blank string, set this to true.
|
27
|
+
- no_blank_error: Set the error message for the no_blank option
|
28
|
+
- flush: Set flush to true to let Attic-Path STDOUT.flush automatically
|
29
|
+
- pathing: Set pathing to true if you want the user to be able to see in which directory he is. Pathing is also needed for the next few options.
|
30
|
+
- pathing_comment: Set a comment that will be shown above the current path.
|
31
|
+
- file_id: set this to true if you want all files / folders to have a unique id per folder. What this does is makes it easier to navigate around or select files/folder with the grab method.
|
32
|
+
- cd: Set this to true in order to let the user cd around his system while being inside the input.
|
33
|
+
- ls: Set to true if you want the user to be able to use ls command while inside the input
|
34
|
+
- lsa: Set to true in order to enable the "ls -a" command, shows all files including hidden files in a folder.
|
35
|
+
- mv: Set to true if you want the user to be able to use mv command while inside the input
|
36
|
+
- grab: Set to true if you want the user to be able to use the grab command while inside the input. The grab command lets the user 'grab' a certain file. When he does this the file will be put into an array, and you can get that array out of the output.
|
37
|
+
- grab_count: Set max allowed files that can be inserted into array, set true if unlimited
|
38
|
+
- grab_exit: Set to true if you want to exit input once the array has enough item
|
39
|
+
- grab_no_file: Set error message if no file is selected
|
40
|
+
- grab_full: Set error message for when grab is full
|
41
|
+
- grab_not_found: Set error message for when grab isn't found
|
42
|
+
- c.help: Set a help message when typing --help
|
43
|
+
- c.cd_help: Set a help message when typing cd cd --help
|
44
|
+
- c.ls_help: Set a help message when typing ls --help
|
45
|
+
- c.mv_help: Set a help message when typing mv --help
|
46
|
+
- c.grab_help: Set a help message when typing grab --help
|
41
47
|
|
42
48
|
Installing
|
43
49
|
=======
|
@@ -64,6 +70,8 @@ attic_c = AtticPathCommands.new do |c|
|
|
64
70
|
# and use any available terminal commands that are set to true
|
65
71
|
|
66
72
|
if c.pathing == true # These options are only available if pathing is enabled
|
73
|
+
c.pathing_comment = "This is your path."
|
74
|
+
|
67
75
|
c.file_id = true # Set to true to enable file id, example: instead of cd Users you can do cd -1
|
68
76
|
|
69
77
|
c.cd = true # Set to true if you want the cd command to be usable
|
@@ -79,12 +87,18 @@ attic_c = AtticPathCommands.new do |c|
|
|
79
87
|
c.grab_no_file = "You didn't select a file." # Set error message if no file is selected
|
80
88
|
c.grab_full = "Can't select more than 4 items" # Set error message for when grab is full
|
81
89
|
c.grab_not_found = "File you typed in wasn't found" # Set error message for when grab isn't found
|
90
|
+
|
91
|
+
c.help = "Help is here!" # Set help command for help
|
92
|
+
c.cd_help = "Use the cd command to browse your system." # Set help command for cd
|
93
|
+
c.ls_help = "Type the ls command to view the files and folders in the current directory.\nType ls -a to also view hidden folder and files" # Set help command for ls
|
94
|
+
c.mv_help = "Use the mv command to move files and folders" # Set help command for mv
|
95
|
+
c.grab_help = "Use the grab command to add a file or folder." # Set help command for grab
|
82
96
|
end
|
83
97
|
end
|
84
98
|
```
|
85
99
|
|
86
100
|
AtticPath Input Functions
|
87
|
-
|
101
|
+
-------------------------
|
88
102
|
|
89
103
|
# attic_path = AtticPathInput.new(attic_c)
|
90
104
|
New input, you don't HAVE to repeat this if your app is straight forward
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class AtticPathCommands
|
2
|
-
attr_accessor :submit, :submit_command, :no_blank, :no_blank_error, :flush, :pathing, :
|
3
|
-
|
2
|
+
attr_accessor :submit, :submit_command, :no_blank, :no_blank_error, :flush, :pathing, :pathing_comment,
|
3
|
+
:file_id, :cd, :ls, :mv, :lsa, :grab, :grab_count, :grab_exit, :grab_no_file, :grab_full, :grab_not_found,
|
4
|
+
:help, :cd_help, :ls_help, :mv_help, :grab_help
|
5
|
+
|
4
6
|
def initialize(&block)
|
5
7
|
instance_eval(&block) if block_given?
|
6
8
|
end
|
@@ -79,6 +79,11 @@ class AtticPathInput
|
|
79
79
|
# this function will be called.
|
80
80
|
def command
|
81
81
|
# If pathing is true, display the current_dir.
|
82
|
+
|
83
|
+
if attic_c.pathing_comment != nil
|
84
|
+
puts attic_c.pathing_comment
|
85
|
+
end
|
86
|
+
|
82
87
|
if attic_c.pathing == true
|
83
88
|
puts "\n>>#{@the_dir}"
|
84
89
|
all_files()
|
@@ -138,7 +143,7 @@ class AtticPathInput
|
|
138
143
|
def cd
|
139
144
|
if attic_c.cd == true
|
140
145
|
if @input[1] == "--help"
|
141
|
-
puts
|
146
|
+
puts attic_c.cd_help
|
142
147
|
command()
|
143
148
|
else
|
144
149
|
if @input[1] == nil || @input[1][0] == "/"
|
@@ -175,7 +180,7 @@ class AtticPathInput
|
|
175
180
|
def ls
|
176
181
|
if attic_c.ls == true
|
177
182
|
if @input[1] == "--help"
|
178
|
-
puts
|
183
|
+
puts attic_c.ls_help
|
179
184
|
command()
|
180
185
|
else
|
181
186
|
Dir.chdir(@the_dir)
|
@@ -216,19 +221,40 @@ class AtticPathInput
|
|
216
221
|
|
217
222
|
# The mv method
|
218
223
|
def mv
|
219
|
-
if
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
224
|
+
if attic_c.mv == true
|
225
|
+
if @input[1] == "--help"
|
226
|
+
puts attic_c.mv_help
|
227
|
+
command()
|
228
|
+
else
|
229
|
+
if @input[1] != nil && @input[2] != nil
|
230
|
+
file_1 = File.join(@the_dir, @input[1])
|
231
|
+
file_2 = File.join(@the_dir, @input[2])
|
232
|
+
if @input[1][0] == "#"
|
233
|
+
number1 = @input[1][1..999].to_i
|
234
|
+
number2 = @input[2][1..999].to_i
|
225
235
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
236
|
+
file_id_1 = File.join(@the_dir, @all_files[number1])
|
237
|
+
file_id_2 = File.join(@the_dir, @all_files[number2])
|
238
|
+
if @input[2][0] == "#"
|
239
|
+
if File.exists? file_id_1
|
240
|
+
if File.exists? file_id_2
|
241
|
+
FileUtils.mv(file_id_1, file_id_2)
|
242
|
+
else
|
243
|
+
puts "Incorrect paths"
|
244
|
+
command()
|
245
|
+
end
|
246
|
+
else
|
247
|
+
puts "Incorrect paths"
|
248
|
+
command()
|
249
|
+
end
|
250
|
+
else
|
251
|
+
|
252
|
+
end
|
253
|
+
end
|
254
|
+
if File.exists? file_1
|
255
|
+
if File.exists? file_2
|
256
|
+
FileUtils.mv(file_1, file_2)
|
257
|
+
command()
|
232
258
|
else
|
233
259
|
puts "Incorrect paths"
|
234
260
|
command()
|
@@ -238,24 +264,10 @@ class AtticPathInput
|
|
238
264
|
command()
|
239
265
|
end
|
240
266
|
else
|
241
|
-
|
242
|
-
end
|
243
|
-
end
|
244
|
-
if File.exists? file_1
|
245
|
-
if File.exists? file_2
|
246
|
-
FileUtils.mv(file_1, file_2)
|
247
|
-
command()
|
248
|
-
else
|
249
|
-
puts "Incorrect paths"
|
267
|
+
puts "No target selected"
|
250
268
|
command()
|
251
269
|
end
|
252
|
-
else
|
253
|
-
puts "Incorrect paths"
|
254
|
-
command()
|
255
270
|
end
|
256
|
-
else
|
257
|
-
puts "No target selected"
|
258
|
-
command()
|
259
271
|
end
|
260
272
|
end
|
261
273
|
|
@@ -364,38 +376,45 @@ class AtticPathInput
|
|
364
376
|
# The grab method, to grab select files.
|
365
377
|
# A user can select multiple files at once.
|
366
378
|
def grabfile
|
367
|
-
if attic_c.grab == true
|
368
|
-
@grab_file = File.join(@the_dir, @input[1])
|
379
|
+
if attic_c.grab == true
|
369
380
|
if @input[1] == "--help"
|
370
|
-
puts
|
381
|
+
puts attic_c.grab_help
|
382
|
+
command()
|
371
383
|
else
|
372
|
-
if attic_c.
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
grabfile_name()
|
377
|
-
elsif @grab_num != attic_c.grab_count
|
378
|
-
grabfile_name()
|
379
|
-
if @grab_num == attic_c.grab_count && attic_c.grab_exit == true
|
380
|
-
flush()
|
381
|
-
else
|
382
|
-
command()
|
383
|
-
end
|
384
|
+
if attic_c.grab == true && @input[1] != nil
|
385
|
+
@grab_file = File.join(@the_dir, @input[1])
|
386
|
+
if @input[1] == "--help"
|
387
|
+
puts "grab help"
|
384
388
|
else
|
385
|
-
if
|
386
|
-
|
389
|
+
if attic_c.file_id == true && @input[1][0] == "#"
|
390
|
+
grab_id()
|
387
391
|
else
|
388
|
-
|
389
|
-
|
392
|
+
if attic_c.grab_count == true
|
393
|
+
grabfile_name()
|
394
|
+
elsif @grab_num != attic_c.grab_count
|
395
|
+
grabfile_name()
|
396
|
+
if @grab_num == attic_c.grab_count && attic_c.grab_exit == true
|
397
|
+
flush()
|
398
|
+
else
|
399
|
+
command()
|
400
|
+
end
|
401
|
+
else
|
402
|
+
if @grab_num == attic_c.grab_count && attic_c.grab_exit == true
|
403
|
+
flush()
|
404
|
+
else
|
405
|
+
puts attic_c.grab_full
|
406
|
+
command()
|
407
|
+
end
|
408
|
+
end
|
390
409
|
end
|
391
410
|
end
|
411
|
+
elsif @input[1] == nil
|
412
|
+
puts attic_c.grab_no_file
|
413
|
+
command()
|
414
|
+
else
|
415
|
+
invalid()
|
392
416
|
end
|
393
417
|
end
|
394
|
-
elsif @input[1] == nil
|
395
|
-
puts attic_c.grab_no_file
|
396
|
-
command()
|
397
|
-
else
|
398
|
-
invalid()
|
399
418
|
end
|
400
419
|
end
|
401
420
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attic-path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fileutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &70275825234700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70275825234700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: terminal-table
|
27
|
-
requirement: &
|
27
|
+
requirement: &70275825234020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70275825234020
|
36
36
|
description:
|
37
37
|
email: attichacker@gmail.com
|
38
38
|
executables: []
|
@@ -68,5 +68,5 @@ signing_key:
|
|
68
68
|
specification_version: 3
|
69
69
|
summary: Attic Path is a gem that gives you more options for gets.chomp. With Attic
|
70
70
|
Path you can browse your system while being in the gets.chomp. The user can select
|
71
|
-
files and add them
|
71
|
+
files and add them to an array.
|
72
72
|
test_files: []
|