edifunct 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +59 -0
- data/CHANGELOG.md +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +2 -0
- data/README_generate.rb +2 -0
- data/edifunct.gemspec +4 -2
- data/lib/edifunct/tokenizer.rb +29 -4
- data/lib/edifunct/version.rb +1 -1
- metadata +29 -12
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d46c6d769342edc4dc737c74e8eef025143b8f0e86b6d42536b2bef7dd09e1f6
|
4
|
+
data.tar.gz: 9be6955544378e8061d8b126d1d4502cfee9dc90f7824ffafca0c60e6852fd13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad2b1dcf0d4757ee18a39c25687c46c84f806c59998d8b7ab244d33b262eca9295fd787a800b7c1894929ba62083b4d10e4bfe1e2770d4bf14dad1dd743520c
|
7
|
+
data.tar.gz: ffa8cbbc849a6f97c2388f867d64df69078a41c9ae9290cc51cde6c1e5309ea1cc614600d8f87563525204fbf992be80513ce197e07b8edfb39c7e2781bd3129
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.5.3
|
11
|
+
|
12
|
+
# Specify service dependencies here if necessary
|
13
|
+
# CircleCI maintains a library of pre-built images
|
14
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
+
# - image: circleci/postgres:9.4
|
16
|
+
|
17
|
+
working_directory: ~/repo
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
|
22
|
+
# Download and cache dependencies
|
23
|
+
- restore_cache:
|
24
|
+
keys:
|
25
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
26
|
+
# fallback to using the latest cache if no exact match is found
|
27
|
+
- v1-dependencies-
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: install dependencies
|
31
|
+
command: |
|
32
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
33
|
+
|
34
|
+
- save_cache:
|
35
|
+
paths:
|
36
|
+
- ./vendor/bundle
|
37
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
38
|
+
|
39
|
+
# run tests!
|
40
|
+
- run:
|
41
|
+
name: run tests
|
42
|
+
command: |
|
43
|
+
mkdir /tmp/test-results
|
44
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
|
45
|
+
circleci tests split --split-by=timings)"
|
46
|
+
|
47
|
+
bundle exec rspec \
|
48
|
+
--format progress \
|
49
|
+
--format RspecJunitFormatter \
|
50
|
+
--out /tmp/test-results/rspec.xml \
|
51
|
+
--format progress \
|
52
|
+
$TEST_FILES
|
53
|
+
|
54
|
+
# collect reports
|
55
|
+
- store_test_results:
|
56
|
+
path: /tmp/test-results
|
57
|
+
- store_artifacts:
|
58
|
+
path: /tmp/test-results
|
59
|
+
destination: test-results
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [2.0.0] - 2020-03-04
|
11
|
+
### Added
|
12
|
+
- MIT license.
|
13
|
+
- Support for UNA Service String Advice.
|
14
|
+
|
15
|
+
## [1.0.0] - 2019-01-20
|
16
|
+
### Added
|
17
|
+
- Released this gem!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Orhan Toy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Fun with EDIFACT :tada:
|
4
4
|
|
5
|
+
[![CircleCI](https://circleci.com/gh/orhantoy/edifunct.svg?style=svg)](https://circleci.com/gh/orhantoy/edifunct)
|
6
|
+
|
5
7
|
EDIFACT files consist of segments and extracting the segments themselves is not too complex.
|
6
8
|
But when segments are being grouped in segment groups and nested segment groups, it would require having an additional, manual parsing step after extracting the segments.
|
7
9
|
This gem makes this easy by parsing the EDIFACT file according to a simple schema which you provide alongside the EDIFACT file.
|
data/README_generate.rb
CHANGED
@@ -7,6 +7,8 @@ puts
|
|
7
7
|
puts <<-MARKDOWN
|
8
8
|
Fun with EDIFACT :tada:
|
9
9
|
|
10
|
+
[![CircleCI](https://circleci.com/gh/orhantoy/edifunct.svg?style=svg)](https://circleci.com/gh/orhantoy/edifunct)
|
11
|
+
|
10
12
|
EDIFACT files consist of segments and extracting the segments themselves is not too complex.
|
11
13
|
But when segments are being grouped in segment groups and nested segment groups, it would require having an additional, manual parsing step after extracting the segments.
|
12
14
|
This gem makes this easy by parsing the EDIFACT file according to a simple schema which you provide alongside the EDIFACT file.
|
data/edifunct.gemspec
CHANGED
@@ -7,6 +7,7 @@ require "edifunct/version"
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "edifunct"
|
9
9
|
spec.version = Edifunct::VERSION
|
10
|
+
spec.licenses = ["MIT"]
|
10
11
|
spec.authors = ["Orhan Toy"]
|
11
12
|
spec.email = ["toyorhan@gmail.com"]
|
12
13
|
|
@@ -23,7 +24,8 @@ Gem::Specification.new do |spec|
|
|
23
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
25
|
spec.require_paths = ["lib"]
|
25
26
|
|
26
|
-
spec.add_development_dependency "bundler", "
|
27
|
-
spec.add_development_dependency "rake", "
|
27
|
+
spec.add_development_dependency "bundler", "> 1.17.0"
|
28
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.0"
|
29
31
|
end
|
data/lib/edifunct/tokenizer.rb
CHANGED
@@ -6,9 +6,27 @@ module Edifunct
|
|
6
6
|
# Tokenizer is responsible for splitting message into segments, data elements and components.
|
7
7
|
class Tokenizer
|
8
8
|
class << self
|
9
|
-
def for_message(
|
10
|
-
|
11
|
-
|
9
|
+
def for_message(edifact_message)
|
10
|
+
if edifact_message.start_with?("UNA")
|
11
|
+
_u,
|
12
|
+
_n,
|
13
|
+
_a,
|
14
|
+
component_data_element_separator,
|
15
|
+
data_element_separator,
|
16
|
+
_decimal_mark_delimiter,
|
17
|
+
release_character,
|
18
|
+
_reserved,
|
19
|
+
segment_terminator = edifact_message.chars
|
20
|
+
|
21
|
+
new(
|
22
|
+
release_character: release_character,
|
23
|
+
segment_terminator: segment_terminator,
|
24
|
+
data_element_separator: data_element_separator,
|
25
|
+
component_data_element_separator: component_data_element_separator
|
26
|
+
)
|
27
|
+
else
|
28
|
+
new
|
29
|
+
end
|
12
30
|
end
|
13
31
|
end
|
14
32
|
|
@@ -22,7 +40,7 @@ module Edifunct
|
|
22
40
|
end
|
23
41
|
|
24
42
|
def as_segments(message_as_string)
|
25
|
-
message_as_string.split(segment_regexp).map do |raw_segment|
|
43
|
+
strip_service_string_advice(message_as_string).split(segment_regexp).map do |raw_segment|
|
26
44
|
segment_tag, data_elements = split_segment(raw_segment)
|
27
45
|
|
28
46
|
Segment.new(tag: segment_tag, raw_segment: raw_segment, data_elements: data_elements)
|
@@ -67,5 +85,12 @@ module Edifunct
|
|
67
85
|
def component_data_element_regexp
|
68
86
|
@component_data_element_regexp ||= Regexp.new("(?!#{Regexp.escape(@release_character)})#{Regexp.escape(@component_data_element_separator)}")
|
69
87
|
end
|
88
|
+
|
89
|
+
SERVICE_STRING_ADVICE_REGEXP = /\A\s*UNA.{6}\s*/
|
90
|
+
|
91
|
+
# Strips the optional UNA segment, also known as the Service String Advice.
|
92
|
+
def strip_service_string_advice(message_as_string)
|
93
|
+
message_as_string.sub(SERVICE_STRING_ADVICE_REGEXP, '')
|
94
|
+
end
|
70
95
|
end
|
71
96
|
end
|
data/lib/edifunct/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edifunct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orhan Toy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.17.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.4.0
|
55
69
|
description: Edifunct provides an easy way to structurally parse an EDIFACT file based
|
56
70
|
on a simple schema
|
57
71
|
email:
|
@@ -60,10 +74,12 @@ executables: []
|
|
60
74
|
extensions: []
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
77
|
+
- ".circleci/config.yml"
|
63
78
|
- ".gitignore"
|
64
79
|
- ".rspec"
|
65
|
-
-
|
80
|
+
- CHANGELOG.md
|
66
81
|
- Gemfile
|
82
|
+
- LICENSE.txt
|
67
83
|
- README.md
|
68
84
|
- README_generate.rb
|
69
85
|
- Rakefile
|
@@ -77,7 +93,8 @@ files:
|
|
77
93
|
- lib/edifunct/tokenizer.rb
|
78
94
|
- lib/edifunct/version.rb
|
79
95
|
homepage: https://github.com/orhantoy/edifunct
|
80
|
-
licenses:
|
96
|
+
licenses:
|
97
|
+
- MIT
|
81
98
|
metadata: {}
|
82
99
|
post_install_message:
|
83
100
|
rdoc_options: []
|