rbbt-util 5.21.89 → 5.21.90
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/etc/app.d/entities.rb +2 -2
- data/lib/rbbt/entity.rb +2 -3
- data/lib/rbbt/tsv/excel.rb +3 -1
- data/lib/rbbt/util/misc/indiferent_hash.rb +0 -1
- data/lib/rbbt/util/misc/inspect.rb +17 -0
- data/test/rbbt/util/test_misc.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e68de8ec56241c9fbc4bceed94f7c632a859c930
|
4
|
+
data.tar.gz: 3e4caace384777f8e4ecce35d89c003be40354fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29df479899b22d4577a28714247a80102836b4a63cd97548e3432d3d9cbcf469b13e3211c757ff4f83940e73f8a96696fa9779c0a5b9e43e8272f95b9738d926
|
7
|
+
data.tar.gz: a89236195f0add1240259fac4627a5e51e5808b73548f8d279586e3390688ef0aafc9e1d288f0704e68febbaf48a4159a6f3e86fbf875e836e320b12cccc3fe9
|
data/etc/app.d/entities.rb
CHANGED
@@ -28,9 +28,9 @@ $annotation_repo = Rbbt.var.sinatra.annotation_repo.find
|
|
28
28
|
|
29
29
|
Log.debug("Persist #{name} #{prop}: #{[type, repo].compact * ", "}")
|
30
30
|
if repo == 'repo'
|
31
|
-
|
31
|
+
options = {:annotation_repo => $annotation_repo}
|
32
32
|
else
|
33
|
-
|
33
|
+
options = {}
|
34
34
|
end
|
35
35
|
persist prop, type, options
|
36
36
|
end
|
data/lib/rbbt/entity.rb
CHANGED
@@ -196,11 +196,10 @@ module Entity
|
|
196
196
|
|
197
197
|
define_method method_name do |*args|
|
198
198
|
id = self.id
|
199
|
-
persist_name = __method__.to_s << ":" << (Array === id ? Misc.
|
200
|
-
persist_name << ":" << Misc.hash2md5({:args => args}) unless args.nil? or args.empty?
|
199
|
+
persist_name = __method__.to_s << ":" << (Array === id ? Misc.obj2digest(id) : id)
|
201
200
|
|
202
201
|
persist_options = options
|
203
|
-
persist_options = persist_options.merge(:other => {:args => args}) if args.any?
|
202
|
+
persist_options = persist_options.merge(:other => {:args => args}) if args and args.any?
|
204
203
|
|
205
204
|
Persist.persist(persist_name, type, persist_options.merge(:persist => true)) do
|
206
205
|
self.send(orig_name, *args)
|
data/lib/rbbt/tsv/excel.rb
CHANGED
@@ -151,6 +151,8 @@ module TSV
|
|
151
151
|
sheet = Misc.process_options options, :sheet
|
152
152
|
header = Misc.process_options options, :header
|
153
153
|
|
154
|
+
iii options
|
155
|
+
iii sheet
|
154
156
|
header = true unless header == false
|
155
157
|
TmpFile.with_file do |filename|
|
156
158
|
workbook = RubyXL::Parser.parse file
|
@@ -248,7 +250,7 @@ module TSV
|
|
248
250
|
end
|
249
251
|
|
250
252
|
def self.excel2tsv(filename, options ={})
|
251
|
-
excel(filename, options
|
253
|
+
excel(filename, options)
|
252
254
|
end
|
253
255
|
|
254
256
|
end
|
@@ -2,6 +2,23 @@ module Misc
|
|
2
2
|
ARRAY_MAX_LENGTH = 1000
|
3
3
|
STRING_MAX_LENGTH = ARRAY_MAX_LENGTH * 10
|
4
4
|
|
5
|
+
def self.break_lines(text, char_size=80)
|
6
|
+
text = text.gsub("\n", " ")
|
7
|
+
lines = []
|
8
|
+
line = []
|
9
|
+
text.split(/([\s\-]+)/).each do |part|
|
10
|
+
if line.join("").length + part.length > char_size
|
11
|
+
lines << line * ""
|
12
|
+
line = []
|
13
|
+
end
|
14
|
+
line << part
|
15
|
+
end
|
16
|
+
|
17
|
+
lines << line * ""
|
18
|
+
|
19
|
+
lines.flatten.collect{|l| l.strip} * "\n"
|
20
|
+
end
|
21
|
+
|
5
22
|
def self.name2basename(file)
|
6
23
|
sanitize_filename(file.gsub("/",'>').gsub("~", '-'))
|
7
24
|
end
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -551,4 +551,10 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
551
551
|
Log.debug "Hola #{[p.first.inspect, p.last.inspect] * "=>"}"
|
552
552
|
end
|
553
553
|
end
|
554
|
+
|
555
|
+
def test_sanitize_filename
|
556
|
+
text = "This is a very long line that needs to be split in several lines"
|
557
|
+
assert Misc.break_lines(text, 10).split("\n").length == 1 + text.length / 10
|
558
|
+
assert Misc.break_lines(text, 10).split("\n").select{|l| l.length > 10 }.empty?
|
559
|
+
end
|
554
560
|
end
|
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.21.
|
4
|
+
version: 5.21.90
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|