adf 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/adf.rb +67 -0
- data/lib/prospect.rb +37 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 80a21d41a50a0b9fadcc16e3259c437f33f26b82
|
|
4
|
+
data.tar.gz: 3f9208451d5a8f3ac45edd30bf2f787642677877
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 15ca7d57270b395ba32780610125215d42bc70abd5db37628a602fed5ad095d307ab008c67cf54401e53c4c87406e8b4e804103e92d9ea209bd49c888615ead3
|
|
7
|
+
data.tar.gz: abece05dcd6f13983a9d651a7db9cfbca18c2f034e92208518c3c3adf281ab88a2e260808b4f4b242d5f5f035491a987a5a092bec5da0b2dc68629e5f0b52709
|
data/lib/adf.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'builder'
|
|
2
|
+
$:.unshift File.dirname(__FILE__)
|
|
3
|
+
puts $LOAD_PATH
|
|
4
|
+
require 'prospect.rb'
|
|
5
|
+
# Sample ADF XML from Wikipedia
|
|
6
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
|
7
|
+
# <?adf version="1.0"?>
|
|
8
|
+
# <adf>
|
|
9
|
+
# <prospect>
|
|
10
|
+
# <requestdate>2000-03-30T15:30:20-08:0</requestdate>
|
|
11
|
+
# <vehicle>
|
|
12
|
+
# <year>2008</year>
|
|
13
|
+
# <make>Make</make>
|
|
14
|
+
# <model>Model</model>
|
|
15
|
+
# </vehicle>
|
|
16
|
+
# <customer>
|
|
17
|
+
# <contact>
|
|
18
|
+
# <name part="first">First</name>
|
|
19
|
+
# <name part="last">Last</name>
|
|
20
|
+
# <phone>323-223-3322</phone>
|
|
21
|
+
# <email>emailaddress</email>
|
|
22
|
+
# </contact>
|
|
23
|
+
# </customer>
|
|
24
|
+
# <vendor>
|
|
25
|
+
# <contact>
|
|
26
|
+
# <name part="full">Dealer Name</name>
|
|
27
|
+
# </contact>
|
|
28
|
+
# </vendor>
|
|
29
|
+
# </prospect>
|
|
30
|
+
# </adf>
|
|
31
|
+
module ADF
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module ADF
|
|
35
|
+
class ADFDoc
|
|
36
|
+
def initialize
|
|
37
|
+
@prospects = []
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def add_prospect(prospect)
|
|
41
|
+
if not prospect.nil?
|
|
42
|
+
@prospects.push prospect
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_xml
|
|
47
|
+
xml = Builder::XmlMarkup.new( :indent => 2 )
|
|
48
|
+
xml.instruct! :xml, :encoding => "UTF-8"
|
|
49
|
+
xml.instruct! :adf, :version => "1.0"
|
|
50
|
+
@prospects.each do |prospect|
|
|
51
|
+
xml.prospect do |p|
|
|
52
|
+
p.request_date prospect.request_date
|
|
53
|
+
p.customer do |customer|
|
|
54
|
+
customer.contact do |contact|
|
|
55
|
+
contact.name(prospect.customer_first, "part" => "first")
|
|
56
|
+
contact.name(prospect.customer_last, "part" => "last")
|
|
57
|
+
contact.phone(prospect.customer_phone)
|
|
58
|
+
contact.email(prospect.customer_email)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
return xml
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
data/lib/prospect.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# <prospect>
|
|
2
|
+
# <requestdate>2000-03-30T15:30:20-08:0</requestdate>
|
|
3
|
+
# <vehicle>
|
|
4
|
+
# <year>2008</year>
|
|
5
|
+
# <make>Make</make>
|
|
6
|
+
# <model>Model</model>
|
|
7
|
+
# </vehicle>
|
|
8
|
+
# <customer>
|
|
9
|
+
# <contact>
|
|
10
|
+
# <name part="first">First</name>
|
|
11
|
+
# <name part="last">Last</name>
|
|
12
|
+
# <phone>323-223-3322</phone>
|
|
13
|
+
# <email>emailaddress</email>
|
|
14
|
+
# </contact>
|
|
15
|
+
# </customer>
|
|
16
|
+
# <vendor>
|
|
17
|
+
# <contact>
|
|
18
|
+
# <name part="full">Dealer Name</name>
|
|
19
|
+
# </contact>
|
|
20
|
+
# </vendor>
|
|
21
|
+
# </prospect>
|
|
22
|
+
module ADF
|
|
23
|
+
class Prospect
|
|
24
|
+
attr_accessor :request_date, :customer_first, :customer_last, :customer_phone,
|
|
25
|
+
:customer_email
|
|
26
|
+
def initialize(request_date)
|
|
27
|
+
@request_date = request_date
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def set_customer(first, last, phone, email)
|
|
31
|
+
@customer_first = first
|
|
32
|
+
@customer_last = last
|
|
33
|
+
@customer_phone = phone
|
|
34
|
+
@customer_email = email
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: adf
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alagu
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: ADF gem helps you to easily create Auto-Dealer Format XML files using
|
|
14
|
+
Ruby's DSL
|
|
15
|
+
email: alagu@alagu.net
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/adf.rb
|
|
21
|
+
- lib/prospect.rb
|
|
22
|
+
homepage: http://rubygems.org/gems/adf
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 2.2.0
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Create Auto-Dealer Format XML files.
|
|
46
|
+
test_files: []
|