mits 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/README.md +4 -4
  4. data/lib/mits.rb +4 -1
  5. data/lib/mits/base_mapper.rb +20 -0
  6. data/lib/mits/document.rb +16 -5
  7. data/lib/mits/saxerator_ext.rb +8 -1
  8. data/lib/mits/v3.0/address.rb +20 -0
  9. data/lib/mits/v3.0/amenity.rb +12 -0
  10. data/lib/mits/v3.0/company.rb +13 -0
  11. data/lib/mits/v3.0/deposit.rb +13 -0
  12. data/lib/mits/v3.0/fees.rb +17 -0
  13. data/lib/mits/v3.0/file.rb +18 -0
  14. data/lib/mits/v3.0/floorplan.rb +13 -0
  15. data/lib/mits/v3.0/mapper.rb +50 -0
  16. data/lib/mits/v3.0/mapper/address_mapper.rb +35 -0
  17. data/lib/mits/v3.0/mapper/amenities_mapper.rb +19 -0
  18. data/lib/mits/v3.0/mapper/company_mapper.rb +15 -0
  19. data/lib/mits/v3.0/mapper/deposit_mapper.rb +32 -0
  20. data/lib/mits/v3.0/mapper/fees_mapper.rb +19 -0
  21. data/lib/mits/v3.0/mapper/files_mapper.rb +25 -0
  22. data/lib/mits/v3.0/mapper/floorplan_mapper.rb +27 -0
  23. data/lib/mits/v3.0/mapper/pet_policy_mapper.rb +37 -0
  24. data/lib/mits/v3.0/mapper/policy_mapper.rb +12 -0
  25. data/lib/mits/v3.0/mapper/property_mapper.rb +57 -0
  26. data/lib/mits/v3.0/pet.rb +13 -0
  27. data/lib/mits/v3.0/pet_policy.rb +17 -0
  28. data/lib/mits/v3.0/policy.rb +10 -0
  29. data/lib/mits/v3.0/property.rb +23 -0
  30. data/lib/mits/v4.1/address.rb +21 -0
  31. data/lib/mits/v4.1/amenity.rb +21 -0
  32. data/lib/mits/v4.1/company.rb +8 -0
  33. data/lib/mits/v4.1/deposit.rb +8 -0
  34. data/lib/mits/v4.1/fees.rb +8 -0
  35. data/lib/mits/v4.1/file.rb +8 -0
  36. data/lib/mits/v4.1/mapper.rb +45 -0
  37. data/lib/mits/v4.1/mapper/address_mapper.rb +29 -0
  38. data/lib/mits/v4.1/mapper/company_mapper.rb +9 -0
  39. data/lib/mits/v4.1/mapper/property_mapper.rb +48 -0
  40. data/lib/mits/v4.1/mapper/units_mapper.rb +26 -0
  41. data/lib/mits/v4.1/pet.rb +8 -0
  42. data/lib/mits/v4.1/pet_policy.rb +8 -0
  43. data/lib/mits/v4.1/policy.rb +8 -0
  44. data/lib/mits/v4.1/property.rb +22 -0
  45. data/lib/mits/v4.1/unit.rb +13 -0
  46. data/lib/mits/version.rb +1 -1
  47. data/mits.gemspec +5 -4
  48. data/spec/fixtures/MITS_3.0_Property.yml +583 -0
  49. data/spec/fixtures/MITS_3.0_Sample.xml +589 -0
  50. data/spec/fixtures/{property.yml → MITS_4.1_Property.yml} +0 -0
  51. data/spec/fixtures/{mits.xml → MITS_4.1_Sample.xml} +0 -0
  52. data/spec/lib/mits/document_spec.rb +3 -3
  53. data/spec/lib/mits/v3.0/address_spec.rb +21 -0
  54. data/spec/lib/mits/v3.0/amenity_spec.rb +13 -0
  55. data/spec/lib/mits/{entities → v3.0}/company_spec.rb +0 -0
  56. data/spec/lib/mits/v3.0/deposit_spec.rb +14 -0
  57. data/spec/lib/mits/v3.0/fees_spec.rb +18 -0
  58. data/spec/lib/mits/v3.0/file_spec.rb +20 -0
  59. data/spec/lib/mits/v3.0/floorplan_spec.rb +14 -0
  60. data/spec/lib/mits/v3.0/mapper_spec.rb +198 -0
  61. data/spec/lib/mits/v3.0/pet_policy_spec.rb +17 -0
  62. data/spec/lib/mits/v3.0/pet_spec.rb +15 -0
  63. data/spec/lib/mits/v3.0/property_spec.rb +23 -0
  64. data/spec/lib/mits/v4.1/address_spec.rb +22 -0
  65. data/spec/lib/mits/v4.1/amenity_spec.rb +11 -0
  66. data/spec/lib/mits/v4.1/company_spec.rb +0 -0
  67. data/spec/lib/mits/v4.1/deposit_spec.rb +14 -0
  68. data/spec/lib/mits/v4.1/fees_spec.rb +18 -0
  69. data/spec/lib/mits/v4.1/file_spec.rb +20 -0
  70. data/spec/lib/mits/v4.1/mapper_spec.rb +194 -0
  71. data/spec/lib/mits/v4.1/pet_policy_spec.rb +16 -0
  72. data/spec/lib/mits/v4.1/pet_spec.rb +15 -0
  73. data/spec/lib/mits/v4.1/property_spec.rb +23 -0
  74. data/spec/lib/mits/v4.1/unit_spec.rb +14 -0
  75. metadata +112 -53
  76. data/lib/mits/entities/address.rb +0 -16
  77. data/lib/mits/entities/amenity.rb +0 -8
  78. data/lib/mits/entities/company.rb +0 -11
  79. data/lib/mits/entities/deposit.rb +0 -11
  80. data/lib/mits/entities/fees.rb +0 -15
  81. data/lib/mits/entities/file.rb +0 -16
  82. data/lib/mits/entities/pet.rb +0 -11
  83. data/lib/mits/entities/pet_policy.rb +0 -15
  84. data/lib/mits/entities/property.rb +0 -20
  85. data/lib/mits/entities/unit.rb +0 -11
  86. data/lib/mits/mapper.rb +0 -48
  87. data/lib/mits/mappers/address_mapper.rb +0 -29
  88. data/lib/mits/mappers/amenities_mapper.rb +0 -14
  89. data/lib/mits/mappers/company_mapper.rb +0 -11
  90. data/lib/mits/mappers/deposit_mapper.rb +0 -24
  91. data/lib/mits/mappers/fees_mapper.rb +0 -15
  92. data/lib/mits/mappers/files_mapper.rb +0 -19
  93. data/lib/mits/mappers/pet_policy_mapper.rb +0 -28
  94. data/lib/mits/mappers/property_mapper.rb +0 -41
  95. data/lib/mits/mappers/units_mapper.rb +0 -22
  96. data/spec/lib/mits/entities/address_spec.rb +0 -16
  97. data/spec/lib/mits/entities/amenity_spec.rb +0 -8
  98. data/spec/lib/mits/entities/deposit_spec.rb +0 -11
  99. data/spec/lib/mits/entities/fees_spec.rb +0 -15
  100. data/spec/lib/mits/entities/file_spec.rb +0 -17
  101. data/spec/lib/mits/entities/pet_policy_spec.rb +0 -14
  102. data/spec/lib/mits/entities/pet_spec.rb +0 -12
  103. data/spec/lib/mits/entities/property_spec.rb +0 -20
  104. data/spec/lib/mits/entities/unit_spec.rb +0 -11
  105. data/spec/lib/mits/mapper_spec.rb +0 -180
File without changes
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module MITS
4
4
  describe Document do
5
- subject { Document.new('./spec/fixtures/mits.xml') }
5
+ subject { Document.new('./spec/fixtures/MITS_4.1_Sample.xml', version: 4.1) }
6
6
 
7
7
  describe '#properties' do
8
8
  it 'will return the properties' do
9
9
  companies = subject.properties.reduce([]) { |arr, property| arr.push(property) }
10
- expect(companies.first).to be_a Property
10
+ expect(companies.first).to be_a V4_1::Property
11
11
  expect(companies.size).to eq 2
12
12
  end
13
13
  end
@@ -15,7 +15,7 @@ module MITS
15
15
  describe '#companies' do
16
16
  it 'will return the companies' do
17
17
  companies = subject.companies.reduce([]) { |arr, company| arr.push(company) }
18
- expect(companies.first).to be_a Company
18
+ expect(companies.first).to be_a V4_1::Company
19
19
  expect(companies.size).to eq 1
20
20
  end
21
21
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/address'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Address do
7
+ it { is_expected.to respond_to(:address) }
8
+ it { is_expected.to respond_to(:city) }
9
+ it { is_expected.to respond_to(:country) }
10
+ it { is_expected.to respond_to(:county_name) }
11
+ it { is_expected.to respond_to(:description) }
12
+ it { is_expected.to respond_to(:latitude) }
13
+ it { is_expected.to respond_to(:longitude) }
14
+ it { is_expected.to respond_to(:postal_code) }
15
+ it { is_expected.to respond_to(:province) }
16
+ it { is_expected.to respond_to(:state) }
17
+ it { is_expected.to respond_to(:type) }
18
+ it { is_expected.to respond_to(:unparsed_address) }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/amenity'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Amenity do
7
+ it { is_expected.to respond_to(:description) }
8
+ it { is_expected.to respond_to(:rank) }
9
+ it { is_expected.to respond_to(:subtype) }
10
+ it { is_expected.to respond_to(:type) }
11
+ end
12
+ end
13
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/deposit'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Deposit do
7
+ it { is_expected.to respond_to(:type) }
8
+ it { is_expected.to respond_to(:description) }
9
+ it { is_expected.to respond_to(:percent_refundable) }
10
+ it { is_expected.to respond_to(:portion_refundable) }
11
+ it { is_expected.to respond_to(:amount) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/fees'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Fees do
7
+ it { is_expected.to respond_to(:admin_fee) }
8
+ it { is_expected.to respond_to(:application_fee) }
9
+ it { is_expected.to respond_to(:broker_fee) }
10
+ it { is_expected.to respond_to(:late_fee_per_day) }
11
+ it { is_expected.to respond_to(:late_min_fee) }
12
+ it { is_expected.to respond_to(:late_percent) }
13
+ it { is_expected.to respond_to(:late_type) }
14
+ it { is_expected.to respond_to(:non_refundable_hold_fee) }
15
+ it { is_expected.to respond_to(:prorate_type) }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/file'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe File do
7
+ it { is_expected.to respond_to(:active) }
8
+ it { is_expected.to respond_to(:caption) }
9
+ it { is_expected.to respond_to(:description) }
10
+ it { is_expected.to respond_to(:format) }
11
+ it { is_expected.to respond_to(:height) }
12
+ it { is_expected.to respond_to(:id) }
13
+ it { is_expected.to respond_to(:name) }
14
+ it { is_expected.to respond_to(:rank) }
15
+ it { is_expected.to respond_to(:source) }
16
+ it { is_expected.to respond_to(:width) }
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/floorplan'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Floorplan do
7
+ it { is_expected.to respond_to(:bathrooms) }
8
+ it { is_expected.to respond_to(:bedrooms) }
9
+ it { is_expected.to respond_to(:name) }
10
+ it { is_expected.to respond_to(:rent) }
11
+ it { is_expected.to respond_to(:sqft) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,198 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/mapper'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Mapper do
7
+ let(:fixture) { YAML.load_file('./spec/fixtures/MITS_3.0_Property.yml') }
8
+
9
+ describe '.address' do
10
+ subject { Mapper.address(fixture[:PropertyID][:Address], fixture[:ILS_Identification]) }
11
+
12
+ it { is_expected.to be_a Address }
13
+
14
+ it 'include various amenities' do
15
+ expect(subject.address).to eq '11401 Dr. Martin Luther King Jr. St N'
16
+ expect(subject.city).to eq 'Saint Petersburg'
17
+ expect(subject.state).to eq 'FL'
18
+ end
19
+ end
20
+
21
+ describe '.amenities' do
22
+ subject { Mapper.amenities(fixture[:Amenity]) }
23
+
24
+ it { is_expected.to be_a Array }
25
+
26
+ it 'include various amenities' do
27
+ first = subject.first
28
+ expect(first).to be_a Amenity
29
+ expect(first.description).to eq 'Extra storage'
30
+ expect(first.type).to eq 'Other'
31
+ end
32
+ end
33
+
34
+ #
35
+ #
36
+ # TODO: VERIFY COMPANY
37
+ #
38
+ #
39
+ describe '.company' do
40
+ let(:tag) do
41
+ {
42
+ Identification: {
43
+ IDValue: 'id value',
44
+ IDType: 'id type'
45
+ },
46
+ CompanyName: 'name',
47
+ Address: fixture[:PropertyID][:Address],
48
+ Website: 'http://...',
49
+ Logo: 'http://...',
50
+ }
51
+ end
52
+
53
+ subject { Mapper.company(tag) }
54
+
55
+ it { is_expected.to be_a Company }
56
+ end
57
+
58
+ describe '.deposits' do
59
+ subject { Mapper.deposits(fixture[:Deposit]) }
60
+
61
+ it { is_expected.to be_a Array }
62
+
63
+ it 'include deposit details' do
64
+ deposit = subject.first
65
+ expect(deposit.amount).to eq 3000.00
66
+ expect(deposit.description).to be_nil
67
+ expect(deposit.type).to eq 'Security Deposit'
68
+ end
69
+
70
+ context 'when a range' do
71
+ let(:ranged_deposit) do
72
+ { Amount: { ValueRange: { Min: 100, Max: 1000 } } }
73
+ end
74
+
75
+ subject { Mapper.deposit(ranged_deposit) }
76
+
77
+ it 'include deposit details' do
78
+ expect(subject.amount).to eq 100..1000
79
+ end
80
+ end
81
+ end
82
+
83
+ describe '.fees' do
84
+ subject { Mapper.fees(fixture[:Fee]) }
85
+
86
+ it { is_expected.to be_a Fees }
87
+
88
+ it 'include individual fee amounts' do
89
+ expect(subject.admin_fee).to eq 0.0
90
+ expect(subject.application_fee).to eq 50.0
91
+ expect(subject.broker_fee).to eq 0.0
92
+ expect(subject.late_fee_per_day).to eq 0.0
93
+ expect(subject.late_min_fee).to eq 0.0
94
+ expect(subject.late_percent).to eq 0.0
95
+ expect(subject.late_type).to eq 'Standard'
96
+ expect(subject.non_refundable_hold_fee).to eq 0.0
97
+ expect(subject.prorate_type).to eq 'Standard'
98
+ end
99
+ end
100
+
101
+ describe '.files' do
102
+ subject { Mapper.files(fixture[:File]) }
103
+
104
+ it { is_expected.to be_a Array }
105
+
106
+ it 'includes each file' do
107
+ first = subject.first
108
+ expect(first).to be_a File
109
+ expect(first.source).to eq 'http://capi.myleasestar.com/v2/dimg/5719594/898x428/5719594.png'
110
+ end
111
+ end
112
+
113
+ describe '.pets' do
114
+ subject { Mapper.pets(fixture[:Policy][:Pet].first[:Pets]) }
115
+
116
+ it { is_expected.to be_a Array }
117
+
118
+ it 'includes each allowed pet' do
119
+ first = subject.first
120
+ expect(first).to be_a Pet
121
+ expect(first.count).to eq 2
122
+ expect(first.type).to eq 'Cat'
123
+ end
124
+ end
125
+
126
+ describe '.pet_policies' do
127
+ subject { Mapper.pet_policies(fixture[:Policy][:Pet]) }
128
+
129
+ it { is_expected.to be_a Array}
130
+
131
+ it 'includes details' do
132
+ first = subject.first
133
+ expect(first.allowed).to be_truthy
134
+ expect(first.care).to be_truthy
135
+ expect(first.fee).to eq 0.00
136
+ expect(first.pets).to be_a Array
137
+ expect(first.rent).to eq 0.00
138
+ end
139
+
140
+ context 'when no pets allowed' do
141
+ before { fixture[:Policy][:Pet].first[:Allowed] = 'false' }
142
+
143
+ it 'will reflect that' do
144
+ expect(subject.first.allowed).to be_falsey
145
+ end
146
+ end
147
+ end
148
+
149
+ describe '.policy' do
150
+ subject { Mapper.policy(fixture[:Policy]) }
151
+
152
+ it { is_expected.to be_a Policy }
153
+
154
+ it 'includes details' do
155
+ expect(subject.general).to be_nil
156
+ expect(subject.pet).to be_a Array
157
+ end
158
+ end
159
+
160
+ describe '.property' do
161
+ subject { Mapper.property(fixture) }
162
+
163
+ it { is_expected.to be_a Property }
164
+
165
+ it 'includes details' do
166
+ expect(subject.address).to be_a Address
167
+ expect(subject.amenities.size).to eq 11
168
+ expect(subject.company_id).to eq '6890047'
169
+ expect(subject.deposit).to be_a Array
170
+ expect(subject.description).to eq 'a very long description'
171
+ expect(subject.fees).to be_a Fees
172
+ expect(subject.files).to be_a Array
173
+ expect(subject.id).to eq '89851'
174
+ expect(subject.name).to eq 'Camden Lakes'
175
+ expect(subject.policy).to be_a Policy
176
+ expect(subject.summary).to eq 'a short description'
177
+ expect(subject.floorplans).to be_a Array
178
+ end
179
+ end
180
+
181
+ describe '.floorplans' do
182
+ subject { Mapper.floorplans(fixture[:Floorplan]) }
183
+
184
+ it { is_expected.to be_a Array }
185
+
186
+ it 'includes individual floorplans' do
187
+ first = subject.first
188
+ expect(first).to be_a Floorplan
189
+ expect(first.bathrooms).to eq 1.0
190
+ expect(first.bedrooms).to eq 1
191
+ expect(first.name).to eq 'Keystone'
192
+ expect(first.rent).to eq 779..979
193
+ expect(first.sqft).to eq 600..615
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/pet_policy'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe PetPolicy do
7
+ it { is_expected.to respond_to(:allowed) }
8
+ it { is_expected.to respond_to(:allowed?) }
9
+ it { is_expected.to respond_to(:care) }
10
+ it { is_expected.to respond_to(:deposit) }
11
+ it { is_expected.to respond_to(:fee) }
12
+ it { is_expected.to respond_to(:pets) }
13
+ it { is_expected.to respond_to(:rent) }
14
+ it { is_expected.to respond_to(:restrictions) }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'mits/v3.0/pet'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Pet do
7
+ it { is_expected.to respond_to(:count) }
8
+ it { is_expected.to respond_to(:description) }
9
+ it { is_expected.to respond_to(:size) }
10
+ it { is_expected.to respond_to(:type) }
11
+ it { is_expected.to respond_to(:weight) }
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'mits/v4.1/property'
3
+
4
+ module MITS
5
+ module V3_0
6
+ describe Property do
7
+ it { is_expected.to respond_to(:address) }
8
+ it { is_expected.to respond_to(:amenities) }
9
+ it { is_expected.to respond_to(:company_id) }
10
+ it { is_expected.to respond_to(:deposit) }
11
+ it { is_expected.to respond_to(:description) }
12
+ it { is_expected.to respond_to(:fees) }
13
+ it { is_expected.to respond_to(:files) }
14
+ it { is_expected.to respond_to(:id) }
15
+ it { is_expected.to respond_to(:name) }
16
+ it { is_expected.to respond_to(:policy) }
17
+ it { is_expected.to respond_to(:summary) }
18
+ it { is_expected.to respond_to(:type) }
19
+ it { is_expected.to respond_to(:units) }
20
+ it { is_expected.to respond_to(:website) }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'mits/v4.1/address'
3
+
4
+ module MITS
5
+ module V4_1
6
+ describe Address do
7
+ it { is_expected.to respond_to(:address1) }
8
+ it { is_expected.to respond_to(:address2) }
9
+ it { is_expected.to respond_to(:city) }
10
+ it { is_expected.to respond_to(:country) }
11
+ it { is_expected.to respond_to(:county_name) }
12
+ it { is_expected.to respond_to(:description) }
13
+ it { is_expected.to respond_to(:latitude) }
14
+ it { is_expected.to respond_to(:longitude) }
15
+ it { is_expected.to respond_to(:postal_code) }
16
+ it { is_expected.to respond_to(:province) }
17
+ it { is_expected.to respond_to(:state) }
18
+ it { is_expected.to respond_to(:type) }
19
+ it { is_expected.to respond_to(:unparsed_address) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'mits/v4.1/amenity'
3
+
4
+ module MITS
5
+ module V4_1
6
+ describe Amenity do
7
+ it { is_expected.to respond_to(:type) }
8
+ it { is_expected.to respond_to(:description) }
9
+ end
10
+ end
11
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'mits/v4.1/deposit'
3
+
4
+ module MITS
5
+ module V4_1
6
+ describe Deposit do
7
+ it { is_expected.to respond_to(:type) }
8
+ it { is_expected.to respond_to(:description) }
9
+ it { is_expected.to respond_to(:percent_refundable) }
10
+ it { is_expected.to respond_to(:portion_refundable) }
11
+ it { is_expected.to respond_to(:amount) }
12
+ end
13
+ end
14
+ end