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
@@ -1,16 +0,0 @@
1
- module MITS
2
- class Address
3
- include SimpleObjects::Base
4
-
5
- attribute :address1
6
- attribute :address2
7
- attribute :city
8
- attribute :country
9
- attribute :description
10
- attribute :latitude
11
- attribute :longitude
12
- attribute :postal_code
13
- attribute :state
14
- attribute :type
15
- end
16
- end
@@ -1,8 +0,0 @@
1
- module MITS
2
- class Amenity
3
- include SimpleObjects::Base
4
-
5
- attribute :description
6
- attribute :type
7
- end
8
- end
@@ -1,11 +0,0 @@
1
- module MITS
2
- class Company
3
- include SimpleObjects::Base
4
-
5
- attribute :id
6
- attribute :name
7
- attribute :address
8
- attribute :website
9
- attribute :logo
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module MITS
2
- class Deposit
3
- include SimpleObjects::Base
4
-
5
- attribute :amount
6
- attribute :description
7
- attribute :percent_refundable
8
- attribute :portion_refundable
9
- attribute :type
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module MITS
2
- class Fees
3
- include SimpleObjects::Base
4
-
5
- attribute :admin_fee
6
- attribute :application_fee
7
- attribute :broker_fee
8
- attribute :late_fee_per_day
9
- attribute :late_min_fee
10
- attribute :late_percent
11
- attribute :late_type
12
- attribute :non_refundable_hold_fee
13
- attribute :prorate_type
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- module MITS
2
- class File
3
- include SimpleObjects::Base
4
-
5
- attribute :active
6
- attribute :caption
7
- attribute :description
8
- attribute :format
9
- attribute :height
10
- attribute :id
11
- attribute :name
12
- attribute :rank
13
- attribute :source
14
- attribute :width
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- module MITS
2
- class Pet
3
- include SimpleObjects::Base
4
-
5
- attribute :count
6
- attribute :description
7
- attribute :size
8
- attribute :type
9
- attribute :weight
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module MITS
2
- class PetPolicy
3
- include SimpleObjects::Base
4
-
5
- attribute :allowed
6
- attribute :care
7
- attribute :deposit
8
- attribute :fee
9
- attribute :pets
10
- attribute :rent
11
- attribute :restrictions
12
-
13
- alias_method :allowed?, :allowed
14
- end
15
- end
@@ -1,20 +0,0 @@
1
- module MITS
2
- class Property
3
- include SimpleObjects::Base
4
-
5
- attribute :address
6
- attribute :amenities
7
- attribute :company_id
8
- attribute :deposit
9
- attribute :description
10
- attribute :fees
11
- attribute :files
12
- attribute :id
13
- attribute :name
14
- attribute :pet_policy
15
- attribute :summary
16
- attribute :type
17
- attribute :units
18
- attribute :website
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- module MITS
2
- class Unit
3
- include SimpleObjects::Base
4
-
5
- attribute :bathrooms
6
- attribute :bedrooms
7
- attribute :name
8
- attribute :rent
9
- attribute :sqft
10
- end
11
- end
data/lib/mits/mapper.rb DELETED
@@ -1,48 +0,0 @@
1
- require 'mits/entities/address'
2
- require 'mits/entities/amenity'
3
- require 'mits/entities/company'
4
- require 'mits/entities/deposit'
5
- require 'mits/entities/fees'
6
- require 'mits/entities/file'
7
- require 'mits/entities/pet'
8
- require 'mits/entities/pet_policy'
9
- require 'mits/entities/property'
10
- require 'mits/entities/unit'
11
-
12
- require 'mits/mappers/address_mapper'
13
- require 'mits/mappers/amenities_mapper'
14
- require 'mits/mappers/company_mapper'
15
- require 'mits/mappers/deposit_mapper'
16
- require 'mits/mappers/fees_mapper'
17
- require 'mits/mappers/files_mapper'
18
- require 'mits/mappers/pet_policy_mapper'
19
- require 'mits/mappers/property_mapper'
20
- require 'mits/mappers/units_mapper'
21
-
22
- module MITS
23
- module Mapper
24
- extend AddressMapper
25
- extend AmenitiesMapper
26
- extend CompanyMapper
27
- extend DepositMapper
28
- extend FeesMapper
29
- extend FilesMapper
30
- extend PetPolicyMapper
31
- extend PropertyMapper
32
- extend UnitsMapper
33
-
34
- extend self
35
-
36
- protected
37
-
38
- def bool(value)
39
- value == 'true'
40
- end
41
-
42
- def try(value, method)
43
- return nil unless value
44
- value.send(method)
45
- end
46
-
47
- end
48
- end
@@ -1,29 +0,0 @@
1
- module MITS
2
- module AddressMapper
3
- def address(tag, secondary_tag = nil)
4
- attrs = address_attributes(tag)
5
-
6
- if secondary_tag
7
- attrs[:latitude] = try(secondary_tag[:Latitude], :to_f)
8
- attrs[:longitude] = try(secondary_tag[:Longitude], :to_f)
9
- end
10
-
11
- Address.new(attrs)
12
- end
13
-
14
- private
15
-
16
- def address_attributes(tag)
17
- {
18
- type: tag[:AddressType],
19
- description: tag[:Description],
20
- address1: tag[:AddressLine1],
21
- address2: tag[:AddressLine2],
22
- city: tag[:City],
23
- state: tag[:State],
24
- postal_code: tag[:PostalCode],
25
- country: tag[:Country],
26
- }
27
- end
28
- end
29
- end
@@ -1,14 +0,0 @@
1
- module MITS
2
- module AmenitiesMapper
3
- def amenities(tags)
4
- if tags
5
- tags = [tags] unless tags.is_a? Array
6
- tags.map { |tag| amenity(tag) }
7
- end
8
- end
9
-
10
- def amenity(tag)
11
- Amenity.new(description: tag[:Description], type: tag[:AmenityType])
12
- end
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- module MITS
2
- module CompanyMapper
3
- def company(tag)
4
- Company.new(address: address(tag[:Address]),
5
- id: tag[:Identification][:IDValue],
6
- logo: tag[:Logo],
7
- name: tag[:CompanyName],
8
- website: tag[:Website])
9
- end
10
- end
11
- end
@@ -1,24 +0,0 @@
1
- module MITS
2
- module DepositMapper
3
- def deposit(tag)
4
- Deposit.new(amount: deposit_amount(tag[:Amount][:ValueRange]),
5
- description: tag[:Description],
6
- percent_refundable: try(tag[:PercentRefundable], :to_f),
7
- portion_refundable: try(tag[:PortionRefundable], :to_f),
8
- type: tag[:DepositType])
9
- end
10
-
11
- private
12
-
13
- def deposit_amount(tag)
14
- if tag[:Exact]
15
- amount = tag[:Exact].to_f
16
- else
17
- min = tag[:Min].to_f
18
- max = tag[:Max].to_f
19
- amount = Range.new(min, max)
20
- end
21
- amount
22
- end
23
- end
24
- end
@@ -1,15 +0,0 @@
1
- module MITS
2
- module FeesMapper
3
- def fees(tag)
4
- Fees.new(admin_fee: try(tag[:AdminFee], :to_f),
5
- application_fee: try(tag[:ApplicationFee], :to_f),
6
- broker_fee: try(tag[:BrokerFee], :to_f),
7
- late_fee_per_day: try(tag[:LateFeePerDay], :to_f),
8
- late_min_fee: try(tag[:LateMinFee], :to_f),
9
- late_percent: try(tag[:LatePercent], :to_f),
10
- late_type: tag[:LateType],
11
- non_refundable_hold_fee: try(tag[:NonRefundableHoldFee], :to_f),
12
- prorate_type: tag[:ProrateType])
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- module MITS
2
- module FilesMapper
3
- def files(tags)
4
- tags = [tags] unless tags.is_a? Array
5
- tags.map do |tag|
6
- File.new(active: bool(tag[:Active]),
7
- caption: tag[:Caption],
8
- description: tag[:Description],
9
- format: tag[:Format],
10
- height: try(tag[:Height], :to_i),
11
- id: tag[:FileID],
12
- name: tag[:Name],
13
- rank: tag[:Rank],
14
- source: tag[:Src],
15
- width: tag[:Width])
16
- end
17
- end
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- module MITS
2
- module PetPolicyMapper
3
- def pet_policy(tag)
4
- if bool(tag[:Allowed])
5
- PetPolicy.new(allowed: true,
6
- care: bool(tag[:PetCare]),
7
- deposit: try(tag[:Deposit], :to_f),
8
- fee: try(tag[:Fee], :to_f),
9
- pets: pets(tag[:Pets]),
10
- rent: try(tag[:Rent], :to_f),
11
- restrictions: tag[:Restrictions])
12
- else
13
- PetPolicy.new(allowed: false)
14
- end
15
- end
16
-
17
- def pets(tags)
18
- tags = [tags] unless tags.is_a? Array
19
- tags.map do |tag|
20
- Pet.new(count: tag[:Count].to_i,
21
- description: tag[:Description],
22
- size: tag[:Size],
23
- weight: tag[:Weight],
24
- type: tag[:PetType])
25
- end
26
- end
27
- end
28
- end
@@ -1,41 +0,0 @@
1
- module MITS
2
- module PropertyMapper
3
- def property(tag)
4
- basics = property_basics(tag)
5
- details = property_details(tag)
6
- Property.new(basics.merge(details))
7
- end
8
-
9
- private
10
-
11
- def property_basics(tag)
12
- propId = tag[:PropertyID]
13
- {
14
- company_id: company_id(propId[:Identification]),
15
- description: tag[:Information][:LongDescription],
16
- id: tag[:IDValue],
17
- name: propId[:MarketingName],
18
- summary: tag[:Information][:ShortDescription],
19
- type: tag[:ILS_Identification][:ILS_IdentificationType],
20
- website: propId[:WebSite]
21
- }
22
- end
23
-
24
- def property_details(tag)
25
- {
26
- address: address(tag[:PropertyID][:Address], tag[:ILS_Identification]),
27
- amenities: amenities(tag[:ILS_Unit][:Amenity]),
28
- deposit: deposit(tag[:Deposit]),
29
- fees: fees(tag[:Fee]),
30
- files: files(tag[:File]),
31
- pet_policy: pet_policy(tag[:Policy][:Pet]),
32
- units: units(tag[:ILS_Unit][:Units][:Unit])
33
- }
34
- end
35
-
36
- def company_id(tags)
37
- tag = tags.find { |t| t[:IDType].downcase == 'company' }
38
- tag[:IDValue] if tag
39
- end
40
- end
41
- end
@@ -1,22 +0,0 @@
1
- module MITS
2
- module UnitsMapper
3
- def units(tags)
4
- tags = [tags] unless tags.is_a? Array
5
- tags.map do |tag|
6
- Unit.new(bathrooms: try(tag[:UnitBathrooms], :to_f),
7
- bedrooms: try(tag[:UnitBedrooms], :to_f),
8
- name: tag[:MarketingName],
9
- rent: try(tag[:UnitRent], :to_f),
10
- sqft: unit_sqft(tag))
11
- end
12
- end
13
-
14
- private
15
-
16
- def unit_sqft(tag)
17
- min = tag[:MinSquareFeet]
18
- max = tag[:MaxSquareFeet]
19
- Range.new(min.to_i, max.to_i)
20
- end
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module MITS
4
- describe Address do
5
- it { is_expected.to respond_to(:address1) }
6
- it { is_expected.to respond_to(:address2) }
7
- it { is_expected.to respond_to(:city) }
8
- it { is_expected.to respond_to(:country) }
9
- it { is_expected.to respond_to(:description) }
10
- it { is_expected.to respond_to(:latitude) }
11
- it { is_expected.to respond_to(:longitude) }
12
- it { is_expected.to respond_to(:postal_code) }
13
- it { is_expected.to respond_to(:state) }
14
- it { is_expected.to respond_to(:type) }
15
- end
16
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module MITS
4
- describe Amenity do
5
- it { is_expected.to respond_to(:type) }
6
- it { is_expected.to respond_to(:description) }
7
- end
8
- end