fled 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +5 -0
- data/bin/fled +9 -8
- data/bin/irtoy +38 -0
- data/lib/dtc/utils/text/ansi.rb +63 -0
- data/lib/dtc/utils/visitor/folder.rb +24 -4
- data/lib/fled.rb +1 -1
- data/tests/readme.rb +4 -0
- metadata +14 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2465c8ae77d6b83eddf259b123cb2c764537b37e
|
4
|
+
data.tar.gz: 44e5f6a8fc628a05b91aa7f8606a7645cda98093
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b156984f98bb7b2f050fca85e9f7a2c83d95aaafb50dd95b016bb8f2e4c5e542d2236ba51635a905e853249e11bb7f1c9932a064d7bfd722c7695a090f3e15b
|
7
|
+
data.tar.gz: 5f8a46312ce259f6106b63af33f5310c231f341d42ec9ea0cb51b96338f7dc7beab5b667c197959ba5423afca11d0e68266856562f2f176b3696e6e2ba7ece02
|
data/README.md
CHANGED
@@ -591,6 +591,11 @@ sub_sub_folder/ :2
|
|
591
591
|
|
592
592
|
## Changelog
|
593
593
|
|
594
|
+
*Version v0.0.4*
|
595
|
+
|
596
|
+
- New: Sort file listing (if gem naturalsort is installed, it is used too)
|
597
|
+
- Fix: Non interactive run mode had a bug
|
598
|
+
|
594
599
|
*Version v0.0.3*
|
595
600
|
|
596
601
|
- New: Interactive mode with `-u`
|
data/bin/fled
CHANGED
@@ -79,12 +79,13 @@ class App
|
|
79
79
|
exit 0
|
80
80
|
end
|
81
81
|
output_version if @options[:verbose]
|
82
|
+
is_interactive = @options[:interactive]
|
82
83
|
update_listing!
|
83
|
-
edit_listing!
|
84
|
-
if
|
84
|
+
edit_listing! is_interactive
|
85
|
+
if is_interactive
|
85
86
|
interactive_main_menu
|
86
87
|
else
|
87
|
-
die! :nothing_edited if operations.empty?
|
88
|
+
return die! :nothing_edited if @operations.empty?
|
88
89
|
print_script
|
89
90
|
end
|
90
91
|
else
|
@@ -108,11 +109,11 @@ class App
|
|
108
109
|
@operations = ops_for_edited_listing(@listing, @listing_text, edited_listing)
|
109
110
|
end
|
110
111
|
|
111
|
-
def edit_listing!
|
112
|
+
def edit_listing! is_interactive
|
112
113
|
edited_listing = DTC::Utils::InteractiveEditor::edit(@edited_listing || @listing_text, ".yaml", @options[:editor])
|
113
114
|
@edited_listing = edited_listing unless edited_listing.to_s.strip == ""
|
114
115
|
update_operations! edited_listing
|
115
|
-
interactive_print_status
|
116
|
+
interactive_print_status if is_interactive
|
116
117
|
end
|
117
118
|
|
118
119
|
def print_script operations = @operations, preview = false
|
@@ -182,13 +183,13 @@ class App
|
|
182
183
|
end
|
183
184
|
|
184
185
|
def interactive_edit_listing # => "(E)dit listing"
|
185
|
-
edit_listing!
|
186
|
+
edit_listing! true
|
186
187
|
end
|
187
188
|
|
188
189
|
def interactive_revert_listing # => "(R)evert listing"
|
189
190
|
@edited_listing = nil
|
190
191
|
@operations = []
|
191
|
-
edit_listing!
|
192
|
+
edit_listing! true
|
192
193
|
end
|
193
194
|
|
194
195
|
def interactive_reconfigure
|
@@ -205,7 +206,7 @@ class App
|
|
205
206
|
@options = @options.merge(new_options)
|
206
207
|
status "Config updated"
|
207
208
|
update_listing!
|
208
|
-
edit_listing!
|
209
|
+
edit_listing! true
|
209
210
|
else
|
210
211
|
@options = @options.merge(new_options)
|
211
212
|
update_operations!
|
data/bin/irtoy
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'yaml'
|
3
|
+
require 'optparse'
|
4
|
+
require 'shellwords'
|
5
|
+
begin
|
6
|
+
require 'dtc/utils'
|
7
|
+
rescue LoadError => e
|
8
|
+
$:.unshift File.join(File.dirname(__FILE__),'../lib')
|
9
|
+
require 'dtc/utils'
|
10
|
+
end
|
11
|
+
fd = IO.sysopen(Dir['/dev/cu.usbmodem*'].first, "w+b")
|
12
|
+
a = IO.new(fd,"w+b")
|
13
|
+
|
14
|
+
vol_up = [
|
15
|
+
"y\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x01\xF8\x00\x01\xF8\x00\x01\xF8\x03\xE0\x0F\xC0\x1F\x00~\x00\x00~\x00\xFC\x00\x00\xFC\x00\x00\xFC\x00\x00\xFC\x00\x00|\x01\xF8\x03\xE0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\a\xE0\x00\a\xE0\x0F\x80",
|
16
|
+
"?\x00|\x01\xF8\x00\x00\x00\x00\x00",
|
17
|
+
"\x7F\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x01\xF8\x00\x01\xF8\x00\x01\xF8\x03\xE0\x0F\xC0\x1F\x00~\x00\x00~\x00\xFC\x00\x00\xFC\x00\x00\xFC\x00\x00\xFC\x00\x00|\x01\xF8\x03\xE0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\a\xE0\x00\a\xE0\x0F\x80",
|
18
|
+
"?\x00|\x01\xF8\x00\x00\x00\x00\x00",
|
19
|
+
"\x7F\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x01\xF0\x00\x01\xF0\x00\x01\xF0\x03\xE0\x0F\x80\x1F\x00|\x00\x00|\x00\xF8\x00\x00\xF8\x00\x00\xF8\x00\x00|\x00\x00|\x01\xF0\x03\xE0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\a\xE0\x00\a\xF0\x0F\x80",
|
20
|
+
"?\x00|\x01\xF8\x00\x00\x00\x00\x00",
|
21
|
+
"\x7F\xFF\xFF\xFF\xFF\x80\x00\x00\x00\x01\xF0\x00\x01\xF8\x00\x01\xF8\x03\xE0\x0F\xC0\x1F\x00~\x00\x00~\x00\xFC\x00\x00\xF8\x00\x00\xFC\x00\x00|\x00\x00|\x01\xF8\x03\xE0\x00\x03\xF0\x00\x03\xF0\x00\x03\xF0\x00\x01\xF0\a\xE0\x00\a\xE0\x0F\x80",
|
22
|
+
"?\x00|\x01\xF8\x00\x00\x00\x00\x00",
|
23
|
+
|
24
|
+
|
25
|
+
]
|
26
|
+
|
27
|
+
DTC::Utils::MiniSelect.run do |sel|
|
28
|
+
sel.add_read(a) do |sel, ev, fd, data|
|
29
|
+
p data
|
30
|
+
end
|
31
|
+
while true
|
32
|
+
vol_up.each do |v|
|
33
|
+
a.write(v)
|
34
|
+
end
|
35
|
+
sleep 3
|
36
|
+
puts "written"
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
module DTC
|
3
|
+
module Utils
|
4
|
+
module Text
|
5
|
+
module ANSI
|
6
|
+
DISPLAY_ATTRIBUTES = ({
|
7
|
+
:reset => 0,
|
8
|
+
:bold => 1,
|
9
|
+
:underline => 4,
|
10
|
+
:reverse => 7,
|
11
|
+
:black => 30,
|
12
|
+
:red => 31,
|
13
|
+
:green => 32,
|
14
|
+
:yellow => 33,
|
15
|
+
:blue => 34,
|
16
|
+
:magenta => 35,
|
17
|
+
:cyan => 36,
|
18
|
+
:white => 37,
|
19
|
+
:bg_black => 40,
|
20
|
+
:bg_red => 41,
|
21
|
+
:bg_green => 42,
|
22
|
+
:bg_yellow => 43,
|
23
|
+
:bg_blue => 44,
|
24
|
+
:bg_magenta => 45,
|
25
|
+
:bg_cyan => 46,
|
26
|
+
:bg_white => 47,
|
27
|
+
})
|
28
|
+
def self.escape_for_display_attributes *attrs
|
29
|
+
"\033[#{attrs.map { |e| DISPLAY_ATTRIBUTES[e] || e}.join(";")}m"
|
30
|
+
end
|
31
|
+
def self.coloured_string *att_text
|
32
|
+
if att_text.last.is_a?(FalseClass)
|
33
|
+
att_text.pop
|
34
|
+
else
|
35
|
+
unless (att_text.select { |e| e.is_a?(Symbol) }.last == :reset)
|
36
|
+
att_text.push :reset
|
37
|
+
end
|
38
|
+
end
|
39
|
+
att_text.map { |t|
|
40
|
+
t.is_a?(String) ? t : escape_for_display_attributes(*Array(t))
|
41
|
+
}.join("")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
mods = [ :reset, :bold, :underline, :reverse ]
|
49
|
+
fgs = [ :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white ]
|
50
|
+
bgs = DTC::Utils::Text::ANSI::DISPLAY_ATTRIBUTES.keys - fgs - mods
|
51
|
+
bg_width = bgs.map { |e| e.to_s.length }.max + 1
|
52
|
+
fgs_width = fgs.map { |e| e.to_s.length }.max + 1
|
53
|
+
mods.each do |mod|
|
54
|
+
puts "\nMode: #{mod.inspect}"
|
55
|
+
fgs.each do |fg|
|
56
|
+
print DTC::Utils::Text::ANSI::coloured_string(mod, fg, fg.to_s.rjust(fgs_width), :reset, " ")
|
57
|
+
bgs.each do |bg|
|
58
|
+
print DTC::Utils::Text::ANSI::coloured_string(mod, fg, bg, bg.to_s.rjust(bg_width), :reset, " ")
|
59
|
+
end
|
60
|
+
puts ""
|
61
|
+
end
|
62
|
+
end
|
63
|
+
# puts DTC::Utils::Text::ANSI::coloured_string("hello", :red, " there !", :reset)
|
@@ -59,12 +59,32 @@ module DTC
|
|
59
59
|
max_depth = options.delete(:max_depth) { -1 }
|
60
60
|
filter = options.empty? ? visitor :
|
61
61
|
FilenameFilteringVisitor.new(visitor, options)
|
62
|
-
accept_path filter, File.expand_path(path), max_depth
|
62
|
+
accept_path filter, File.expand_path(path), max_depth, (options[:sorted].nil? ? true : options[:sorted])
|
63
63
|
visitor
|
64
64
|
end
|
65
|
-
|
66
|
-
|
65
|
+
|
66
|
+
begin
|
67
|
+
require 'forwardable'
|
68
|
+
require 'natural_sort'
|
69
|
+
def self.string_compare a, b
|
70
|
+
NaturalSort.comparator(a, b)
|
71
|
+
end
|
72
|
+
rescue LoadError
|
73
|
+
def self.string_compare a, b
|
74
|
+
a.casecmp(b)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.accept_path visitor, path, max_depth = -1, sorted
|
67
79
|
return unless visitor.enter path
|
80
|
+
dir = Dir.new(path)
|
81
|
+
if sorted
|
82
|
+
dir = dir.each.to_a.sort do |a, b|
|
83
|
+
a_is_dir = File.directory?(File.join(path, a))
|
84
|
+
b_is_dir = File.directory?(File.join(path, b))
|
85
|
+
a_is_dir != b_is_dir ? (a_is_dir ? -1 : 1) : self.string_compare(a, b)
|
86
|
+
end
|
87
|
+
end
|
68
88
|
dir.each do |f|
|
69
89
|
full_path = File.join(path, f)
|
70
90
|
next if f == "." || f == ".."
|
@@ -73,7 +93,7 @@ module DTC
|
|
73
93
|
if max_depth == 0
|
74
94
|
visitor.leave if visitor.enter(full_path)
|
75
95
|
else
|
76
|
-
self.accept_path(visitor, full_path, max_depth - 1)
|
96
|
+
self.accept_path(visitor, full_path, max_depth - 1, sorted)
|
77
97
|
end
|
78
98
|
else
|
79
99
|
visitor.add f, full_path
|
data/lib/fled.rb
CHANGED
data/tests/readme.rb
CHANGED
@@ -315,6 +315,10 @@ readme do
|
|
315
315
|
'New: Editor and diff tool are configurable from configuration files',
|
316
316
|
'Meta: Refactoring of code',
|
317
317
|
],
|
318
|
+
'v0.0.4' => [
|
319
|
+
'New: Sort file listing (if gem naturalsort is installed, it is used too)',
|
320
|
+
'Fix: Non interactive run mode had a bug',
|
321
|
+
],
|
318
322
|
}).sort { |a, b| b[0] <=> a[0] }.each do |version, changes|
|
319
323
|
em "Version #{version}"
|
320
324
|
li *changes
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Eric Doughty-Papassideris
|
@@ -19,47 +18,48 @@ executables:
|
|
19
18
|
extensions: []
|
20
19
|
extra_rdoc_files: []
|
21
20
|
files:
|
21
|
+
- README.md
|
22
|
+
- bin/fled
|
23
|
+
- bin/irtoy
|
24
|
+
- lib/dtc/utils.rb
|
22
25
|
- lib/dtc/utils/exec.rb
|
23
26
|
- lib/dtc/utils/interactive_edit.rb
|
24
27
|
- lib/dtc/utils/meta.rb
|
25
28
|
- lib/dtc/utils/mini_select.rb
|
29
|
+
- lib/dtc/utils/text.rb
|
30
|
+
- lib/dtc/utils/text/ansi.rb
|
26
31
|
- lib/dtc/utils/text/html.rb
|
27
32
|
- lib/dtc/utils/text/line_writer.rb
|
28
|
-
- lib/dtc/utils/
|
33
|
+
- lib/dtc/utils/visitor.rb
|
29
34
|
- lib/dtc/utils/visitor/dsl.rb
|
30
35
|
- lib/dtc/utils/visitor/folder.rb
|
31
|
-
- lib/
|
32
|
-
- lib/dtc/utils.rb
|
36
|
+
- lib/fled.rb
|
33
37
|
- lib/fled/file_listing.rb
|
34
38
|
- lib/fled/file_listing_builder.rb
|
35
|
-
- lib/fled.rb
|
36
|
-
- bin/fled
|
37
39
|
- tests/helper.rb
|
38
40
|
- tests/readme.rb
|
39
41
|
- tests/test_operations.rb
|
40
|
-
- README.md
|
41
42
|
homepage: http://github.com/ddlsmurf/fled
|
42
43
|
licenses: []
|
44
|
+
metadata: {}
|
43
45
|
post_install_message:
|
44
46
|
rdoc_options: []
|
45
47
|
require_paths:
|
46
48
|
- lib
|
47
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
50
|
requirements:
|
50
|
-
- -
|
51
|
+
- - ">="
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: '0'
|
53
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version:
|
61
|
+
rubygems_version: 2.2.2
|
62
62
|
signing_key:
|
63
|
-
specification_version:
|
63
|
+
specification_version: 4
|
64
64
|
summary: FlEd lets you edit file names and paths in your favourite editor
|
65
65
|
test_files: []
|