adf_builder 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +55 -5
- data/adf_builder.gemspec +2 -2
- data/lib/adf_builder.rb +18 -5
- data/lib/adf_builder/base.rb +15 -0
- data/lib/adf_builder/base/prospect.rb +29 -0
- data/lib/adf_builder/base/request_date.rb +21 -0
- data/lib/adf_builder/id.rb +20 -0
- data/lib/adf_builder/version.rb +1 -1
- metadata +8 -5
- data/lib/adf_builder/lead.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a45dd0135682b562fe9fe49cacd5590a0da5c702894ae9f0b888d1d48c6536c
|
4
|
+
data.tar.gz: 479f5c42eb07d457a0196abe35192f719d77a953bf6045739a3944157ff41434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d43d0eb120efacce6e7e52e610a51435f7d9dbc2f0cd366dbeae29f57eb1446ff220e70ce600dd8adeb9b33a0609d897a34ba4efa519af631777d9413563c6d
|
7
|
+
data.tar.gz: 63e65e9fa0fe65d6a285bdf52d246ab4f075fefd297fe9fda70d6784358a502ec2924f5dce41f5e5209cbc09835898e646784b9976aa7b237880559bfa297a96
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
|
+
- Add Vehicle structure
|
3
|
+
- Add Vendor structure
|
4
|
+
- Add Customer structure
|
5
|
+
- Add Provider structure
|
6
|
+
- Add Contact structure
|
7
|
+
- Add Price structure
|
8
|
+
|
9
|
+
## [0.0.2] - 2021-08-04
|
10
|
+
|
11
|
+
- Can create a prospect and dynamically update params and values for the base and parent level
|
2
12
|
|
3
13
|
## [0.0.1] - 2021-08-03
|
4
14
|
|
5
15
|
- Initial release
|
6
|
-
- Can return the
|
16
|
+
- Can return the minimal XML given from spec doc
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# AdfBuilder
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/adf_builder`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
Hopefully this will help with development in the ADF format. The goal is to intuitively create an update an ADF XML file that can easily be added to an email or saved to a file.
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -22,7 +19,60 @@ Or install it yourself as:
|
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
Quickly create the minimal lead found in the spec document
|
23
|
+
|
24
|
+
builder = AdfBuilder::Builder.new
|
25
|
+
builder.minimal_lead
|
26
|
+
|
27
|
+
Start Building
|
28
|
+
|
29
|
+
builder = AdfBuilder::Builder.new
|
30
|
+
builder.to_xml
|
31
|
+
|
32
|
+
Outputs
|
33
|
+
|
34
|
+
<?ADF version="1.0"?>
|
35
|
+
<?xml version="1.0"?>
|
36
|
+
<adf>
|
37
|
+
<prospect status="new">
|
38
|
+
<requestdate>2021-08-04T15:18:30+04:00</requestdate>
|
39
|
+
</prospect>
|
40
|
+
</adf>
|
41
|
+
|
42
|
+
Update Requestdate value
|
43
|
+
|
44
|
+
builder = AdfBuilder::Builder.new
|
45
|
+
builder.base.prospect.request_date.update_val(Date.new(2021,12,12))
|
46
|
+
|
47
|
+
Outputs
|
48
|
+
|
49
|
+
<?ADF version="1.0"?>
|
50
|
+
|
51
|
+
<?xml version="1.0"?>
|
52
|
+
<adf>
|
53
|
+
<prospect status="new">
|
54
|
+
<requestdate>2021-12-12T00:00:00+00:00</requestdate>
|
55
|
+
</prospect>
|
56
|
+
</adf>
|
57
|
+
|
58
|
+
Add ID tag to Prospect
|
59
|
+
|
60
|
+
builder = AdfBuilder::Builder.new
|
61
|
+
builder.base.prospect.add_id('howdy', 'Ag')
|
62
|
+
|
63
|
+
Outputs
|
64
|
+
|
65
|
+
<?ADF version="1.0"?>
|
66
|
+
|
67
|
+
<?xml version="1.0"?>
|
68
|
+
<adf>
|
69
|
+
<prospect status="new">
|
70
|
+
<id sequence="1" source="Ag">howdy</id>
|
71
|
+
<requestdate>2021-08-04T15:24:16+04:00</requestdate>
|
72
|
+
</prospect>
|
73
|
+
</adf>
|
74
|
+
|
75
|
+
|
26
76
|
|
27
77
|
## Development
|
28
78
|
|
data/adf_builder.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["marcus.salinas"]
|
9
9
|
spec.email = ["12.marcus.salinas@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "Create XML for the Auto-
|
12
|
-
spec.description = "
|
11
|
+
spec.summary = "Create XML for the Auto-base Date Format"
|
12
|
+
spec.description = "Easily create XML in ADF format to send by email."
|
13
13
|
spec.homepage = "https://github.com/jippylong12/adf_builder"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.4.0"
|
data/lib/adf_builder.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "adf_builder/version"
|
4
|
-
require_relative 'adf_builder/
|
4
|
+
require_relative 'adf_builder/base'
|
5
|
+
require_relative 'adf_builder/base/prospect'
|
6
|
+
require_relative 'adf_builder/base/request_date'
|
7
|
+
require_relative 'adf_builder/id'
|
8
|
+
|
5
9
|
|
6
10
|
require 'ox'
|
7
11
|
|
@@ -10,15 +14,20 @@ module AdfBuilder
|
|
10
14
|
class Builder
|
11
15
|
def initialize
|
12
16
|
@doc = self.init_doc
|
13
|
-
@
|
17
|
+
@base = Base.new(@doc)
|
18
|
+
end
|
19
|
+
|
20
|
+
def base
|
21
|
+
@base
|
14
22
|
end
|
15
23
|
|
16
|
-
|
17
|
-
|
24
|
+
# output the XML
|
25
|
+
def to_xml
|
26
|
+
Ox.dump(@doc, {})
|
18
27
|
end
|
19
28
|
|
20
29
|
# def an example of minimal XML taken from ADF spec file http://adfxml.info/adf_spec.pdf
|
21
|
-
def
|
30
|
+
def minimal_lead
|
22
31
|
adf = Ox::Element.new("adf")
|
23
32
|
|
24
33
|
prospect = Ox::Element.new("prospect")
|
@@ -69,6 +78,8 @@ module AdfBuilder
|
|
69
78
|
end
|
70
79
|
|
71
80
|
|
81
|
+
|
82
|
+
|
72
83
|
private
|
73
84
|
|
74
85
|
|
@@ -82,6 +93,8 @@ module AdfBuilder
|
|
82
93
|
instruct = Ox::Instruct.new(:xml)
|
83
94
|
instruct[:version] = '1.0'
|
84
95
|
doc << instruct
|
96
|
+
adf = Ox::Element.new("adf")
|
97
|
+
doc << adf
|
85
98
|
doc
|
86
99
|
end
|
87
100
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class Prospect
|
3
|
+
STATUSES = {
|
4
|
+
new: :new,
|
5
|
+
resend: :resend
|
6
|
+
}
|
7
|
+
|
8
|
+
def initialize(doc)
|
9
|
+
@doc = doc
|
10
|
+
@doc.adf << Ox::Element.new("prospect")
|
11
|
+
@prospect = @doc.adf.prospect
|
12
|
+
@prospect[:status] = STATUSES[:new]
|
13
|
+
@request_date = RequestDate.new(@prospect)
|
14
|
+
end
|
15
|
+
|
16
|
+
def request_date
|
17
|
+
@request_date
|
18
|
+
end
|
19
|
+
|
20
|
+
# set status to renew
|
21
|
+
def set_renew
|
22
|
+
@prospect[:status] = STATUSES[:resend]
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_id(value, source=nil, sequence=1)
|
26
|
+
Id.new.add(@prospect, value, source, sequence)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class RequestDate
|
3
|
+
WITH_SYMBOLS = '%FT%T%:z'
|
4
|
+
WITHOUT_SYMBOLS = '%Y%m%dT%H%M%S%z'
|
5
|
+
|
6
|
+
def initialize(prospect_node)
|
7
|
+
@request_date_node = Ox::Element.new('requestdate')
|
8
|
+
@request_date_node << DateTime.now.strftime('%FT%T%:z')
|
9
|
+
prospect_node << @request_date_node
|
10
|
+
@request_date_node
|
11
|
+
end
|
12
|
+
|
13
|
+
def update_val(datetime_value, format=1)
|
14
|
+
if format == 1
|
15
|
+
@request_date_node.replace_text(datetime_value.strftime(WITH_SYMBOLS))
|
16
|
+
elsif format == 2
|
17
|
+
@request_date_node.replace_text(datetime_value.strftime(WITHOUT_SYMBOLS))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class Id
|
3
|
+
def initialize
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
# add id tag to the form
|
8
|
+
def add(parent_node, value, source=nil, sequence=1)
|
9
|
+
id_node = Ox::Element.new('id')
|
10
|
+
id_node << value
|
11
|
+
id_node[:sequence] = sequence
|
12
|
+
|
13
|
+
if source
|
14
|
+
id_node[:source] = source
|
15
|
+
end
|
16
|
+
|
17
|
+
parent_node.prepend_child(id_node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/adf_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adf_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marcus.salinas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.14'
|
27
|
-
description:
|
27
|
+
description: Easily create XML in ADF format to send by email.
|
28
28
|
email:
|
29
29
|
- 12.marcus.salinas@gmail.com
|
30
30
|
executables: []
|
@@ -45,7 +45,10 @@ files:
|
|
45
45
|
- bin/console
|
46
46
|
- bin/setup
|
47
47
|
- lib/adf_builder.rb
|
48
|
-
- lib/adf_builder/
|
48
|
+
- lib/adf_builder/base.rb
|
49
|
+
- lib/adf_builder/base/prospect.rb
|
50
|
+
- lib/adf_builder/base/request_date.rb
|
51
|
+
- lib/adf_builder/id.rb
|
49
52
|
- lib/adf_builder/version.rb
|
50
53
|
homepage: https://github.com/jippylong12/adf_builder
|
51
54
|
licenses:
|
@@ -72,5 +75,5 @@ requirements: []
|
|
72
75
|
rubygems_version: 3.1.4
|
73
76
|
signing_key:
|
74
77
|
specification_version: 4
|
75
|
-
summary: Create XML for the Auto-
|
78
|
+
summary: Create XML for the Auto-base Date Format
|
76
79
|
test_files: []
|