mymatrix 0.0.9 → 0.1.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.
@@ -15,14 +15,14 @@ class LoaderCsv < FileIO
15
15
  else
16
16
  #1.9以上の場合
17
17
  require 'csv'
18
- Encoding.default_external = opts[:encode]
18
+ #Encoding.default_external = opts[:encode]
19
19
  csv = CSV
20
20
  end
21
21
  out = []
22
22
  i= 0
23
23
  syspath = self.encodePath(file)
24
- csv.foreach(syspath, {:row_sep => "\r\n", :encoding => opts[:encode]}) do |row|
25
- p row
24
+ #csv.foreach(syspath, {:row_sep => "\r\n", :encoding => opts[:encode]}) do |row|
25
+ csv.foreach(syspath, {:encoding => opts[:encode]}) do |row|
26
26
  if(opts[:offset])
27
27
  if(opts[:offset] < i)
28
28
  next
@@ -33,7 +33,8 @@ class LoaderCsv < FileIO
33
33
  row.each do |cell|
34
34
  cell = cell.to_s
35
35
  cell ||= ''
36
- cell = MyMatrix.toutf8(cell)
36
+ p cell
37
+ #cell = MyMatrix.toutf8(cell)
37
38
  #cell = cell.gsub(/^\"/, "")
38
39
  #cell = cell.gsub(/\"$/, "")
39
40
  #"
@@ -15,7 +15,7 @@ class LoaderTxt < FileIO
15
15
  end
16
16
  end
17
17
  path = self.encodePath(file)
18
- fi = open(path, "r:#{opts[:file_encode]}")
18
+ fi = open(path, "r:#{opts[:encode]}")
19
19
  if(opts[:offset])
20
20
  opts[:offset].times do |i|
21
21
  fi.gets
@@ -1,3 +1,3 @@
1
1
  class MyMatrix
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
Binary file
@@ -1,3 +1,2 @@
1
1
  a,b,c
2
- ,�ޗ�,���
3
- "�_�u��""�N�I�[�e�[�V����","�J��,�}",aaa
2
+ ,奈良,大阪
@@ -99,8 +99,12 @@ describe MyMatrix do
99
99
  mx[1][0].should == 'ダブル"クオーテーション'
100
100
  mx[1][1].should == 'カン,マ'
101
101
  mx[1][2].should == 'aaa'
102
-
103
-
102
+ end
103
+ it 'UTF-8形式のcsvファイルが読めること' do
104
+ mx = makecsv_utf
105
+ mx[0][0].should == ''
106
+ mx[0][2].should == '大阪'
107
+ mx.val(mx[0], 'b').should == '奈良'
104
108
  end
105
109
  it 'tsvファイルを読めること' do
106
110
  mx = MyMatrix.new('spec/jptest.txt')
@@ -338,6 +342,15 @@ def makecsv
338
342
  mx = MyMatrix.new('spec/csv.csv')
339
343
  return mx
340
344
  end
345
+ def makecsv_utf
346
+ open('spec/csv.csv', 'w') do |fo|
347
+ fo.write("a,b,c\r\n")
348
+ fo.write(',奈良,大阪')
349
+ fo.write("\r\n")
350
+ end
351
+ mx = MyMatrix.new('spec/csv.csv', :encode => 'utf-8')
352
+ return mx
353
+ end
341
354
  def makecsv_norow
342
355
  open('spec/csv.csv', 'w') do |fo|
343
356
  fo.write("a,b,c\r\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mymatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -82,6 +82,7 @@ files:
82
82
  - pkg/mymatrix-0.0.4.gem
83
83
  - pkg/mymatrix-0.0.5.gem
84
84
  - pkg/mymatrix-0.0.8.gem
85
+ - pkg/mymatrix-0.0.9.gem
85
86
  - spec/csv.csv
86
87
  - spec/csv.csv.txt
87
88
  - spec/csv_test.csv