datashift 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ Jeweler::Tasks.new do |gem|
31
31
  gem.homepage = "http://github.com/autotelik/datashift"
32
32
  gem.license = "MIT"
33
33
  gem.summary = %Q{ Shift data betwen Excel/CSV and any Ruby app}
34
- gem.description = %Q{ Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby projec.}
34
+ gem.description = %Q{Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby project.}
35
35
  gem.email = "rubygems@autotelik.co.uk"
36
36
  gem.authors = ["Thomas Statter"]
37
37
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.10.1
data/datashift.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "datashift"
8
- s.version = "0.10.0"
8
+ s.version = "0.10.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Statter"]
12
12
  s.date = "2012-09-25"
13
- s.description = " Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby projec."
13
+ s.description = "Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby project."
14
14
  s.email = "rubygems@autotelik.co.uk"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -33,7 +33,7 @@ if(DataShift::Guards::jruby?)
33
33
  end
34
34
 
35
35
  def []=( column, value )
36
- get_or_create_cell(column, value).setCellValue((value.to_s || ""))
36
+ get_or_create_cell(column, value).setCellValue( poi_cell_value(value) )
37
37
  end
38
38
 
39
39
  def get_or_create_cell( column, value = nil )
@@ -30,9 +30,7 @@ module ExcelBase
30
30
  end
31
31
 
32
32
  records.each do |record|
33
- create_row(row_index)
34
-
35
- ar_to_xls_row(0, record)
33
+ ar_to_xls_row(row_index, 0, record)
36
34
 
37
35
  row_index += 1
38
36
  end
@@ -179,7 +179,7 @@ if(DataShift::Guards::jruby?)
179
179
  def set_cell(row, column, value)
180
180
  @row = row(row)
181
181
 
182
- @row.get_or_create_cell(column, value).setCellValue((value || ""))
182
+ @row[column] = value
183
183
  end
184
184
 
185
185
  def write( filename = nil )
@@ -44,11 +44,26 @@ if(DataShift::Guards::jruby?)
44
44
  end
45
45
  end
46
46
 
47
- # Return the suitable type for a HSSFCell from a Ruby data type
48
47
 
48
+ # Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA,
49
+ # Cell.CELL_TYPE_BLANK, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR
50
+
51
+ # TODO - properly
52
+ def poi_cell_value(data)
53
+ case(data)
54
+ when BigDecimal
55
+ data.to_f
56
+ when Numeric, TrueClass, FalseClass
57
+ data
58
+ else
59
+ data.to_s
60
+ end
61
+ end
62
+
63
+ # Return the suitable type for a HSSFCell from a Ruby data type
49
64
  def poi_cell_type(data)
50
65
 
51
- if(data.kind_of?(Numeric))
66
+ if(data.is_a?(Numeric))
52
67
  HSSFCell::CELL_TYPE_NUMERIC
53
68
  elsif(data.nil?)
54
69
  HSSFCell::CELL_TYPE_BLANK
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: datashift
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.0
5
+ version: 0.10.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Statter
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: "0"
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
- description: " Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby projec."
37
+ description: Comprehensive tools to import/export between Excel/CSV and ActiveRecord databases, Rails apps, and any Ruby project.
38
38
  email: rubygems@autotelik.co.uk
39
39
  executables: []
40
40