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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzE5ZjU3NWU3Mzg0YmM0MGI0MDI0Y2MxNzYzMDMxNGMwZjA3NmM3ZQ==
4
+ MWIyYWQyNmYwNjJhYTk3ODNhNmUyMDYxODUzMmM0NTYxNGM5NmRlNg==
5
5
  data.tar.gz: !binary |-
6
- NzNmZDRmNGJjYjQ5NzY4MjZjYWRjODY4ZjU0NTExYThkYWI4YzUxZA==
6
+ MDgzOWQ4YmNhYzNhOWFiODg3OTczYjhkMTg1NjNjYmRlYjJmODhkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTVhNzBkODE5YjgwNzQ3NWE5YTdiYTg2NzkwODkxZDFlYTM2ODkyYWEyYjZh
10
- N2FlMDI3ODkxMzZjNGYyZDNlNGJkOGNjNWJmMzc2Yjc4ZTlmMjYyZmJlNmVi
11
- NDIyNTIwOGI3NGI0OWNiMzU1YzQ4NTM4ZGVkNjMyZGY2YmNhYzU=
9
+ ZmE5ZWYyNGVlN2ZhNGE4ZDRlMDA3YWI0NzkxMzNkOTMzZDA0NmNkNzAxNjBm
10
+ YWNmZjFlNTQxOWY1OTQxMmRjZThmZDRlYjM1ZTJmZjM5ZTgwMDA3NDcwNTll
11
+ OWM4MTVlYWEwZDQyNTZmZTBmZTI1NjFmMGVmY2ZjZWM4ZWQ1NDA=
12
12
  data.tar.gz: !binary |-
13
- NzUzNjE1YzhhOGZiNzgzNWFjOWIxMzk2MGY3Njg0ZTMzMmE2YzA0NTgyZTJl
14
- MmZjN2Y3ODQ3YzcyZDJiZDY0NjdjYjNiOTNhYTViYzFmY2QyZDA4ZWVhMGIx
15
- NDBmZmEwN2I5NTI5YzczYTYwM2Q0MGUwMjVkZmU2YzhjMmEwY2M=
13
+ NTYzMmI4Y2EwOWIxOTZmYWJhMzFlM2ZlOGQwNjNiNWU5MmY3ZDExZmQ3NTAw
14
+ NjkwMmE5MTI2OTRkYWEwN2NlOTE3NGZiMDk3ZTBjNTFlYjAzN2RiYjc2YzY0
15
+ ZDk4MGM4MjczN2M2MDA0NzRlNWVjZjg1MmMzNjI1OGI4N2ZmNGY=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FlfCreator
2
2
 
3
- TODO: Write a gem description
3
+ FlfCreator is a simple library of helper functions for creating fixed length record files.
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'lib/flf_creator'
7
+ t.test_files = FileList['test/lib/flf_creator/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
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($/)
@@ -1,3 +1,3 @@
1
1
  module FlfCreator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/flf_creator.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "flf_creator/version"
2
-
2
+ require 'date'
3
3
  module FlfCreator
4
4
  def self.build_field(args = {})
5
5
  value = format_value(args[:value], args[:format])
@@ -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
@@ -0,0 +1,8 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe FlfCreator do
4
+ it "must be defined" do
5
+ FlfCreator::VERSION.wont_be_nil
6
+ end
7
+
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require File.expand_path('../../lib/flf_creator.rb', __FILE__)
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.1
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
- homepage: ''
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