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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c905d2edd9ff4e5738a2a14992e64168ab876049a481a57f03bfec551aa65bbc
4
- data.tar.gz: 81a3dabab5584a115d2a2826e34d681c7a910201b1a13ee58b5b3a9f2129b728
3
+ metadata.gz: 2512c35335e90e398fa2a8e71f7f5fb070edaf73cf52d53c20b1c2af2be5646f
4
+ data.tar.gz: 1db6bbad945aad61174cb71dc2f14e9ed563b048706ec368b83eda1062794294
5
5
  SHA512:
6
- metadata.gz: 6daaa56aeba42a400b2a6e0387fc329e7b95b88a16bae5b704efc2ec956f59d0e0c1580816ea4378441bee7755fc3d1bacb2f7e48f3ac5553b45dcc97330c112
7
- data.tar.gz: 05b6d0bd082e135f2274d3e896c2baab6da7d4ec02bebdb05c3f4a8a05b5cfe342f020985c29efabd4b421968c803afb02ba5349ad23d28ee6ea7acce22a5c0e
6
+ metadata.gz: d4a3a513f9f47637632998d2264a34fa935a5082997139f1637ead91c6f78fc1f5b6502690c2f5fe107685beac3e8909c1a62c87dd14f669f317ab7d1eb93234
7
+ data.tar.gz: 2944e0d81230264af1762c3a8ff439f949c2d79340f2d184061376dd94f2d63d2561d84c36b48312eb7054ed7193cd063fdf94e14ab10e663b2586192a290336
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.118
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
  #
@@ -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
- io = IO.popen([bin, "-d" ,"-c", path])
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: couln't find #{bin.inspect} in the path"
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
- result = yield(io)
835
- io.close
836
- result
837
- else
838
- io
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
 
@@ -137,7 +137,8 @@ module Term
137
137
  return @columns if @columns
138
138
  w = @width
139
139
  w -= indent
140
- (w-2) / (@max_size + @padding)
140
+ cols = (w-2) / (@max_size + @padding)
141
+ cols > 0 ? cols : 1
141
142
  end
142
143
 
143
144
  def num_rows
@@ -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
 
@@ -4,8 +4,8 @@ describe Term do
4
4
 
5
5
  it "sizes" do
6
6
  width, height = Term.size
7
- width.class.should == Fixnum
8
- height.class.should == Fixnum
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 = [ [1,2,3], [4,5,6] ]
46
- table.rows << [1,2,3]
47
- table.rows << [4,5,6]
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.118
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: 2018-12-03 00:00:00.000000000 Z
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
- rubyforge_project:
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!