reso 0.1.0.0
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/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +149 -0
- data/Rakefile +1 -0
- data/app/controllers/syndication_controller.rb +5 -0
- data/app/models/.keep +0 -0
- data/app/models/address.rb +25 -0
- data/app/models/address_type.rb +3 -0
- data/app/models/alternate_price.rb +2 -0
- data/app/models/appliance.rb +3 -0
- data/app/models/architecture_style.rb +5 -0
- data/app/models/area_unit.rb +2 -0
- data/app/models/brokerage.rb +4 -0
- data/app/models/builder.rb +4 -0
- data/app/models/business.rb +8 -0
- data/app/models/community.rb +5 -0
- data/app/models/cooling_system.rb +3 -0
- data/app/models/county.rb +5 -0
- data/app/models/currency_period.rb +3 -0
- data/app/models/enumeration.rb +7 -0
- data/app/models/expense.rb +6 -0
- data/app/models/expense_category.rb +2 -0
- data/app/models/exterior_type.rb +3 -0
- data/app/models/floor_covering.rb +3 -0
- data/app/models/foreclosure_status.rb +5 -0
- data/app/models/franchise.rb +4 -0
- data/app/models/gender.rb +3 -0
- data/app/models/heating_fuel.rb +3 -0
- data/app/models/heating_system.rb +3 -0
- data/app/models/home_feature.rb +3 -0
- data/app/models/import.rb +16 -0
- data/app/models/import_format.rb +3 -0
- data/app/models/license_category.rb +2 -0
- data/app/models/listing.rb +64 -0
- data/app/models/listing_category.rb +5 -0
- data/app/models/listing_media.rb +6 -0
- data/app/models/listing_provider.rb +9 -0
- data/app/models/listing_status.rb +5 -0
- data/app/models/multiple_listing_service.rb +5 -0
- data/app/models/neighborhood.rb +3 -0
- data/app/models/office.rb +6 -0
- data/app/models/open_house.rb +4 -0
- data/app/models/parking.rb +3 -0
- data/app/models/participant.rb +5 -0
- data/app/models/participant_license.rb +8 -0
- data/app/models/participant_role.rb +3 -0
- data/app/models/person.rb +18 -0
- data/app/models/photo.rb +3 -0
- data/app/models/place.rb +3 -0
- data/app/models/price.rb +4 -0
- data/app/models/property_sub_type.rb +5 -0
- data/app/models/property_type.rb +5 -0
- data/app/models/queued_listing.rb +26 -0
- data/app/models/roof_type.rb +3 -0
- data/app/models/room.rb +4 -0
- data/app/models/room_category.rb +2 -0
- data/app/models/school.rb +3 -0
- data/app/models/school_category.rb +2 -0
- data/app/models/source_provider_category.rb +2 -0
- data/app/models/tax.rb +3 -0
- data/app/models/video.rb +3 -0
- data/app/models/view_type.rb +3 -0
- data/app/models/virtual_tour.rb +3 -0
- data/app/views/syndication/rets.xml.erb +325 -0
- data/lib/class_extensions.rb +53 -0
- data/lib/generators/reso/install_generator.rb +43 -0
- data/lib/generators/reso/setup.rb +36 -0
- data/lib/generators/reso/templates/create_addresses.rb +33 -0
- data/lib/generators/reso/templates/create_businesses.rb +19 -0
- data/lib/generators/reso/templates/create_enumerations.rb +11 -0
- data/lib/generators/reso/templates/create_expenses.rb +13 -0
- data/lib/generators/reso/templates/create_imports.rb +17 -0
- data/lib/generators/reso/templates/create_join_tables.rb +27 -0
- data/lib/generators/reso/templates/create_listing_media.rb +19 -0
- data/lib/generators/reso/templates/create_listing_providers.rb +12 -0
- data/lib/generators/reso/templates/create_listings.rb +154 -0
- data/lib/generators/reso/templates/create_multiple_listing_services.rb +11 -0
- data/lib/generators/reso/templates/create_offices.rb +29 -0
- data/lib/generators/reso/templates/create_open_houses.rb +18 -0
- data/lib/generators/reso/templates/create_participant_licenses.rb +13 -0
- data/lib/generators/reso/templates/create_participants.rb +26 -0
- data/lib/generators/reso/templates/create_people.rb +18 -0
- data/lib/generators/reso/templates/create_places.rb +20 -0
- data/lib/generators/reso/templates/create_prices.rb +19 -0
- data/lib/generators/reso/templates/create_queued_listings.rb +10 -0
- data/lib/generators/reso/templates/create_rooms.rb +10 -0
- data/lib/generators/reso/templates/create_schools.rb +13 -0
- data/lib/generators/reso/templates/create_taxes.rb +12 -0
- data/lib/generators/reso/templates/enumerations.csv +748 -0
- data/lib/mapper/reso.rb +658 -0
- data/lib/mapper.rb +114 -0
- data/lib/reso/engine.rb +13 -0
- data/lib/reso/railties/reso.rake +128 -0
- data/lib/reso/version.rb +3 -0
- data/lib/reso.rb +10 -0
- data/reso.gemspec +31 -0
- metadata +261 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f40fc790012ddccc71df15ef4ded0e4e2da9c158
|
4
|
+
data.tar.gz: e83245209c33c892e5db60621b33409663610ca5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9d4a8f7591292f3f68a4b1ec15fe90498250d76ea57214ec32cded2c661839910691491af8d877da43df6da7600d33bafccfcd2ca29c28e8e701c4ae22f885c
|
7
|
+
data.tar.gz: fdbacc52993e69b3260051e3e53bf05795ad0860f990bc17377b6ed62abc6496e6539a1aa18f4630b468c2a7e89d2823e33c6f4eaadb78fce6d4cd79dd9c5ee6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Michael Edlund
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# RESO Data Dictionary
|
2
|
+
|
3
|
+
The RESO Data Dictionary gem is an ongoing effort to provide data models and data import based on the Real Estate Standardization Organization Data Dictionary syndication format for exchange of real estate listing data.
|
4
|
+
|
5
|
+
Read more here:
|
6
|
+
http://www.reso.org/schemas-for-syndication
|
7
|
+
|
8
|
+
This gem has been written for MySQL. If you test it using another RDBMS, let me know the result.
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'reso'
|
16
|
+
|
17
|
+
And then install:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Run the generator to copy migrations to your app:
|
22
|
+
|
23
|
+
$ rails g reso:install
|
24
|
+
|
25
|
+
Create the database:
|
26
|
+
|
27
|
+
$ rake db:create
|
28
|
+
|
29
|
+
Run the migrations:
|
30
|
+
|
31
|
+
$ rake db:migrate
|
32
|
+
|
33
|
+
Populate the database with necessary seed data:
|
34
|
+
|
35
|
+
$ rake reso:seed
|
36
|
+
|
37
|
+
Populate the database with an example listing:
|
38
|
+
|
39
|
+
$ rake reso:import
|
40
|
+
|
41
|
+
This will download and install an example listing in the RESO format, as provided by ListHub, the largest US listing syndicator. The information needed is populated by the seed task through the Import model. If you want to add your own import, you would open the console and create an import:
|
42
|
+
|
43
|
+
> Import.create(token: 'myimport', name: 'My Import', source_url: 'http://somewebsite.com/myfeed.xml')
|
44
|
+
|
45
|
+
You would then import it by passing the token value to the import rake task:
|
46
|
+
|
47
|
+
$ rake reso:import[myimport]
|
48
|
+
|
49
|
+
|
50
|
+
## Usage
|
51
|
+
|
52
|
+
Fetch a listing:
|
53
|
+
|
54
|
+
@listing = Listing.first
|
55
|
+
|
56
|
+
Access direct attributes:
|
57
|
+
|
58
|
+
@listing.list_price
|
59
|
+
@listing.list_price_low
|
60
|
+
@listing.listing_url
|
61
|
+
@listing.lead_routing_email
|
62
|
+
@listing.bedrooms
|
63
|
+
@listing.bathrooms
|
64
|
+
@listing.listing_key
|
65
|
+
@listing.permit_address_on_internet
|
66
|
+
@listing.vow_address_display
|
67
|
+
@listing.vow_automated_valuation_display
|
68
|
+
@listing.vow_consumer_comment
|
69
|
+
@listing.disclose_address
|
70
|
+
@listing.short_sale
|
71
|
+
@listing.listing_description
|
72
|
+
@listing.listing_service_identifier
|
73
|
+
@listing.living_area
|
74
|
+
@listing.lot_size
|
75
|
+
@listing.lot_size_unit
|
76
|
+
@listing.listing_date
|
77
|
+
@listing.listing_title
|
78
|
+
@listing.full_bathrooms
|
79
|
+
@listing.three_quarter_bathrooms
|
80
|
+
@listing.half_bathrooms
|
81
|
+
@listing.one_quarter_bathrooms
|
82
|
+
@listing.partial_bathrooms
|
83
|
+
@listing.latitude
|
84
|
+
@listing.longitude
|
85
|
+
@listing.directions
|
86
|
+
@listing.elevation
|
87
|
+
@listing.geocode_options
|
88
|
+
@listing.parcel_info
|
89
|
+
@listing.year_built
|
90
|
+
@listing.year_updated
|
91
|
+
@listing.building_unit_count
|
92
|
+
@listing.num_floors
|
93
|
+
@listing.condo_floor_num
|
94
|
+
@listing.num_parking_spaces
|
95
|
+
@listing.room_count
|
96
|
+
@listing.legal_description
|
97
|
+
|
98
|
+
Access related models:
|
99
|
+
|
100
|
+
@listing.address
|
101
|
+
@listing.alternate_prices
|
102
|
+
@listing.appliances
|
103
|
+
@listing.architecture_style
|
104
|
+
@listing.brokerage
|
105
|
+
@listing.builders
|
106
|
+
@listing.community
|
107
|
+
@listing.cooling_systems
|
108
|
+
@listing.county
|
109
|
+
@listing.expenses
|
110
|
+
@listing.exterior_types
|
111
|
+
@listing.floor_coverings
|
112
|
+
@listing.foreclosure_status
|
113
|
+
@listing.franchises
|
114
|
+
@listing.heating_fuels
|
115
|
+
@listing.heating_systems
|
116
|
+
@listing.home_features
|
117
|
+
@listing.listing_category
|
118
|
+
@listing.listing_office
|
119
|
+
@listing.listing_provider
|
120
|
+
@listing.listing_service
|
121
|
+
@listing.listing_status
|
122
|
+
@listing.multiple_listing_service
|
123
|
+
@listing.neighborhoods
|
124
|
+
@listing.offices
|
125
|
+
@listing.open_houses
|
126
|
+
@listing.parking
|
127
|
+
@listing.participants
|
128
|
+
@listing.photos
|
129
|
+
@listing.property_sub_type
|
130
|
+
@listing.property_type
|
131
|
+
@listing.roof_types
|
132
|
+
@listing.rooms
|
133
|
+
@listing.taxes
|
134
|
+
@listing.videos
|
135
|
+
@listing.view_types
|
136
|
+
@listing.virtual_tours
|
137
|
+
|
138
|
+
Other:
|
139
|
+
|
140
|
+
@brokerage.address
|
141
|
+
@builder.address
|
142
|
+
@franchise.address
|
143
|
+
|
144
|
+
## License
|
145
|
+
|
146
|
+
MIT License. Copyright 2013-2015 Michael Edlund, medlund@mac.com.
|
147
|
+
|
148
|
+
|
149
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/app/models/.keep
ADDED
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Address < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :address_type
|
4
|
+
belongs_to :addressable, polymorphic: true
|
5
|
+
|
6
|
+
before_save :validate_and_sanitize_us_address
|
7
|
+
|
8
|
+
def address_concatenated
|
9
|
+
[self.full_street_address, self.city, self.state_or_province, self.postal_code].join(', ')
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate_and_sanitize_us_address
|
13
|
+
if (address = StreetAddress::US.parse(self.address_concatenated))
|
14
|
+
self.street_number = address.number
|
15
|
+
self.street_dir_prefix = address.prefix
|
16
|
+
self.street_name = address.street
|
17
|
+
self.street_suffix = address.street_type
|
18
|
+
self.street_dir_suffix = address.suffix
|
19
|
+
self.unit_number = address.unit unless address.unit.blank?
|
20
|
+
self.state_or_province = address.state
|
21
|
+
self.country = 'US'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Import < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :import_format
|
4
|
+
|
5
|
+
has_many :listings
|
6
|
+
has_many :queued_listings
|
7
|
+
|
8
|
+
validates_uniqueness_of :token
|
9
|
+
|
10
|
+
before_save :set_import_format
|
11
|
+
|
12
|
+
def set_import_format
|
13
|
+
self.import_format = ImportFormat.find_by(name: 'reso') unless self.import_format.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Listing < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :architecture_style
|
4
|
+
belongs_to :brokerage
|
5
|
+
belongs_to :builder
|
6
|
+
belongs_to :community
|
7
|
+
belongs_to :county
|
8
|
+
belongs_to :foreclosure_status
|
9
|
+
belongs_to :franchise
|
10
|
+
belongs_to :import
|
11
|
+
belongs_to :listing_category
|
12
|
+
belongs_to :listing_provider
|
13
|
+
belongs_to :listing_status
|
14
|
+
belongs_to :multiple_listing_service
|
15
|
+
belongs_to :property_sub_type
|
16
|
+
belongs_to :property_type
|
17
|
+
belongs_to :office
|
18
|
+
belongs_to :zoning_type
|
19
|
+
|
20
|
+
has_one :address, as: :addressable, dependent: :destroy
|
21
|
+
|
22
|
+
has_many :alternate_prices, dependent: :destroy
|
23
|
+
has_many :expenses, dependent: :destroy
|
24
|
+
has_many :open_houses, dependent: :destroy
|
25
|
+
has_many :photos, dependent: :destroy
|
26
|
+
has_many :people, through: :participants
|
27
|
+
has_many :rooms, dependent: :destroy
|
28
|
+
has_many :taxes, dependent: :destroy
|
29
|
+
has_many :videos, dependent: :destroy
|
30
|
+
has_many :virtual_tours, dependent: :destroy
|
31
|
+
|
32
|
+
has_and_belongs_to_many :appliances, association_foreign_key: "enumeration_id"
|
33
|
+
has_and_belongs_to_many :cooling_systems, association_foreign_key: "enumeration_id"
|
34
|
+
has_and_belongs_to_many :exterior_types, association_foreign_key: "enumeration_id"
|
35
|
+
has_and_belongs_to_many :floor_coverings, association_foreign_key: "enumeration_id"
|
36
|
+
has_and_belongs_to_many :heating_fuels, association_foreign_key: "enumeration_id"
|
37
|
+
has_and_belongs_to_many :heating_systems, association_foreign_key: "enumeration_id"
|
38
|
+
has_and_belongs_to_many :home_features, association_foreign_key: "enumeration_id"
|
39
|
+
has_and_belongs_to_many :neighborhoods, association_foreign_key: "place_id"
|
40
|
+
has_and_belongs_to_many :parking, association_foreign_key: "enumeration_id"
|
41
|
+
has_and_belongs_to_many :participants
|
42
|
+
has_and_belongs_to_many :roof_types, association_foreign_key: "enumeration_id"
|
43
|
+
has_and_belongs_to_many :view_types, association_foreign_key: "enumeration_id"
|
44
|
+
|
45
|
+
accepts_nested_attributes_for :alternate_prices, allow_destroy: true
|
46
|
+
accepts_nested_attributes_for :appliances
|
47
|
+
accepts_nested_attributes_for :cooling_systems
|
48
|
+
accepts_nested_attributes_for :expenses, allow_destroy: true
|
49
|
+
accepts_nested_attributes_for :exterior_types
|
50
|
+
accepts_nested_attributes_for :floor_coverings
|
51
|
+
accepts_nested_attributes_for :heating_fuels
|
52
|
+
accepts_nested_attributes_for :heating_systems
|
53
|
+
accepts_nested_attributes_for :home_features
|
54
|
+
accepts_nested_attributes_for :neighborhoods
|
55
|
+
accepts_nested_attributes_for :open_houses, allow_destroy: true
|
56
|
+
accepts_nested_attributes_for :parking
|
57
|
+
accepts_nested_attributes_for :participants, allow_destroy: true
|
58
|
+
accepts_nested_attributes_for :roof_types
|
59
|
+
accepts_nested_attributes_for :rooms, allow_destroy: true
|
60
|
+
accepts_nested_attributes_for :taxes, allow_destroy: true
|
61
|
+
accepts_nested_attributes_for :view_types
|
62
|
+
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Person < ActiveRecord::Base
|
2
|
+
belongs_to :gender
|
3
|
+
|
4
|
+
def complete_name
|
5
|
+
# Dr. Edwin E. 'Buzz' Aldrin Jr.
|
6
|
+
|
7
|
+
self.nick_name.blank? ? nick_name = nil : nick_name = "'#{self.nick_name}'"
|
8
|
+
self.middle_name.blank? ? middle_name = nil : middle_name = "#{self.middle_name.first.upcase}."
|
9
|
+
[
|
10
|
+
self.personal_title,
|
11
|
+
self.first_name,
|
12
|
+
middle_name,
|
13
|
+
nick_name,
|
14
|
+
self.last_name,
|
15
|
+
self.suffix
|
16
|
+
].delete_if{|i| i.blank? }.join(' ')
|
17
|
+
end
|
18
|
+
end
|
data/app/models/photo.rb
ADDED
data/app/models/place.rb
ADDED
data/app/models/price.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class QueuedListing < ActiveRecord::Base
|
2
|
+
belongs_to :import
|
3
|
+
serialize :listing_data
|
4
|
+
after_save :create_listing_and_remove_myself
|
5
|
+
|
6
|
+
def mapper
|
7
|
+
"Mapper::#{self.import.import_format.name.downcase.capitalize}".constantize
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_or_update_listing
|
11
|
+
listing = self.import.listings.eager_load(:address).eager_load(:photos).find_or_initialize_by(
|
12
|
+
listing_key: mapper.unique_identifier(self)
|
13
|
+
)
|
14
|
+
if (listing.modification_timestamp != mapper.modification_timestamp(self, listing))
|
15
|
+
Mapper::RESO_LISTING_ATTRIBUTES.each do |attribute|
|
16
|
+
listing.send("#{attribute}=", mapper.send(attribute, self, listing))
|
17
|
+
end
|
18
|
+
listing.save
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_listing_and_remove_myself
|
23
|
+
create_or_update_listing ? self.destroy : false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/app/models/room.rb
ADDED