adf_builder 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a0aaeb6ecf4e9ee4c73a74b6e74051ee56d53cf75dcba5939fc8349c374a810
4
- data.tar.gz: feb8b40fd25eb88c1284ae30ad9d8f098296181722bbcec9078850303e61671e
3
+ metadata.gz: 22d08bb10c44efbd81470a2623878e2d168edde0fe1255872b1b24cc80f0b484
4
+ data.tar.gz: 3a367084f65bd676bea7bc40ced1ae75987984e687e3c44c5ac64f3844439f63
5
5
  SHA512:
6
- metadata.gz: 2050252ed990af7a9f4a2d42005f018d5b20a3a05a911c80a40cd4f44499ad28c710826c5a109af80063b332e05d9e1d0e05972880ba67e2bf87afb1b4738e0f
7
- data.tar.gz: 47eb36b0fe511153cf8ffdaebfc58a642b37e58966081a1069d2b0eb88e632f1adc1f8a76e8c3d3c2888ce50c7c9289541e37b95aed34813dcc063656686f6e4
6
+ metadata.gz: ccd4ff42b0718572645eaf571ec0f42212b30b7017875afb6ac273cf61d286ca7045d64b084a4ee4b3ef10413130a8176aea983d64a7850dddca260c458b8795
7
+ data.tar.gz: 2eebf6109af2c803ad2fce7c46744a0f6ec3f91af8405e413bfcbd2e0ce5f4f483d617f2e69c87b67c07a62c087a5a226095b79f10d39a9e36b60356e90f15cd
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
  .idea
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ deploy.txt
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@
7
7
  - Contact
8
8
  - Vehicle
9
9
 
10
+ ## [0.3.0] - 2023-11-28
11
+ - Completed Customer - timeframe and comments tags
12
+
13
+ ## [0.2.2] - 2021-11-02
14
+ - Fixed bug where ADF and xml tags were flipped
15
+
10
16
  ## [0.2.1] - 2021-11-02
11
17
  - Add comments to the Vehicle nodes
12
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adf_builder (0.2.0)
4
+ adf_builder (0.3.0)
5
5
  ox (~> 2.14)
6
6
 
7
7
  GEM
@@ -46,6 +46,7 @@ GEM
46
46
 
47
47
  PLATFORMS
48
48
  arm64-darwin-20
49
+ arm64-darwin-22
49
50
 
50
51
  DEPENDENCIES
51
52
  adf_builder!
@@ -55,4 +56,4 @@ DEPENDENCIES
55
56
  rubocop (~> 1.7)
56
57
 
57
58
  BUNDLED WITH
58
- 2.2.25
59
+ 2.4.4
@@ -3,6 +3,7 @@ module AdfBuilder
3
3
  def initialize(prospect)
4
4
  @customer = Ox::Element.new('customer')
5
5
  @contact = nil
6
+ @timeframe = nil
6
7
 
7
8
  prospect << @customer
8
9
  end
@@ -11,6 +12,9 @@ module AdfBuilder
11
12
  @contact
12
13
  end
13
14
 
15
+ def timeframe
16
+ @timeframe
17
+ end
14
18
  def add(name, opts={})
15
19
  @contact = Contact.new(@customer, name, opts)
16
20
  end
@@ -23,5 +27,32 @@ module AdfBuilder
23
27
  end
24
28
  end
25
29
 
30
+ # @param descriptin [String] - Description of customer’s timing intention.
31
+ # @param earliest_date [DateTime] - Earliest date customer is interested in. If timeframe tag
32
+ # is present, it is required to specify earliestdate and/or
33
+ # latestdate
34
+ # @param latest_date [DateTime] - Latest date customer is interested in. If timeframe tag
35
+ # is present, it is required to specify earliestdate and/or
36
+ # latestdate
37
+ def add_timeframe(description, earliest_date=nil, latest_date=nil)
38
+ if earliest_date.nil? and latest_date.nil?
39
+ return false
40
+ end
41
+
42
+ if earliest_date and earliest_date.class != DateTime
43
+ return false
44
+ end
45
+
46
+ if latest_date and latest_date.class != DateTime
47
+ return false
48
+ end
49
+
50
+ @timeframe = Timeframe.new(@customer, description, earliest_date, latest_date) if @timeframe.nil?
51
+ end
52
+
53
+ def update_comments(comments)
54
+ return false if comments.class != String
55
+ AdfBuilder::Builder.update_node(@customer, :comments, comments)
56
+ end
26
57
  end
27
58
  end
@@ -0,0 +1,44 @@
1
+ module AdfBuilder
2
+ class Timeframe
3
+ def initialize(customer, description, earliest_date, latest_date)
4
+
5
+ begin
6
+ earliest_date = earliest_date.strftime('%FT%T%:z') if earliest_date
7
+ latest_date = latest_date.strftime('%FT%T%:z') if latest_date
8
+ rescue => e
9
+ return nil
10
+ end
11
+
12
+ @timeframe = Ox::Element.new('timeframe')
13
+
14
+
15
+ @timeframe << (Ox::Element.new('description') << description)
16
+ @timeframe << (Ox::Element.new('earliestdate') << earliest_date) if earliest_date
17
+ @timeframe << (Ox::Element.new('latestdate') << latest_date) if latest_date
18
+ customer << @timeframe
19
+ end
20
+
21
+ def update_description(description)
22
+ AdfBuilder::Builder.update_node(@timeframe, :description, description)
23
+ end
24
+
25
+ def update_earliest_date(date)
26
+ begin
27
+ date = date.strftime('%FT%T%:z')
28
+ rescue
29
+ return false
30
+ end
31
+ AdfBuilder::Builder.update_node(@timeframe, :earliestdate, date)
32
+ end
33
+
34
+ def update_latest_date(date)
35
+ begin
36
+ date = date.strftime('%FT%T%:z')
37
+ rescue
38
+ return false
39
+ end
40
+
41
+ AdfBuilder::Builder.update_node(@timeframe, :latestdate, date)
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdfBuilder
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/adf_builder.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "adf_builder/version"
7
7
 
8
8
  # CUSTOMER
9
9
  require_relative 'adf_builder/customer/customer'
10
+ require_relative 'adf_builder/customer/timeframe'
10
11
 
11
12
  # BASE
12
13
  require_relative 'adf_builder/base/base'
@@ -102,11 +103,11 @@ module AdfBuilder
102
103
  # all the files will start with this same header
103
104
  def init_doc
104
105
  doc = Ox::Document.new
105
- instruct = Ox::Instruct.new('ADF')
106
+ instruct = Ox::Instruct.new(:xml)
106
107
  instruct[:version] = '1.0'
107
108
  doc << instruct
108
- doc << Ox::Raw.new("\n")
109
- instruct = Ox::Instruct.new(:xml)
109
+ doc << Ox::Raw.new("")
110
+ instruct = Ox::Instruct.new('ADF')
110
111
  instruct[:version] = '1.0'
111
112
  doc << instruct
112
113
  adf = Ox::Element.new("adf")
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.2.1
4
+ version: 0.3.0
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-11-02 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -49,6 +49,7 @@ files:
49
49
  - lib/adf_builder/base/prospect.rb
50
50
  - lib/adf_builder/base/request_date.rb
51
51
  - lib/adf_builder/customer/customer.rb
52
+ - lib/adf_builder/customer/timeframe.rb
52
53
  - lib/adf_builder/data/iso-4217-currency-codes.json
53
54
  - lib/adf_builder/provider/provider.rb
54
55
  - lib/adf_builder/shared/contact.rb
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  - !ruby/object:Gem::Version
81
82
  version: '0'
82
83
  requirements: []
83
- rubygems_version: 3.1.4
84
+ rubygems_version: 3.1.6
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: Create XML for the Auto-base Date Format