omarskalli / fixy Goto Github PK
View Code? Open in Web Editor NEWLibrary for generating fixed width documents
License: MIT License
Library for generating fixed width documents
License: MIT License
I tried using the new cr/lf line ending as documented:
set_line_ending Fixy::Record::LINE_ENDING_CRLF
And.... no change to the line endings. Looking into the code a bit, the line ending seems to be held in an instance variable and accessed from a class method, which could explain the problem... and I'm not sure what the intention was, so I'm reporting it rather than trying to fix it. Thanks!
Should be exist a feature that let you choose what's line ending append at the end of the row because some formats are different like American express that does not accept \r\n (carriage return)
in order to support different validations, this specific one is to
Acquisition Participant (AP)
Sponsored Merchant File
Technical File Specification
from American express apr 2017
Recent record.rb changes no longer use the "decorator" method, instead parse and generate have
decorator = debug ? Fixy::Decorator::Debug : Fixy::Decorator::Default
Please revert to calling the decorator method to allow other decorators to be used by overriding it.
Hi,
given the use of bytesize, accents confuse the algorithm.
Below an implementation that does not break positioting:
module Alphanumeric
def format_alphanumeric(input, byte_width)
input = input.to_s
String.new(input).ljust(byte_width, " ")
end
end
I will also paste all my formatters below in case someone may need them.
module Fixy
module Formatter
# Justifies an alpha to the left
module Alphanumeric
def format_alphanumeric(input, byte_width)
input = input.to_s
String.new(input).ljust(byte_width, " ")
end
end
# Formats a number 93 to "00000093"
module Numeric
def format_numeric(input, byte_width)
String.new(input.to_s).rjust(byte_width, "0")
end
end
# Formats datetime to YYYYMMDDHHMMSS
module DateTime
def format_datetime(input, byte_width)
input.strftime("%Y%m%d%H%M%S")
end
end
# Formats date to YYYYMMDD
module Date
def format_date(input, byte_width)
::Date.strptime(input, "%d/%m/%Y").strftime("%Y%m%d")
end
end
# Formats date to YYMMDD
module ShortDate
def format_short_date(input, byte_width)
::Date.strptime(input, "%d/%m/%Y").strftime("%y%m%d")
end
end
# Formats floating point "9.34" to "000000934"
module Amount
def format_amount(input, byte_width)
input = "%0.2f" % input
input.gsub(".", "").rjust(byte_width, "0")
end
end
end
end
Hello,
nice work here -- but your web page mentions numeric formatter, and that is not
included in the git source... just wondering if it an oversight, or should I write it ?
surely they are needed by almost anyone making fixed records.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.