mls 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,8 @@ class Region < MLS::Model
4
4
 
5
5
  self.inheritance_column = nil
6
6
 
7
+ CITY_TYPES = ["City", "Municipality", "Village", "Rural Municipality", "Town", "Resort Village", "Community Government"]
8
+
7
9
  belongs_to :cover_photo, :class_name => 'Image'
8
10
  belongs_to :market, :class_name => 'Region'
9
11
  belongs_to :flagship, :class_name => 'Region'
@@ -23,6 +25,10 @@ class Region < MLS::Model
23
25
  end
24
26
  end
25
27
 
28
+ def tree_name
29
+ slug.split("/").map(&:humanize).map(&:titleize).map{|r| r.length == 2 ? r.upcase : r}.reverse.join(", ")
30
+ end
31
+
26
32
  def cover_photo_url(options={})
27
33
 
28
34
  options.reverse_merge!({
@@ -10,8 +10,8 @@ class Session < MLS::Model
10
10
  email_address = email_address[:email_address]
11
11
  end
12
12
 
13
- Session.create(:email_address => email_address, :password => password)
14
- rescue Sunstone::Exception::Unauthorized
13
+ Session.create!(:email_address => email_address, :password => password)
14
+ rescue Sunstone::Exception::Unauthorized, ActiveRecord::RecordInvalid
15
15
  nil
16
16
  end
17
17
 
@@ -2,14 +2,15 @@ class Source < MLS::Model
2
2
 
3
3
  has_many :tasks, :as => :subject
4
4
  has_many :emails
5
+ has_many :email_addresses
6
+ has_many :webpages, :inverse_of => :source
5
7
 
6
8
  belongs_to :account
7
9
  belongs_to :organization
8
10
  belongs_to :upload, class_name: 'Flyer'
9
11
 
10
12
  def name
11
- return email_address if email_address.present?
12
- url.match(/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/)[1]
13
+ domain
13
14
  end
14
15
 
15
16
  end
@@ -0,0 +1,24 @@
1
+ class Subscription < MLS::Model
2
+ self.inheritance_column = nil
3
+
4
+ belongs_to :membership
5
+ belongs_to :subject, polymorphic: true
6
+ belongs_to :credit_card
7
+
8
+ def name
9
+ case self.type
10
+ when "unlimited"
11
+ "Unlimited Premium Listings"
12
+ when "premium"
13
+ "Premium Listings"
14
+ when "elite"
15
+ "Elite Account"
16
+ when "coworking"
17
+ "Coworking Space"
18
+ end
19
+ end
20
+
21
+ def cost
22
+ read_attribute(:cost) / 100.0 if read_attribute(:cost)
23
+ end
24
+ end
@@ -3,6 +3,7 @@ class Task < MLS::Model
3
3
 
4
4
  belongs_to :subject, :polymorphic => true
5
5
  belongs_to :account
6
+ belongs_to :source
6
7
 
7
8
  has_many :events
8
9
  has_many :mistakes
@@ -15,7 +16,7 @@ class Task < MLS::Model
15
16
  end
16
17
 
17
18
  def for_task?
18
- subject_type == "Taks"
19
+ subject_type == "Task"
19
20
  end
20
21
 
21
22
  def review?
@@ -30,23 +31,28 @@ class Task < MLS::Model
30
31
  type == "parse"
31
32
  end
32
33
 
34
+ def crawl?
35
+ type == "crawl"
36
+ end
37
+
38
+ def paused?
39
+ status == 'paused'
40
+ end
41
+
33
42
  def duration
34
- time_logs.where(:started_at => true, :stopped_at => true).sum("duration")
43
+ time_logs.where(TimeLog.arel_table[:started_at].not_eq(nil)).where(TimeLog.arel_table[:stopped_at].not_eq(nil)).sum("duration")
35
44
  end
36
45
 
37
46
  def pause
38
- log = time_logs.where(:started_at => true, :stopped_at => false).first
47
+ log = time_logs.where(:stopped_at => nil).where(TimeLog.arel_table[:started_at].not_eq(nil)).first
39
48
  if log
40
49
  log.update(:stopped_at => Time.now)
41
50
  end
42
51
  end
43
52
 
44
53
  def resume
45
- time_logs << TimeLog.create(:started_at => Time.now)
46
- end
47
-
48
- def paused?
49
- !started_at.nil? && completed_at.nil? && time_logs.where(:started_at => true, :stopped_at => false).length == 0
54
+ #time_logs << TimeLog.create(:started_at => Time.now)
55
+ TimeLog.create(task_id: self.id, started_at: Time.now)
50
56
  end
51
57
 
52
58
  end
@@ -0,0 +1,6 @@
1
+ class Team < MLS::Model
2
+
3
+ has_and_belongs_to_many :accounts
4
+ belongs_to :organization
5
+
6
+ end
@@ -1,3 +1,27 @@
1
1
  class View < MLS::Model
2
2
  belongs_to :subject, polymorphic: true
3
+
4
+ def self.by_day(filter)
5
+ req = Net::HTTP::Get.new("/views/by_day")
6
+ req.body = {
7
+ where: filter
8
+ }.to_json
9
+ connection.instance_variable_get(:@connection).send_request(req).body
10
+ end
11
+
12
+ def self.by_week(filter)
13
+ req = Net::HTTP::Get.new("/views/by_week")
14
+ req.body = {
15
+ where: filter
16
+ }.to_json
17
+ connection.instance_variable_get(:@connection).send_request(req).body
18
+ end
19
+
20
+ def self.by_month(filter)
21
+ req = Net::HTTP::Get.new("/views/by_month")
22
+ req.body = {
23
+ where: filter
24
+ }.to_json
25
+ connection.instance_variable_get(:@connection).send_request(req).body
26
+ end
3
27
  end
@@ -6,7 +6,7 @@ class Webpage < MLS::Model
6
6
  validates :url, presence: true
7
7
 
8
8
  def name
9
- url.match(/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/)[1]
9
+ url.match(/^(?:https?:\/\/)?(?:www\.)?(.*)/)[1]
10
10
  end
11
11
 
12
12
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mls"
6
- s.version = '1.5.0'
6
+ s.version = '1.5.1'
7
7
  s.authors = ["Jon Bracy", "James R. Bracy"]
8
8
  s.email = ["jon@42floors.com", "james@42floors.com"]
9
9
  s.homepage = "http://mls.42floors.com"
@@ -31,6 +31,9 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'sdoc-templates-42floors'
32
32
 
33
33
  # Runtime
34
+ s.add_runtime_dependency 'phony'
35
+ s.add_runtime_dependency 'arel-extensions'
34
36
  s.add_runtime_dependency 'rgeo', '>= 0.4.0'
35
37
  s.add_runtime_dependency 'sunstone', '>= 2.0.1'
38
+ s.add_runtime_dependency 'bcrypt'
36
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-27 00:00:00.000000000 Z
12
+ date: 2017-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -165,6 +165,34 @@ dependencies:
165
165
  - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: phony
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: arel-extensions
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :runtime
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
168
196
  - !ruby/object:Gem::Dependency
169
197
  name: rgeo
170
198
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +221,20 @@ dependencies:
193
221
  - - ">="
194
222
  - !ruby/object:Gem::Version
195
223
  version: 2.0.1
224
+ - !ruby/object:Gem::Dependency
225
+ name: bcrypt
226
+ requirement: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ type: :runtime
232
+ prerelease: false
233
+ version_requirements: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
196
238
  description: Ruby library for integrating with the 42Floors MLS
197
239
  email:
198
240
  - jon@42floors.com
@@ -207,25 +249,33 @@ files:
207
249
  - Rakefile
208
250
  - lib/mls.rb
209
251
  - lib/mls/account.rb
252
+ - lib/mls/accounts_region.rb
253
+ - lib/mls/action.rb
210
254
  - lib/mls/address.rb
211
- - lib/mls/agency.rb
212
- - lib/mls/change.rb
255
+ - lib/mls/api_key.rb
213
256
  - lib/mls/comment.rb
214
257
  - lib/mls/coworking_space.rb
258
+ - lib/mls/credit_card.rb
259
+ - lib/mls/datum.rb
215
260
  - lib/mls/document.rb
216
261
  - lib/mls/email.rb
217
262
  - lib/mls/email_address.rb
263
+ - lib/mls/email_digest.rb
218
264
  - lib/mls/event.rb
219
- - lib/mls/event_action.rb
265
+ - lib/mls/flyer.rb
220
266
  - lib/mls/geometry.rb
221
- - lib/mls/green_sheet.rb
222
267
  - lib/mls/image_ordering.rb
268
+ - lib/mls/impression_count.rb
223
269
  - lib/mls/inquiry.rb
270
+ - lib/mls/invoice.rb
224
271
  - lib/mls/lead.rb
225
272
  - lib/mls/listing.rb
226
273
  - lib/mls/locality.rb
274
+ - lib/mls/membership.rb
275
+ - lib/mls/metadatum.rb
227
276
  - lib/mls/mistake.rb
228
277
  - lib/mls/organization.rb
278
+ - lib/mls/ownership.rb
229
279
  - lib/mls/phone.rb
230
280
  - lib/mls/property.rb
231
281
  - lib/mls/recommendation.rb
@@ -236,9 +286,10 @@ files:
236
286
  - lib/mls/source.rb
237
287
  - lib/mls/space.rb
238
288
  - lib/mls/stat.rb
289
+ - lib/mls/subscription.rb
239
290
  - lib/mls/task.rb
291
+ - lib/mls/team.rb
240
292
  - lib/mls/time_log.rb
241
- - lib/mls/unit.rb
242
293
  - lib/mls/use.rb
243
294
  - lib/mls/vendor.rb
244
295
  - lib/mls/view.rb
@@ -268,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
319
  version: '0'
269
320
  requirements: []
270
321
  rubyforge_project: mls
271
- rubygems_version: 2.4.5
322
+ rubygems_version: 2.5.1
272
323
  signing_key:
273
324
  specification_version: 4
274
325
  summary: 42Floors MLS Client
@@ -1,6 +0,0 @@
1
- class Agency < MLS::Model
2
-
3
- belongs_to :listing
4
- belongs_to :agent, :class_name => 'Account', :inverse_of => :agencies
5
-
6
- end
@@ -1,40 +0,0 @@
1
- class Change < MLS::Model
2
- self.inheritance_column = nil
3
-
4
- belongs_to :subject, :polymorphic => true
5
- has_many :event_actions, :as => :action
6
- has_many :mistakes
7
-
8
- # Returns the association instance for the given name, instantiating it if it doesn't already exist
9
- def association(name) #:nodoc:
10
- association = super
11
-
12
- return association if name.to_s != 'subject'
13
-
14
- association.instance_exec do
15
- def klass
16
- type = owner[reflection.foreign_type]
17
- type.presence && type.constantize
18
- rescue NameError
19
- nil
20
- end
21
-
22
- def reader(force_reload=false)
23
- if klass
24
- if force_reload
25
- klass.uncached { reload }
26
- elsif !loaded? || stale_target?
27
- reload
28
- end
29
-
30
- target
31
- else
32
- nil
33
- end
34
- end
35
- end
36
-
37
- association
38
- end
39
-
40
- end
@@ -1,6 +0,0 @@
1
- class EventAction < MLS::Model
2
-
3
- belongs_to :event
4
- belongs_to :action, polymorphic: true
5
-
6
- end
@@ -1,5 +0,0 @@
1
- class GreenSheet < MLS::Model
2
-
3
- has_one :account, :foreign_key => :green_sheet_uuid
4
-
5
- end
@@ -1,38 +0,0 @@
1
- class Unit < MLS::Model
2
- self.inheritance_column = nil
3
-
4
- include MLS::Slugger
5
- include MLS::Avatar
6
-
7
- belongs_to :property
8
- belongs_to :floorplan, :class_name => 'Document'
9
-
10
- has_many :listings
11
- has_many :image_orderings, as: :subject
12
- has_many :photos, through: :image_orderings, source: :image
13
- # has_many :photos, -> { order(:order => :asc) }, :as => :subject, :inverse_of => :subject
14
-
15
- has_and_belongs_to_many :uses
16
-
17
- def tags
18
- read_attribute(:tags) || []
19
- end
20
-
21
- def name
22
- name = ""
23
- case self.type
24
- when 'unit'
25
- name += "Unit"
26
- name += " #{self.number}" if self.number
27
- name += " (Floor #{self.floor})" if self.floor
28
- when 'floor'
29
- name += "Floor"
30
- name += " #{self.floor}" if self.floor
31
- name += " (Unit #{self.number})" if self.number
32
- when 'building'
33
- "Entire Building"
34
- end
35
- name
36
- end
37
-
38
- end