data_miner 2.3.1 → 2.3.2

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2.3.2 / 2012-06-25
2
+
3
+ * Bug fixes
4
+
5
+ * Make sure 't', 'true', 1, '1', 'on', 'yes', etc. are treated as true for boolean columns (and 'f', 'false', 'FALSE', etc.)
6
+
1
7
  2.3.1 / 2012-06-22
2
8
 
3
9
  * Bug fixes
@@ -64,6 +64,10 @@ class DataMiner
64
64
  DEFAULT_UPCASE = false
65
65
  DEFAULT_OVERWRITE = true
66
66
 
67
+ # activerecord-3.2.6/lib/active_record/connection_adapters/column.rb
68
+ TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES', 'y', 'Y']
69
+ FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO', 'n', 'N']
70
+
67
71
  # @private
68
72
  attr_reader :step
69
73
 
@@ -261,6 +265,15 @@ class DataMiner
261
265
  return value
262
266
  end
263
267
  value = value.to_s
268
+ if boolean_column?
269
+ if TRUE_VALUES.include?(value)
270
+ return true
271
+ elsif FALSE_VALUES.include?(value)
272
+ return false
273
+ else
274
+ return
275
+ end
276
+ end
264
277
  if number_column?
265
278
  period_position = value.rindex '.'
266
279
  comma_position = value.rindex ','
@@ -330,15 +343,18 @@ class DataMiner
330
343
  end
331
344
 
332
345
  def text_column?
333
- return @text_column_query.first if @text_column_query.is_a?(Array)
334
- @text_column_query = [model.columns_hash[name.to_s].text?]
335
- @text_column_query.first
346
+ return @text_column_boolean if defined?(@text_column_boolean)
347
+ @text_column_boolean = model.columns_hash[name.to_s].text?
336
348
  end
337
349
 
338
350
  def number_column?
339
- return @number_column_query.first if @number_column_query.is_a?(Array)
340
- @number_column_query = [model.columns_hash[name.to_s].number?]
341
- @number_column_query.first
351
+ return @number_column_boolean if defined?(@number_column_boolean)
352
+ @number_column_boolean = model.columns_hash[name.to_s].number?
353
+ end
354
+
355
+ def boolean_column?
356
+ return @boolean_column_boolean if defined?(@boolean_column_boolean)
357
+ @boolean_column_boolean = (model.columns_hash[name.to_s].type == :boolean)
342
358
  end
343
359
 
344
360
  def static?
@@ -1,3 +1,3 @@
1
1
  class DataMiner
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_miner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-22 00:00:00.000000000 Z
14
+ date: 2012-06-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: aasm