efo_nelfo 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f9ae41470f7ec5868f8fd94fd888c0d4169b41
4
- data.tar.gz: 14d7f5c2ea9b10a8125b3e89aad2b08d92794041
3
+ metadata.gz: 339fc7d74621d26713c98008d2060452753e3998
4
+ data.tar.gz: 0020dbe4e5129c8890165cf01bae901bcd1373ee
5
5
  SHA512:
6
- metadata.gz: 2c9aa39390094e1565b171f2fb8a42367fe7eec2233e390a75b3804f76e5d0949333e4e43a31ad70347ae19f3b581bbdf7797ea3c8174f7c835da9b41ff1921d
7
- data.tar.gz: 083a82ef15c19943d31594efe997c6e68b07e48e066570d94ed136baefca287485eda6a91041eac4b6540c5936b24084af7058c01ddb15630416e86ffa6e675e
6
+ metadata.gz: 058e13eeccaaf4657c8f58711c3d278ef5190afb1a96b470ed3e38df8242e1b80ddc9ef8482be084012f2e758e1bf27e8270d044808e7c1761cb5b0de20ed873
7
+ data.tar.gz: 2a755cf54f5d2481297513748eb14a944412364ecc2274ff4be40a75b2ed564fa522baff9753045fc27b1f566a7a5265c02e0b65819671796919b9c699579d09
@@ -44,14 +44,17 @@ module EfoNelfo
44
44
  end
45
45
  end
46
46
 
47
+ # Format value for given attribute
47
48
  def formatted_for_csv(attr)
49
+
48
50
  if respond_to?("format_#{attr}")
49
51
  value = send "format_#{attr}"
50
52
  else
51
53
  value = send attr
52
54
 
53
55
  type = properties[attr][:type]
54
- case type
56
+
57
+ value = case type
55
58
  when :date
56
59
  value ? value.strftime("%Y%m%d") : nil
57
60
  when :boolean
@@ -60,6 +63,7 @@ module EfoNelfo
60
63
  value
61
64
  end
62
65
  end
66
+ value.respond_to?(:encode) ? value.encode(Encoding::ISO_8859_1) : value
63
67
  end
64
68
 
65
69
  module ClassMethods
@@ -106,8 +110,7 @@ module EfoNelfo
106
110
  # Creates an attribute setter for name
107
111
  def create_setter_for(name, options)
108
112
  define_method "#{name}=" do |value|
109
- encoded_value = value.respond_to?(:encode) ? value.encode(Encoding::ISO_8859_1) : value
110
- attributes[name] = format_value(encoded_value, options[:type])
113
+ attributes[name] = format_value(value, options[:type])
111
114
  end
112
115
  end
113
116
 
@@ -8,7 +8,6 @@ module EfoNelfo
8
8
  col_sep: ';',
9
9
  headers: false,
10
10
  row_sep: "\r\n",
11
- encoding: "iso-8859-1",
12
11
  quote_char: "\x00",
13
12
  force_quotes: false,
14
13
  skip_blanks: true
@@ -18,7 +17,7 @@ module EfoNelfo
18
17
 
19
18
  def initialize(options)
20
19
  if options[:filename]
21
- @data = File.read(options[:filename], encoding: CSV_OPTIONS[:encoding])
20
+ @data = File.read(options[:filename], encoding: Encoding::ISO_8859_1)
22
21
  else
23
22
  @data = options[:data]
24
23
  end
@@ -1,3 +1,3 @@
1
1
  module EfoNelfo
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -30,9 +30,9 @@ describe EfoNelfo::Property do
30
30
  obj.foo.must_equal 'Test'
31
31
  end
32
32
 
33
- it "converts encoding to ISO-8859-1" do
33
+ it "won't do any encoding conversions" do
34
34
  obj.foo = 'Sjøhest'
35
- obj.foo.encoding.name.must_equal 'ISO-8859-1'
35
+ obj.foo.encoding.name.must_equal 'UTF-8'
36
36
  end
37
37
 
38
38
  it "adds an alias getter and setter for foo" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: efo_nelfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gudleik Rasch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-12 00:00:00.000000000 Z
11
+ date: 2013-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -170,4 +170,3 @@ test_files:
170
170
  - spec/samples/B650517.032.csv
171
171
  - spec/samples/V4_varefil.csv
172
172
  - spec/spec_helper.rb
173
- has_rdoc: