office_csv 0.1 → 0.2.0
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 +7 -0
- data/lib/office_csv.rb +9 -7
- metadata +38 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cbfe6dce469f97fb9b767dd98eab3eb14809e391
|
4
|
+
data.tar.gz: d7346871a76abc1e8a0d8bfaeba7683c39cd3725
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e85ca926e3adde3167a90ba8013388139219412eaf0e1b068588a43543b93e1841f1dc2e522d1b57739b283735d7d423f9914490f4afb3e7063496581576d68
|
7
|
+
data.tar.gz: 1d11c4f1648d6798bb10e6c683a3ed279db44d79af0d49e0410b5a013dc171ecdf6da71c9b78ce90b7724b2c5a080efef2ff6c84944ef685104d09bcbb575ae1
|
data/lib/office_csv.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
require '
|
1
|
+
require 'csv'
|
2
2
|
require 'iconv'
|
3
3
|
|
4
4
|
class OfficeCSV
|
5
|
-
|
5
|
+
BOM = [0xff, 0xfe].pack('C*').force_encoding('UTF-16LE')
|
6
|
+
|
7
|
+
# Works just like CSV.generate. It adds a byte order mark to the beginning of the document and
|
6
8
|
# converts the contents from UTF-8 to UTF-16LE.
|
7
9
|
def self.generate(&block)
|
8
|
-
|
9
|
-
|
10
|
+
BOM + Iconv.iconv('UTF-16LE', 'UTF-8',
|
11
|
+
CSV.generate(:col_sep => "\t", &block)
|
10
12
|
).join
|
11
13
|
end
|
12
14
|
|
13
|
-
# Just like
|
15
|
+
# Just like CSV.parse. It removes the byte order mark and transcodes from UTF-16LE to UTF-8.
|
14
16
|
def self.parse(csv)
|
15
|
-
|
17
|
+
CSV.parse(Iconv.iconv('UTF-8', 'UTF-16LE', csv).first[1..-1], :col_sep => "\t")
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,65 +1,62 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: office_csv
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Manfred Stienstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: iconv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
21
24
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
24
|
-
|
25
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: |2
|
28
|
+
Tiny wrapper around FasterCSV to create CSV which is read properly by Microsoft Office.
|
26
29
|
email: manfred@fngtps.com
|
27
30
|
executables: []
|
28
|
-
|
29
31
|
extensions: []
|
30
|
-
|
31
|
-
extra_rdoc_files:
|
32
|
+
extra_rdoc_files:
|
32
33
|
- LICENSE
|
33
|
-
files:
|
34
|
+
files:
|
34
35
|
- LICENSE
|
35
36
|
- lib/office_csv.rb
|
36
|
-
has_rdoc: true
|
37
37
|
homepage:
|
38
38
|
licenses: []
|
39
|
-
|
39
|
+
metadata: {}
|
40
40
|
post_install_message:
|
41
|
-
rdoc_options:
|
42
|
-
- --charset=utf-8
|
43
|
-
require_paths:
|
41
|
+
rdoc_options:
|
42
|
+
- "--charset=utf-8"
|
43
|
+
require_paths:
|
44
44
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
47
|
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
|
51
|
-
|
52
|
-
requirements:
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
53
52
|
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
version:
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
57
55
|
requirements: []
|
58
|
-
|
59
56
|
rubyforge_project:
|
60
|
-
rubygems_version:
|
57
|
+
rubygems_version: 2.2.0
|
61
58
|
signing_key:
|
62
|
-
specification_version:
|
63
|
-
summary: Tiny wrapper around FasterCSV to create CSV which is read properly by Microsoft
|
59
|
+
specification_version: 4
|
60
|
+
summary: Tiny wrapper around FasterCSV to create CSV which is read properly by Microsoft
|
61
|
+
Office.
|
64
62
|
test_files: []
|
65
|
-
|