epitools 0.5.118 → 0.5.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/epitools/core_ext/numbers.rb +11 -0
- data/lib/epitools/path.rb +30 -11
- data/lib/epitools/term.rb +2 -1
- data/spec/path_spec.rb +3 -2
- data/spec/term_spec.rb +6 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2512c35335e90e398fa2a8e71f7f5fb070edaf73cf52d53c20b1c2af2be5646f
|
4
|
+
data.tar.gz: 1db6bbad945aad61174cb71dc2f14e9ed563b048706ec368b83eda1062794294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4a3a513f9f47637632998d2264a34fa935a5082997139f1637ead91c6f78fc1f5b6502690c2f5fe107685beac3e8909c1a62c87dd14f669f317ab7d1eb93234
|
7
|
+
data.tar.gz: 2944e0d81230264af1762c3a8ff439f949c2d79340f2d184061376dd94f2d63d2561d84c36b48312eb7054ed7193cd063fdf94e14ab10e663b2586192a290336
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.119
|
@@ -366,6 +366,17 @@ class Integer
|
|
366
366
|
end
|
367
367
|
alias_method :fibonacci, :fib
|
368
368
|
|
369
|
+
|
370
|
+
#
|
371
|
+
# Flip all bits except the sign bit.
|
372
|
+
#
|
373
|
+
# NOTE: This method should only be used with unsigned integers; if you use it with a signed
|
374
|
+
# integer, it will only flip the non-sign bits (I dunno if that's useful for anything; nothing comes to mind.)
|
375
|
+
#
|
376
|
+
def invert
|
377
|
+
to_s(2).tr("01","10").to_i(2)
|
378
|
+
end
|
379
|
+
|
369
380
|
end
|
370
381
|
|
371
382
|
#
|
data/lib/epitools/path.rb
CHANGED
@@ -807,7 +807,7 @@ class Path
|
|
807
807
|
# zopen("otherfile.gz", "w") #=> #<Zlib::GzipWriter:0x7fe30448>>
|
808
808
|
# zopen("test.txt.gz") { |f| f.read } # read the contents of the .gz file, then close the file handle automatically.
|
809
809
|
#
|
810
|
-
def zopen(mode="rb")
|
810
|
+
def zopen(mode="rb", &block)
|
811
811
|
# if ext == "gz"
|
812
812
|
# io = open(mode)
|
813
813
|
# case mode
|
@@ -822,21 +822,40 @@ class Path
|
|
822
822
|
# elsif bin = COMPRESSORS[ext]
|
823
823
|
if bin = COMPRESSORS[ext]
|
824
824
|
if which(bin)
|
825
|
-
|
825
|
+
case mode
|
826
|
+
when "w", "wb"
|
827
|
+
# TODO: figure out how to pipe the compressor directly a file so we don't require a block
|
828
|
+
raise "Error: Must supply a block when writing" unless block_given?
|
829
|
+
|
830
|
+
IO.popen([bin, "-c"], "wb+") do |compressor|
|
831
|
+
yield(compressor)
|
832
|
+
compressor.close_write
|
833
|
+
open("wb") { |output| IO.copy_stream(compressor, output) }
|
834
|
+
end
|
835
|
+
when "r", "rb"
|
836
|
+
if block_given?
|
837
|
+
IO.popen([bin, "-d" ,"-c", path], "rb", &block)
|
838
|
+
else
|
839
|
+
IO.popen([bin, "-d" ,"-c", path], "rb")
|
840
|
+
end
|
841
|
+
else
|
842
|
+
raise "Error: Mode #{mode.inspect} not recognized"
|
843
|
+
end
|
826
844
|
else
|
827
|
-
raise "Error:
|
845
|
+
raise "Error: couldn't find #{bin.inspect} in the path"
|
828
846
|
end
|
829
847
|
else
|
830
|
-
io = open(path)
|
848
|
+
# io = open(path)
|
849
|
+
raise "Error: #{ext.inspect} is an unsupported format"
|
831
850
|
end
|
832
851
|
|
833
|
-
if block_given?
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
else
|
838
|
-
|
839
|
-
end
|
852
|
+
# if block_given?
|
853
|
+
# result = yield(io)
|
854
|
+
# io.close
|
855
|
+
# result
|
856
|
+
# else
|
857
|
+
# io
|
858
|
+
# end
|
840
859
|
|
841
860
|
end
|
842
861
|
|
data/lib/epitools/term.rb
CHANGED
data/spec/path_spec.rb
CHANGED
@@ -371,7 +371,7 @@ describe Path do
|
|
371
371
|
tmp.size.should == before
|
372
372
|
end
|
373
373
|
|
374
|
-
it "zopens" do
|
374
|
+
it "zopens for reading/writing" do
|
375
375
|
tmpjson = Path["/tmp/test.json"]
|
376
376
|
|
377
377
|
hash = {
|
@@ -385,9 +385,10 @@ describe Path do
|
|
385
385
|
parsed = tmpjson.parse
|
386
386
|
parsed.should == hash
|
387
387
|
|
388
|
-
system("gzip -c < #{tmpjson} > #{tmpjson}.gz")
|
388
|
+
# system("gzip -c < #{tmpjson} > #{tmpjson}.gz")
|
389
389
|
|
390
390
|
tmpgzip = Path["#{tmpjson}.gz"]
|
391
|
+
tmpgzip.zopen("w") { |io| io.write(JSON.dump(hash)) }
|
391
392
|
tmpgzip.exists?.should == true
|
392
393
|
tmpgzip.size.should be > 0
|
393
394
|
|
data/spec/term_spec.rb
CHANGED
@@ -4,8 +4,8 @@ describe Term do
|
|
4
4
|
|
5
5
|
it "sizes" do
|
6
6
|
width, height = Term.size
|
7
|
-
width.class.should ==
|
8
|
-
height.class.should ==
|
7
|
+
width.class.should == Integer
|
8
|
+
height.class.should == Integer
|
9
9
|
end
|
10
10
|
|
11
11
|
it "tables" do
|
@@ -41,11 +41,10 @@ describe Term do
|
|
41
41
|
# [4,5,6]
|
42
42
|
# ]
|
43
43
|
|
44
|
-
table = Term::Table.new
|
45
|
-
table.rows
|
46
|
-
table.rows << [
|
47
|
-
table.
|
48
|
-
table.add_row [1,2,3,4,5]
|
44
|
+
# table = Term::Table.new([ [1,2,3], [4,5,6] ])
|
45
|
+
# table.rows << [1,2,3]
|
46
|
+
# table.rows << [4,5,6]
|
47
|
+
# table.add_row [1,2,3,4,5]
|
49
48
|
end
|
50
49
|
|
51
50
|
it "tables nothing" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.119
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- epitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -133,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.7.7
|
136
|
+
rubygems_version: 3.0.3
|
138
137
|
signing_key:
|
139
138
|
specification_version: 3
|
140
139
|
summary: Not utils... METILS!
|