mls 0.0.23 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mls.rb CHANGED
@@ -5,32 +5,50 @@ module MLS
5
5
 
6
6
  class << self
7
7
 
8
- attr_accessor :environment
9
-
10
- def env
11
- @environment ||= 'development'
12
- end
13
-
14
- def site
15
- env == 'production' ? 'http://mls.42floors.com' : 'http://staging.mls.42floors.com'
16
- end
17
-
18
- def asset_host=(host)
19
- @asset_host = host
20
- end
21
-
22
- def asset_host
23
- return @asset_host if @asset_host
24
- env == 'production' ? 'assets.42floors.com' : 's3.amazonaws.com/staging-assets.42floors.com'
25
- end
26
-
27
- end
28
-
29
- class Resource < ActiveResource::Base
30
- self.site = MLS.site
31
- self.user = nil
32
- self.password = nil
33
- end
8
+ attr_accessor :environment
9
+
10
+ def env
11
+ @environment ||= 'development'
12
+ end
13
+
14
+ def site
15
+ env == 'production' ? 'http://mls.42floors.com' : 'http://staging.mls.42floors.com'
16
+ end
17
+
18
+ def asset_host=(host)
19
+ @asset_host = host
20
+ end
21
+
22
+ def asset_host
23
+ return @asset_host if @asset_host
24
+ env == 'production' ? 'assets.42floors.com' : 's3.amazonaws.com/staging-assets.42floors.com'
25
+ end
26
+
27
+ end
28
+
29
+ class Resource < ActiveResource::Base
30
+ self.site = MLS.site
31
+ self.prefix = '/api/'
32
+ self.user = nil
33
+ self.password = nil
34
+
35
+ def create
36
+ json = JSON.generate({self.class.element_name => JSON.parse(encode)})
37
+ connection.post(collection_path, json, self.class.headers).tap do |response|
38
+ self.id = id_from_response(response)
39
+ load_attributes_from_response(response)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def self.instantiate_collection(collection, prefix_options = {})
46
+ collection[self.collection_name].collect! do |record|
47
+ instantiate_record(record, prefix_options)
48
+ end
49
+ end
50
+
51
+ end
34
52
 
35
53
  end
36
54
 
@@ -1,6 +1,6 @@
1
1
  class MLS::Listing < MLS::Resource
2
2
 
3
- KINDS = %w(lease shared coworking)
3
+ KINDS = %w(lease sublease coworking)
4
4
  SPACE_TYPES = %w(unit floor building)
5
5
  LEASE_TYPES = ['Full Service', 'NNN', 'Gross', 'Industrial Gross', 'Modified Gross', 'Triple Net', 'Modified Net']
6
6
 
@@ -75,22 +75,6 @@ class MLS::Listing < MLS::Resource
75
75
  attribute :rate_units, :string
76
76
  end
77
77
 
78
- def name
79
- return attributes[:name] if attributes[:name] && !attributes[:name].empty?
80
-
81
- if address.name
82
- name = address.name
83
- if space_type == 'unit'
84
- name += ", Unit #{unit}" if unit
85
- elsif space_type == 'floor'
86
- name += ", Floor #{floor}" if floor
87
- end
88
- return name
89
- end
90
-
91
- return address.formatted_address.sub(/,.+$/,'')
92
- end
93
-
94
78
  def available_on
95
79
  Date.parse(attributes[:available_on])
96
80
  end
@@ -108,10 +92,4 @@ class MLS::Listing < MLS::Resource
108
92
  @photos
109
93
  end
110
94
 
111
- private
112
-
113
- def self.instantiate_collection(collection, prefix_options = {})
114
- collection['listings'].collect! { |record| instantiate_record(record, prefix_options) }
115
- end
116
-
117
95
  end
@@ -1,3 +1,3 @@
1
1
  module MLS
2
- VERSION = "0.0.23"
2
+ VERSION = "0.1.0"
3
3
  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: 0.0.23
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70282397812780 !ruby/object:Gem::Requirement
16
+ requirement: &70199603792500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70282397812780
24
+ version_requirements: *70199603792500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70282397812140 !ruby/object:Gem::Requirement
27
+ requirement: &70199603791900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70282397812140
35
+ version_requirements: *70199603791900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70282397811460 !ruby/object:Gem::Requirement
38
+ requirement: &70199603791360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70282397811460
46
+ version_requirements: *70199603791360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &70282397810760 !ruby/object:Gem::Requirement
49
+ requirement: &70199603790900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70282397810760
57
+ version_requirements: *70199603790900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: turn
60
- requirement: &70282397810100 !ruby/object:Gem::Requirement
60
+ requirement: &70199603790360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70282397810100
68
+ version_requirements: *70199603790360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activeresource
71
- requirement: &70282397809480 !ruby/object:Gem::Requirement
71
+ requirement: &70199603789760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70282397809480
79
+ version_requirements: *70199603789760
80
80
  description: Ruby library for integrating with the 42Floors MLS
81
81
  email:
82
82
  - james@42floors.com
@@ -91,7 +91,6 @@ files:
91
91
  - lib/mls/address.rb
92
92
  - lib/mls/listing.rb
93
93
  - lib/mls/photo.rb
94
- - lib/mls/property.rb
95
94
  - lib/mls/use.rb
96
95
  - lib/mls/version.rb
97
96
  - mls.gemspec
@@ -115,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
114
  version: '0'
116
115
  requirements: []
117
116
  rubyforge_project: mls
118
- rubygems_version: 1.8.11
117
+ rubygems_version: 1.8.15
119
118
  signing_key:
120
119
  specification_version: 3
121
120
  summary: 42Floors MLS Client
@@ -1,13 +0,0 @@
1
- class MLS::Property < MLS::Resource
2
-
3
- def addresses
4
- @addresses ||= MLS::Address.all :params => {:property_id => id}
5
- end
6
-
7
- private
8
-
9
- def self.instantiate_collection(collection, prefix_options = {})
10
- collection['properties'].collect! { |record| instantiate_record(record, prefix_options) }
11
- end
12
-
13
- end