flf_creator 0.0.1 → 0.0.2
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 +8 -8
- data/README.md +1 -1
- data/Rakefile +10 -0
- data/flf_creator.gemspec +1 -1
- data/lib/flf_creator/version.rb +1 -1
- data/lib/flf_creator.rb +1 -1
- data/test/lib/flf_creator/flf_creator_test.rb +53 -0
- data/test/lib/flf_creator/version_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWIyYWQyNmYwNjJhYTk3ODNhNmUyMDYxODUzMmM0NTYxNGM5NmRlNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDgzOWQ4YmNhYzNhOWFiODg3OTczYjhkMTg1NjNjYmRlYjJmODhkYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmE5ZWYyNGVlN2ZhNGE4ZDRlMDA3YWI0NzkxMzNkOTMzZDA0NmNkNzAxNjBm
|
10
|
+
YWNmZjFlNTQxOWY1OTQxMmRjZThmZDRlYjM1ZTJmZjM5ZTgwMDA3NDcwNTll
|
11
|
+
OWM4MTVlYWEwZDQyNTZmZTBmZTI1NjFmMGVmY2ZjZWM4ZWQ1NDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTYzMmI4Y2EwOWIxOTZmYWJhMzFlM2ZlOGQwNjNiNWU5MmY3ZDExZmQ3NTAw
|
14
|
+
NjkwMmE5MTI2OTRkYWEwN2NlOTE3NGZiMDk3ZTBjNTFlYjAzN2RiYjc2YzY0
|
15
|
+
ZDk4MGM4MjczN2M2MDA0NzRlNWVjZjg1MmMzNjI1OGI4N2ZmNGY=
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/flf_creator.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["mduffield@gmail.com"]
|
11
11
|
spec.description = %q{Helper for building fixed length files}
|
12
12
|
spec.summary = %q{Gem for fixed length file creation methods}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://github.com/mduffield/flf_creator"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/flf_creator/version.rb
CHANGED
data/lib/flf_creator.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
describe FlfCreator do
|
4
|
+
describe '.build_field' do
|
5
|
+
it 'should return a space delimited, left justified field' do
|
6
|
+
FlfCreator.build_field({:value => 'foo', :length => 5}).must_equal('foo ')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'when there is a justification value' do
|
10
|
+
it 'should return a right justified value' do
|
11
|
+
FlfCreator.build_field({:value => 'foo', :length => 5, :justify => 'right'}).must_equal(' foo')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'when there is a padding_char value' do
|
16
|
+
it 'should return a zero padded field' do
|
17
|
+
FlfCreator.build_field({:value => 5, :length => 5, :justify => 'right', :padding_char => '0'}).must_equal('00005')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'when the length of value is too large' do
|
22
|
+
it 'should truncate' do
|
23
|
+
FlfCreator.build_field({:value => 'foobar', :length => 3}).must_equal('foo')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.format_value' do
|
29
|
+
it 'should format using a proc' do
|
30
|
+
FlfCreator.format_value('foo', Proc.new { |value| value.sub('foo','bar')}).must_equal('bar')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should format a datetime using a String' do
|
34
|
+
FlfCreator.format_value(DateTime.parse('2012-07-13T14:08:06'), '%Y%m%d').must_equal('20120713')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should format a date using a String' do
|
38
|
+
FlfCreator.format_value('2012-07-13', '%Y%m%d').must_equal Date.parse('2012-07-13').strftime('%Y%m%d')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.build_record' do
|
43
|
+
it 'should return a record' do
|
44
|
+
FlfCreator.build_record(['FOO ', '000005', 'BAR ']).must_equal('FOO 000005BAR ')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.build_file' do
|
49
|
+
it 'should return a record' do
|
50
|
+
FlfCreator.build_file(['FOO ', '000005', 'BAR ']).must_equal("FOO \n000005\nBAR ")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flf_creator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Duffield
|
@@ -53,7 +53,10 @@ files:
|
|
53
53
|
- flf_creator.gemspec
|
54
54
|
- lib/flf_creator.rb
|
55
55
|
- lib/flf_creator/version.rb
|
56
|
-
|
56
|
+
- test/lib/flf_creator/flf_creator_test.rb
|
57
|
+
- test/lib/flf_creator/version_test.rb
|
58
|
+
- test/test_helper.rb
|
59
|
+
homepage: http://github.com/mduffield/flf_creator
|
57
60
|
licenses:
|
58
61
|
- MIT
|
59
62
|
metadata: {}
|
@@ -77,4 +80,7 @@ rubygems_version: 2.1.11
|
|
77
80
|
signing_key:
|
78
81
|
specification_version: 4
|
79
82
|
summary: Gem for fixed length file creation methods
|
80
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- test/lib/flf_creator/flf_creator_test.rb
|
85
|
+
- test/lib/flf_creator/version_test.rb
|
86
|
+
- test/test_helper.rb
|