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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5a5ab8b4aa58bad54d6716b49419cb715c6a161
4
- data.tar.gz: 1dc0a78f1cb2b47a885f606a48e7c629fa415508
3
+ metadata.gz: e68de8ec56241c9fbc4bceed94f7c632a859c930
4
+ data.tar.gz: 3e4caace384777f8e4ecce35d89c003be40354fc
5
5
  SHA512:
6
- metadata.gz: 2806f19bd8a01092da0aeb63064cb666c61fbdc298b741182c2f649cee70189d7da202cbfd0bf3c9d8d990b5ac70722cbe88cedc3bf9dc7a2812f695618aaf8e
7
- data.tar.gz: 6673c36664b4674c1efed59f72b17cdcb0fa4c6cebf2be84bbbb25e158a90b2fdfce34bcc037b3493abee9ce7d9783605752b0f12ec5e51be531f92caf66dc40
6
+ metadata.gz: 29df479899b22d4577a28714247a80102836b4a63cd97548e3432d3d9cbcf469b13e3211c757ff4f83940e73f8a96696fa9779c0a5b9e43e8272f95b9738d926
7
+ data.tar.gz: a89236195f0add1240259fac4627a5e51e5808b73548f8d279586e3390688ef0aafc9e1d288f0704e68febbaf48a4159a6f3e86fbf875e836e320b12cccc3fe9
@@ -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
- options = {:annotation_repo => $annotation_repo}
31
+ options = {:annotation_repo => $annotation_repo}
32
32
  else
33
- options = {}
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.hash2md5(:id => id) : id)
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)
@@ -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
@@ -8,7 +8,6 @@ module IndiferentHash
8
8
  new = self.dup
9
9
  IndiferentHash.setup(new)
10
10
  other.each do |k,value|
11
- new.delete k
12
11
  new[k] = value
13
12
  end
14
13
  new
@@ -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
@@ -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.89
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-06-28 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake