initial commit
This commit is contained in:
commit
afc14ba244
37 changed files with 3539 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.gem
|
||||
Gemfile.lock
|
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Changelog
|
||||
## 1.0.0 (01-Oct-20)
|
||||
* Initial release
|
7
Gemfile
Normal file
7
Gemfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# foodsoft_article_import/Gemfile
|
||||
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gemspec
|
33
Gemfile.lock
Normal file
33
Gemfile.lock
Normal file
|
@ -0,0 +1,33 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
foodsoft_article_import (1.0.0)
|
||||
roo (~> 2.9.0)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
docile (1.4.0)
|
||||
nokogiri (1.14.0-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
racc (1.6.2)
|
||||
roo (2.9.0)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.3.0, < 3.0.0)
|
||||
rubyzip (2.3.2)
|
||||
simplecov (0.22.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
simplecov_json_formatter (~> 0.1)
|
||||
simplecov-html (0.12.3)
|
||||
simplecov_json_formatter (0.1.4)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
foodsoft_article_import!
|
||||
simplecov
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.2
|
644
LICENSE
Normal file
644
LICENSE
Normal file
|
@ -0,0 +1,644 @@
|
|||
Copyright (C) 2022 Viehlieb
|
||||
|
||||
|
||||
Comment: Most of the source code was originally written for https://github.com/foodcoops/sharedlists under the GNU License and therefore special credit is attributed to the contributors of the sharedlists application:
|
||||
|
||||
Authors: Kidhab: https://github.com/kidhab,
|
||||
Benjamin Meichsner: https://github.com/benni-as, Wvengen: https://github.com/wvengen, Robwa: https://github.com/robwa, 1resu: https://github.com/1resu, JuliusR: https://github.com/JuliusR
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
44
README.md
Normal file
44
README.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
# FoodsoftArticleImport
|
||||
This gem provides FoodsoftArticleImport integration for Ruby on Rails and allows to parse a variety of files containing article information. These article information are standardized or customly declared. Possible File Ending are: .bnn, .BNN, .csv, .CSV . It relies on [roo](https://github.com/roo-rb/roo) to read and parse the data
|
||||
|
||||
|
||||
## Getting started
|
||||
This is a very simple gem that can be used to extract data from files in the formats .bnn, .xml and .csv.
|
||||
Given one of the aforementioned files, the gem returns information.
|
||||
|
||||
example for foodsoft file:
|
||||
|
||||
|Status|Order number|Name|Note|Manufacturer|Origin|Unit|Price (net)|VAT|Deposit|Unit quantity|(Reserved)|(Reserved)|Category|
|
||||
|--- | --- | --- | --- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |
|
||||
||1234A|Walnuts||Nuttyfarm|CA|500 gr|8.90|7.0|0|6|||Nuts|
|
||||
|x|4321Z|Tomato juice|Organic|Brownfields|IN|1.5 l|4.35|7.0|0|1|||Juices|
|
||||
||4322Q|Tomato juice|Organic|Greenfields|TR|1.2 l|4.02|7.0|0|2|||Juices|
|
||||
|
||||
bnn file reference:
|
||||
https://n-bnn.de/fileadmin/user_upload/Leistungen_Services/Markt-_und_Produktdaten/BNN3_1Schnittstelle_20.08.21.pdf
|
||||
|
||||
Information about Manufacturer, article category, tax and deposit are conveyed through "bnn codes".
|
||||
A "bnn code" is a mapping of some abbreviation or number to the relevant data.
|
||||
The data for suppliers lies at DataNatuRe and we just have a list of some mappings.
|
||||
Much more codes are needed to make this gem more powerfull. Maybe an xml api to DataNatuRe can be implemented in the futurepossibility.
|
||||
The list used in this gem is not complete, since it needs data from all manufacturers.
|
||||
If your local foodcoop posesses keys for article mapping, it is possible to use ypour custom code mapping.
|
||||
|
||||
You can extend it for your local foodcoop, if you create a custom_codes.yml, and put it in your root folder.
|
||||
|
||||
extracted article attributes will be:
|
||||
|
||||
* name: article name from bnn
|
||||
* order_number: order number from bnn
|
||||
* note: extra note from bnn
|
||||
* manufacturer: e.g. ALN -> AL Naturkost Handels GmbH"
|
||||
* origin: e.g. "GB"
|
||||
* article_category: e.g. "0202": Sauermilchprodukte
|
||||
* unit:
|
||||
* price:
|
||||
* tax: e.g. "1" -> "7.0"
|
||||
* unit_quantity:
|
||||
* deposit: e.g. "930190" -> 0.08
|
||||
|
||||
## Ruby Version
|
||||
This gem requires Ruby 2.7
|
31
foodsoft_article_import.gemspec
Normal file
31
foodsoft_article_import.gemspec
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path('lib/foodsoft_article_import/version', __dir__)
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = 'foodsoft_article_import'
|
||||
spec.version = FoodsoftArticleImport::VERSION
|
||||
|
||||
spec.authors = ['Philipp Feuerbach, Wvengen']
|
||||
spec.email = ['pf@pragma-shift.net']
|
||||
|
||||
spec.summary = 'Import Files for Foodcoops for Ruby on Rails'
|
||||
spec.description = 'This gem allows to import files containing article information to foodsoft. It was created to avoid code redundancy and is based on the sharedlist application https://github.com/foodcoops/sharedlists.'
|
||||
spec.homepage = 'https://gitea.com/viehlieb/foodsoft-article_import'
|
||||
|
||||
spec.license = 'MIT'
|
||||
spec.platform = Gem::Platform::RUBY
|
||||
|
||||
spec.required_ruby_version = '>= 2.7.0'
|
||||
|
||||
spec.files = Dir['README.md', 'LICENSE',
|
||||
'CHANGELOG.md', 'lib/**/*.rb',
|
||||
'lib/foodsoft_article_import/bnn.rb',
|
||||
'lib/foodsoft_article_import.rb',
|
||||
'lib/**/*.rake',
|
||||
'foodsoft_article_import.gemspec', '.github/*.md',
|
||||
'Gemfile', 'Rakefile']
|
||||
spec.extra_rdoc_files = ['README.md']
|
||||
|
||||
spec.add_dependency 'roo', '~> 2.9.0'
|
||||
spec.add_development_dependency 'simplecov'
|
||||
end
|
80
lib/foodsoft_article_import.rb
Normal file
80
lib/foodsoft_article_import.rb
Normal file
|
@ -0,0 +1,80 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'digest/sha1'
|
||||
require 'tempfile'
|
||||
require 'csv'
|
||||
require 'yaml'
|
||||
require 'active_support/core_ext/hash/keys'
|
||||
require_relative 'foodsoft_article_import/bioromeo'
|
||||
require_relative 'foodsoft_article_import/bnn'
|
||||
require_relative 'foodsoft_article_import/utf8_encoder'
|
||||
require_relative 'foodsoft_article_import/odin'
|
||||
require_relative 'foodsoft_article_import/foodsoft'
|
||||
module FoodsoftArticleImport
|
||||
class ConversionFailedException < StandardError; end
|
||||
|
||||
# return list of known file formats
|
||||
# each file_format module has
|
||||
# #name return a human-readable file format name
|
||||
# #outlist_unlisted if returns true, unlisted articles are outlisted
|
||||
# #detect return a likelyhood (0-1) of being able to process
|
||||
# #parse parse the data
|
||||
#
|
||||
def self.file_formats
|
||||
@@file_formats ||= {
|
||||
'bnn' => FoodsoftArticleImport::Bnn,
|
||||
'foodsoft' => FoodsoftArticleImport::Foodsoft,
|
||||
'dnb_xml' => FoodsoftArticleImport::Odin,
|
||||
'odin' => FoodsoftArticleImport::Odin,
|
||||
'bioromeo' => FoodsoftArticleImport::Bioromeo
|
||||
}.freeze
|
||||
end
|
||||
|
||||
# Parse file by type (one of {.file_formats})
|
||||
#
|
||||
# @param file [File, Tempfile]
|
||||
# @option opts [String] type file format (required) (see {.file_formats})
|
||||
# @return [File, Roo::Spreadsheet] file with encoding set if needed
|
||||
def self.parse(file, custom_file_path: nil, type: nil, &blk)
|
||||
custom_file_path ||= nil
|
||||
type ||= 'bnn'
|
||||
parser = file_formats[type]
|
||||
if block_given?
|
||||
parser.parse(file, custom_file_path: custom_file_path, &blk)
|
||||
else
|
||||
data = []
|
||||
parser.parse(file, custom_file_path: custom_file_path) { |a| data << a }
|
||||
data
|
||||
end
|
||||
end
|
||||
|
||||
# Helper method to generate an article number for suppliers that do not have one
|
||||
def self.generate_number(article)
|
||||
# something unique, but not too unique
|
||||
s = "#{article[:name]}-#{article[:unit_quantity]}x#{article[:unit]}"
|
||||
s = s.downcase.gsub(/[^a-z0-9.]/, '')
|
||||
# prefix abbreviated sha1-hash with colon to indicate that it's a generated number
|
||||
article[:order_number] = ":#{Digest::SHA1.hexdigest(s)[-7..]}"
|
||||
article
|
||||
end
|
||||
|
||||
# Helper method for opening a spreadsheet file
|
||||
#
|
||||
# @param file [File] file to open
|
||||
# @param filename [String, NilClass] optional filename for guessing the file format
|
||||
# @param encoding [String, NilClass] optional CSV encoding
|
||||
# @param col_sep [String, NilClass] optional column separator
|
||||
# @return [Roo::Spreadsheet]
|
||||
def self.open_spreadsheet(file, filename: nil, encoding: nil, col_sep: nil, liberal_parsing: nil)
|
||||
opts = { csv_options: {} }
|
||||
opts[:csv_options][:encoding] = encoding if encoding
|
||||
opts[:csv_options][:col_sep] = col_sep if col_sep
|
||||
opts[:csv_options][:liberal_parsing] = true if liberal_parsing
|
||||
opts[:extension] = File.extname(filename) if filename
|
||||
begin
|
||||
Roo::Spreadsheet.open(file, **opts)
|
||||
rescue StandardError => e
|
||||
raise "Failed to parse foodsoft file. make sure file format is correct: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
190
lib/foodsoft_article_import/bioromeo.rb
Normal file
190
lib/foodsoft_article_import/bioromeo.rb
Normal file
|
@ -0,0 +1,190 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Module for import of BioRomeo products from their Excel sheet, from Aug 2014 onwards
|
||||
|
||||
require 'roo'
|
||||
require 'roo-xls'
|
||||
|
||||
module FoodsoftArticleImport
|
||||
class Bioromeo
|
||||
NAME = 'BioRomeo (XLSX, XLS, CSV)'
|
||||
OUTLIST = true
|
||||
OPTIONS = {
|
||||
encoding: 'UTF-8',
|
||||
col_sep: ';'
|
||||
}.freeze
|
||||
|
||||
RE_UNITS = /(kg|gr|gram|pond|st|stuks?|set|bos|bossen|bosjes?|bak|bakjes?|liter|ltr|[lL]\.|ml|bol|krop)(\s*\.)?/i.freeze
|
||||
RES_PARSE_UNIT_LIST = [
|
||||
/\b((per|a)\s*)?([0-9,.]+\s*x\s*[0-9,.]+\s*#{RE_UNITS})/i, # 1x5 kg
|
||||
/\b((per|a)\s*)?([0-9,.]+\s*#{RE_UNITS}\s+x\s*[0-9,.]+)/i, # 1kg x 5
|
||||
/\b((per|a)\s*)?(([0-9,.]+\s*,\s+)*[0-9,.]+\s+of\s+[0-9,.]+\s*#{RE_UNITS})/i, # 1, 2 of 5 kg
|
||||
/\b((per|a)\s*)?([0-9,.]+\s*#{RE_UNITS})/i, # 1kg
|
||||
/\b((per|a)\s*)?(#{RE_UNITS})/i # kg
|
||||
].freeze
|
||||
# first parse with dash separator at the end, fallback to less specific
|
||||
RES_PARSE_UNIT = RES_PARSE_UNIT_LIST.map { |r| /-\s*#{r}\s*$/ } +
|
||||
RES_PARSE_UNIT_LIST.map { |r| /-\s+#{r}/ } +
|
||||
RES_PARSE_UNIT_LIST.map { |r| /#{r}\s*$/ } +
|
||||
RES_PARSE_UNIT_LIST.map { |r| /-#{r}/ }
|
||||
|
||||
def self.parse(file, custom_file_path: nil)
|
||||
custom_file_path ||= nil
|
||||
opts = OPTIONS.dup
|
||||
opts[:liberal_parsing] = true
|
||||
opts[:col_sep] = ','
|
||||
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)
|
||||
header_row = true
|
||||
sheet = ss.sheet(0).parse(clean: true,
|
||||
order_number: /Artnr./,
|
||||
name: /Product/,
|
||||
skal: /Skal$/,
|
||||
demeter: /Demeter$/,
|
||||
unit_price: /prijs\b.*\beenh/i,
|
||||
pack_price: /prijs\b.*\bcolli/i,
|
||||
comment: /opm(erking)?/i)
|
||||
|
||||
linenum = 0
|
||||
category = nil
|
||||
|
||||
sheet.each do |row|
|
||||
linenum += 1
|
||||
row[:name].to_s.strip.empty? and next
|
||||
# (sub)categories are in first two content cells - assume if there's a price it's a product
|
||||
if row[:order_number].to_s.strip.empty? && row[:unit_price].to_s.strip.empty?
|
||||
category = row[:name]
|
||||
yield nil, nil, linenum
|
||||
next
|
||||
end
|
||||
# skip products without a number
|
||||
if row[:order_number].to_s.strip.empty?
|
||||
yield nil, nil, linenum
|
||||
next
|
||||
end
|
||||
# extract name and unit
|
||||
errors = []
|
||||
notes = []
|
||||
unit_price = row[:unit_price].gsub('€', '').to_s.strip.to_f
|
||||
pack_price = row[:pack_price].gsub('€', '').to_s.strip.to_f
|
||||
number = row[:order_number]
|
||||
name = row[:name]
|
||||
unit = nil
|
||||
manufacturer = nil
|
||||
prod_category = nil
|
||||
RES_PARSE_UNIT.each do |re|
|
||||
m = name.match(re)
|
||||
unless m
|
||||
yield nil, nil, linenum
|
||||
next
|
||||
end
|
||||
unit = normalize_unit(m[3])
|
||||
name = name.sub(re, '').sub(/\(\s*\)\s*$/, '').sub(/\s+/, ' ').sub(/\.\s*$/, '').strip
|
||||
break
|
||||
end
|
||||
unit ||= '1 st' if name.match(/\bsla\b/i)
|
||||
unit ||= '1 bos' if name.match(/\bradijs\b/i)
|
||||
unit ||= '1 bosje' if category.match(/\bkruid/i)
|
||||
if unit.nil?
|
||||
unit = '?'
|
||||
errors << "Cannot find unit in name '#{name}'"
|
||||
end
|
||||
# handle multiple units in one line
|
||||
if unit.match(/\b(,\s+|of)\b/)
|
||||
# TODO: create multiple articles instead of taking first one
|
||||
end
|
||||
# sometimes category is also used to indicate manufacturer
|
||||
m = category.match(/((eko\s*)?boerderij.*?)\s*$/i) and manufacturer = m[1]
|
||||
# Ad-hoc fix for package of eggs: always take pack price
|
||||
if name.match(/^eieren/i)
|
||||
unit_price = pack_price
|
||||
prod_category = 'Eieren'
|
||||
end
|
||||
prod_category = 'Kaas' if name.match(/^kaas/i)
|
||||
# figure out unit_quantity
|
||||
if unit.match(/x/)
|
||||
unit_quantity, unit = unit.split(/\s*x\s*/i, 2)
|
||||
unit, unit_quantity = unit_quantity, unit if unit_quantity.match(/[a-z]/i)
|
||||
elsif (unit_price - pack_price).abs < 1e-3
|
||||
unit_quantity = 1
|
||||
elsif (m = unit.match(/^(.*)\b\s*(st|bos|bossen|bosjes?)\.?\s*$/i))
|
||||
unit_quantity, unit = m[1..2]
|
||||
unit_quantity.blank? and unit_quantity = 1
|
||||
else
|
||||
unit_quantity = 1
|
||||
end
|
||||
# there may be a more informative unit in the line
|
||||
if unit == 'st' && !name.match(/kool/i)
|
||||
RES_PARSE_UNIT.each do |re|
|
||||
m = name.match(re) or next
|
||||
unit = normalize_unit(m[3])
|
||||
name = name.sub(re, '').strip
|
||||
end
|
||||
end
|
||||
# NOTE: from various fields
|
||||
notes.append("Skal #{row[:skal]}") unless row[:skal].to_s.strip.empty?
|
||||
notes.append(row[:demeter]) unless row[:skal].to_s.strip.empty?
|
||||
notes.append("Demeter #{row[:demeter]}") unless row[:skal].to_s.strip.empty? && row[:demeter].is_a?(Integer)
|
||||
notes.append "(#{row[:comment]})" unless row[:comment].to_s.strip.empty?
|
||||
name.sub!(/(,\.?\s*)?\bDemeter\b/i, '') and notes.prepend('Demeter')
|
||||
name.sub!(/(,\.?\s*)?\bBIO\b/i, '') and notes.prepend 'BIO'
|
||||
# unit check
|
||||
errors << check_price(unit, unit_quantity, unit_price, pack_price)
|
||||
# create new article
|
||||
name.gsub!(/\s+/, ' ')
|
||||
article = { order_number: number,
|
||||
name: name.strip,
|
||||
note: notes.count.positive? && notes.map(&:strip).join('; '),
|
||||
manufacturer: manufacturer,
|
||||
origin: 'Noordoostpolder, NL',
|
||||
unit: unit,
|
||||
price: pack_price.to_f / unit_quantity,
|
||||
unit_quantity: unit_quantity,
|
||||
tax: 6,
|
||||
deposit: 0,
|
||||
article_category: prod_category || category }
|
||||
errors.compact!
|
||||
if errors.count.positive?
|
||||
yield article, errors.join("\n"), linenum
|
||||
else
|
||||
# outlisting not used by supplier
|
||||
yield article, nil, linenum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_price(unit, unit_quantity, unit_price, pack_price)
|
||||
if (unit_price - pack_price).abs < 1e-3
|
||||
return if unit_quantity == 1
|
||||
|
||||
return "price per unit #{unit_price} is pack price, but unit quantity #{unit_quantity} is not one"
|
||||
end
|
||||
|
||||
return "could not parse unit: #{unit}" unless (m = unit.match(/^(.*)(#{RE_UNITS})\s*$/))
|
||||
|
||||
amount, what = m[1..2]
|
||||
|
||||
# perhaps unit price is kg-price
|
||||
kgprice = case what
|
||||
when /^kg/i
|
||||
pack_price.to_f / amount.to_f
|
||||
when /^gr/
|
||||
pack_price.to_f / amount.to_f * 1000
|
||||
end
|
||||
return unless kgprice.to_s.strip.empty? && (kgprice - unit_price.to_f).abs < 1e-2
|
||||
|
||||
unit_price_computed = pack_price.to_f / unit_quantity.to_i
|
||||
return unless (unit_price_computed - unit_price.to_f).abs > 1e-2
|
||||
|
||||
"price per unit given #{unit_price.round(3)} does not match computed " \
|
||||
"#{pack_price.round(3)}/#{unit_quantity}=#{unit_price_computed.round(3)}" +
|
||||
(kgprice ? " (nor is it a kg-price #{kgprice.round(3)})" : '')
|
||||
end
|
||||
|
||||
def self.normalize_unit(unit)
|
||||
unit = unit.sub(/1\s*x\s*/, '')
|
||||
unit = unit.sub(/,([0-9])/, '.\1').gsub(/^per\s*/, '').sub(/^1\s*([^0-9.])/, '\1').sub(/^a\b\s*/, '')
|
||||
unit = unit.sub(/(bossen|bosjes?)/, 'bos').sub(/(liter|l\.|L\.)/, 'ltr').sub(/stuks?/, 'st').sub('gram', 'gr')
|
||||
unit = unit.sub(/\s*\.\s*$/, '').sub(/\s+/, ' ').strip
|
||||
end
|
||||
end
|
||||
end
|
91
lib/foodsoft_article_import/bnn.rb
Normal file
91
lib/foodsoft_article_import/bnn.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Module for translation and parsing of BNN-files (www.n-bnn.de)
|
||||
#
|
||||
module FoodsoftArticleImport
|
||||
module Bnn
|
||||
@@codes = {}
|
||||
@@midgard = {}
|
||||
# Loads the codes_file config/bnn_codes.yml into the class variable @@codes
|
||||
def self.load_codes(custom_file_path = nil)
|
||||
@gem_lib = File.expand_path '..', __dir__
|
||||
dir = File.join @gem_lib, 'foodsoft_article_import'
|
||||
begin
|
||||
@@codes = YAML.safe_load(File.open(File.join(dir, 'bnn_codes.yml'))).symbolize_keys
|
||||
if custom_file_path
|
||||
custom_codes = YAML.safe_load(File.open(custom_file_path)).symbolize_keys
|
||||
custom_codes.each_key do |key|
|
||||
custom_codes[key] = custom_codes[key].merge @@codes[key] if @@codes.keys.include?(key)
|
||||
@@codes = @@codes.merge custom_codes
|
||||
end
|
||||
end
|
||||
@@midgard = YAML.safe_load(File.open(File.join(dir, 'midgard_codes.yml'))).symbolize_keys
|
||||
rescue StandardError => e
|
||||
raise "Failed to load bnn_codes: #{dir}/{bnn,midgard}_codes.yml: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
$missing_bnn_codes = []
|
||||
|
||||
# translates codes from BNN to foodsoft-code
|
||||
def self.translate(key, value)
|
||||
if @@codes[key][value]
|
||||
@@codes[key][value]
|
||||
elsif @@midgard[key]
|
||||
@@midgard[key][value]
|
||||
elsif !value.nil?
|
||||
$missing_bnn_codes << value
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
NAME = 'BNN (CSV)'
|
||||
OUTLIST = false
|
||||
OPTIONS = {
|
||||
encoding: 'IBM850',
|
||||
col_sep: ';'
|
||||
}.freeze
|
||||
|
||||
# parses a bnn-file
|
||||
def self.parse(file, custom_file_path: nil, **opts)
|
||||
custom_file_path ||= nil
|
||||
encoding = opts[:encoding] || OPTIONS[:encoding]
|
||||
col_sep = opts[:col_sep] || OPTIONS[:col_sep]
|
||||
load_codes(custom_file_path)
|
||||
CSV.foreach(file, { col_sep: col_sep, encoding: encoding, headers: true }).with_index(1) do |row, i|
|
||||
# check if the line is empty
|
||||
unless row[0] == '' || row[0].nil?
|
||||
article = {
|
||||
name: UTF8Encoder.clean(row[6]),
|
||||
order_number: row[0],
|
||||
note: UTF8Encoder.clean(row[7]),
|
||||
manufacturer: translate(:manufacturer, row[10]),
|
||||
origin: row[12],
|
||||
article_category: translate(:category, row[16]),
|
||||
unit: row[23],
|
||||
price: row[37],
|
||||
tax: translate(:tax, row[33]),
|
||||
unit_quantity: row[22]
|
||||
}
|
||||
|
||||
# TODO: Complete deposit list....
|
||||
article.merge!(deposit: translate(:deposit, row[26])) if translate(:deposit, row[26])
|
||||
|
||||
if !row[62].nil?
|
||||
# consider special prices
|
||||
article[:note] = "Sonderpreis: #{article[:price]} von #{row[62]} bis #{row[63]}"
|
||||
yield article, :special, i
|
||||
|
||||
# Check now for article status, we only consider outlisted articles right now
|
||||
# N=neu, A=Änderung, X=ausgelistet, R=Restbestand,
|
||||
# V=vorübergehend ausgelistet, W=wiedergelistet
|
||||
elsif row[1] == 'X' || row[1] == 'V'
|
||||
yield article, :outlisted, i
|
||||
else
|
||||
yield article, nil, i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
1119
lib/foodsoft_article_import/bnn_codes.yml
Normal file
1119
lib/foodsoft_article_import/bnn_codes.yml
Normal file
File diff suppressed because it is too large
Load diff
129
lib/foodsoft_article_import/dnb_codes.yml
Normal file
129
lib/foodsoft_article_import/dnb_codes.yml
Normal file
|
@ -0,0 +1,129 @@
|
|||
|
||||
# from http://www.nieuweband.nl/producten/groepen/
|
||||
indeling:
|
||||
1: Verswaren
|
||||
50: Kaas
|
||||
62: Schapenkaas
|
||||
|
||||
2: Basisproducten
|
||||
850: Noten
|
||||
855: Noten grootverbruik
|
||||
700: Peulvruchten
|
||||
705: Peulvruchten grootverbruik
|
||||
340: Rijst
|
||||
341: Rijst grootverbruik
|
||||
450: Vlokken
|
||||
455: Vlokken grootverbruik
|
||||
800: Zaden en pitten
|
||||
805: Zaden en pitten grootverbruik
|
||||
603: Melen grootverbruik
|
||||
|
||||
3: Ontbijt en lunch
|
||||
943: Marmelade
|
||||
1272: Muesli en poppies
|
||||
1000: Notenpasta
|
||||
1276: Ontbijtmelen
|
||||
1295: Rijstwafels
|
||||
1290: Roggebrood
|
||||
1270: Sandwichspread
|
||||
940: Vruchtenbeleg
|
||||
942: Vruchtenjam
|
||||
944: Vruchtenstroop
|
||||
1300: Knäckebröd, toast en beschuit
|
||||
|
||||
4: Warme maaltijd
|
||||
1820: Mosterd
|
||||
1610: Olijfolie
|
||||
1600: Olijven
|
||||
1451: Peulvruchtenconserven
|
||||
1957: Pindasaus
|
||||
1960: Sambal, ketjap en pittige smaakmakers
|
||||
2170: Seitan
|
||||
2260: Siropen
|
||||
2248: Smaakmakers
|
||||
1500: Soepen en bouillon
|
||||
1515: Soepstengels
|
||||
2000: Sojasauzen
|
||||
2250: Suiker
|
||||
1452: Tafelzuren
|
||||
1590: Tamme-kastanje-producten
|
||||
1975: Thaise keuken
|
||||
1900: Tomatenproducten
|
||||
1670: Vetten
|
||||
1930: Visconserven
|
||||
2175: Vleesvervangers
|
||||
1360: Vruchtencompote
|
||||
1400: Vruchtenconserven
|
||||
1350: Vruchtenmoes en -puree
|
||||
2249: Zout en kruidenzout
|
||||
|
||||
5: Sappen en dranken
|
||||
2605: Rode wijn Oostenrijk
|
||||
2604: Rode wijn Portugal
|
||||
2602: Rode wijn Spanje
|
||||
2608: Rode wijn Zuid-Afrika
|
||||
2612: Rosé Spanje
|
||||
2617: Rosé Zuid-Afrika
|
||||
2420: Smoothies
|
||||
2455: Sojamelkproducten
|
||||
2505: Speciaalbieren
|
||||
2400: Vruchtensappen
|
||||
2490: Waterijs
|
||||
2637: Witte wijn Argentinië
|
||||
2630: Witte wijn Frankrijk
|
||||
2634: Witte wijn Griekenland
|
||||
2631: Witte wijn Italië
|
||||
2635: Witte wijn Oostenrijk
|
||||
2632: Witte wijn Spanje
|
||||
2638: Witte wijn Zuid-Afrika
|
||||
|
||||
6: Warme dranken en theekruiden
|
||||
3102: Kruidenthee builtjes
|
||||
3100: Kruidenthee los
|
||||
3020: Kruidenthee met geneeskrachtige werking
|
||||
3009: Rooibosthee
|
||||
3010: Thee grootverpakking
|
||||
3052: Theekruiden
|
||||
3008: Witte thee
|
||||
3011: Yogi spice tea
|
||||
3012: Yogi tao tea
|
||||
3000: Zwarte thee
|
||||
|
||||
7: Versnaperingen
|
||||
3552: Lollies
|
||||
3470: Nougat en fudge
|
||||
3570: Raw Food
|
||||
3360: Rozijntjes in kinderverpakking
|
||||
3410: Snijkoek
|
||||
3555: Snoep met suiker
|
||||
3550: Snoep zonder suiker
|
||||
3405: Stroopwafels
|
||||
3350: Tortillachips en salsa
|
||||
3358: Zoete chips
|
||||
3540: Zoethoutstokjes
|
||||
3365: Zoutjes, hartige bites en popcorn
|
||||
3530: Laurierdrop
|
||||
|
||||
8: Persoonlijke verzorging en cosmetica
|
||||
5036: Lavera
|
||||
5037: Namaste
|
||||
5040: Natracare
|
||||
5042: Odylique
|
||||
5049: Sonett
|
||||
5055: Urtekram
|
||||
5065: Weleda
|
||||
|
||||
9: Natuurtherapeutisch
|
||||
5455: Kruidentincturen
|
||||
5420: Propolis-producten
|
||||
5245: Zelfzorgmiddelen
|
||||
5280: Huid- en massage-olie
|
||||
|
||||
10: Non Food
|
||||
5517: Luiers en babydoekjes
|
||||
5510: Maandverband en tampons
|
||||
5520: Toiletpapier e.d.
|
||||
5890: Voor kinderen (en volwassenen)
|
||||
5650: Was- en schoonmaakmiddelen
|
||||
5515: Watten
|
||||
5610: Luchtverfrissers
|
60
lib/foodsoft_article_import/foodsoft.rb
Normal file
60
lib/foodsoft_article_import/foodsoft.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Module for Foodsoft-file import
|
||||
# The Foodsoft-file is a CSV-file, with semicolon-separated columns, or ODS/XLS/XLSX
|
||||
|
||||
require 'roo'
|
||||
require 'roo-xls'
|
||||
|
||||
module FoodsoftArticleImport
|
||||
module Foodsoft
|
||||
NAME = 'Foodsoft (CSV, ODS, XLS, XLSX)'
|
||||
OUTLIST = false
|
||||
OPTIONS = {
|
||||
encoding: 'UTF-8',
|
||||
col_sep: ';'
|
||||
}.freeze
|
||||
|
||||
# Parses Foodsoft file
|
||||
# the yielded article is a simple hash
|
||||
def self.parse(file, custom_file_path: nil)
|
||||
custom_file_path ||= nil
|
||||
opts = OPTIONS.dup
|
||||
|
||||
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)
|
||||
|
||||
header_row = true
|
||||
ss.sheet(0).each.with_index(1) do |row, i|
|
||||
# skip first header row
|
||||
if header_row
|
||||
header_row = false
|
||||
next
|
||||
end
|
||||
# skip empty lines
|
||||
if row[2].to_s.strip.empty?
|
||||
# raise no order number given
|
||||
yield nil, nil, i
|
||||
next
|
||||
end
|
||||
|
||||
article = { order_number: row[1],
|
||||
name: row[2],
|
||||
note: row[3],
|
||||
manufacturer: row[4],
|
||||
origin: row[5],
|
||||
unit: row[6],
|
||||
price: row[7],
|
||||
tax: row[8],
|
||||
unit_quantity: row[10],
|
||||
article_category: row[13] }
|
||||
article.merge!(deposit: row[9]) unless row[9].nil?
|
||||
FoodsoftArticleImport.generate_number(article) if article[:order_number].to_s.strip.empty?
|
||||
if row[6].nil? || row[7].nil? || row[8].nil?
|
||||
yield article, 'Error: unit, price and tax must be entered', i
|
||||
else
|
||||
yield article, (row[0] == 'x' ? :outlisted : nil), i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
294
lib/foodsoft_article_import/midgard_codes.yml
Normal file
294
lib/foodsoft_article_import/midgard_codes.yml
Normal file
|
@ -0,0 +1,294 @@
|
|||
manufacturer:
|
||||
"61": Maintal
|
||||
AB: Agrobioservice
|
||||
AD: Anita Dehnert
|
||||
AH: Phyto Treasures e.K.
|
||||
AO: Arganöl
|
||||
AR: ARIES
|
||||
AS: Abraham Schinken
|
||||
Ad: Molkerei Andechs
|
||||
An: Frans Andringa
|
||||
Ap: Apfeltraum
|
||||
Ar: Provamel über Arche
|
||||
Ay: Aytem
|
||||
BA: BauckHof Amelinghausn
|
||||
BB: Bakenhus Biofleisch GmbH
|
||||
BC: Bio-Bäckerei Bucco
|
||||
BD: Biosa
|
||||
BF: Bruno Fischer
|
||||
BG: Bauers Garten
|
||||
BH: Bauck Hof
|
||||
BHA: Bauck Hof Amelinghausen
|
||||
BI: Biofarben
|
||||
BK: Burger Knäcke
|
||||
BKO: BioKräuterei Oberhavel
|
||||
BL: Beumer & Lutum
|
||||
BM: Bohlsener Mühle
|
||||
BN: Brochenin
|
||||
BOD: Bode Naturkost
|
||||
BR: Luchs Bier
|
||||
BT: Beltane Naturkost GmbH
|
||||
BU: Baumschule am Butzelberg
|
||||
BV: BIO VITA
|
||||
BZ: Biozeit
|
||||
Ba: Bauck demeter Produkte
|
||||
Bb: Beutelsbacher
|
||||
Bd: Biosa Danmark Aps
|
||||
Be: Behncken
|
||||
Bf: Backforum
|
||||
Bg: Butzelberg
|
||||
Bh: Barnhouse
|
||||
Bj: Milchschafhof Brünjes
|
||||
Bk: Blank
|
||||
Bm: Biomax
|
||||
Bn: Bentele
|
||||
Bo: Bobalis
|
||||
Bt: Bretti's
|
||||
Bu: Biogärtnerei Bauer
|
||||
By: Byodo
|
||||
CA: Care
|
||||
CF: CLUB Feinkost
|
||||
CI: CIDRERIE
|
||||
CV: Cosmoveda
|
||||
Ca: Campo
|
||||
Cl: Obsthof Clostermann
|
||||
Co: Obsthof Cordes (Heinrich)
|
||||
Cp: Campobello
|
||||
Cs: Cosmoveda
|
||||
Ct: cbet GmbH
|
||||
DA: Danival
|
||||
DE: DEMETER-Erzeugergemeinschaft
|
||||
DH: Dieter Hein Wurstwaren
|
||||
DM: Dr. Martins
|
||||
DN: Hof Dannwisch
|
||||
DO: Donath-Mühle
|
||||
DR: De Rit
|
||||
DV: Davert
|
||||
DW: Vovic / Evian
|
||||
De: Dennree
|
||||
Dk: Dinkula
|
||||
EB: Erich Boden
|
||||
EH: Engemann Handel
|
||||
EI: Natürlich Eistert
|
||||
ELM: BIONADE
|
||||
EN: Provence Regime
|
||||
EO: Eosta
|
||||
ER: Euresis
|
||||
Eb: Eisblümerl
|
||||
Eh: Erhardt Meerrettichprodukte
|
||||
Ei: Eiland
|
||||
El: Kelterei Elm
|
||||
En: Eichhorn
|
||||
Er: Erdmannhauser Brezelfabrik
|
||||
Es: Erntesegen
|
||||
FB: Flensburger Brauerei
|
||||
FE: Frucht-Express
|
||||
FF: Schiffers
|
||||
FI: Fromi GmbH
|
||||
FL: Florian Kerzen
|
||||
FR: I Frutti del Sole
|
||||
FU: Future 3000
|
||||
Fh: Florahof
|
||||
Fq: Fläming-Quelle
|
||||
Fr: Frunet
|
||||
Ft: Fontaine
|
||||
GA: Bio-Gärtnerei Altglobsow
|
||||
GG: Naturhof Günter Gaßmann
|
||||
GH: Gutshöfe
|
||||
GN: Nesse Gewürze
|
||||
GO: Der Georgshof
|
||||
GS: Gut Schmerwitz
|
||||
GT: Gut Temmen
|
||||
Gb: Grabower
|
||||
Gl: Glaciar
|
||||
Go: Golden Temple
|
||||
Gr: Grützdorfer
|
||||
Gw: Gwidon Zastawa
|
||||
Gä: Gärtnerei am Bauerngut
|
||||
GÖ: Stadtgut Görlitz
|
||||
HA: Haaner Felsenquelle
|
||||
HB: Hof Bockum
|
||||
HF: Hühnerhof Falkenthal
|
||||
HK: Heinz Ketchup
|
||||
HM: Hof Marienhöhe
|
||||
HO: Hoffmann
|
||||
HS: Obstbau H. Schalkau
|
||||
Ha: Hake
|
||||
Hc: Hoch Oblatenfabrik
|
||||
He: Hennicke
|
||||
Hk: Natur Obsthof Hauke
|
||||
Hl: Heidehof
|
||||
Ho: Holle
|
||||
Hu: Humanopolis
|
||||
Hü: Hütterman
|
||||
IC: Japan Grüntee
|
||||
IN: Isola della Natura
|
||||
IOC: IOC
|
||||
IS: Isana
|
||||
Ib: Iberia
|
||||
Il: Il Nuraghe
|
||||
Is: ISANA
|
||||
JH: Beerenobst
|
||||
JS: Juers Fruchtchips
|
||||
Je: Jelitta Käse
|
||||
KD: Kristdyn
|
||||
KG: Kräuter Gut
|
||||
KK: 74271
|
||||
KN: Öko-Gartenbau
|
||||
KP: Kräutergarten Pommerland
|
||||
Ka: Kanne
|
||||
Kg: Karg Brotgenuß
|
||||
Kä: Kärrners
|
||||
Kö: Obsthof König
|
||||
LB: Lammsbräu
|
||||
LE: LEEB Schaf- und Ziegenmolkerei
|
||||
LI: Legend Organics
|
||||
LM: LeMar
|
||||
LS: La Selva
|
||||
La: Lahmann
|
||||
Lb: Lebensbaum
|
||||
Le: Leuchtenberg Sauerkrautfabrik
|
||||
Lh: Lindenhof
|
||||
Li: Lima Belgien
|
||||
Lk: Landkrone
|
||||
Ln: Land in Sicht
|
||||
Ls: Lubs GmbH
|
||||
Lu: Luvos Heilerde
|
||||
Lw: Gärtnerei Löwenzahn
|
||||
MA: Mack
|
||||
MB: Mabutake
|
||||
ME: Martin Evers
|
||||
MH: Märkische Heide
|
||||
MI: Martin Ibele
|
||||
MII: Katal. Olivenöl
|
||||
ML: Märkisches Landbrot
|
||||
MM: Bioland Imkerei
|
||||
MT: Maintal
|
||||
MV: MegaVega Limited
|
||||
MY: Mayka Brezel
|
||||
Ma: Marschland
|
||||
Mg: MIDGARD
|
||||
Mh: Melchhof
|
||||
Mn: Mosna
|
||||
Mo: Mosaikwerkstätten
|
||||
My: MAYKA, Brezelfabrik
|
||||
Mü: Hofmolkerei GmbH Münchehofe
|
||||
MÖ: Märkischer Ökovertrieb
|
||||
NE: Natürlich Eistert
|
||||
NM:
|
||||
NO: Nürnberger Bio Originale
|
||||
NQ: Pineo Wasser
|
||||
Na: NATURATA
|
||||
Nt: Natumi
|
||||
OTC: OTC
|
||||
Od: ODIN Holland
|
||||
PB: Peter Bentele
|
||||
PG: Pilzgarten
|
||||
PH: Biopilzhof
|
||||
PM: Pinkus Müller
|
||||
PN: Pro Natura
|
||||
Pi: Piding
|
||||
Pt: Port International
|
||||
QB: Panettoncino
|
||||
RB: Rother Bräu
|
||||
RP: Rheinsberger Preussenquelle
|
||||
RS: rosmarin BIOBACK
|
||||
RZ: Ranch Zempow
|
||||
Ra: Raab
|
||||
Rb: Rabenhorst
|
||||
Re: Rebgarten
|
||||
Rg: Rosengarten
|
||||
Rh: Rotenhäusler
|
||||
Ro: Geflügelhof Robert
|
||||
RoL: Robert´s LOSE
|
||||
Rt: Rottstock
|
||||
Rö: Römerquelle
|
||||
SB: Sabines Bauernhof
|
||||
SBP: Stiftelsen Bananen
|
||||
SC: Sommer & Co.
|
||||
SF: Sprossen
|
||||
SH: Spreewälder Hirse
|
||||
SI: SINFO
|
||||
SK: Spargelhof Kreienbaum
|
||||
SL: St. Leonhardsquelle
|
||||
SM: Seenlan Müritz
|
||||
SO: Sonett
|
||||
SR: Sprossenmanufaktur GbR
|
||||
STN: Sonnentor
|
||||
SV: SANTAVERDE ALOE VERA
|
||||
Sa: Salamita
|
||||
Sb: Hans Hermann Soetbeer
|
||||
Sc: Schulz-Deetz
|
||||
Sch: Hof Schütte
|
||||
Sd: Savid
|
||||
Se: Sekem, Ägypten
|
||||
Sf: Sauerkonservenfabrik Schweizer
|
||||
Sh: Kombucha
|
||||
Si: Land in Sicht
|
||||
Sk: Schock Ludwigsburg
|
||||
Sm: Schramm
|
||||
So: Sophienhof
|
||||
Sp: Spielberger
|
||||
Sr: Sanmar
|
||||
St: Steck Senf
|
||||
StB: Stralsunder Brauerei
|
||||
Su: Sun,Backwaren aus Norwegen
|
||||
Sv: Sunval demeter-Produkte
|
||||
Sw: Szilleweit
|
||||
Sy: Synanon
|
||||
Sz: Schrozberg
|
||||
Sü: Südasien
|
||||
TB: Team Blue
|
||||
TF: Terra Frischdienst
|
||||
TN: Tofu Nagel
|
||||
TR: Teltower Rübchen
|
||||
Ta: Tarpa
|
||||
Te: Teutoburger Ölmühle
|
||||
Ti: Tiedemann
|
||||
Tm: Tillmann
|
||||
Tr: tri d´Aix
|
||||
Tt: Tautropfen
|
||||
Tö: Töpfer Rohrzucker
|
||||
UK: Udo Kolm Bananen
|
||||
UL: Gärtnerei Ulenburg
|
||||
UV: Uni-Vert
|
||||
Ul: Ulenburg Bioland Gemüse
|
||||
VA: Kleingenossenschaft VENUSTA
|
||||
VD: V & D
|
||||
VE: Vega e.K.
|
||||
VG: Biolog. Vollwertgetränke
|
||||
VT: Vogt
|
||||
VV: Vallé Käse
|
||||
Vi: Viana Tofu
|
||||
VlV: Vivo Lo Vin
|
||||
Vo: Voelkel
|
||||
WB: Weber
|
||||
WD: Werder Feinkost GmbH
|
||||
WH: Weide-Hardebek
|
||||
WK: BioCompany Kaffee
|
||||
WL: Wendland Storchenmilch
|
||||
WP: Plosewasser
|
||||
WR: Speickwerke
|
||||
WS: Weingut Sander
|
||||
Wa: Watzkendorf
|
||||
We: Wendts
|
||||
Wh: Molkerei Weißenhorn
|
||||
Wz: Werz Heidenheim
|
||||
ZA: Bio-Center Zann
|
||||
ZF: Obsthof zum Felde
|
||||
ZG: Zwergenwiese
|
||||
ZI: Biolandhof Zielke
|
||||
ZK: Ziegenkäserei Karolinenhof
|
||||
ZP: Bioland Ranch Zempow
|
||||
ZW: Zellertaler Wein
|
||||
bF: bio Frische
|
||||
bi: biosanica
|
||||
dB: ÖMA-d`Beers, Kisslegg im Algäu
|
||||
eu: felicia
|
||||
fa: familia Müsli
|
||||
ha: Hawlik
|
||||
vL: v.d.Linden
|
||||
öG: Öko-Gartenbau
|
||||
öh: ökohum Blumenerde
|
||||
ÖL: Öko-Line
|
||||
ÖS: Ölmühle Solling
|
85
lib/foodsoft_article_import/odin.rb
Normal file
85
lib/foodsoft_article_import/odin.rb
Normal file
|
@ -0,0 +1,85 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Article import for De Nieuw Band XML file
|
||||
#
|
||||
# Always contains full assortment, including recently outlisted articles.
|
||||
# To make sure we don't keep old articles when a number of updates was missed,
|
||||
# +OUTLIST+ is set to +true+ to remove articles not present in the file.
|
||||
#
|
||||
require 'nokogiri'
|
||||
|
||||
module FoodsoftArticleImport
|
||||
class Odin
|
||||
NAME = 'De Nieuwe Band (XML)'
|
||||
OUTLIST = true
|
||||
OPTIONS = {}.freeze
|
||||
|
||||
# parses a string or file
|
||||
def self.parse(file, custom_file_path: nil, **_opts)
|
||||
custom_file_path ||= nil
|
||||
xml = File.open(file)
|
||||
doc = Nokogiri.XML(xml, nil, nil,
|
||||
Nokogiri::XML::ParseOptions::RECOVER +
|
||||
Nokogiri::XML::ParseOptions::NONET +
|
||||
Nokogiri::XML::ParseOptions::COMPACT) # do not modify doc!
|
||||
load_codes(custom_file_path)
|
||||
doc.search('product').each.with_index(1) do |row, i|
|
||||
# create a new article
|
||||
unit = row.search('eenheid').text
|
||||
unit = case unit.strip
|
||||
when '' then 'st'
|
||||
when 'stuk' then 'st'
|
||||
when 'g' then 'gr' # need at least 2 chars
|
||||
when 'l' then 'ltr'
|
||||
else unit
|
||||
end
|
||||
inhoud = row.search('inhoud').text
|
||||
inhoud.to_s.strip.empty? or (inhoud.to_f - 1).abs > 1e-3 and unit = inhoud.gsub(/\.0+\s*$/, '') + unit
|
||||
deposit = row.search('statiegeld').text
|
||||
deposit.to_s.strip.empty? and deposit = 0
|
||||
category = [
|
||||
@@codes[:indeling][row.search('indeling').text.to_i],
|
||||
@@codes[:indeling][row.search('subindeling').text.to_i]
|
||||
].compact.join(' - ')
|
||||
|
||||
status = row.search('status').text == 'Actief' ? nil : :outlisted
|
||||
article = {}
|
||||
unless row.search('bestelnummer').text == ''
|
||||
article = { order_number: row.search('bestelnummer').text,
|
||||
# :ean => row.search('eancode').text,
|
||||
name: row.search('omschrijving').text,
|
||||
note: row.search('kwaliteit').text,
|
||||
manufacturer: row.search('merk').text,
|
||||
origin: row.search('herkomst').text,
|
||||
unit: unit,
|
||||
price: row.search('prijs inkoopprijs').text,
|
||||
unit_quantity: row.search('sve').text,
|
||||
tax: row.search('btw').text,
|
||||
deposit: deposit,
|
||||
article_category: category }
|
||||
end
|
||||
yield article, status, i
|
||||
end
|
||||
end
|
||||
|
||||
@@codes = {}
|
||||
|
||||
def self.load_codes(custom_file_path = nil)
|
||||
@gem_lib = File.expand_path '..', __dir__
|
||||
dir = File.join @gem_lib, 'foodsoft_article_import'
|
||||
begin
|
||||
@@codes = YAML.safe_load(File.open(File.join(dir, 'dnb_codes.yml'))).symbolize_keys
|
||||
if custom_file_path
|
||||
custom_codes = YAML.safe_load(File.open(custom_file_path)).symbolize_keys
|
||||
custom_codes.each_key do |key|
|
||||
custom_codes[key] = custom_codes[key].merge @@codes[key] if @@codes.keys.include?(key)
|
||||
@@codes = @@codes.merge custom_codes
|
||||
end
|
||||
end
|
||||
@@codes
|
||||
rescue StandardError => e
|
||||
raise "Failed to load dnb_codes: #{dir}/dnb_codes.yml: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
11
lib/foodsoft_article_import/utf8_encoder.rb
Normal file
11
lib/foodsoft_article_import/utf8_encoder.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module UTF8Encoder
|
||||
def self.clean(string)
|
||||
if string.nil?
|
||||
string
|
||||
else
|
||||
string.encode('UTF-8')
|
||||
end
|
||||
end
|
||||
end
|
5
lib/foodsoft_article_import/version.rb
Normal file
5
lib/foodsoft_article_import/version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module FoodsoftArticleImport
|
||||
VERSION = '1.0.0'
|
||||
end
|
12
spec/files/bioromeo/bioromeo_flawless.csv
Normal file
12
spec/files/bioromeo/bioromeo_flawless.csv
Normal file
|
@ -0,0 +1,12 @@
|
|||
,,,,,,
|
||||
,Bestelling plaatsen via info@bioromeo.nl,,,,,
|
||||
,Op maandag bestellen.,,,,,
|
||||
,Uitleveren. ,,,,,
|
||||
Zwijnsweg 5,Prijzen blablabla,,,,,
|
||||
8307 PP Ens,"En nog meer wat €0,- kosten",,,,,
|
||||
skal 012345,bla in overleg,,,,,
|
||||
Vragen: bel iemand 01-23456789,,,,,,
|
||||
,,,,,,
|
||||
Artnr.,Product,Skal,Demeter, Prijs per eenh. , Prijs per colli ,Bestelling,opm.
|
||||
,"Aardappels ""nieuwe oogst""",,,,,,
|
||||
1,Wilde aardappels - 5kg,1234,123456, € 1.00 , € 5.00 ,,Kopervrij
|
Can't render this file because it has a wrong number of fields in line 10.
|
3
spec/files/bnn/bnn_bad_encoding.BNN
Normal file
3
spec/files/bnn/bnn_bad_encoding.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
64721;A;;;4280001958081;4280001958203;Greek Dressing - Kräuter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-ÖKO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
;;99
|
3
spec/files/bnn/bnn_flawless.BNN
Normal file
3
spec/files/bnn/bnn_flawless.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
64721;X;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
;;99
|
3
spec/files/bnn/bnn_flawless_category.BNN
Normal file
3
spec/files/bnn/bnn_flawless_category.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;4000;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
;;99
|
3
spec/files/bnn/bnn_flawless_special.BNN
Normal file
3
spec/files/bnn/bnn_flawless_special.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;20230101;20230201;;Kg;28,571;;
|
||||
;;99
|
3
spec/files/bnn/bnn_missing_entries.BNN
Normal file
3
spec/files/bnn/bnn_missing_entries.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;HDE;;GR;C%;DE-™KO-001;120;1100;10;55;;1;6 x35g;6;35g;1;N;;99260;;1,41;;;;1;;;4,49;2,89;J;;;;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
;;99
|
3
spec/files/bnn/bnn_missing_order_number.BNN
Normal file
3
spec/files/bnn/bnn_missing_order_number.BNN
Normal file
|
@ -0,0 +1,3 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;HDE;;GR;C%;DE-™KO-001;120;1100;10;55;;1;6 x35g;6;35g;1;N;;99260;;1,41;;;;1;;;4,49;2,89;J;;;;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
;;99
|
8
spec/files/custom_codes.yml
Normal file
8
spec/files/custom_codes.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
# BNN Codes
|
||||
category:
|
||||
"4000": "Schuhe"
|
||||
additional:
|
||||
"additional": "value"
|
||||
indeling:
|
||||
11: Test Indeling
|
||||
111: Test Subindeling
|
3
spec/files/foodsoft/foodsoft_flawless.csv
Normal file
3
spec/files/foodsoft/foodsoft_flawless.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category
|
||||
;1;product;bio;someone;eu;1 kg;1.23;6;0;10;;;coolstuff
|
||||
;12;other product;bio;someone;eu;2 kg;3.45;6;0;10;;;coolstuff
|
|
3
spec/files/foodsoft/foodsoft_generate_order_number.csv
Normal file
3
spec/files/foodsoft/foodsoft_generate_order_number.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category
|
||||
;;product;bio;someone;eu;1 kg;1.23;6;0;10;;;coolstuff
|
||||
;;other product;bio;someone;eu;2 kg;3.45;6;0;10;;;coolstuff
|
|
2
spec/files/foodsoft/foodsoft_missing_entries.csv
Normal file
2
spec/files/foodsoft/foodsoft_missing_entries.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category
|
||||
;12;product;bio;;eu;1 kg;1.23;;0;10;;;coolstuff
|
|
75
spec/files/odin/odin_flawless.xml
Normal file
75
spec/files/odin/odin_flawless.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>nucli rose</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>750</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>NELEMAN</merk>
|
||||
<kwaliteit>Biologisch</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>ES</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>21</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>0109</bestelnummer>
|
||||
<sve>6</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>4.52</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
77
spec/files/odin/odin_flawless_custom_category.xml
Normal file
77
spec/files/odin/odin_flawless_custom_category.xml
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>nucli rose</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>750</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>NELEMAN</merk>
|
||||
<kwaliteit>Biologisch</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>ES</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>21</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>0109</bestelnummer>
|
||||
<indeling>11</indeling>
|
||||
<subindeling>111</subindeling>
|
||||
<sve>6</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>4.52</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
75
spec/files/odin/odin_missing_entries.xml
Normal file
75
spec/files/odin/odin_missing_entries.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>nucli rose</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>750</inhoud>
|
||||
<eenheid></eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk></merk>
|
||||
<kwaliteit>Biologisch</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>ES</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>21</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>0109</bestelnummer>
|
||||
<sve>6</sve>
|
||||
<status>Non Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>4.52</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
75
spec/files/odin/odin_missing_order_number.xml
Normal file
75
spec/files/odin/odin_missing_order_number.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>nucli rose</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>750</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>NELEMAN</merk>
|
||||
<kwaliteit>Biologisch</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>ES</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>21</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer></bestelnummer>
|
||||
<sve>6</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>4.52</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
25
spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb
Normal file
25
spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require_relative '../../../lib/foodsoft_article_import'
|
||||
|
||||
describe FoodsoftArticleImport do
|
||||
files_path = File.expand_path '../../files', __dir__
|
||||
bioromeo_files_path = File.join(files_path, 'bioromeo')
|
||||
|
||||
dummy_article = { order_number: '1', name: 'Wilde aardappels', article_category: 'Aardappels "nieuwe oogst"',
|
||||
deposit: 0, manufacturer: nil, origin: 'Noordoostpolder, NL', price: 5.0, tax: 6, unit: '5kg', unit_quantity: 1, note: 'Skal 1234; 123456; Demeter 123456; (Kopervrij)' }
|
||||
|
||||
empty = {}
|
||||
|
||||
context 'bioromeo' do
|
||||
it 'parses file correctly with type parameter bioromeo' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bioromeo_files_path, 'bioromeo_flawless.csv')),
|
||||
type: 'bioromeo') do |new_attrs, _status, _line|
|
||||
next if new_attrs.nil?
|
||||
|
||||
expect(new_attrs).to eq dummy_article
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
86
spec/lib/bnn/foodsoft_article_import_bnn_spec.rb
Normal file
86
spec/lib/bnn/foodsoft_article_import_bnn_spec.rb
Normal file
|
@ -0,0 +1,86 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require_relative '../../../lib/foodsoft_article_import'
|
||||
|
||||
describe FoodsoftArticleImport do
|
||||
files_path = File.expand_path '../../files', __dir__
|
||||
bnn_files_path = File.join(files_path, 'bnn')
|
||||
|
||||
dummy_article = { name: 'Greek Dressing - Kräuter Mix', order_number: '64721', note: 'Oregano, Basilikum und Minze',
|
||||
manufacturer: 'Medousa, Griechenland Importe', origin: 'GR', article_category: 'Kräutermischungen', unit: '35g', price: '2,89', tax: 7.0, unit_quantity: '6' }
|
||||
|
||||
article = dummy_article.merge({ deposit: 0.08 })
|
||||
article_special = article.merge(note: 'Sonderpreis: 2,89 von 20230101 bis 20230201')
|
||||
|
||||
article_2 = dummy_article.merge({ manufacturer: nil, article_category: nil })
|
||||
|
||||
article_custom_code = article.merge(article_category: 'Schuhe')
|
||||
|
||||
empty = {}
|
||||
|
||||
context 'bnn' do
|
||||
it 'parses bnn file correctly without type parameter' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path,
|
||||
'bnn_flawless.BNN'))) do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq article
|
||||
expect(status).to eq :outlisted
|
||||
end
|
||||
end
|
||||
it 'parses file correctly with type parameter' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),
|
||||
type: 'bnn') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq article
|
||||
expect(status).to eq :outlisted
|
||||
end
|
||||
end
|
||||
it 'raises error wenn wrong type (except dnb_xml) specified' do
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),
|
||||
type: 'foodsoft')
|
||||
end.to raise_error(RuntimeError)
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),
|
||||
type: 'bioromeo')
|
||||
end.to raise_error(RuntimeError)
|
||||
|
||||
expect(FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),
|
||||
type: 'dnb_xml')).to eq []
|
||||
end
|
||||
it 'parses article with special correctly' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless_special.BNN')),
|
||||
type: 'bnn') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq article_special
|
||||
expect(status).to eq :special
|
||||
end
|
||||
end
|
||||
it 'parses missing entries correctly' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_missing_entries.BNN')),
|
||||
type: 'bnn') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq article_2
|
||||
expect(status).to eq nil
|
||||
end
|
||||
end
|
||||
it 'skips rows without order_number' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_missing_order_number.BNN')),
|
||||
type: 'bnn') do |new_attrs, _status, _line|
|
||||
expect(new_attrs).to eq empty
|
||||
end
|
||||
end
|
||||
it 'joins custom_codes file' do
|
||||
custom_file_path = File.join(files_path, 'custom_codes.yml').to_s
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless_category.BNN')),
|
||||
custom_file_path: custom_file_path, type: 'bnn') do |new_attrs, _status, _line|
|
||||
expect(new_attrs).to eq article_custom_code
|
||||
end
|
||||
end
|
||||
it 'parses file with different encoding' do
|
||||
# the bnn file is loaded with encoding ibm850. If file is not ibm850 encoded, some characters might look weird
|
||||
FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_bad_encoding.BNN')),
|
||||
type: 'bnn') do |new_attrs, _status, _line|
|
||||
expect(new_attrs[:order_number]).to eq('64721')
|
||||
expect(new_attrs[:name]).to eq('Greek Dressing - Kräuter Mix')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
68
spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb
Normal file
68
spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require_relative '../../../lib/foodsoft_article_import'
|
||||
|
||||
describe FoodsoftArticleImport do
|
||||
files_path = File.expand_path '../../files', __dir__
|
||||
foodsoft_files_path = File.join(files_path, 'foodsoft')
|
||||
|
||||
dummy_article = { order_number: '1', name: 'product', note: 'bio', manufacturer: 'someone', origin: 'eu',
|
||||
unit: '1 kg', price: '1.23', tax: '6', unit_quantity: '10', article_category: 'coolstuff', deposit: '0' }
|
||||
|
||||
dummy_article_2 = { order_number: '12', name: 'other product', note: 'bio', manufacturer: 'someone',
|
||||
origin: 'eu', unit: '2 kg', price: '3.45', tax: '6', unit_quantity: '10', article_category: 'coolstuff', deposit: '0' }
|
||||
|
||||
articles = [dummy_article, dummy_article_2]
|
||||
|
||||
dummy_article_3 = dummy_article.merge({ order_number: ':d8df298' })
|
||||
dummy_article_4 = dummy_article_2.merge({ order_number: ':1f37e39' })
|
||||
articles_number_generated = [dummy_article_3, dummy_article_4]
|
||||
empty = {}
|
||||
|
||||
context 'foodsoft' do
|
||||
it 'parses file correctly with type parameter foodsoft' do
|
||||
count = 0
|
||||
FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),
|
||||
type: 'foodsoft') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq articles[count]
|
||||
expect(status).to eq nil
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
it 'raises error wenn wrong type specified' do
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),
|
||||
type: 'bioromeo')
|
||||
end.to raise_error(Roo::HeaderRowNotFoundError)
|
||||
expect(FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),
|
||||
type: 'odin')).to eq []
|
||||
|
||||
expect(FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),
|
||||
type: 'bnn')).to eq []
|
||||
end
|
||||
it 'parses missing entries correctly' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_missing_entries.csv')),
|
||||
type: 'foodsoft') do |new_attrs, status, _line|
|
||||
expect(status).to eq 'Error: unit, price and tax must be entered'
|
||||
expect(new_attrs[:unit]).to eq '1 kg'
|
||||
expect(new_attrs[:manufacturer]).to eq nil
|
||||
end
|
||||
end
|
||||
it 'generates order numbers for articles without order number' do
|
||||
count = 0
|
||||
FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_generate_order_number.csv')),
|
||||
type: 'foodsoft') do |new_attrs, _status, _line|
|
||||
expect(new_attrs).to eq articles_number_generated[count]
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
xit 'joins custom_codes file' do
|
||||
custom_file_path = File.join(files_path, 'custom_codes.yml').to_s
|
||||
FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless_custom_category.csv')),
|
||||
custom_file_path: custom_file_path, type: 'foodsoft') do |new_attrs, _status, _line|
|
||||
expect(new_attrs[:article_category]).to eq 'Test Indeling - Test Subindeling'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
84
spec/lib/odin/foodsoft_article_import_odin_spec.rb
Normal file
84
spec/lib/odin/foodsoft_article_import_odin_spec.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require_relative '../../../lib/foodsoft_article_import'
|
||||
|
||||
describe FoodsoftArticleImport do
|
||||
files_path = File.expand_path '../../files', __dir__
|
||||
odin_files_path = File.join(files_path, 'odin')
|
||||
|
||||
dummy_article = { order_number: '0109', name: 'nucli rose', note: 'Biologisch', manufacturer: 'NELEMAN',
|
||||
origin: 'ES', unit: '750gr', price: '4.52', unit_quantity: '6', tax: '21', deposit: '0', article_category: '' }
|
||||
|
||||
empty = {}
|
||||
|
||||
context 'odin/dnb_xml' do
|
||||
it 'parses file correctly with type parameter dnb_xml' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),
|
||||
type: 'dnb_xml') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq dummy_article
|
||||
expect(status).to eq nil
|
||||
end
|
||||
end
|
||||
it 'parses file correctly with type parameter odin' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),
|
||||
type: 'odin') do |new_attrs, status, _line|
|
||||
expect(new_attrs).to eq dummy_article
|
||||
expect(status).to eq nil
|
||||
end
|
||||
end
|
||||
it 'raises error wenn wrong type specified' do
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),
|
||||
type: 'foodsoft')
|
||||
end.to raise_error(RuntimeError)
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),
|
||||
type: 'bioromeo')
|
||||
end.to raise_error(RuntimeError)
|
||||
|
||||
expect do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),
|
||||
type: 'bnn')
|
||||
end.to raise_error(CSV::MalformedCSVError)
|
||||
end
|
||||
it 'parses missing entries correctly' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_missing_entries.xml')),
|
||||
type: 'odin') do |new_attrs, status, _line|
|
||||
expect(status).to eq :outlisted
|
||||
expect(new_attrs[:unit]).to eq '750st'
|
||||
expect(new_attrs[:manufacturer]).to eq ''
|
||||
end
|
||||
end
|
||||
it 'skips rows without order_number' do
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_missing_order_number.xml')),
|
||||
type: 'odin') do |new_attrs, _status, _line|
|
||||
expect(new_attrs).to eq empty
|
||||
end
|
||||
end
|
||||
it 'joins custom_codes file' do
|
||||
custom_file_path = File.join(files_path, 'custom_codes.yml').to_s
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless_custom_category.xml')),
|
||||
custom_file_path: custom_file_path, type: 'odin') do |new_attrs, _status, _line|
|
||||
expect(new_attrs[:article_category]).to eq 'Test Indeling - Test Subindeling'
|
||||
end
|
||||
end
|
||||
|
||||
xit 'parses dummy_article with special correctly' do
|
||||
# TODO: find out whether there are special prices for odin files
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'bnn_flawless_special.BNN')),
|
||||
type: 'bnn') do |new_attrs, _status, _line|
|
||||
expect(new_attrs.manufacturer).to eq nil
|
||||
expect(new_attrs.unit).to eq '750st'
|
||||
end
|
||||
end
|
||||
xit 'parses file with different encoding' do
|
||||
# the bnn file is loaded with encoding ibm850. If file is not ibm850 encoded, some characters might look weird
|
||||
FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'bnn_bad_encoding.BNN')),
|
||||
type: 'bnn') do |new_attrs, _status, _line|
|
||||
expect(new_attrs[:order_number]).to eq('64721')
|
||||
expect(new_attrs[:name]).to eq('Greek Dressing - Kräuter Mix')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
100
spec/spec_helper.rb
Normal file
100
spec/spec_helper.rb
Normal file
|
@ -0,0 +1,100 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'simplecov'
|
||||
SimpleCov.start
|
||||
# This file was generated by the `rspec --init` command. Conventionally, all
|
||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
||||
# this file to always be loaded, without a need to explicitly require it in any
|
||||
# files.
|
||||
#
|
||||
# Given that it is always loaded, you are encouraged to keep this file as
|
||||
# light-weight as possible. Requiring heavyweight dependencies from this file
|
||||
# will add to the boot time of your test suite on EVERY test run, even for an
|
||||
# individual file that may not need all of that loaded. Instead, consider making
|
||||
# a separate helper file that requires the additional dependencies and performs
|
||||
# the additional setup, and require it from the spec files that actually need
|
||||
# it.
|
||||
#
|
||||
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||
RSpec.configure do |config|
|
||||
# rspec-expectations config goes here. You can use an alternate
|
||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||
# assertions if you prefer.
|
||||
config.expect_with :rspec do |expectations|
|
||||
# This option will default to `true` in RSpec 4. It makes the `description`
|
||||
# and `failure_message` of custom matchers include text for helper methods
|
||||
# defined using `chain`, e.g.:
|
||||
# be_bigger_than(2).and_smaller_than(4).description
|
||||
# # => "be bigger than 2 and smaller than 4"
|
||||
# ...rather than:
|
||||
# # => "be bigger than 2"
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
# rspec-mocks config goes here. You can use an alternate test double
|
||||
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
||||
config.mock_with :rspec do |mocks|
|
||||
# Prevents you from mocking or stubbing a method that does not exist on
|
||||
# a real object. This is generally recommended, and will default to
|
||||
# `true` in RSpec 4.
|
||||
mocks.verify_partial_doubles = true
|
||||
end
|
||||
|
||||
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
||||
# have no way to turn it off -- the option exists only for backwards
|
||||
# compatibility in RSpec 3). It causes shared context metadata to be
|
||||
# inherited by the metadata hash of host groups and examples, rather than
|
||||
# triggering implicit auto-inclusion in groups with matching metadata.
|
||||
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||
|
||||
# The settings below are suggested to provide a good initial experience
|
||||
# with RSpec, but feel free to customize to your heart's content.
|
||||
# # This allows you to limit a spec run to individual examples or groups
|
||||
# # you care about by tagging them with `:focus` metadata. When nothing
|
||||
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
||||
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
||||
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
||||
# config.filter_run_when_matching :focus
|
||||
#
|
||||
# # Allows RSpec to persist some state between runs in order to support
|
||||
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
||||
# # you configure your source control system to ignore this file.
|
||||
# config.example_status_persistence_file_path = "spec/examples.txt"
|
||||
#
|
||||
# # Limits the available syntax to the non-monkey patched syntax that is
|
||||
# # recommended. For more details, see:
|
||||
# # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
|
||||
# config.disable_monkey_patching!
|
||||
#
|
||||
# # This setting enables warnings. It's recommended, but in some cases may
|
||||
# # be too noisy due to issues in dependencies.
|
||||
# config.warnings = true
|
||||
#
|
||||
# # Many RSpec users commonly either run the entire suite or an individual
|
||||
# # file, and it's useful to allow more verbose output when running an
|
||||
# # individual spec file.
|
||||
# if config.files_to_run.one?
|
||||
# # Use the documentation formatter for detailed output,
|
||||
# # unless a formatter has already been configured
|
||||
# # (e.g. via a command-line flag).
|
||||
# config.default_formatter = "doc"
|
||||
# end
|
||||
#
|
||||
# # Print the 10 slowest examples and example groups at the
|
||||
# # end of the spec run, to help surface which specs are running
|
||||
# # particularly slow.
|
||||
# config.profile_examples = 10
|
||||
#
|
||||
# # Run specs in random order to surface order dependencies. If you find an
|
||||
# # order dependency and want to debug it, you can fix the order by providing
|
||||
# # the seed, which is printed after each run.
|
||||
# # --seed 1234
|
||||
# config.order = :random
|
||||
#
|
||||
# # Seed global randomization in this process using the `--seed` CLI option.
|
||||
# # Setting this allows you to use `--seed` to deterministically reproduce
|
||||
# # test failures related to randomization by passing the same `--seed` value
|
||||
# # as the one that triggered the failure.
|
||||
# Kernel.srand config.seed
|
||||
end
|
Loading…
Reference in a new issue