fixy 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/fixy/formatter/alphanumeric.rb +5 -4
- data/lib/fixy/version.rb +1 -1
- data/spec/fixy/record_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3d8c35cccf39e65c7ceeeebc7d3cc3d2e08296a
|
4
|
+
data.tar.gz: dbb83894c29fccf2b036fa4658af9987d849b541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3677b88c7b380b05154131b4db1298ac86fe3b7db5baeef25e7664ed757e9206a7861ffcd023b7a04ba672479bc35fb4508761227e8f0e332f2eecb6ecf8036a
|
7
|
+
data.tar.gz: 9d474b78d20ca903a8a618b8a7a8002f128308268cdc4e14d09bdb980094571ff9f5b95cc4c061d64f8a075a30d5dd239cbb2ef52f05a240bfca42a016ec6c3f
|
data/CHANGELOG.md
CHANGED
@@ -10,12 +10,13 @@ module Fixy
|
|
10
10
|
#
|
11
11
|
|
12
12
|
def format_alphanumeric(input, byte_width)
|
13
|
+
input_string = String.new(input.to_s)
|
13
14
|
result = ''
|
14
15
|
|
15
|
-
if
|
16
|
-
result
|
16
|
+
if input_string.bytesize <= byte_width
|
17
|
+
result << input_string
|
17
18
|
else
|
18
|
-
|
19
|
+
input_string.each_char do |char|
|
19
20
|
if result.bytesize + char.bytesize <= byte_width
|
20
21
|
result << char
|
21
22
|
else
|
@@ -24,7 +25,7 @@ module Fixy
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
result <<
|
28
|
+
result << ' ' * (byte_width - result.bytesize)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
data/lib/fixy/version.rb
CHANGED
data/spec/fixy/record_spec.rb
CHANGED
@@ -101,6 +101,23 @@ describe 'Generating a Record' do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
context 'when a field value is nil' do
|
105
|
+
it 'should emit spaces' do
|
106
|
+
class PersonRecordNil < Fixy::Record
|
107
|
+
include Fixy::Formatter::Alphanumeric
|
108
|
+
|
109
|
+
set_record_length 9
|
110
|
+
|
111
|
+
field :name, 9, '1-9' , :alphanumeric
|
112
|
+
|
113
|
+
field_value :name, -> { nil }
|
114
|
+
end
|
115
|
+
|
116
|
+
value = PersonRecordNil.new.generate
|
117
|
+
value.should == " \n"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
104
121
|
context 'when definition is incomplete (e.g. undefined columns)' do
|
105
122
|
it 'should raise an error' do
|
106
123
|
class PersonRecordF < Fixy::Record
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Skalli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|