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 +4 -4
- data/lib/efo_nelfo/property.rb +6 -3
- data/lib/efo_nelfo/reader/csv.rb +1 -2
- data/lib/efo_nelfo/version.rb +1 -1
- data/spec/property_spec.rb +2 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 339fc7d74621d26713c98008d2060452753e3998
|
4
|
+
data.tar.gz: 0020dbe4e5129c8890165cf01bae901bcd1373ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 058e13eeccaaf4657c8f58711c3d278ef5190afb1a96b470ed3e38df8242e1b80ddc9ef8482be084012f2e758e1bf27e8270d044808e7c1761cb5b0de20ed873
|
7
|
+
data.tar.gz: 2a755cf54f5d2481297513748eb14a944412364ecc2274ff4be40a75b2ed564fa522baff9753045fc27b1f566a7a5265c02e0b65819671796919b9c699579d09
|
data/lib/efo_nelfo/property.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
|
data/lib/efo_nelfo/reader/csv.rb
CHANGED
@@ -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:
|
20
|
+
@data = File.read(options[:filename], encoding: Encoding::ISO_8859_1)
|
22
21
|
else
|
23
22
|
@data = options[:data]
|
24
23
|
end
|
data/lib/efo_nelfo/version.rb
CHANGED
data/spec/property_spec.rb
CHANGED
@@ -30,9 +30,9 @@ describe EfoNelfo::Property do
|
|
30
30
|
obj.foo.must_equal 'Test'
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "won't do any encoding conversions" do
|
34
34
|
obj.foo = 'Sjøhest'
|
35
|
-
obj.foo.encoding.name.must_equal '
|
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.
|
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-
|
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:
|