rbbt-util 5.34.13 → 5.34.14
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/lib/rbbt/resource.rb +4 -0
- data/lib/rbbt/tsv/csv.rb +3 -1
- data/lib/rbbt/tsv/excel.rb +2 -2
- data/lib/rbbt/util/misc/development.rb +10 -0
- data/lib/rbbt/util/misc.rb +4 -1
- data/lib/rbbt/util/open.rb +5 -4
- data/lib/rbbt/workflow/step/accessor.rb +1 -1
- data/share/Rlib/plot.R +6 -0
- data/share/Rlib/util.R +1 -1
- data/test/rbbt/util/test_misc.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e50428f936aab209874c5f26e7504aa14da9a30bc7e2b13575432527a5b6a4
|
4
|
+
data.tar.gz: e522b76bb910b477e303e2cfc323c8708fa4d3bbecc0a7c46de473fe81f1ef6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e73a4ceda5eca11497ea4f0fe91fda7275375aaf8aeb6f9f70a45a46d4c71022527d7cd32c0cb30700a6bc2724bd1e2d2e0bd808a553ee3c8d6e729baa1dc2c0
|
7
|
+
data.tar.gz: a050c5defff3e3d36fe5682c117802d54cfeb930e3e61ff96da29e326719bf97af6fe85b5c30812dd91c5c6a447201164c15a3e1714aa1226690a0c49782ba9a
|
data/lib/rbbt/resource.rb
CHANGED
@@ -204,6 +204,10 @@ module Resource
|
|
204
204
|
case type
|
205
205
|
when :string
|
206
206
|
Misc.sensiblewrite(final_path, content)
|
207
|
+
when :csv
|
208
|
+
require 'rbbt/tsv/csv'
|
209
|
+
tsv = TSV.csv Open.open(content)
|
210
|
+
Misc.sensiblewrite(final_path, tsv.to_s)
|
207
211
|
when :url
|
208
212
|
options = {}
|
209
213
|
options[:noz] = true if Open.gzip?(final_path) || Open.bgzip?(final_path) || Open.zip?(final_path)
|
data/lib/rbbt/tsv/csv.rb
CHANGED
data/lib/rbbt/tsv/excel.rb
CHANGED
@@ -266,7 +266,7 @@ module TSV
|
|
266
266
|
|
267
267
|
def self.xls(filename, options ={})
|
268
268
|
if Open.remote? filename
|
269
|
-
TmpFile.with_file do |tmp|
|
269
|
+
TmpFile.with_file nil, :extension => 'xls' do |tmp|
|
270
270
|
Open.download(filename, tmp)
|
271
271
|
TSV::XLS.read(tmp, options)
|
272
272
|
end
|
@@ -278,7 +278,7 @@ module TSV
|
|
278
278
|
def self.xlsx(filename, options ={})
|
279
279
|
if Open.remote? filename
|
280
280
|
|
281
|
-
TmpFile.with_file do |tmp|
|
281
|
+
TmpFile.with_file nil, :extension => 'xlsx' do |tmp|
|
282
282
|
Open.download(filename, tmp)
|
283
283
|
TSV::XLSX.read(tmp, options)
|
284
284
|
end
|
@@ -193,6 +193,16 @@ def self.add_libdir(dir=nil)
|
|
193
193
|
insist(3, &block)
|
194
194
|
end
|
195
195
|
|
196
|
+
def self.chunk(array, num)
|
197
|
+
total = array.length
|
198
|
+
current = 0
|
199
|
+
while current < total
|
200
|
+
last = current + num - 1
|
201
|
+
yield array[current..last]
|
202
|
+
current = last + 1
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
196
206
|
# Divides the array into +num+ chunks of the same size by placing one
|
197
207
|
# element in each chunk iteratively.
|
198
208
|
def self.divide(array, num)
|
data/lib/rbbt/util/misc.rb
CHANGED
@@ -71,6 +71,9 @@ module Misc
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.timespan(str, default = "s")
|
74
|
+
|
75
|
+
return - timespan(str[1..-1], default) if str[0] == "-"
|
76
|
+
|
74
77
|
if str.include?(":")
|
75
78
|
seconds, minutes, hours = str.split(":").reverse
|
76
79
|
return seconds.to_i + minutes.to_i * 60 + hours.to_i * 60 * 60
|
@@ -86,7 +89,7 @@ module Misc
|
|
86
89
|
"h" => (60 * 60),
|
87
90
|
"d" => (60 * 60 * 24),
|
88
91
|
"w" => (60 * 60 * 24 * 7),
|
89
|
-
"mo" => (60 * 60 * 24 *
|
92
|
+
"mo" => (60 * 60 * 24 * 31),
|
90
93
|
"y" => (60 * 60 * 24 * 365),
|
91
94
|
}
|
92
95
|
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -640,7 +640,7 @@ module Open
|
|
640
640
|
io
|
641
641
|
end
|
642
642
|
|
643
|
-
def self.
|
643
|
+
def self.download_old(url, file)
|
644
644
|
Open.open(url, :mode => 'rb', :noz => true) do |sin|
|
645
645
|
Open.open(file, :mode => 'wb') do |sout|
|
646
646
|
Misc.consume_stream(sin, false, sout)
|
@@ -648,6 +648,10 @@ module Open
|
|
648
648
|
end
|
649
649
|
end
|
650
650
|
|
651
|
+
def self.download(url, path)
|
652
|
+
Open.wget(url, "--output-document" => path, :pipe => false)
|
653
|
+
end
|
654
|
+
|
651
655
|
def self.can_open?(file)
|
652
656
|
String === file and (Open.exist?(file) or remote?(file))
|
653
657
|
end
|
@@ -841,7 +845,4 @@ module Open
|
|
841
845
|
File.symlink?(path) && ! File.exist?(File.readlink(path))
|
842
846
|
end
|
843
847
|
|
844
|
-
def self.download(url, path)
|
845
|
-
Open.wget(url, "--output-document" => path)
|
846
|
-
end
|
847
848
|
end
|
data/share/Rlib/plot.R
CHANGED
@@ -39,3 +39,9 @@ geom_entity <- function (real.geom = NULL, mapping = NULL, data = NULL, stat = "
|
|
39
39
|
}
|
40
40
|
|
41
41
|
rbbt.ggplot2.rotate_x_labels <- function(){ theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) }
|
42
|
+
|
43
|
+
rbbt.ggplot2.theme <- function(plot){
|
44
|
+
|
45
|
+
plot + theme_classic() + scale_y_continuous(labels=scales::comma) + scale_x_continuous(labels=scales::comma) + rbbt.ggplot2.rotate_x_labels()
|
46
|
+
|
47
|
+
}
|
data/share/Rlib/util.R
CHANGED
@@ -812,7 +812,7 @@ rbbt.plot.text_scatter <- function(formula, data) {
|
|
812
812
|
rbbt.install.CRAN <- function(pkg){
|
813
813
|
cat("Try CRAN install:", pkg, "\n")
|
814
814
|
res = FALSE
|
815
|
-
tryCatch({ install.packages(pkg); library(pkg); res = TRUE; }, error = function(e){ str(e); warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
815
|
+
tryCatch({ install.packages(pkg); library(pkg, character.only=T); res = TRUE; }, error = function(e){ str(e); warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
816
816
|
return(res)
|
817
817
|
}
|
818
818
|
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -610,6 +610,8 @@ EOF
|
|
610
610
|
assert_equal 60*60*24, Misc.timespan('1d')
|
611
611
|
assert_equal 60*60*24, Misc.timespan('1d')
|
612
612
|
assert_equal 60*60*24, Misc.timespan('24:00:00')
|
613
|
+
|
614
|
+
assert_equal Misc.timespan('1min'), - Misc.timespan('-1min')
|
613
615
|
end
|
614
616
|
|
615
617
|
def test_remove_long_items
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.34.
|
4
|
+
version: 5.34.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|