l 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,105 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class LTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @dir = File.dirname(__FILE__)
7
+ @file = __FILE__
8
+ end
9
+
10
+ def test_build_command
11
+ L.clear_options
12
+ assert_equal ['ls'], L.build_command([]), 'ls only'
13
+ end
14
+
15
+ def test_build_command_with_file
16
+ L.clear_options
17
+ assert_equal ['less', @file], L.build_command([@file]), 'less file'
18
+ end
19
+
20
+ def test_build_command_with_dir
21
+ L.clear_options
22
+ assert_equal ['ls', @dir], L.build_command([@dir]), 'ls dir'
23
+ end
24
+
25
+ def test_parse
26
+ args = ['-i', '-I', '-e', '--quit-at-eof', '--raw-control-chars']
27
+ L.init_options(args)
28
+ L.parse(args)
29
+ assert_equal ['ls'], L.build_command(args), 'filter inappropriate options for ls'
30
+
31
+ args = [@file, '-l', '-1', '--recursive', '-a']
32
+ L.init_options(args)
33
+ L.parse(args)
34
+ assert_equal ['less', @file], L.build_command(args), 'filter inappropriate options for less'
35
+ end
36
+
37
+ def test_parse_with_file
38
+ args = ['-e', @file]
39
+ L.init_options(args)
40
+ L.parse(args)
41
+ assert_equal ['less', '-e', @file], L.build_command(args), 'less -e file'
42
+
43
+ args = ['-el', @file]
44
+ L.init_options(args)
45
+ L.parse(args)
46
+ assert_equal ['less', '-e', @file], L.build_command(args), 'less -e file, no -l'
47
+
48
+ args = ['-e', @file, '-l']
49
+ L.init_options(args)
50
+ L.parse(args)
51
+ assert_equal ['less', '-e', @file], L.build_command(args), 'less -e file, no -l'
52
+ end
53
+
54
+ def test_parse_with_dir
55
+ args = ['-l', @dir]
56
+ L.init_options(args)
57
+ L.parse(args)
58
+ assert_equal ['ls', '-l', @dir], L.build_command(args), 'ls -l dir'
59
+
60
+ args = ['-le', @dir]
61
+ L.init_options(args)
62
+ L.parse(args)
63
+ assert_equal ['ls', '-l', @dir], L.build_command(args), 'ls -l dir, no -e'
64
+
65
+ args = ['-l', @dir, '-e']
66
+ L.init_options(args)
67
+ L.parse(args)
68
+ assert_equal ['ls', '-l', @dir], L.build_command(args), 'ls -l dir, no -e'
69
+ end
70
+
71
+ def test_general
72
+
73
+ # help
74
+ args = ['-h']
75
+ L.init_options(args)
76
+
77
+ assert_raise SystemExit do
78
+ begin
79
+ # temporarily redirect STDOUT to silence output
80
+ stdout_orig = STDOUT.dup
81
+ STDOUT.reopen('/dev/null')
82
+ L.parse(args)
83
+ ensure
84
+ STDOUT.reopen(stdout_orig)
85
+ end
86
+ end
87
+
88
+ # version
89
+ args = ['-V']
90
+ L.init_options(args)
91
+
92
+ assert_raise SystemExit do
93
+ begin
94
+ # temporarily redirect STDOUT to silence output
95
+ stdout_orig = STDOUT.dup
96
+ STDOUT.reopen('/dev/null')
97
+ L.parse(args)
98
+ ensure
99
+ STDOUT.reopen(stdout_orig)
100
+ end
101
+ end
102
+
103
+ end
104
+ end
105
+
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/l'
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.1
3
+ specification_version: 1
4
+ name: l
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-01-30 00:00:00 +01:00
8
+ summary: A commandline application that combines ls and less for easier shell navigation
9
+ require_paths:
10
+ - lib
11
+ email: kristoffer.lunden@gmail.com
12
+ homepage: http://l-ruby.rubyforge.org
13
+ rubyforge_project: l-ruby
14
+ description: "l is a frontend for ls and less, invoking either depending on if it is fed directories or files. This makes navigating a shell a bit smoother and easier, as it is common to switch between the two commands while poking around the file system (see Sample session). The program filters the switches for ls and less, keeping the most useful and common for each. Sample session: user@box:~ l Documents Music Projects user@box:~ l Documents/ Personal some_doc.pdf example.txt Work user@box:~ l Documents/example.txt This is just an example Documents/example.txt (END) user@box:~ l Documents/Work/ proposal.odt document.pdf user@box:~ l -l Documents/Work/ -rw-r--r-- 1 user user 32974 2006-03-31 12:29 proposal.odt -rw-r--r-- 1 user user 451726 2006-04-13 10:33 document.pdf Aliases: Most aliases for ls as used in .bashrc will work as usual if ls is replaced with l, but there's more: you can combine switches for both ls and less in your alias and l will filter out the inappropriate ones. The following will set ll to use long lists for directories and to ignore case for searches when displaying files: alias ll='l -I -l' Because ls and less can't safely share the same switches, there are a few cases where a workaround is needed: For ls: -i doesn't work, use --inode instead -I doesn't work, use --ignore=PATTERN For less: -r and -R doesn't work, use --raw-control-chars instead"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - "Kristoffer Lund\xC3\xA9n"
31
+ files:
32
+ - Rakefile
33
+ - README.txt
34
+ - CHANGELOG.txt
35
+ - Manifest.txt
36
+ - COPYRIGHT.txt
37
+ - setup.rb
38
+ - test/test_helper.rb
39
+ - test/l_test.rb
40
+ - bin/l
41
+ - lib/l.rb
42
+ - examples/bashrc.example
43
+ test_files:
44
+ - test/l_test.rb
45
+ rdoc_options: []
46
+
47
+ extra_rdoc_files: []
48
+
49
+ executables:
50
+ - l
51
+ extensions: []
52
+
53
+ requirements: []
54
+
55
+ dependencies: []
56
+