ptools 1.3.4 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.md} +55 -30
- data/Gemfile +1 -1
- data/MANIFEST.md +27 -0
- data/{README → README.md} +30 -26
- data/Rakefile +30 -78
- data/certs/djberg96_pub.pem +22 -17
- data/lib/ptools.rb +26 -36
- data/ptools.gemspec +13 -7
- data/spec/binary_spec.rb +59 -0
- data/spec/constants_spec.rb +33 -0
- data/spec/head_spec.rb +41 -0
- data/spec/image_spec.rb +51 -0
- data/{test → spec}/img/test.gif +0 -0
- data/spec/img/test.ico +0 -0
- data/{test → spec}/img/test.jpg +0 -0
- data/{test → spec}/img/test.png +0 -0
- data/spec/nlconvert_spec.rb +104 -0
- data/spec/sparse_spec.rb +43 -0
- data/spec/tail_spec.rb +107 -0
- data/spec/touch_spec.rb +47 -0
- data/spec/txt/empty.txt +0 -0
- data/{test → spec}/txt/english.txt +0 -0
- data/spec/txt/english.utf16 +0 -0
- data/{test → spec}/txt/korean.txt +0 -0
- data/spec/wc_spec.rb +65 -0
- data/spec/whereis_spec.rb +87 -0
- data/spec/which_spec.rb +112 -0
- metadata +66 -74
- metadata.gz.sig +0 -0
- data/MANIFEST +0 -20
- data/test/test_binary.rb +0 -70
- data/test/test_constants.rb +0 -38
- data/test/test_head.rb +0 -48
- data/test/test_image.rb +0 -57
- data/test/test_is_sparse.rb +0 -53
- data/test/test_nlconvert.rb +0 -110
- data/test/test_null.rb +0 -40
- data/test/test_tail.rb +0 -124
- data/test/test_touch.rb +0 -53
- data/test/test_wc.rb +0 -73
- data/test/test_whereis.rb +0 -98
- data/test/test_which.rb +0 -126
data/test/test_which.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
#####################################################################
|
2
|
-
# test_which.rb
|
3
|
-
#
|
4
|
-
# Test case for the File.which method. You should run this test
|
5
|
-
# via the 'rake test_which' rake task.
|
6
|
-
#
|
7
|
-
# NOTE: I make the assumption that Ruby (or JRuby) is in your
|
8
|
-
# PATH for these tests.
|
9
|
-
#####################################################################
|
10
|
-
require 'test-unit'
|
11
|
-
require 'rbconfig'
|
12
|
-
require 'fileutils'
|
13
|
-
require 'ptools'
|
14
|
-
require 'tempfile'
|
15
|
-
|
16
|
-
class TC_FileWhich < Test::Unit::TestCase
|
17
|
-
def self.startup
|
18
|
-
@@windows = File::ALT_SEPARATOR
|
19
|
-
@@dir = File.join(Dir.pwd, 'tempdir')
|
20
|
-
@@non_exe = File.join(Dir.pwd, 'tempfile')
|
21
|
-
|
22
|
-
Dir.mkdir(@@dir) unless File.exist?(@@dir)
|
23
|
-
FileUtils.touch(@@non_exe)
|
24
|
-
File.chmod(775, @@dir)
|
25
|
-
File.chmod(644, @@non_exe)
|
26
|
-
end
|
27
|
-
|
28
|
-
def setup
|
29
|
-
@ruby = RUBY_PLATFORM.match('java') ? 'jruby' : 'ruby'
|
30
|
-
@ruby = 'rbx' if defined?(Rubinius)
|
31
|
-
|
32
|
-
@exe = File.join(
|
33
|
-
RbConfig::CONFIG['bindir'],
|
34
|
-
RbConfig::CONFIG['ruby_install_name']
|
35
|
-
)
|
36
|
-
|
37
|
-
if @@windows
|
38
|
-
@exe.tr!('/','\\')
|
39
|
-
@exe << ".exe"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
test "which method basic functionality" do
|
44
|
-
assert_respond_to(File, :which)
|
45
|
-
assert_nothing_raised{ File.which(@ruby) }
|
46
|
-
assert_kind_of(String, File.which(@ruby))
|
47
|
-
end
|
48
|
-
|
49
|
-
test "which accepts an optional path to search" do
|
50
|
-
assert_nothing_raised{ File.which(@ruby, "/usr/bin:/usr/local/bin") }
|
51
|
-
end
|
52
|
-
|
53
|
-
test "which returns nil if not found" do
|
54
|
-
assert_equal(nil, File.which(@ruby, '/bogus/path'))
|
55
|
-
assert_equal(nil, File.which('blahblahblah'))
|
56
|
-
end
|
57
|
-
|
58
|
-
test "which handles executables without extensions on windows" do
|
59
|
-
omit_unless(@@windows, "test skipped unless MS Windows")
|
60
|
-
assert_not_nil(File.which('ruby'))
|
61
|
-
assert_not_nil(File.which('notepad'))
|
62
|
-
end
|
63
|
-
|
64
|
-
test "which handles executables that already contain extensions on windows" do
|
65
|
-
omit_unless(@@windows, "test skipped unless MS Windows")
|
66
|
-
assert_not_nil(File.which('ruby.exe'))
|
67
|
-
assert_not_nil(File.which('notepad.exe'))
|
68
|
-
end
|
69
|
-
|
70
|
-
test "which returns argument if an existent absolute path is provided" do
|
71
|
-
assert_equal(@exe, File.which(@ruby), "=> May fail on a symlink")
|
72
|
-
end
|
73
|
-
|
74
|
-
test "which returns nil if a non-existent absolute path is provided" do
|
75
|
-
assert_nil(File.which('/foo/bar/baz/ruby'))
|
76
|
-
end
|
77
|
-
|
78
|
-
test "which does not pickup files that are not executable" do
|
79
|
-
assert_nil(File.which(@@non_exe))
|
80
|
-
end
|
81
|
-
|
82
|
-
test "which does not pickup executable directories" do
|
83
|
-
assert_nil(File.which(@@dir))
|
84
|
-
end
|
85
|
-
|
86
|
-
test "which accepts a minimum of one argument" do
|
87
|
-
assert_raises(ArgumentError){ File.which }
|
88
|
-
end
|
89
|
-
|
90
|
-
test "which accepts a maximum of two arguments" do
|
91
|
-
assert_raises(ArgumentError){ File.which(@ruby, "foo", "bar") }
|
92
|
-
end
|
93
|
-
|
94
|
-
test "the second argument cannot be nil or empty" do
|
95
|
-
assert_raises(ArgumentError){ File.which(@ruby, nil) }
|
96
|
-
assert_raises(ArgumentError){ File.which(@ruby, '') }
|
97
|
-
end
|
98
|
-
|
99
|
-
test "resolves with with ~" do
|
100
|
-
omit_if(@@windows, "~ tests skipped on MS Windows")
|
101
|
-
begin
|
102
|
-
old_home = ENV['HOME']
|
103
|
-
|
104
|
-
ENV['HOME'] = Dir::Tmpname.tmpdir
|
105
|
-
program = Tempfile.new(['program', '.sh'])
|
106
|
-
File.chmod(755, program.path)
|
107
|
-
|
108
|
-
assert_not_nil(File.which(File.basename(program.path), '~/'))
|
109
|
-
ensure
|
110
|
-
ENV['HOME'] = old_home
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def teardown
|
115
|
-
@exe = nil
|
116
|
-
@ruby = nil
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.shutdown
|
120
|
-
FileUtils.rm(@@non_exe)
|
121
|
-
FileUtils.rm_rf(@@dir)
|
122
|
-
@@windows = nil
|
123
|
-
@@dir = nil
|
124
|
-
@@non_exe = nil
|
125
|
-
end
|
126
|
-
end
|