csv_builder 0.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/lib/transliterating_filter.rb +22 -0
- metadata +3 -2
data/CHANGELOG.rdoc
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
class TransliteratingFilter
|
2
|
+
# Transliterate into the required encoding if necessary
|
3
|
+
# TODO: make defaults configurable
|
4
|
+
def initialize(faster_csv, input_encoding = 'UTF-8', output_encoding = 'LATIN1')
|
5
|
+
@faster_csv = faster_csv
|
6
|
+
|
7
|
+
# TODO: do some checking to make sure iconv works correctly in
|
8
|
+
# current environment. See ActiveSupport::Inflector#transliterate
|
9
|
+
# definition for details
|
10
|
+
#
|
11
|
+
# Not using the more standard //IGNORE//TRANSLIT because it raises
|
12
|
+
# Iconv::IllegalSequence for some inputs
|
13
|
+
@iconv = Iconv.new("#{output_encoding}//TRANSLIT//IGNORE", input_encoding) if input_encoding != output_encoding
|
14
|
+
end
|
15
|
+
|
16
|
+
# Transliterate before passing to FasterCSV so that the right characters (e.g. quotes) get escaped
|
17
|
+
def <<(row)
|
18
|
+
@faster_csv << if @iconv then row.map { |value| @iconv.iconv(value.to_s) } else row end
|
19
|
+
end
|
20
|
+
|
21
|
+
alias :add_row :<<
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Econsultancy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-29 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- rails/init.rb
|
41
41
|
- lib/csv_builder.rb
|
42
|
+
- lib/transliterating_filter.rb
|
42
43
|
has_rdoc: true
|
43
44
|
homepage: http://github.com/dasil003/csv_builder
|
44
45
|
licenses: []
|