rfd 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/bin/rfd +1 -0
- data/lib/rfd.rb +18 -9
- data/lib/rfd/commands.rb +3 -1
- data/lib/rfd/item.rb +4 -3
- data/lib/rfd/windows.rb +20 -4
- data/rfd.gemspec +4 -3
- data/spec/controller_spec.rb +13 -10
- data/spec/spec_helper.rb +1 -0
- data/spec/support/capture_helper.rb +1 -0
- data/spec/testdir/.link1 +1 -0
- data/spec/testdir/dirlink1 +1 -0
- data/spec/testdir/link1 +1 -0
- data/spec/testdir/link2 +1 -0
- metadata +13 -11
- data/spec/testdir/.link1 +0 -0
- data/spec/testdir/link1 +0 -1
- data/spec/testdir/link2 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73cf32d334a52233e41042d8dad8b7bc1a00d6c0
|
4
|
+
data.tar.gz: 7d6eb47271a96ab17bacccfdbe34ffdd81d8f31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3fe7fbaad753cbb3b466c8736d5a07f23cdedde45251198526883427c3bef2390774cd834009f4a56e9af879ac2bbcdc1fa2ce038b4a4cb645dbdf887344d35
|
7
|
+
data.tar.gz: 5a948b9f5d22eaf9e1c75b3d9986ced53237b8f249f837d6c68db4f8ce89c5bcbe18a5598ea60da19cfeaa8bedf6f79b59004e5367b7a53c8a7c1495d2a4f4f5
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/rfd
CHANGED
data/lib/rfd.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'curses'
|
2
3
|
require 'fileutils'
|
3
4
|
require 'tmpdir'
|
@@ -382,10 +383,14 @@ module Rfd
|
|
382
383
|
# Rename selected files and directories.
|
383
384
|
#
|
384
385
|
# ==== Parameters
|
385
|
-
# * +pattern+ -
|
386
|
+
# * +pattern+ - new filename, or a shash separated Regexp like string
|
386
387
|
def rename(pattern)
|
387
|
-
from, to = pattern.split '/'
|
388
|
-
|
388
|
+
from, to = pattern.sub(/^\//, '').sub(/\/$/, '').split '/'
|
389
|
+
if to.nil?
|
390
|
+
from, to = current_item.name, from
|
391
|
+
else
|
392
|
+
from = Regexp.new from
|
393
|
+
end
|
389
394
|
unless in_zip?
|
390
395
|
selected_items.each do |item|
|
391
396
|
name = item.name.gsub from, to
|
@@ -507,7 +512,7 @@ module Rfd
|
|
507
512
|
# Archive selected files and directories into a .zip file.
|
508
513
|
def zip(zipfile_name)
|
509
514
|
return unless zipfile_name
|
510
|
-
zipfile_name
|
515
|
+
zipfile_name += '.zip' unless zipfile_name.end_with? '.zip'
|
511
516
|
|
512
517
|
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
513
518
|
selected_items.each do |item|
|
@@ -623,6 +628,12 @@ module Rfd
|
|
623
628
|
c if (0..255) === c.ord
|
624
629
|
end
|
625
630
|
|
631
|
+
def clear_command_line
|
632
|
+
command_line.writeln 0, ""
|
633
|
+
command_line.clear
|
634
|
+
command_line.noutrefresh
|
635
|
+
end
|
636
|
+
|
626
637
|
# Accept user input, and directly execute it as a Ruby method call to the controller.
|
627
638
|
#
|
628
639
|
# ==== Parameters
|
@@ -633,13 +644,11 @@ module Rfd
|
|
633
644
|
cmd, *args = command_line.get_command(prompt: prompt).split(' ')
|
634
645
|
if cmd && !cmd.empty? && respond_to?(cmd)
|
635
646
|
ret = self.public_send cmd, *args
|
636
|
-
|
637
|
-
command_line.noutrefresh
|
647
|
+
clear_command_line
|
638
648
|
ret
|
639
649
|
end
|
640
650
|
rescue Interrupt
|
641
|
-
|
642
|
-
command_line.noutrefresh
|
651
|
+
clear_command_line
|
643
652
|
end
|
644
653
|
|
645
654
|
# Accept user input, and directly execute it in an external shell.
|
@@ -740,7 +749,7 @@ module Rfd
|
|
740
749
|
end
|
741
750
|
|
742
751
|
def expand_path(path)
|
743
|
-
File.expand_path path.start_with?('/'
|
752
|
+
File.expand_path path.start_with?('/', '~') ? path : current_dir ? current_dir.join(path) : path
|
744
753
|
end
|
745
754
|
|
746
755
|
def load_item(path: nil, dir: nil, name: nil, stat: nil)
|
data/lib/rfd/commands.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rfd
|
2
3
|
module Commands
|
3
4
|
# Change permission ("A"ttributes) of selected files and directories.
|
@@ -230,7 +231,8 @@ module Rfd
|
|
230
231
|
# Number of times to repeat the next command.
|
231
232
|
(?0..?9).each do |n|
|
232
233
|
define_method(n) do
|
233
|
-
|
234
|
+
@times ||= ''
|
235
|
+
@times += n
|
234
236
|
end
|
235
237
|
end
|
236
238
|
|
data/lib/rfd/item.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rfd
|
2
3
|
class Item
|
3
4
|
include Comparable
|
@@ -83,9 +84,9 @@ module Rfd
|
|
83
84
|
def mode
|
84
85
|
@mode ||= begin
|
85
86
|
m = stat.mode
|
86
|
-
|
87
|
-
[(m & 0700) / 64, (m & 070) / 8, m & 07].inject(
|
88
|
-
str
|
87
|
+
ft = directory? ? 'd' : symlink? ? 'l' : '-'
|
88
|
+
ret = [(m & 0700) / 64, (m & 070) / 8, m & 07].inject(ft) do |str, s|
|
89
|
+
str += "#{s & 4 == 4 ? 'r' : '-'}#{s & 2 == 2 ? 'w' : '-'}#{s & 1 == 1 ? 'x' : '-'}"
|
89
90
|
end
|
90
91
|
if m & 04000 != 0
|
91
92
|
ret[3] = directory? ? 's' : 'S'
|
data/lib/rfd/windows.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'delegate'
|
2
3
|
|
3
4
|
module Rfd
|
@@ -19,6 +20,7 @@ module Rfd
|
|
19
20
|
setpos row, 0
|
20
21
|
clrtoeol
|
21
22
|
self << str
|
23
|
+
refresh
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -145,14 +147,28 @@ module Rfd
|
|
145
147
|
end
|
146
148
|
end
|
147
149
|
|
150
|
+
def getstr_with_echo
|
151
|
+
str = ""
|
152
|
+
loop do
|
153
|
+
case (c = Curses.getch)
|
154
|
+
when 27
|
155
|
+
raise Interrupt
|
156
|
+
when 10, 13
|
157
|
+
break
|
158
|
+
else
|
159
|
+
self << c
|
160
|
+
refresh
|
161
|
+
str << c
|
162
|
+
end
|
163
|
+
end
|
164
|
+
str
|
165
|
+
end
|
166
|
+
|
148
167
|
def get_command(prompt: nil)
|
149
|
-
Curses.echo
|
150
168
|
startx = prompt ? prompt.size : 1
|
151
169
|
setpos 0, startx
|
152
|
-
s =
|
170
|
+
s = getstr_with_echo
|
153
171
|
"#{prompt[1..-1] if prompt}#{s.strip}"
|
154
|
-
ensure
|
155
|
-
Curses.noecho
|
156
172
|
end
|
157
173
|
|
158
174
|
def show_error(str)
|
data/rfd.gemspec
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "rfd"
|
7
|
-
spec.version = '0.6.
|
8
|
+
spec.version = '0.6.7'
|
8
9
|
spec.authors = ["Akira Matsuda"]
|
9
10
|
spec.email = ["ronnie@dio.jp"]
|
10
11
|
spec.description = 'Ruby on Files & Directories'
|
@@ -20,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
20
21
|
spec.add_dependency 'curses', '>= 1.0.0'
|
21
22
|
spec.add_dependency 'rubyzip', '>= 1.0.0'
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
-
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency "rake", "< 11.0"
|
25
|
+
spec.add_development_dependency 'rspec', "< 2.99"
|
25
26
|
end
|
data/spec/controller_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'rfd'
|
3
4
|
|
@@ -346,16 +347,18 @@ describe Rfd::Controller do
|
|
346
347
|
end
|
347
348
|
end
|
348
349
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
350
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin/
|
351
|
+
describe '#pbcopy' do
|
352
|
+
before do
|
353
|
+
controller.find '.file1'
|
354
|
+
controller.toggle_mark
|
355
|
+
controller.find 'dir3'
|
356
|
+
controller.toggle_mark
|
357
|
+
controller.clipboard
|
358
|
+
end
|
359
|
+
it 'copies the selected paths into clipboard' do
|
360
|
+
`pbpaste`.should == "#{File.join(tmpdir, 'dir3')} #{File.join(tmpdir, '.file1')}"
|
361
|
+
end
|
359
362
|
end
|
360
363
|
end
|
361
364
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/testdir/.link1
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/testdir/.file1
|
@@ -0,0 +1 @@
|
|
1
|
+
spec/testdir/dir1
|
data/spec/testdir/link1
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/testdir/file1
|
data/spec/testdir/link2
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/testdir/file2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -56,30 +56,30 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '11.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "<"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '11.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2.99'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2.99'
|
83
83
|
description: Ruby on Files & Directories
|
84
84
|
email:
|
85
85
|
- ronnie@dio.jp
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- spec/testdir/dir1/.keep
|
110
110
|
- spec/testdir/dir2/.keep
|
111
111
|
- spec/testdir/dir3/.keep
|
112
|
+
- spec/testdir/dirlink1
|
112
113
|
- spec/testdir/file1
|
113
114
|
- spec/testdir/file2
|
114
115
|
- spec/testdir/file3
|
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
139
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.6.8
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: Ruby on Files & Directories
|
@@ -151,6 +152,7 @@ test_files:
|
|
151
152
|
- spec/testdir/dir1/.keep
|
152
153
|
- spec/testdir/dir2/.keep
|
153
154
|
- spec/testdir/dir3/.keep
|
155
|
+
- spec/testdir/dirlink1
|
154
156
|
- spec/testdir/file1
|
155
157
|
- spec/testdir/file2
|
156
158
|
- spec/testdir/file3
|
data/spec/testdir/.link1
DELETED
File without changes
|
data/spec/testdir/link1
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
file1
|
data/spec/testdir/link2
DELETED
File without changes
|