csv_orm 0.2.6 → 0.2.7

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: 730c15e2c0eb324df47f44eb149c2b4eedcffef7
4
- data.tar.gz: 8d49682cc8005439eaed2b5aeb0cbf12cb267a15
3
+ metadata.gz: e7a427fb5a76f952bc2ad8553ce3f68d104d43e6
4
+ data.tar.gz: ef90e333cb90a21f8215869ac33fe05865d3b2ff
5
5
  SHA512:
6
- metadata.gz: b33af817e446782e7e048ee6a27b77b9f71f7a64e0ea2df2b46c4f90a10da2809f820de55e14e6f3c7ab0db73d2e8d72bc4f0672195ef703f9bf332ed6c0bef0
7
- data.tar.gz: 2c3002a5499dd6b2eb2e6ce132c07f6f065d9bae7c129e94781e7bc4705b66103fdf959133adf7496bfaebf8ea2993126ac05c5344a2b227899bfd0cf08f752e
6
+ metadata.gz: 394884fda2f5412dd9d07b237bbd447c6210a9fb5925658a3f3445a20f34fe3aff7fe49748df9758f3756579296ca98ff7e7ee07fdaf1efd55583633a46fa324
7
+ data.tar.gz: 051c764a106e287f8c191c4a393f2002977685dd9f4a843ac6d777aa490a602a4b47f90113aa5103cf168b0f061d8dcc53652898fa69fd0fd14028823c79fb7f
@@ -38,13 +38,18 @@ module CsvOrm
38
38
  return field.to_s unless @smart
39
39
 
40
40
  # integers are almost certainly not meant to be time. probably will have to address this at some point.
41
- return field if field.is_a?(Numeric)
42
-
41
+ return field if confidence_in_numeric?(field)
42
+
43
43
  date = DateTime.parse(field) rescue nil
44
44
  if date
45
45
  return date.to_time.to_i
46
46
  end
47
47
  field.to_s
48
48
  end
49
+
50
+ def confidence_in_numeric?(string)
51
+ return true if string =~ /\A\d+\Z/
52
+ true if Float(string) rescue false
53
+ end
49
54
  end
50
55
  end
@@ -1,3 +1,3 @@
1
1
  module CsvOrm
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_orm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Lerner