markup_fuel 0.1.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +8 -0
- data/.gitignore +6 -0
- data/.rubocop.yml +36 -0
- data/.ruby-version +1 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Guardfile +16 -0
- data/LICENSE +7 -0
- data/README.md +216 -0
- data/Rakefile +17 -0
- data/bin/console +18 -0
- data/exe/.gitkeep +0 -0
- data/lib/markup_fuel.rb +13 -0
- data/lib/markup_fuel/library.rb +19 -0
- data/lib/markup_fuel/library/deserialize/xml.rb +56 -0
- data/lib/markup_fuel/library/serialize/xml.rb +51 -0
- data/lib/markup_fuel/version.rb +12 -0
- data/markup_fuel.gemspec +41 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea7a3ad7534be259ec85bfa1f89f6ea6fea811921d30f4a5252b61dcbbbe935b
|
4
|
+
data.tar.gz: 49968cc0fb9c099ad1b343a435b9934721050e1de8efbf7ed737b3dd8e1da0cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72582746573eb3362aa3880a37f1f113bf352d4110249aa107cdcad62896e270bc6a0a1c41d059e09362f4dcbf954b787e02dce4384318b85c00dcefea75811b
|
7
|
+
data.tar.gz: 5b72ca75d18f8745682db2bb3af10dfcefe28a3a6dfaf812f3a38e5b87a8f74f12aa98dd35769762387aad10f885898949a15a5d92cb4eb4dd266fb33b3afe54
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
4
|
+
|
5
|
+
Layout/LineLength:
|
6
|
+
Max: 100
|
7
|
+
Exclude:
|
8
|
+
- markup_fuel.gemspec
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
ExcludedMethods:
|
12
|
+
- let
|
13
|
+
- it
|
14
|
+
- describe
|
15
|
+
- context
|
16
|
+
- specify
|
17
|
+
- define
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 30
|
21
|
+
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Max: 25
|
24
|
+
|
25
|
+
Metrics/ClassLength:
|
26
|
+
Max: 125
|
27
|
+
|
28
|
+
Metrics/ParameterLists:
|
29
|
+
CountKeywordArgs: false
|
30
|
+
|
31
|
+
Style/TrailingCommaInHashLiteral:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/TrailingCommaInArrayLiteral:
|
35
|
+
Enabled: false
|
36
|
+
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=fa3b91a072547e91492ea97e69498eb5cfc472daec7d24827549f515a3bb929e
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
7
|
+
- 2.5.8
|
8
|
+
- 2.6.6
|
9
|
+
- 2.7.1
|
10
|
+
cache: bundler
|
11
|
+
before_script:
|
12
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
13
|
+
- chmod +x ./cc-test-reporter
|
14
|
+
- ./cc-test-reporter before-build
|
15
|
+
script:
|
16
|
+
- bundle exec rubocop
|
17
|
+
- bundle exec rspec spec --format documentation
|
18
|
+
after_script:
|
19
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
20
|
+
addons:
|
21
|
+
# https://docs.travis-ci.com/user/uploading-artifacts/
|
22
|
+
artifacts:
|
23
|
+
paths:
|
24
|
+
- Gemfile.lock
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
|
4
|
+
require 'guard/rspec/dsl'
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
6
|
+
|
7
|
+
# RSpec files
|
8
|
+
rspec = dsl.rspec
|
9
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_files)
|
12
|
+
|
13
|
+
# Ruby files
|
14
|
+
ruby = dsl.ruby
|
15
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2020 Blue Marble Payroll, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
# Markup Fuel
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/markup_fuel.svg)](https://badge.fury.io/rb/markup_fuel) [![Build Status](https://travis-ci.com/bluemarblepayroll/markup_fuel.svg?branch=master)](https://travis-ci.com/bluemarblepayroll/markup_fuel) [![Maintainability](https://api.codeclimate.com/v1/badges/e38efa993c8292a45a99/maintainability)](https://codeclimate.com/github/bluemarblepayroll/markup_fuel/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e38efa993c8292a45a99/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/markup_fuel/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
|
+
|
5
|
+
This library is a plugin for [Burner](https://github.com/bluemarblepayroll/burner). It adds jobs focused around XML processing such as reading and writing XML documents. XML can get very non-trivial quickly, but this library aims at implementing only what is identified as necessary for XML processing. Pull requests are welcomed to add more additional functionality.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
To install through Rubygems:
|
10
|
+
|
11
|
+
````bash
|
12
|
+
gem install markup_fuel
|
13
|
+
````
|
14
|
+
|
15
|
+
You can also add this to your Gemfile:
|
16
|
+
|
17
|
+
````bash
|
18
|
+
bundle add markup_fuel
|
19
|
+
````
|
20
|
+
## Jobs
|
21
|
+
|
22
|
+
Refer to the [Burner](https://github.com/bluemarblepayroll/burner) library for more specific information on how Burner works. This section will just focus on what this library directly adds.
|
23
|
+
|
24
|
+
* **markup_fuel/deserialize/xml** [force_array, register]: Take a register's value as a string and parse it as XML into a rich Ruby object modeling. The `force_array` option is false by default. If `force_array` is true then each keys' value will be wrapped in an array.
|
25
|
+
* **markup_fuel/serialize/xml** [no_attributes, register, root_name]: Take a register's value as a Ruby object model and convert it to an XML document in string form. The `no_attributes` option is set to true by default which will force each key to a node. The `root_name` is nil by default, which will produce an `<opt>` node around the entire document. This can be configured to be something other than `<opt>` by passing in something not nil. If `root_name` is a blank string then no top level node will exist.
|
26
|
+
|
27
|
+
## Examples
|
28
|
+
|
29
|
+
### Parsing (de-serializing) an XML Document
|
30
|
+
|
31
|
+
Let's use the example fixture file as an example XML file to read and parse (located at `spec/fixtures/patients.xml`). We could execute the following Burner pipeline:
|
32
|
+
|
33
|
+
````ruby
|
34
|
+
pipeline = {
|
35
|
+
jobs: [
|
36
|
+
{
|
37
|
+
name: 'read',
|
38
|
+
type: 'b/value/static',
|
39
|
+
register: 'patients',
|
40
|
+
value: <<~XML
|
41
|
+
<patients>
|
42
|
+
<patient>
|
43
|
+
<id>1</id>
|
44
|
+
<demographics>
|
45
|
+
<first>Bozo</first>
|
46
|
+
<last>Clown</last>
|
47
|
+
</demographics>
|
48
|
+
</patient>
|
49
|
+
<patient>
|
50
|
+
<id>2</id>
|
51
|
+
<demographics>
|
52
|
+
<first>Frank</first>
|
53
|
+
<last>Rizzo</last>
|
54
|
+
</demographics>
|
55
|
+
</patient>
|
56
|
+
</patients>
|
57
|
+
XML
|
58
|
+
},
|
59
|
+
{
|
60
|
+
name: 'parse',
|
61
|
+
register: 'patients',
|
62
|
+
type: 'markup_fuel/deserialize/xml'
|
63
|
+
}
|
64
|
+
]
|
65
|
+
}
|
66
|
+
|
67
|
+
payload = Burner::Payload.new
|
68
|
+
|
69
|
+
Burner::Pipeline.make(pipeline).execute(payload: payload)
|
70
|
+
````
|
71
|
+
|
72
|
+
Inspecting the payload's registers would now look something like this:
|
73
|
+
|
74
|
+
````ruby
|
75
|
+
patients = payload['patients']
|
76
|
+
|
77
|
+
#{
|
78
|
+
# 'patient' => [
|
79
|
+
# {
|
80
|
+
# 'demographics' => {
|
81
|
+
# 'first' => 'Bozo',
|
82
|
+
# 'last' => 'Clown'
|
83
|
+
# },
|
84
|
+
# 'id' => '1'
|
85
|
+
# },
|
86
|
+
# {
|
87
|
+
# 'demographics' => {
|
88
|
+
# 'first' => 'Frank',
|
89
|
+
# 'last' => 'Rizzo'
|
90
|
+
# },
|
91
|
+
# 'id' => '2'
|
92
|
+
# }
|
93
|
+
# ]
|
94
|
+
#}
|
95
|
+
````
|
96
|
+
|
97
|
+
### Writing (serializing) an XML Document
|
98
|
+
|
99
|
+
Let's do an exact opposite of the above example. Let's say we would like to write an XML document:
|
100
|
+
|
101
|
+
````ruby
|
102
|
+
pipeline = {
|
103
|
+
jobs: [
|
104
|
+
{
|
105
|
+
name: 'load_patients',
|
106
|
+
type: 'b/value/static',
|
107
|
+
register: :patients,
|
108
|
+
value: {
|
109
|
+
'patient' => [
|
110
|
+
{
|
111
|
+
'demographics' => {
|
112
|
+
'first' => 'Bozo',
|
113
|
+
'last' => 'Clown'
|
114
|
+
},
|
115
|
+
'id' => '1'
|
116
|
+
},
|
117
|
+
{
|
118
|
+
'demographics' => {
|
119
|
+
'first' => 'Frank',
|
120
|
+
'last' => 'Rizzo'
|
121
|
+
},
|
122
|
+
'id' => '2'
|
123
|
+
}
|
124
|
+
]
|
125
|
+
}
|
126
|
+
},
|
127
|
+
{
|
128
|
+
name: 'to_xml',
|
129
|
+
type: 'markup_fuel/serialize/xml',
|
130
|
+
register: :patients,
|
131
|
+
root_name: :patients
|
132
|
+
}
|
133
|
+
]
|
134
|
+
}
|
135
|
+
|
136
|
+
payload = Burner::Payload.new
|
137
|
+
|
138
|
+
Burner::Pipeline.make(pipeline).execute(payload: payload)
|
139
|
+
````
|
140
|
+
|
141
|
+
Inspecting the payload's registers would now look something like this:
|
142
|
+
|
143
|
+
````ruby
|
144
|
+
patients = payload['patients']
|
145
|
+
|
146
|
+
# <patients>
|
147
|
+
# <patient>
|
148
|
+
# <demographics>
|
149
|
+
# <first>Bozo</first>
|
150
|
+
# <last>Clown</last>
|
151
|
+
# </demographics>
|
152
|
+
# <id>1</id>
|
153
|
+
# </patient>
|
154
|
+
# <patient>
|
155
|
+
# <demographics>
|
156
|
+
# <first>Frank</first>
|
157
|
+
# <last>Rizzo</last>
|
158
|
+
# </demographics>
|
159
|
+
# <id>2</id>
|
160
|
+
# </patient>
|
161
|
+
# </patients>
|
162
|
+
````
|
163
|
+
|
164
|
+
## Contributing
|
165
|
+
|
166
|
+
### Development Environment Configuration
|
167
|
+
|
168
|
+
Basic steps to take to get this repository compiling:
|
169
|
+
|
170
|
+
1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (check markup_fuel.gemspec for versions supported)
|
171
|
+
2. Install bundler (gem install bundler)
|
172
|
+
3. Clone the repository (git clone git@github.com:bluemarblepayroll/markup_fuel.git)
|
173
|
+
4. Navigate to the root folder (cd markup_fuel)
|
174
|
+
5. Install dependencies (bundle)
|
175
|
+
|
176
|
+
### Running Tests
|
177
|
+
|
178
|
+
To execute the test suite run:
|
179
|
+
|
180
|
+
````bash
|
181
|
+
bundle exec rspec spec --format documentation
|
182
|
+
````
|
183
|
+
|
184
|
+
Alternatively, you can have Guard watch for changes:
|
185
|
+
|
186
|
+
````bash
|
187
|
+
bundle exec guard
|
188
|
+
````
|
189
|
+
|
190
|
+
Also, do not forget to run Rubocop:
|
191
|
+
|
192
|
+
````bash
|
193
|
+
bundle exec rubocop
|
194
|
+
````
|
195
|
+
|
196
|
+
### Publishing
|
197
|
+
|
198
|
+
Note: ensure you have proper authorization before trying to publish new versions.
|
199
|
+
|
200
|
+
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
|
201
|
+
|
202
|
+
1. Merge Pull Request into master
|
203
|
+
2. Update `lib/markup_fuel/version.rb` using [semantic versioning](https://semver.org/)
|
204
|
+
3. Install dependencies: `bundle`
|
205
|
+
4. Update `CHANGELOG.md` with release notes
|
206
|
+
5. Commit & push master to remote and ensure CI builds master successfully
|
207
|
+
6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
208
|
+
|
209
|
+
## Code of Conduct
|
210
|
+
|
211
|
+
Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/markup_fuel/blob/master/CODE_OF_CONDUCT.md).
|
212
|
+
|
213
|
+
## License
|
214
|
+
|
215
|
+
This project is MIT Licensed.
|
216
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
RuboCop::RakeTask.new
|
16
|
+
|
17
|
+
task default: %i[rubocop spec]
|
data/bin/console
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
6
|
+
#
|
7
|
+
# This source code is licensed under the MIT license found in the
|
8
|
+
# LICENSE file in the root directory of this source tree.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bundler/setup'
|
12
|
+
require 'markup_fuel'
|
13
|
+
|
14
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
15
|
+
# with your gem easier. You can also use a different console, if you like.
|
16
|
+
|
17
|
+
require 'pry'
|
18
|
+
Pry.start
|
data/exe/.gitkeep
ADDED
File without changes
|
data/lib/markup_fuel.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'burner'
|
11
|
+
require 'xmlsimple'
|
12
|
+
|
13
|
+
require_relative 'markup_fuel/library'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'library/deserialize/xml'
|
11
|
+
require_relative 'library/serialize/xml'
|
12
|
+
|
13
|
+
module Burner
|
14
|
+
# Open up the Burner::Jobs class and register our jobs.
|
15
|
+
class Jobs
|
16
|
+
register 'markup_fuel/deserialize/xml', MarkupFuel::Library::Deserialize::Xml
|
17
|
+
register 'markup_fuel/serialize/xml', MarkupFuel::Library::Serialize::Xml
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module MarkupFuel
|
11
|
+
module Library
|
12
|
+
module Deserialize
|
13
|
+
# This job works on a single register, reads its value, and de-serializes it using
|
14
|
+
# the XmlSimple gem. There is some nice documentation that ships with the gem
|
15
|
+
# located here: https://github.com/maik/xml-simple/tree/master/docs.
|
16
|
+
# More or less, this is just a Burner::Job wrapper around the XmlSimple#xml_in API.
|
17
|
+
#
|
18
|
+
# Expected Payload[register] input: string of XML.
|
19
|
+
# Payload[register] output: Ruby object representation of the XML.
|
20
|
+
class Xml < Burner::JobWithRegister
|
21
|
+
FORCE_ARRAY_KEY = 'ForceArray'
|
22
|
+
|
23
|
+
attr_reader :options
|
24
|
+
|
25
|
+
def initialize(
|
26
|
+
name:,
|
27
|
+
force_array: false,
|
28
|
+
register: Burner::DEFAULT_REGISTER
|
29
|
+
)
|
30
|
+
super(name: name, register: register)
|
31
|
+
|
32
|
+
@options = make_options(force_array)
|
33
|
+
|
34
|
+
freeze
|
35
|
+
end
|
36
|
+
|
37
|
+
def perform(_output, payload)
|
38
|
+
value = payload[register]
|
39
|
+
|
40
|
+
if value.to_s.empty?
|
41
|
+
payload[register] = nil
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
payload[register] = XmlSimple.xml_in(payload[register], options)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def make_options(force_array)
|
51
|
+
{ FORCE_ARRAY_KEY => force_array }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module MarkupFuel
|
11
|
+
module Library
|
12
|
+
module Serialize
|
13
|
+
# This job works on a single register, reads its value, and serializes it using
|
14
|
+
# the XmlSimple gem. There is some nice documentation that ships with the gem
|
15
|
+
# located here: https://github.com/maik/xml-simple/tree/master/docs.
|
16
|
+
# More or less, this is just a Burner::Job wrapper around the XmlSimple#xml_out API.
|
17
|
+
#
|
18
|
+
# Expected Payload[register] input: Ruby object modeling.
|
19
|
+
# Payload[register] output: XML representation of the Ruby object modeling as a string.
|
20
|
+
class Xml < Burner::JobWithRegister
|
21
|
+
NO_ATTR_KEY = 'NoAttr'
|
22
|
+
ROOT_NAME_KEY = 'RootName'
|
23
|
+
|
24
|
+
attr_reader :options
|
25
|
+
|
26
|
+
def initialize(
|
27
|
+
name:,
|
28
|
+
no_attributes: true,
|
29
|
+
register: Burner::DEFAULT_REGISTER,
|
30
|
+
root_name: nil
|
31
|
+
)
|
32
|
+
super(name: name, register: register)
|
33
|
+
|
34
|
+
@options = make_options(no_attributes, root_name)
|
35
|
+
|
36
|
+
freeze
|
37
|
+
end
|
38
|
+
|
39
|
+
def perform(_output, payload)
|
40
|
+
payload[register] = XmlSimple.xml_out(payload[register] || {}, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def make_options(no_attributes, root_name)
|
44
|
+
{ NO_ATTR_KEY => no_attributes }.tap do |opts|
|
45
|
+
opts[ROOT_NAME_KEY] = root_name unless root_name.to_s.empty?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module MarkupFuel
|
11
|
+
VERSION = '0.1.0-alpha'
|
12
|
+
end
|
data/markup_fuel.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/markup_fuel/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'markup_fuel'
|
7
|
+
s.version = MarkupFuel::VERSION
|
8
|
+
s.summary = 'XML jobs for Burner'
|
9
|
+
|
10
|
+
s.description = <<-DESCRIPTION
|
11
|
+
This library adds XML-centric jobs to the Burner library. Burner does not ship with XML jobs out of the box.
|
12
|
+
DESCRIPTION
|
13
|
+
|
14
|
+
s.authors = ['Matthew Ruggio']
|
15
|
+
s.email = ['mruggio@bluemarblepayroll.com']
|
16
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
s.bindir = 'exe'
|
18
|
+
s.executables = %w[]
|
19
|
+
s.homepage = 'https://github.com/bluemarblepayroll/markup_fuel'
|
20
|
+
s.license = 'MIT'
|
21
|
+
s.metadata = {
|
22
|
+
'bug_tracker_uri' => 'https://github.com/bluemarblepayroll/markup_fuel/issues',
|
23
|
+
'changelog_uri' => 'https://github.com/bluemarblepayroll/markup_fuel/blob/master/CHANGELOG.md',
|
24
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/markup_fuel',
|
25
|
+
'homepage_uri' => s.homepage,
|
26
|
+
'source_code_uri' => s.homepage
|
27
|
+
}
|
28
|
+
|
29
|
+
s.required_ruby_version = '>= 2.5'
|
30
|
+
|
31
|
+
s.add_dependency('burner', '~>1.0')
|
32
|
+
s.add_dependency('xml-simple', '~>1.1')
|
33
|
+
|
34
|
+
s.add_development_dependency('guard-rspec', '~>4.7')
|
35
|
+
s.add_development_dependency('pry', '~>0')
|
36
|
+
s.add_development_dependency('rake', '~> 13')
|
37
|
+
s.add_development_dependency('rspec', '~> 3.8')
|
38
|
+
s.add_development_dependency('rubocop', '~>0.90.0')
|
39
|
+
s.add_development_dependency('simplecov', '~>0.18.5')
|
40
|
+
s.add_development_dependency('simplecov-console', '~>0.7.0')
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markup_fuel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Ruggio
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: burner
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xml-simple
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.90.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.90.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.18.5
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.18.5
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov-console
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.7.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.7.0
|
139
|
+
description: " This library adds XML-centric jobs to the Burner library. Burner
|
140
|
+
does not ship with XML jobs out of the box.\n"
|
141
|
+
email:
|
142
|
+
- mruggio@bluemarblepayroll.com
|
143
|
+
executables: []
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".editorconfig"
|
148
|
+
- ".gitignore"
|
149
|
+
- ".rubocop.yml"
|
150
|
+
- ".ruby-version"
|
151
|
+
- ".travis.yml"
|
152
|
+
- CHANGELOG.md
|
153
|
+
- CODE_OF_CONDUCT.md
|
154
|
+
- Gemfile
|
155
|
+
- Guardfile
|
156
|
+
- LICENSE
|
157
|
+
- README.md
|
158
|
+
- Rakefile
|
159
|
+
- bin/console
|
160
|
+
- exe/.gitkeep
|
161
|
+
- lib/markup_fuel.rb
|
162
|
+
- lib/markup_fuel/library.rb
|
163
|
+
- lib/markup_fuel/library/deserialize/xml.rb
|
164
|
+
- lib/markup_fuel/library/serialize/xml.rb
|
165
|
+
- lib/markup_fuel/version.rb
|
166
|
+
- markup_fuel.gemspec
|
167
|
+
homepage: https://github.com/bluemarblepayroll/markup_fuel
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata:
|
171
|
+
bug_tracker_uri: https://github.com/bluemarblepayroll/markup_fuel/issues
|
172
|
+
changelog_uri: https://github.com/bluemarblepayroll/markup_fuel/blob/master/CHANGELOG.md
|
173
|
+
documentation_uri: https://www.rubydoc.info/gems/markup_fuel
|
174
|
+
homepage_uri: https://github.com/bluemarblepayroll/markup_fuel
|
175
|
+
source_code_uri: https://github.com/bluemarblepayroll/markup_fuel
|
176
|
+
post_install_message:
|
177
|
+
rdoc_options: []
|
178
|
+
require_paths:
|
179
|
+
- lib
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '2.5'
|
185
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 1.3.1
|
190
|
+
requirements: []
|
191
|
+
rubygems_version: 3.0.3
|
192
|
+
signing_key:
|
193
|
+
specification_version: 4
|
194
|
+
summary: XML jobs for Burner
|
195
|
+
test_files: []
|