excelinator 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -112,8 +112,10 @@ I did, and I apologize. Lemme know when your pull request is ready.
112
112
 
113
113
  ###Are there any options to re-use CSV/HTML views with No additional controller/view code?
114
114
 
115
- I've tinkered with it, but it requires a bit of duck punching of the Rails
116
- rendering code.
115
+ I've tinkered with it, but it requires a bit of duck punching of the
116
+ Rails rendering code. Checkout
117
+ [exceliderp](https://github.com/chrismo/exceliderp) and see if I've
118
+ pushed it up there yet.
117
119
 
118
120
  ###What if I want to generate a real Excel spreadsheet from scratch with all sorts of awesome in it?
119
121
 
@@ -144,3 +146,9 @@ XMLDoc.
144
146
 
145
147
  They're not all supposed to work. Think of it more as a workshop for example
146
148
  code.
149
+
150
+ CHANGELOG
151
+ ---------
152
+ ####1.1.0
153
+
154
+ Added Ruby 1.9 support.
@@ -2,7 +2,16 @@ require 'excelinator/xls'
2
2
  require 'excelinator/rails'
3
3
  require 'excelinator/version'
4
4
  require 'spreadsheet'
5
- require 'fastercsv'
5
+
6
+ def ruby19?
7
+ RUBY_VERSION =~ /1.9/
8
+ end
9
+
10
+ if ruby19?
11
+ require 'csv'
12
+ else
13
+ require 'fastercsv'
14
+ end
6
15
 
7
16
  if defined?(Rails)
8
17
  Excelinator::Rails.setup
@@ -1,3 +1,3 @@
1
1
  module Excelinator
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -7,8 +7,9 @@ module Excelinator
7
7
  content =~ /<table/ ? Excelinator.html_as_xls(content) : Excelinator.csv_to_xls(content)
8
8
  end
9
9
 
10
- def self.csv_to_xls(csv_content)
11
- ary = FasterCSV.parse(csv_content)
10
+ def self.csv_to_xls(csv_content)
11
+ ary = (ruby19? ? CSV : FasterCSV).parse(csv_content)
12
+
12
13
  book = Spreadsheet::Workbook.new
13
14
  sheet = book.create_worksheet
14
15
  ary.each_with_index do |row_ary, index|
@@ -32,7 +33,7 @@ module Excelinator
32
33
  # If you don't have need of utf-8 encoding, or want to prepend that yourself, there's no need to use this method.
33
34
  def self.html_as_xls(html_content, options={})
34
35
  encoding_meta_tag = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
35
- encoding_meta_tag + (options.delete(:do_not_strip) ? html_content : html_content.scan(/<table.*\/table>/mi).to_s)
36
+ encoding_meta_tag + (options.delete(:do_not_strip) ? html_content : html_content.scan(/<table.*\/table>/mi).join)
36
37
  end
37
38
 
38
39
  # def self.html_to_xls might be nice to do - convert html table to _real_ xls file
metadata CHANGED
@@ -1,26 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excelinator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - chrismo
14
+ - jwhitmire
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2012-08-03 00:00:00 -05:00
19
- default_executable:
19
+ date: 2012-12-12 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: spreadsheet
23
- prerelease: false
24
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
@@ -34,9 +33,9 @@ dependencies:
34
33
  version: 0.6.8
35
34
  type: :runtime
36
35
  requirement: *id001
36
+ prerelease: false
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: fastercsv
39
- prerelease: false
40
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
@@ -48,9 +47,9 @@ dependencies:
48
47
  version: "0"
49
48
  type: :runtime
50
49
  requirement: *id002
50
+ prerelease: false
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rake
53
- prerelease: false
54
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
@@ -62,9 +61,9 @@ dependencies:
62
61
  version: "0"
63
62
  type: :development
64
63
  requirement: *id003
64
+ prerelease: false
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: rspec
67
- prerelease: false
68
67
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
68
  none: false
70
69
  requirements:
@@ -76,9 +75,11 @@ dependencies:
76
75
  version: "0"
77
76
  type: :development
78
77
  requirement: *id004
78
+ prerelease: false
79
79
  description: convert your csv data and html tables to excel data
80
80
  email:
81
81
  - chrismo@clabs.org
82
+ - jeff@jwhitmire.com
82
83
  executables: []
83
84
 
84
85
  extensions: []
@@ -91,7 +92,6 @@ files:
91
92
  - lib/excelinator/rails.rb
92
93
  - lib/excelinator/version.rb
93
94
  - lib/excelinator/xls.rb
94
- has_rdoc: true
95
95
  homepage: https://github.com/livingsocial/excelinator
96
96
  licenses: []
97
97
 
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements: []
122
122
 
123
123
  rubyforge_project:
124
- rubygems_version: 1.6.2
124
+ rubygems_version: 1.8.24
125
125
  signing_key:
126
126
  specification_version: 3
127
127
  summary: Excel Converter