fixy 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da0096eb40aeacfe04cf63c2389ca65064fcbae5
4
- data.tar.gz: 9e0721a2d0987f29d7fea9a33cfd99e8c1658b4b
3
+ metadata.gz: a3d8c35cccf39e65c7ceeeebc7d3cc3d2e08296a
4
+ data.tar.gz: dbb83894c29fccf2b036fa4658af9987d849b541
5
5
  SHA512:
6
- metadata.gz: ecbac0ae5a1a21134cacf33dd911a88c0c8b908617ee4c5261920a13bd224e1ed07311ec62da655a6d021b39b1cef4dd0664999f0397c3bbf936ceb9ba3fc202
7
- data.tar.gz: 0fedb296e3d9952edb107169a4c8fa15285155d817d6e7ee2a2a25f66552537fca9e7cb1272c44779c1ebe373005c62a09254e4d2e015431d9db02f53d090a01
6
+ metadata.gz: 3677b88c7b380b05154131b4db1298ac86fe3b7db5baeef25e7664ed757e9206a7861ffcd023b7a04ba672479bc35fb4508761227e8f0e332f2eecb6ecf8036a
7
+ data.tar.gz: 9d474b78d20ca903a8a618b8a7a8002f128308268cdc4e14d09bdb980094571ff9f5b95cc4c061d64f8a075a30d5dd239cbb2ef52f05a240bfca42a016ec6c3f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.0.5
2
+
3
+ * Allow nil values for alphanumeric formatter
4
+
1
5
  ## v0.0.4
2
6
 
3
7
  * Basic support for parsing records
@@ -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 input.bytesize <= byte_width
16
- result = input.dup
16
+ if input_string.bytesize <= byte_width
17
+ result << input_string
17
18
  else
18
- input.each_char do |char|
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 << " " * (byte_width - result.bytesize)
28
+ result << ' ' * (byte_width - result.bytesize)
28
29
  end
29
30
  end
30
31
  end
data/lib/fixy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fixy
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -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
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-02-13 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler