GFunk911-dataload 0.9.0 → 0.9.1

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 9
@@ -20,8 +20,14 @@ class TableLoaderDSL
20
20
  master.add(self)
21
21
  end
22
22
  def column(name,type,&blk)
23
- blk ||= lambda { |x| x.send(name) }
24
- loader.columns << Column.new(:target_name => name, :blk => blk)
23
+ real_name = name
24
+ if name.is_a?(Hash)
25
+ raise "block given with hash" if block_given?
26
+ blk = lambda { |x| x.send(name.values.first) }
27
+ real_name = name.keys.first
28
+ end
29
+ blk ||= lambda { |x| x.send(real_name) }
30
+ loader.columns << Column.new(:target_name => real_name, :blk => blk)
25
31
  end
26
32
  def method_missing(sym,*args,&b)
27
33
  if [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].include?(sym)
@@ -1,6 +1,6 @@
1
1
  class FasterCSV::Row
2
2
  def method_missing(sym,*args,&b)
3
- if self[sym.to_s]
3
+ if self[sym.to_s] or include?(sym.to_s)
4
4
  self[sym.to_s].safe_to_num
5
5
  else
6
6
  super(sym,*args,&b)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: GFunk911-dataload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Harris
@@ -66,6 +66,7 @@ files:
66
66
  - lib/dataload/table_module.rb
67
67
  - lib/dataload.rb
68
68
  - samples/sample.rb
69
+ - samples/sample2.rb
69
70
  - samples/tables.rb
70
71
  - spec/dataload_spec.rb
71
72
  - spec/spec_helper.rb