droxi 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/droxi.1.template +3 -0
- data/droxi.gemspec +1 -1
- data/lib/droxi/commands.rb +32 -19
- data/lib/droxi.rb +1 -1
- data/spec/commands_spec.rb +47 -26
- data/spec/complete_spec.rb +1 -1
- data/spec/testutils.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c2e238628368cdd91abd0fb76a31cb0b217159
|
4
|
+
data.tar.gz: bf2bec767b3e0b80bf264a2784fc9b2c3cda15a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f9cad5986b95260f0c9743231bff2c5a9bc634d7fa61a39ead74664d8c61a2a803b31a91bfd96df2a7acbecf381aa04c8d13c378ad2aaa0d08e94fdbf94f0d
|
7
|
+
data.tar.gz: 0414164a2564a94de66d758422ef65e213909952a3dc69f4fb1dd10265f01cb000f7d5debb10afd302116d55f47979656720bf4b9866dc5db859d059272a7a2b
|
data/Rakefile
CHANGED
@@ -65,10 +65,11 @@ task :build do
|
|
65
65
|
|
66
66
|
def build_page
|
67
67
|
gemspec = IO.read('droxi.gemspec')
|
68
|
+
main = IO.read('lib/droxi.rb')
|
68
69
|
|
69
70
|
contents = format(IO.read('droxi.1.template'),
|
70
71
|
date: date(gemspec),
|
71
|
-
version:
|
72
|
+
version: main[/\d+\.\d+\.\d+/],
|
72
73
|
commands: commands)
|
73
74
|
|
74
75
|
IO.write('build/droxi.1', contents)
|
data/droxi.1.template
CHANGED
@@ -9,6 +9,9 @@ Features include smart tab completion, globbing, and interactive help. If
|
|
9
9
|
invoked without arguments, runs in interactive mode. If invoked with arguments,
|
10
10
|
parses the arguments as a command invocation, executes the command, and exits.
|
11
11
|
.SH COMMANDS
|
12
|
+
.TP
|
13
|
+
!STRING
|
14
|
+
Pass a string to be executed by the local shell.
|
12
15
|
%{commands}
|
13
16
|
.SH OPTIONS
|
14
17
|
.TP
|
data/droxi.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'droxi'
|
3
3
|
s.version = IO.read('lib/droxi.rb')[/VERSION = '(.+)'/, 1]
|
4
|
-
s.date = '2014-06-
|
4
|
+
s.date = '2014-06-08'
|
5
5
|
s.summary = 'ftp-like command-line interface to Dropbox'
|
6
6
|
s.description = "A command-line Dropbox interface inspired by GNU \
|
7
7
|
coreutils, GNU ftp, and lftp. Features include smart tab \
|
data/lib/droxi/commands.rb
CHANGED
@@ -61,6 +61,22 @@ module Commands
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
# Print the contents of remote files.
|
65
|
+
CAT = Command.new(
|
66
|
+
'cat REMOTE_FILE...',
|
67
|
+
'Print the concatenated contents of remote files.',
|
68
|
+
lambda do |client, state, args|
|
69
|
+
extract_flags('cat', args, '')
|
70
|
+
state.expand_patterns(args).each do |path|
|
71
|
+
if path.is_a?(GlobError)
|
72
|
+
warn "cat: #{path}: no such file or directory"
|
73
|
+
else
|
74
|
+
puts client.get_file(path)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
)
|
79
|
+
|
64
80
|
# Change the remote working directory.
|
65
81
|
CD = Command.new(
|
66
82
|
'cd [REMOTE_DIR]',
|
@@ -314,29 +330,26 @@ module Commands
|
|
314
330
|
|
315
331
|
# Upload a local file.
|
316
332
|
PUT = Command.new(
|
317
|
-
'put [-f] LOCAL_FILE
|
318
|
-
"Upload
|
319
|
-
|
320
|
-
of the same name already exists, Dropbox will rename the upload unless \
|
333
|
+
'put [-f] LOCAL_FILE...',
|
334
|
+
"Upload local files to the remote working directory. If a remote file of \
|
335
|
+
the same name already exists, Dropbox will rename the upload unless the \
|
321
336
|
the -f option is given, in which case the remote file will be \
|
322
|
-
overwritten.
|
323
|
-
to a file of the same name in the remote working directory.",
|
337
|
+
overwritten.",
|
324
338
|
lambda do |client, state, args|
|
325
339
|
flags = extract_flags('put', args, '-f')
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
340
|
+
args.each do |arg|
|
341
|
+
to_path = state.resolve_path(File.basename(arg))
|
342
|
+
|
343
|
+
try_and_handle(StandardError) do
|
344
|
+
File.open(File.expand_path(arg), 'rb') do |file|
|
345
|
+
if flags.include?('-f') && state.metadata(to_path)
|
346
|
+
client.file_delete(to_path)
|
347
|
+
state.cache.remove(to_path)
|
348
|
+
end
|
349
|
+
data = client.put_file(to_path, file)
|
350
|
+
state.cache.add(data)
|
351
|
+
puts "#{arg} -> #{data['path']}"
|
336
352
|
end
|
337
|
-
data = client.put_file(to_path, file)
|
338
|
-
state.cache.add(data)
|
339
|
-
puts "#{from_path} -> #{data['path']}"
|
340
353
|
end
|
341
354
|
end
|
342
355
|
end
|
data/lib/droxi.rb
CHANGED
data/spec/commands_spec.rb
CHANGED
@@ -31,6 +31,36 @@ describe Commands do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe 'when executing the cat command' do
|
35
|
+
before do
|
36
|
+
state.pwd = TestUtils::TEST_ROOT
|
37
|
+
@cat = proc do |*args|
|
38
|
+
capture_io { Commands::CAT.exec(client, state, *args) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'must print the contents of existing remote files' do
|
43
|
+
`echo hello > hello.txt`
|
44
|
+
`echo world > world.txt`
|
45
|
+
capture_io do
|
46
|
+
Commands::PUT.exec(client, state, 'hello.txt', 'world.txt')
|
47
|
+
end
|
48
|
+
out, _ = @cat.call('hello.txt', 'world.txt')
|
49
|
+
out.must_equal("hello\nworld\n")
|
50
|
+
`rm hello.txt world.txt`
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'must give an error message if trying to cat a bogus file' do
|
54
|
+
_, err = @cat.call('bogus')
|
55
|
+
err.lines.size.must_equal 1
|
56
|
+
err.start_with?('cat: ').must_equal true
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'must fail with UsageError when given no args' do
|
60
|
+
proc { @cat.call }.must_raise Commands::UsageError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
34
64
|
describe 'when executing the cd command' do
|
35
65
|
before do
|
36
66
|
@cd = proc do |*args|
|
@@ -148,6 +178,12 @@ describe Commands do
|
|
148
178
|
out.must_equal("1\n")
|
149
179
|
end
|
150
180
|
|
181
|
+
it 'must handle syntax errors' do
|
182
|
+
ARGV << '--debug'
|
183
|
+
_, err = @debug.call('"x')
|
184
|
+
err.lines.size.must_equal 1
|
185
|
+
end
|
186
|
+
|
151
187
|
it 'must print the resulting exception if given exceptional input' do
|
152
188
|
ARGV << '--debug'
|
153
189
|
_, err = @debug.call('x')
|
@@ -410,28 +446,13 @@ describe Commands do
|
|
410
446
|
end
|
411
447
|
end
|
412
448
|
|
413
|
-
it 'must put
|
414
|
-
TestUtils.not_structure(client, state, '
|
415
|
-
`
|
416
|
-
@put.call('
|
417
|
-
`rm
|
418
|
-
state.metadata('/testing/
|
419
|
-
|
420
|
-
|
421
|
-
it 'must put a file with the stated name when given 2 args' do
|
422
|
-
TestUtils.not_structure(client, state, 'dest.txt')
|
423
|
-
`echo hello > test.txt`
|
424
|
-
@put.call('test.txt', 'dest.txt')
|
425
|
-
`rm test.txt`
|
426
|
-
state.metadata('/testing/dest.txt').wont_be_nil
|
427
|
-
end
|
428
|
-
|
429
|
-
it 'must put file in directory if second arg is directory' do
|
430
|
-
TestUtils.not_structure(client, state, 'test.txt')
|
431
|
-
`touch test.txt`
|
432
|
-
@put.call('test.txt', '/testing')
|
433
|
-
`rm test.txt`
|
434
|
-
state.metadata('/testing/test.txt').wont_be_nil
|
449
|
+
it 'must put multiple files' do
|
450
|
+
TestUtils.not_structure(client, state, 'file1.txt', 'file2.txt')
|
451
|
+
`touch file1.txt file2.txt`
|
452
|
+
@put.call('file1.txt', 'file2.txt')
|
453
|
+
`rm file1.txt file2.txt`
|
454
|
+
state.metadata('/testing/file1.txt').wont_be_nil
|
455
|
+
state.metadata('/testing/file2.txt').wont_be_nil
|
435
456
|
end
|
436
457
|
|
437
458
|
it 'must not overwrite without -f option' do
|
@@ -574,7 +595,7 @@ describe Commands do
|
|
574
595
|
end
|
575
596
|
|
576
597
|
it 'must fail with error if remote directory not empty' do
|
577
|
-
TestUtils.structure(client, state, 'test', 'test/
|
598
|
+
TestUtils.structure(client, state, 'test', 'test/subtest')
|
578
599
|
_, err = @rmdir.call('/testing/test')
|
579
600
|
err.lines.size.must_equal 1
|
580
601
|
err.start_with?('rmdir: ').must_equal true
|
@@ -650,12 +671,12 @@ describe Commands do
|
|
650
671
|
end
|
651
672
|
|
652
673
|
it 'must return correct types for in-bounds indices' do
|
653
|
-
Commands::
|
654
|
-
Commands::
|
674
|
+
Commands::MV.type_of_arg(0).must_equal 'REMOTE_FILE'
|
675
|
+
Commands::MV.type_of_arg(1).must_equal 'REMOTE_FILE'
|
655
676
|
end
|
656
677
|
|
657
678
|
it 'must return last types for out-of-bounds index' do
|
658
|
-
Commands::PUT.type_of_arg(3).must_equal '
|
679
|
+
Commands::PUT.type_of_arg(3).must_equal 'LOCAL_FILE'
|
659
680
|
end
|
660
681
|
end
|
661
682
|
end
|
data/spec/complete_spec.rb
CHANGED
@@ -68,7 +68,7 @@ describe Complete do
|
|
68
68
|
it 'lists all remote files and end with correct char' do
|
69
69
|
state.pwd = '/'
|
70
70
|
entries = remote_contents(state, '/')
|
71
|
-
Complete.complete('
|
71
|
+
Complete.complete('get thing ', state).sort.must_equal entries.sort
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
data/spec/testutils.rb
CHANGED
@@ -64,7 +64,9 @@ module TestUtils
|
|
64
64
|
`touch testing/#{basename}`
|
65
65
|
real_stdout = $stdout
|
66
66
|
$stdout = StringIO.new
|
67
|
-
|
67
|
+
prev_pwd, state.pwd = state.pwd, '/testing'
|
68
|
+
Commands::PUT.exec(client, state, "testing/#{basename}")
|
69
|
+
state.pwd = prev_pwd
|
68
70
|
$stdout = real_stdout
|
69
71
|
`rm -rf testing`
|
70
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droxi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mulcahy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox-sdk
|