data_tables 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGI0NDY4ZTExOTU0MmI0NmUzYzEwNWQzYzZmYzliZWI1ODVkM2I1MA==
4
+ ZTg0MjU2ZmY4MjlmY2JjOTQwZDVkYjQ3YTRmNDBmNWM3ZDcwMzUyMg==
5
5
  data.tar.gz: !binary |-
6
- MGFiMzQ1NjBkMjAyZDcyMzcxNWQ3MWNjNTc3NWUxNDcwNWIyYTQxMg==
6
+ MGNkMTc2Mjg2NDNhMTMzYWEwNTc4NDJkNTVlNjNmMTNiZGYyZTU3ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWFkNTE1ZmY5NzVhMWYyYjkwZTEwZjY1MzYzYjk1YWMxMDRhMzRmNDg2MTli
10
- Yjg1NGU1YThlOGJlYjMzODI3NWIzZmUzMDE4ODQyNDUwZDYzYTM1ZThmNjlj
11
- NGNiYjM1ZGExOTdlY2YwYzc5NzM0ODlhZDU1NjI1MzdkNDIzNzQ=
9
+ NjczMWUzZTc4NDNkZmE2MjRlNjViNWVlMDZjZDBhZmMyNmMwY2Q4YTUxZWFm
10
+ OTU2OWFmNTAxNGNjOWU2NjJmMmM3YWJjODNjZTc2ZmQ3YmVjODU0Yjc0Nzlj
11
+ ZWNhNDlhYzAzYTU4NDE5ZWY0MzJmYjYyYmM1MGJjNzZmNDdiNzc=
12
12
  data.tar.gz: !binary |-
13
- YzNjOTRjNmMzNmY3NGE2MzI4ZTU5M2I4MjFjZGVjZDY3NDU0YTkzMDRhNTYz
14
- ZjBlY2ZmZDI2Nzg5NjY5NmZkYzU5NDQzYzhkOTEyMGU2YjY3NmFlNDZiNzYw
15
- Y2U0NjA1ZmUwYWU3YzFmMTc4M2RhOTA4MDA0OTUxZWE3YzE5Yjk=
13
+ MThiNjRlMzg1MGU2Yjg1MjU1ZDllYTM2MGM4OTA5NmVkMmM0OWZkNzIyODg3
14
+ ZDY5OWE4MmUyMDNjOGMxYjZlZWI5ZGE4NTNiZTA3YzM3N2U0ZjAyNGUzODY5
15
+ NjM5NWJlZjlhNzUzNGZmZDY5NzhhYTVhMTM0OTRkODk0NDY2Zjc=
data/data_tables.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'data_tables'
5
- s.version = '0.1.25'
5
+ s.version = '0.1.26'
6
6
  s.date = Time.now.strftime("%Y-%m-%d")
7
7
  s.summary = "Rails friendly interface into DataTables"
8
8
  s.description = "DataTables for Rails"
data/lib/data_tables.rb CHANGED
@@ -402,24 +402,46 @@ module DataTablesController
402
402
  # gets the value for a column and row
403
403
  def datatables_instance_get_value(instance, column)
404
404
  if column[:special]
405
- special = column[:special]
406
-
407
- if special[:method]
408
- return method(special[:method].to_sym).call(instance)
409
- elsif special[:eval]
410
- proc = lambda { obj = instance; binding }
411
- return Kernel.eval(special[:eval], proc.call)
412
- end
405
+ get_instance_special_value(instance, column[:special])
413
406
  elsif column[:attribute]
414
- val = instance.send(column[:attribute].to_sym)
415
- if !val.blank? || val == false
416
- trans = I18n.t(val.to_s.to_sym, :default => val.to_s)
417
- return trans.class == String ? trans : val.to_s
418
- else
419
- return ''
407
+ begin
408
+ get_instance_value(instance.send("#{column[:attribute]}"))
409
+ rescue ArgumentError => error
410
+ handle_argument_error(error, instance, column)
420
411
  end
412
+ else
413
+ return "value not found"
414
+ end
415
+ end
416
+
417
+ def get_instance_special_value(instance, special)
418
+ if special[:method]
419
+ return method(special[:method].to_sym).call(instance)
420
+ elsif special[:eval]
421
+ proc = lambda { obj = instance; binding }
422
+ return Kernel.eval(special[:eval], proc.call)
423
+ end
424
+ end
425
+
426
+ def get_instance_value(value)
427
+ if !value.blank? || value == false
428
+ trans = I18n.t(value.to_s.to_sym, :default => value.to_s)
429
+ return trans.class == String ? trans : value.to_s
430
+ else
431
+ return ''
432
+ end
433
+ end
434
+
435
+ def handle_argument_error(error, instance, column)
436
+ if error.message.include? "UTF-8"
437
+ invalid_sequence = instance.send("#{column[:attribute]}").bytes.to_a
438
+ logger.warn("[datatables] Error: #{instance.class.name} for "+
439
+ "id #{instance.id}, column #{column[:attribute]}: " +
440
+ "Invalid UTF8 sequence is [#{invalid_sequence.join(", ")}]")
441
+ return ''
442
+ else
443
+ raise
421
444
  end
422
- return "value not found"
423
445
  end
424
446
 
425
447
  def datatable_source(name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duane Compton
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-04-24 00:00:00.000000000 Z
15
+ date: 2015-11-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec