ptools 1.3.7-universal-mingw32 → 1.4.0-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +5 -2
- data/Gemfile +1 -1
- data/MANIFEST +19 -14
- data/README +1 -1
- data/Rakefile +30 -78
- data/lib/ptools.rb +1 -31
- data/ptools.gemspec +3 -3
- 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/{test → 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/{test → spec}/txt/empty.txt +0 -0
- data/{test → spec}/txt/english.txt +0 -0
- data/{test → 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 +31 -49
- metadata.gz.sig +0 -0
- data/test/test_binary.rb +0 -74
- data/test/test_constants.rb +0 -39
- data/test/test_head.rb +0 -48
- data/test/test_image.rb +0 -62
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2511ed84e4a1ce0ebc834b5827455ec5d635c371a322d796605ded4415986dc0
|
4
|
+
data.tar.gz: 4a1cd91f42be4f4c8f8800aa47c15d0b60eb47b60f86a861edecec6f428d1f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 307c82262a8d4319b8dfb4b8fe40ffc3d19d922ff49b119d3b59b2e511c19be4c0e8e38ff23809e12462be64ad6f74c611f94d6c675251ebb5458bc3acd01b1a
|
7
|
+
data.tar.gz: f9cfc533c43421df79e433b8076784ce94dc90d1b0211da54dbb8817e699cfc362a6d065ab106938b9a6ce39d57f38610f30803c541621eadc501cb2d1613fb5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.4.0 - 20-Aug-2020
|
2
|
+
* Switched from test-unit to rspec, and reworked the tests bit in general.
|
3
|
+
* Removed the File.null method since Ruby has IO::NULL.
|
4
|
+
|
1
5
|
== 1.3.7 - 24-Jun-2020
|
2
6
|
* Fixed a bug where the File.binary? method would bomb on a zero byte file.
|
3
7
|
Thanks go to Alexandru Emil Lupu for the spot and patch.
|
@@ -28,8 +32,7 @@
|
|
28
32
|
* The Rakefile tasks now assume Rubygems 2.x.
|
29
33
|
|
30
34
|
== 1.3.2 - 11-Dec-2014
|
31
|
-
* Update to the File.tail method that
|
32
|
-
issues in JRuby.
|
35
|
+
* Update to the File.tail method that prevents potential line ending issues in JRuby.
|
33
36
|
* Added known issues with JRuby to the README.
|
34
37
|
|
35
38
|
== 1.3.1 - 9-Dec-2014
|
data/Gemfile
CHANGED
data/MANIFEST
CHANGED
@@ -6,17 +6,22 @@
|
|
6
6
|
* ptools.gemspec
|
7
7
|
* certs/djberg96_pub.pem
|
8
8
|
* lib/ptools.rb
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
9
|
+
* spec/binary_spec.rb
|
10
|
+
* spec/constants_spec.rb
|
11
|
+
* spec/head_spec.rb
|
12
|
+
* spec/image_spec.rb
|
13
|
+
* spec/nlconvert_spec.rb
|
14
|
+
* spec/sparse_spec.rb
|
15
|
+
* spec/tail_spec.rb
|
16
|
+
* spec/touch_spec.rb
|
17
|
+
* spec/wc_spec.rb
|
18
|
+
* spec/whereis_spec.rb
|
19
|
+
* spec/which_spec.rb
|
20
|
+
* spec/img/test.gif
|
21
|
+
* spec/img/test.ico
|
22
|
+
* spec/img/test.jpg
|
23
|
+
* spec/img/test.png
|
24
|
+
* spec/txt/empty.txt
|
25
|
+
* spec/txt/english.txt
|
26
|
+
* spec/txt/english.utf16
|
27
|
+
* spec/txt/korean.txt
|
data/README
CHANGED
data/Rakefile
CHANGED
@@ -2,9 +2,10 @@ require 'rake'
|
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rbconfig'
|
5
|
+
require 'rspec/core/rake_task'
|
5
6
|
include RbConfig
|
6
7
|
|
7
|
-
CLEAN.include("**/*.gem", "**/*.rbc", "**/*coverage*")
|
8
|
+
CLEAN.include("**/*.gem", "**/*.rbc", "**/*coverage*", "**/*.lock")
|
8
9
|
|
9
10
|
desc 'Install the ptools package (non-gem)'
|
10
11
|
task :install do
|
@@ -19,7 +20,7 @@ namespace 'gem' do
|
|
19
20
|
require 'rubygems/package'
|
20
21
|
spec = eval(IO.read('ptools.gemspec'))
|
21
22
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
22
|
-
Gem::Package.build(spec
|
23
|
+
Gem::Package.build(spec)
|
23
24
|
end
|
24
25
|
|
25
26
|
desc 'Install the ptools gem'
|
@@ -33,103 +34,54 @@ namespace 'gem' do
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
t.warning = true
|
40
|
-
end
|
41
|
-
|
42
|
-
namespace 'test' do
|
43
|
-
desc "Check test coverage using rcov"
|
44
|
-
task :coverage => [:clean] do
|
45
|
-
require 'rcov'
|
46
|
-
rm_rf 'coverage'
|
47
|
-
sh "rcov -Ilib test/test*.rb"
|
37
|
+
namespace 'spec' do
|
38
|
+
RSpec::Core::RakeTask.new(:binary) do |t|
|
39
|
+
t.pattern = 'spec/binary_spec.rb'
|
48
40
|
end
|
49
41
|
|
50
|
-
|
51
|
-
t.
|
52
|
-
t.verbose = true
|
53
|
-
t.warning = true
|
54
|
-
t.test_files = FileList['test/test_binary.rb']
|
42
|
+
RSpec::Core::RakeTask.new(:constants) do |t|
|
43
|
+
t.pattern = 'spec/constants_spec.rb'
|
55
44
|
end
|
56
45
|
|
57
|
-
|
58
|
-
t.
|
59
|
-
t.verbose = true
|
60
|
-
t.warning = true
|
61
|
-
t.test_files = FileList['test/test_constants.rb']
|
46
|
+
RSpec::Core::RakeTask.new(:head) do |t|
|
47
|
+
t.pattern = 'spec/head_spec.rb'
|
62
48
|
end
|
63
49
|
|
64
|
-
|
65
|
-
t.
|
66
|
-
t.verbose = true
|
67
|
-
t.warning = true
|
68
|
-
t.test_files = FileList['test/test_head.rb']
|
50
|
+
RSpec::Core::RakeTask.new(:image) do |t|
|
51
|
+
t.pattern = 'spec/image_spec.rb'
|
69
52
|
end
|
70
53
|
|
71
|
-
|
72
|
-
t.
|
73
|
-
t.verbose = true
|
74
|
-
t.warning = true
|
75
|
-
t.test_files = FileList['test/test_image.rb']
|
54
|
+
RSpec::Core::RakeTask.new(:nlconvert) do |t|
|
55
|
+
t.pattern = 'spec/nlconvert_spec.rb'
|
76
56
|
end
|
77
57
|
|
78
|
-
|
79
|
-
t.
|
80
|
-
t.verbose = true
|
81
|
-
t.warning = true
|
82
|
-
t.test_files = FileList['test/test_nlconvert.rb']
|
58
|
+
RSpec::Core::RakeTask.new(:sparse) do |t|
|
59
|
+
t.pattern = 'spec/sparse_spec.rb'
|
83
60
|
end
|
84
61
|
|
85
|
-
|
86
|
-
t.
|
87
|
-
t.verbose = true
|
88
|
-
t.warning = true
|
89
|
-
t.test_files = FileList['test/test_null.rb']
|
62
|
+
RSpec::Core::RakeTask.new(:tail) do |t|
|
63
|
+
t.pattern = 'spec/tail_spec.rb'
|
90
64
|
end
|
91
65
|
|
92
|
-
|
93
|
-
t.
|
94
|
-
t.verbose = true
|
95
|
-
t.warning = true
|
96
|
-
t.test_files = FileList['test/test_is_sparse.rb']
|
66
|
+
RSpec::Core::RakeTask.new(:touch) do |t|
|
67
|
+
t.pattern = 'spec/touch_spec.rb'
|
97
68
|
end
|
98
69
|
|
99
|
-
|
100
|
-
t.
|
101
|
-
t.verbose = true
|
102
|
-
t.warning = true
|
103
|
-
t.test_files = FileList['test/test_tail.rb']
|
70
|
+
RSpec::Core::RakeTask.new(:wc) do |t|
|
71
|
+
t.pattern = 'spec/wc_spec.rb'
|
104
72
|
end
|
105
|
-
|
106
|
-
|
107
|
-
t.
|
108
|
-
t.verbose = true
|
109
|
-
t.warning = true
|
110
|
-
t.test_files = FileList['test/test_touch.rb']
|
111
|
-
end
|
112
|
-
|
113
|
-
Rake::TestTask.new('wc') do |t|
|
114
|
-
t.libs << 'test'
|
115
|
-
t.verbose = true
|
116
|
-
t.warning = true
|
117
|
-
t.test_files = FileList['test/test_wc.rb']
|
73
|
+
|
74
|
+
RSpec::Core::RakeTask.new(:whereis) do |t|
|
75
|
+
t.pattern = 'spec/whereis_spec.rb'
|
118
76
|
end
|
119
77
|
|
120
|
-
|
121
|
-
t.
|
122
|
-
t.verbose = true
|
123
|
-
t.warning = true
|
124
|
-
t.test_files = FileList['test/test_whereis.rb']
|
78
|
+
RSpec::Core::RakeTask.new(:which) do |t|
|
79
|
+
t.pattern = 'spec/which_spec.rb'
|
125
80
|
end
|
126
81
|
|
127
|
-
|
128
|
-
t.
|
129
|
-
t.verbose = true
|
130
|
-
t.warning = true
|
131
|
-
t.test_files = FileList['test/test_which.rb']
|
82
|
+
RSpec::Core::RakeTask.new(:all) do |t|
|
83
|
+
t.pattern = 'spec/*_spec.rb'
|
132
84
|
end
|
133
85
|
end
|
134
86
|
|
135
|
-
task :default => :
|
87
|
+
task :default => 'spec:all'
|
data/lib/ptools.rb
CHANGED
@@ -3,7 +3,7 @@ require 'win32/file' if File::ALT_SEPARATOR
|
|
3
3
|
|
4
4
|
class File
|
5
5
|
# The version of the ptools library.
|
6
|
-
PTOOLS_VERSION = '1.
|
6
|
+
PTOOLS_VERSION = '1.4.0'.freeze
|
7
7
|
|
8
8
|
# :stopdoc:
|
9
9
|
|
@@ -44,36 +44,6 @@ class File
|
|
44
44
|
bool
|
45
45
|
end
|
46
46
|
|
47
|
-
# Returns the name of the null device (aka bitbucket) on your platform.
|
48
|
-
#
|
49
|
-
# Examples:
|
50
|
-
#
|
51
|
-
# # On Linux
|
52
|
-
# File.null # => '/dev/null'
|
53
|
-
#
|
54
|
-
# # On MS Windows
|
55
|
-
# File.null # => 'NUL'
|
56
|
-
#--
|
57
|
-
# The values I used here are based on information from
|
58
|
-
# http://en.wikipedia.org/wiki//dev/null
|
59
|
-
#
|
60
|
-
def self.null
|
61
|
-
case RbConfig::CONFIG['host_os']
|
62
|
-
when /mswin|win32|msdos|mingw|windows/i
|
63
|
-
'NUL'
|
64
|
-
when /amiga/i
|
65
|
-
'NIL:'
|
66
|
-
when /openvms/i
|
67
|
-
'NL:'
|
68
|
-
else
|
69
|
-
'/dev/null'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class << self
|
74
|
-
alias null_device null
|
75
|
-
end
|
76
|
-
|
77
47
|
# Returns whether or not +file+ is a binary non-image file, i.e. executable,
|
78
48
|
# shared object, ect. Note that this is NOT guaranteed to be 100% accurate.
|
79
49
|
# It performs a "best guess" based on a simple test of the first
|
data/ptools.gemspec
CHANGED
@@ -2,13 +2,13 @@ require 'rbconfig'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'ptools'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.4.0'
|
6
6
|
spec.license = 'Artistic-2.0'
|
7
7
|
spec.author = 'Daniel J. Berger'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
9
9
|
spec.homepage = 'https://github.com/djberg96/ptools'
|
10
10
|
spec.summary = 'Extra methods for the File class'
|
11
|
-
spec.test_files = Dir['
|
11
|
+
spec.test_files = Dir['spec/_spec*']
|
12
12
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
13
13
|
spec.cert_chain = ['certs/djberg96_pub.pem']
|
14
14
|
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
EOF
|
22
22
|
|
23
23
|
spec.add_development_dependency('rake')
|
24
|
-
spec.add_development_dependency('
|
24
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
25
25
|
|
26
26
|
if File::ALT_SEPARATOR
|
27
27
|
spec.platform = Gem::Platform.new(['universal', 'mingw32'])
|
data/spec/binary_spec.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#####################################################################
|
2
|
+
# test_binary.rb
|
3
|
+
#
|
4
|
+
# Test case for the File.binary? method. You should run this test
|
5
|
+
# via the 'rake test_binary' task.
|
6
|
+
#####################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rspec'
|
9
|
+
require 'ptools'
|
10
|
+
|
11
|
+
RSpec.describe File, :binary do
|
12
|
+
let(:dirname) { File.dirname(__FILE__) }
|
13
|
+
let(:bin_file) { File::ALT_SEPARATOR ? File.join(ENV['windir'], 'notepad.exe') : '/bin/ls' }
|
14
|
+
|
15
|
+
before do
|
16
|
+
@txt_file = File.join(dirname, 'txt', 'english.txt')
|
17
|
+
@emp_file = File.join(dirname, 'txt', 'empty.txt')
|
18
|
+
@uni_file = File.join(dirname, 'txt', 'korean.txt')
|
19
|
+
@utf_file = File.join(dirname, 'txt', 'english.utf16')
|
20
|
+
@png_file = File.join(dirname, 'img', 'test.png')
|
21
|
+
@jpg_file = File.join(dirname, 'img', 'test.jpg')
|
22
|
+
@gif_file = File.join(dirname, 'img', 'test.gif')
|
23
|
+
end
|
24
|
+
|
25
|
+
example "File.binary? basic functionality" do
|
26
|
+
expect(File).to respond_to(:binary?)
|
27
|
+
expect{ File.binary?(@txt_file) }.not_to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
example "File.binary? returns true for binary files" do
|
31
|
+
expect(File.binary?(bin_file)).to be true
|
32
|
+
end
|
33
|
+
|
34
|
+
example "File.binary? returns false for text files" do
|
35
|
+
expect(File.binary?(@emp_file)).to be false
|
36
|
+
expect(File.binary?(@txt_file)).to be false
|
37
|
+
expect(File.binary?(@uni_file)).to be false
|
38
|
+
expect(File.binary?(@utf_file)).to be false
|
39
|
+
end
|
40
|
+
|
41
|
+
example "File.binary? returns false for image files" do
|
42
|
+
expect(File.binary?(@png_file)).to be false
|
43
|
+
expect(File.binary?(@jpg_file)).to be false
|
44
|
+
expect(File.binary?(@gif_file)).to be false
|
45
|
+
end
|
46
|
+
|
47
|
+
example "File.binary? accepts an optional percentage argument" do
|
48
|
+
expect(File.binary?(@txt_file, 0.50)).to be false
|
49
|
+
expect(File.binary?(@txt_file, 0.05)).to be true
|
50
|
+
end
|
51
|
+
|
52
|
+
example "File.binary? raises an error if the file cannot be found" do
|
53
|
+
expect{ File.binary?('bogus') }.to raise_error(SystemCallError)
|
54
|
+
end
|
55
|
+
|
56
|
+
example "File.binary? only accepts one argument" do
|
57
|
+
expect{ File.binary?(@txt_file, bin_file) }.to raise_error(ArgumentError)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# constants_spec.rb
|
3
|
+
#
|
4
|
+
# Specs for the constants that have been defined in the ptools library.
|
5
|
+
# This test case should be run via the 'rake spec:constants' task.
|
6
|
+
##############################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rspec'
|
9
|
+
require 'rbconfig'
|
10
|
+
require 'ptools'
|
11
|
+
|
12
|
+
RSpec.describe File, :constants do
|
13
|
+
let(:windows) { File::ALT_SEPARATOR }
|
14
|
+
|
15
|
+
example "PTOOLS_VERSION constant is set to expected value" do
|
16
|
+
expect(File::PTOOLS_VERSION).to eq('1.4.0')
|
17
|
+
expect(File::PTOOLS_VERSION.frozen?).to be true
|
18
|
+
end
|
19
|
+
|
20
|
+
example "IMAGE_EXT constant is set to array of values" do
|
21
|
+
expect(File::IMAGE_EXT.sort).to eq(%w[.bmp .gif .jpeg .jpg .png])
|
22
|
+
end
|
23
|
+
|
24
|
+
example "WINDOWS constant is defined on MS Windows" do
|
25
|
+
skip "skipped unless MS Windows" unless windows
|
26
|
+
expect(File::MSWINDOWS).not_to be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
example "WIN32EXTS constant is defined on MS Windows" do
|
30
|
+
skip "skipped unless MS Windows" unless windows
|
31
|
+
expect(File::WIN32EXTS).not_to be_nil
|
32
|
+
end
|
33
|
+
end
|
data/spec/head_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
######################################################################
|
2
|
+
# head_spec.rb
|
3
|
+
#
|
4
|
+
# Specs for the File.head method. These specs should be run via
|
5
|
+
# the 'rake spec:head' task.
|
6
|
+
######################################################################
|
7
|
+
require 'rspec'
|
8
|
+
require 'ptools'
|
9
|
+
|
10
|
+
RSpec.describe File, :head do
|
11
|
+
let(:test_file) { 'test_file_head.txt' }
|
12
|
+
|
13
|
+
before do
|
14
|
+
File.open(test_file, 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
|
15
|
+
@expected_head1 = ["line1\n","line2\n","line3\n","line4\n","line5\n"]
|
16
|
+
@expected_head1.push("line6\n","line7\n","line8\n","line9\n","line10\n")
|
17
|
+
@expected_head2 = ["line1\n","line2\n","line3\n","line4\n","line5\n"]
|
18
|
+
end
|
19
|
+
|
20
|
+
example "head method basic functionality" do
|
21
|
+
expect(File).to respond_to(:head)
|
22
|
+
expect{ File.head(test_file) }.not_to raise_error
|
23
|
+
expect{ File.head(test_file, 5) }.not_to raise_error
|
24
|
+
expect{ File.head(test_file){} }.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
example "head method returns the expected results" do
|
28
|
+
expect(File.head(test_file)).to be_kind_of(Array)
|
29
|
+
expect(File.head(test_file)).to eq(@expected_head1)
|
30
|
+
expect(File.head(test_file, 5)).to eq(@expected_head2)
|
31
|
+
end
|
32
|
+
|
33
|
+
example "head method requires two arguments" do
|
34
|
+
expect{ File.head(test_file, 5, "foo") }.to raise_error(ArgumentError)
|
35
|
+
expect{ File.head("bogus") }.to raise_error(Errno::ENOENT)
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
File.delete(test_file) if File.exists?(test_file)
|
40
|
+
end
|
41
|
+
end
|