apartment_ratings 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +12 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +20 -0
- data/README.md +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/apartment_ratings.gemspec +93 -0
- data/lib/apartment_ratings.rb +33 -0
- data/lib/apartment_ratings/address.rb +9 -0
- data/lib/apartment_ratings/client.rb +31 -0
- data/lib/apartment_ratings/complex.rb +21 -0
- data/lib/apartment_ratings/configuration.rb +15 -0
- data/lib/apartment_ratings/review.rb +15 -0
- data/lib/apartment_ratings/reviews/rating.rb +11 -0
- data/lib/apartment_ratings/reviews/response.rb +9 -0
- data/spec/apartment_ratings/address_spec.rb +24 -0
- data/spec/apartment_ratings/client_spec.rb +0 -0
- data/spec/apartment_ratings/complex_spec.rb +81 -0
- data/spec/apartment_ratings/review_spec.rb +50 -0
- data/spec/apartment_ratings/reviews/rating_spec.rb +14 -0
- data/spec/apartment_ratings/reviews/response_spec.rb +22 -0
- data/spec/apartment_ratings_spec.rb +43 -0
- data/spec/spec_helper.rb +33 -0
- metadata +237 -0
data/.document
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'hashie', git: 'https://github.com/intridea/hashie.git', branch: :master
|
4
|
+
gem 'faraday', '~> 0.9.0'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'pry'
|
8
|
+
gem 'rr', '~> 1.1.2'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rdoc', '~> 3.12'
|
11
|
+
gem 'bundler', '~> 1.0'
|
12
|
+
gem 'jeweler', '~> 2.0.1'
|
13
|
+
gem 'simplecov', '>= 0'
|
14
|
+
gem 'rubocop', '>=0.21.0'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/intridea/hashie.git
|
3
|
+
revision: 8b4ffbd6aa2ff9e6aeccd8181c82a85ffd1eea7a
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
hashie (3.1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
ast (2.0.0)
|
13
|
+
builder (3.2.2)
|
14
|
+
coderay (1.1.0)
|
15
|
+
descendants_tracker (0.0.4)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
17
|
+
diff-lcs (1.2.5)
|
18
|
+
docile (1.1.5)
|
19
|
+
faraday (0.9.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
git (1.2.7)
|
22
|
+
github_api (0.11.3)
|
23
|
+
addressable (~> 2.3)
|
24
|
+
descendants_tracker (~> 0.0.1)
|
25
|
+
faraday (~> 0.8, < 0.10)
|
26
|
+
hashie (>= 1.2)
|
27
|
+
multi_json (>= 1.7.5, < 2.0)
|
28
|
+
nokogiri (~> 1.6.0)
|
29
|
+
oauth2
|
30
|
+
highline (1.6.21)
|
31
|
+
jeweler (2.0.1)
|
32
|
+
builder
|
33
|
+
bundler (>= 1.0)
|
34
|
+
git (>= 1.2.5)
|
35
|
+
github_api
|
36
|
+
highline (>= 1.6.15)
|
37
|
+
nokogiri (>= 1.5.10)
|
38
|
+
rake
|
39
|
+
rdoc
|
40
|
+
json (1.8.1)
|
41
|
+
jwt (1.0.0)
|
42
|
+
method_source (0.8.2)
|
43
|
+
mini_portile (0.6.0)
|
44
|
+
multi_json (1.10.1)
|
45
|
+
multi_xml (0.5.5)
|
46
|
+
multipart-post (2.0.0)
|
47
|
+
nokogiri (1.6.2.1)
|
48
|
+
mini_portile (= 0.6.0)
|
49
|
+
oauth2 (0.9.4)
|
50
|
+
faraday (>= 0.8, < 0.10)
|
51
|
+
jwt (~> 1.0)
|
52
|
+
multi_json (~> 1.3)
|
53
|
+
multi_xml (~> 0.5)
|
54
|
+
rack (~> 1.2)
|
55
|
+
parser (2.2.0.pre.3)
|
56
|
+
ast (>= 1.1, < 3.0)
|
57
|
+
slop (~> 3.4, >= 3.4.5)
|
58
|
+
powerpack (0.0.9)
|
59
|
+
pry (0.10.0)
|
60
|
+
coderay (~> 1.1.0)
|
61
|
+
method_source (~> 0.8.1)
|
62
|
+
slop (~> 3.4)
|
63
|
+
rack (1.5.2)
|
64
|
+
rainbow (2.0.0)
|
65
|
+
rake (10.3.2)
|
66
|
+
rdoc (3.12.2)
|
67
|
+
json (~> 1.4)
|
68
|
+
rr (1.1.2)
|
69
|
+
rspec (3.0.0)
|
70
|
+
rspec-core (~> 3.0.0)
|
71
|
+
rspec-expectations (~> 3.0.0)
|
72
|
+
rspec-mocks (~> 3.0.0)
|
73
|
+
rspec-core (3.0.2)
|
74
|
+
rspec-support (~> 3.0.0)
|
75
|
+
rspec-expectations (3.0.2)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.0.0)
|
78
|
+
rspec-mocks (3.0.2)
|
79
|
+
rspec-support (~> 3.0.0)
|
80
|
+
rspec-support (3.0.2)
|
81
|
+
rubocop (0.24.1)
|
82
|
+
json (>= 1.7.7, < 2)
|
83
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
84
|
+
powerpack (~> 0.0.6)
|
85
|
+
rainbow (>= 1.99.1, < 3.0)
|
86
|
+
ruby-progressbar (~> 1.4)
|
87
|
+
ruby-progressbar (1.5.1)
|
88
|
+
simplecov (0.8.2)
|
89
|
+
docile (~> 1.1.0)
|
90
|
+
multi_json
|
91
|
+
simplecov-html (~> 0.8.0)
|
92
|
+
simplecov-html (0.8.0)
|
93
|
+
slop (3.5.0)
|
94
|
+
thread_safe (0.3.4)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
bundler (~> 1.0)
|
101
|
+
faraday (~> 0.9.0)
|
102
|
+
hashie!
|
103
|
+
jeweler (~> 2.0.1)
|
104
|
+
pry
|
105
|
+
rdoc (~> 3.12)
|
106
|
+
rr (~> 1.1.2)
|
107
|
+
rspec (~> 3.0)
|
108
|
+
rubocop (>= 0.21.0)
|
109
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 gregory
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# ApartmentRatings [![Build Status](https://travis-ci.org/gregory/apartment_ratings.svg)](https://travis-ci.org/gregory/apartment_ratings)
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
## Contributing to apartment_ratings
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
## Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2014 gregory. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "apartment_ratings"
|
18
|
+
gem.homepage = "http://github.com/gregory/apartment_ratings"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ruby client for ApartmentRating API}
|
21
|
+
gem.description = gem.summary
|
22
|
+
gem.email = "greg2502@gmail.com"
|
23
|
+
gem.authors = ["gregory"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['spec'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'rubocop/rake_task'
|
41
|
+
RuboCop::RakeTask.new(:rubocop)
|
42
|
+
|
43
|
+
task default: [:rubocop, :simplecov]
|
44
|
+
|
45
|
+
require 'rdoc/task'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "apartment_ratings #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "apartment_ratings"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["gregory"]
|
12
|
+
s.date = "2014-07-08"
|
13
|
+
s.description = "Ruby client for ApartmentRating API"
|
14
|
+
s.email = "greg2502@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
".rubocop.yml",
|
23
|
+
".travis.yml",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"apartment_ratings.gemspec",
|
31
|
+
"lib/apartment_ratings.rb",
|
32
|
+
"lib/apartment_ratings/address.rb",
|
33
|
+
"lib/apartment_ratings/client.rb",
|
34
|
+
"lib/apartment_ratings/complex.rb",
|
35
|
+
"lib/apartment_ratings/configuration.rb",
|
36
|
+
"lib/apartment_ratings/review.rb",
|
37
|
+
"lib/apartment_ratings/reviews/rating.rb",
|
38
|
+
"lib/apartment_ratings/reviews/response.rb",
|
39
|
+
"spec/apartment_ratings/address_spec.rb",
|
40
|
+
"spec/apartment_ratings/client_spec.rb",
|
41
|
+
"spec/apartment_ratings/complex_spec.rb",
|
42
|
+
"spec/apartment_ratings/review_spec.rb",
|
43
|
+
"spec/apartment_ratings/reviews/rating_spec.rb",
|
44
|
+
"spec/apartment_ratings/reviews/response_spec.rb",
|
45
|
+
"spec/apartment_ratings_spec.rb",
|
46
|
+
"spec/spec_helper.rb"
|
47
|
+
]
|
48
|
+
s.homepage = "http://github.com/gregory/apartment_ratings"
|
49
|
+
s.licenses = ["MIT"]
|
50
|
+
s.require_paths = ["lib"]
|
51
|
+
s.rubygems_version = "1.8.23"
|
52
|
+
s.summary = "Ruby client for ApartmentRating API"
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<faraday>, ["~> 0.9.0"])
|
60
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<rr>, ["~> 1.1.2"])
|
62
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.0"])
|
63
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
64
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
65
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
66
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<rubocop>, [">= 0.21.0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
70
|
+
s.add_dependency(%q<faraday>, ["~> 0.9.0"])
|
71
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
72
|
+
s.add_dependency(%q<rr>, ["~> 1.1.2"])
|
73
|
+
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
74
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
75
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
76
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
77
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rubocop>, [">= 0.21.0"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
82
|
+
s.add_dependency(%q<faraday>, ["~> 0.9.0"])
|
83
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rr>, ["~> 1.1.2"])
|
85
|
+
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
86
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
87
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
88
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
89
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
90
|
+
s.add_dependency(%q<rubocop>, [">= 0.21.0"])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'apartment_ratings'))
|
4
|
+
|
5
|
+
module ApartmentRatings
|
6
|
+
autoload :Configuration, 'configuration'
|
7
|
+
autoload :Client, 'client'
|
8
|
+
autoload :Address, 'address'
|
9
|
+
autoload :Complex, 'complex'
|
10
|
+
autoload :Review, 'review'
|
11
|
+
|
12
|
+
module Reviews
|
13
|
+
autoload :Rating, 'reviews/rating'
|
14
|
+
autoload :Response, 'reviews/response'
|
15
|
+
end
|
16
|
+
|
17
|
+
class<<self
|
18
|
+
attr_reader :config
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure
|
22
|
+
@config = Configuration.new.tap { |configuration| yield(configuration) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.client
|
26
|
+
options = {
|
27
|
+
username: config.username,
|
28
|
+
password: config.password,
|
29
|
+
api_base_path: config.api_base_path
|
30
|
+
}
|
31
|
+
Client.new(options)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module ApartmentRatings
|
4
|
+
class Client
|
5
|
+
def initialize(options = {})
|
6
|
+
path = options.fetch(:api_base_path)
|
7
|
+
params = {
|
8
|
+
username: options.fetch(:username),
|
9
|
+
password: options.fetch(:password)
|
10
|
+
}
|
11
|
+
|
12
|
+
@client = Faraday.new(path, params) do |faraday|
|
13
|
+
faraday.response :json, content_type: /\bjson\z/
|
14
|
+
faraday.response :logger if ApartmentRatings.config.debug
|
15
|
+
|
16
|
+
faraday.adapter ApartmentRatings.config.faraday_adapter || Faraday.default_adapter
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def complexes
|
21
|
+
result = @client.get('index')
|
22
|
+
# TODO: store the result and hangle unsuccessful response
|
23
|
+
result['complexes'].map { |complex_json| Complex.new complex_json }
|
24
|
+
end
|
25
|
+
|
26
|
+
def complex(id)
|
27
|
+
result = @client.get('complex', complexId: id)
|
28
|
+
Complex.new result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ApartmentRatings
|
2
|
+
class Complex < Hashie::Trash
|
3
|
+
include Hashie::Extensions::IgnoreUndeclared
|
4
|
+
include Hashie::Extensions::Coercion
|
5
|
+
|
6
|
+
property :id
|
7
|
+
property :name, from: :propertyName
|
8
|
+
property :address, from: :propertyAddress
|
9
|
+
property :propertyAddress
|
10
|
+
property :feedUrl
|
11
|
+
|
12
|
+
property :apartmentRating
|
13
|
+
property :averageRating
|
14
|
+
property :percentageRecomanded
|
15
|
+
property :reviews
|
16
|
+
|
17
|
+
coerce_key :address, Address
|
18
|
+
coerce_key :averageRating, Hash[String => Reviews::Rating]
|
19
|
+
coerce_key :reviews, Set[Review]
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ApartmentRatings
|
2
|
+
class Configuration < Hashie::Dash
|
3
|
+
DEFAULTS = {
|
4
|
+
format: 'json',
|
5
|
+
api_base_path: 'https://services.apartmentratings.com/services/rms/v1/',
|
6
|
+
hours_before_token_expiration: 48
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
property :username
|
10
|
+
property :password
|
11
|
+
property :format, default: DEFAULTS[:format]
|
12
|
+
property :api_base_path, default: DEFAULTS[:api_base_path]
|
13
|
+
property :hours_before_token_expiration, default: DEFAULTS[:hours_before_token_expiration]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ApartmentRatings
|
2
|
+
class Review < Hashie::Trash
|
3
|
+
include Hashie::Extensions::Coercion
|
4
|
+
|
5
|
+
property :datePosted
|
6
|
+
property :text, from: :fullReviewText
|
7
|
+
property :responses
|
8
|
+
property :author, from: :reviewerScreenName
|
9
|
+
property :rating, from: :starRatings
|
10
|
+
property :url
|
11
|
+
|
12
|
+
coerce_key :responses, Set[Reviews::Response]
|
13
|
+
coerce_key :rating, Hash[String => Reviews::Rating]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings::Address do
|
4
|
+
describe '.new(hash)' do
|
5
|
+
let(:hash) { { full_address: '1234 Complex St, The City, ST 55001' } }
|
6
|
+
|
7
|
+
subject { described_class.new(hash) }
|
8
|
+
|
9
|
+
it 'build a valid Address from a hash' do
|
10
|
+
expect(subject.full_address).to eq hash[:full_address]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.coerce(hash)' do
|
15
|
+
let(:hash) { { full_address: '1234 Complex St, The City, ST 55001' } }
|
16
|
+
|
17
|
+
subject { described_class.coerce(hash[:full_address]) }
|
18
|
+
|
19
|
+
it 'coerce hash into Address' do
|
20
|
+
expect(subject).to be_a ApartmentRatings::Address
|
21
|
+
expect(subject.full_address).to eq hash[:full_address]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings::Complex do
|
4
|
+
let(:hash) do
|
5
|
+
{
|
6
|
+
id: '1234',
|
7
|
+
name: 'Complex Name',
|
8
|
+
address: '1234 Complex St, The City, ST 55001',
|
9
|
+
feedUrl: 'https://services.apartmentratings.com/services/rms/v1/complex?complexId=1234',
|
10
|
+
averageRating: {
|
11
|
+
'construction' => nil,
|
12
|
+
'grounds' => 2,
|
13
|
+
'maintenance' => 2.5,
|
14
|
+
'neighbordhood' => 0,
|
15
|
+
'noise' => 2.5,
|
16
|
+
'safety' => 2,
|
17
|
+
'staff' => 2.5
|
18
|
+
},
|
19
|
+
percentageRecommanded: '50%',
|
20
|
+
reviews: [
|
21
|
+
{
|
22
|
+
datePosted: 'Mar 21, 2012',
|
23
|
+
fullReviewText: %(I currently live there but moving out soon and it has been all not so great.
|
24
|
+
Mold on my walls from all the water leaks from the roof.),
|
25
|
+
responses: [
|
26
|
+
{
|
27
|
+
datePosted: 'Jun 19, 2014',
|
28
|
+
fullText: 'Thanks for your review, we will take care of the problems.',
|
29
|
+
responderScreenName: 'adasaev'
|
30
|
+
},
|
31
|
+
{
|
32
|
+
datePosted: 'Jun 19, 2014',
|
33
|
+
fullText: 'Hello, let us work on the issue. \n\nThanks',
|
34
|
+
responderScreenName: 'Manager Response'
|
35
|
+
}
|
36
|
+
],
|
37
|
+
reviewerScreenName: 'anonymous',
|
38
|
+
starRatings: {
|
39
|
+
'construction' => nil,
|
40
|
+
'grounds' => 2,
|
41
|
+
'maintenance' => 2.5,
|
42
|
+
'neighbordhood' => 0,
|
43
|
+
'noise' => 2.5,
|
44
|
+
'safety' => 2,
|
45
|
+
'staff' => 2.5
|
46
|
+
},
|
47
|
+
url: 'http://www.apartmentratings.com/rate/CA-Los-Angeles-Da-Capo-Building-1409821.html'
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.new(hash)' do
|
54
|
+
subject { described_class.new(hash) }
|
55
|
+
|
56
|
+
it 'build a valid Complex from a hash' do
|
57
|
+
expect(subject.id).to eq hash[:id]
|
58
|
+
expect(subject.name).to eq hash[:name]
|
59
|
+
expect(subject.feedUrl).to eq hash[:feedUrl]
|
60
|
+
expect(subject.address).to be_a ApartmentRatings::Address
|
61
|
+
expect(subject.averageRating).to be_a Hash
|
62
|
+
expect(subject.averageRating.values.map(&:class).uniq).to eq [ApartmentRatings::Reviews::Rating]
|
63
|
+
expect(subject.reviews).to be_a Set
|
64
|
+
expect(subject.reviews.map(&:class).uniq).to eq [ApartmentRatings::Review]
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the keys dont match' do
|
68
|
+
let(:hash) do
|
69
|
+
{
|
70
|
+
propertyAddress: '1234 Complex St, The City, ST 55001',
|
71
|
+
propertyName: 'Complex Name'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'transforms the keys properly' do
|
76
|
+
expect(subject.name).to eq hash[:propertyName]
|
77
|
+
expect(subject.address).to be_a ApartmentRatings::Address
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings::Review do
|
4
|
+
let(:hash) do
|
5
|
+
{
|
6
|
+
datePosted: 'Mar 21, 2012',
|
7
|
+
fullReviewText: %(I currently live there but moving out soon and it has been all not so great.
|
8
|
+
Mold on my walls from all the water leaks from the roof.),
|
9
|
+
responses: [
|
10
|
+
{
|
11
|
+
datePosted: 'Jun 19, 2014',
|
12
|
+
fullText: 'Thanks for your review, we will take care of the problems.',
|
13
|
+
responderScreenName: 'adasaev'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
datePosted: 'Jun 19, 2014',
|
17
|
+
fullText: 'Hello, let us work on the issue. \n\nThanks',
|
18
|
+
responderScreenName: 'Manager Response'
|
19
|
+
}
|
20
|
+
],
|
21
|
+
reviewerScreenName: 'anonymous',
|
22
|
+
starRatings: {
|
23
|
+
'construction' => nil,
|
24
|
+
'grounds' => 2,
|
25
|
+
'maintenance' => 2.5,
|
26
|
+
'neighbordhood' => 0,
|
27
|
+
'noise' => 2.5,
|
28
|
+
'safety' => 2,
|
29
|
+
'staff' => 2.5
|
30
|
+
},
|
31
|
+
url: 'http://www.apartmentratings.com/rate/CA-Los-Angeles-Da-Capo-Building-1409821.html'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.new(hash)' do
|
36
|
+
subject { described_class.new(hash) }
|
37
|
+
|
38
|
+
it 'build a valid Review from a hash' do
|
39
|
+
expect(subject.datePosted).to eq hash[:datePosted]
|
40
|
+
expect(subject.text).to eq hash[:fullReviewText]
|
41
|
+
expect(subject.author).to eq hash[:reviewerScreenName]
|
42
|
+
expect(subject.url).to eq hash[:url]
|
43
|
+
expect(subject.responses).to be_a Set
|
44
|
+
expect(subject.rating).to be_a Hash
|
45
|
+
|
46
|
+
expect(subject.responses.map(&:class).uniq).to eq [ApartmentRatings::Reviews::Response]
|
47
|
+
expect(subject.rating.values.map(&:class).uniq).to eq [ApartmentRatings::Reviews::Rating]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings::Reviews::Rating do
|
4
|
+
let(:rating) { 2.6 }
|
5
|
+
|
6
|
+
describe '.coerce(raw_rating)' do
|
7
|
+
subject { described_class.coerce(rating) }
|
8
|
+
|
9
|
+
it 'coerce the rating and set the value' do
|
10
|
+
expect(subject).to be_a described_class
|
11
|
+
expect(subject.value).to eq rating
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings::Reviews::Response do
|
4
|
+
let(:response) do
|
5
|
+
{
|
6
|
+
datePosted: 'Jun 19, 2014',
|
7
|
+
fullText: 'Thanks for your review, we will take care of the problems.',
|
8
|
+
responderScreenName: 'adasaev'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.new(response)' do
|
13
|
+
subject { described_class.new(response) }
|
14
|
+
|
15
|
+
it 'build a valid Response from a hash' do
|
16
|
+
expect(subject).to be_a described_class
|
17
|
+
expect(subject.created_at).to eq response[:datePosted]
|
18
|
+
expect(subject.text).to eq response[:fullText]
|
19
|
+
expect(subject.author).to eq response[:responderScreenName]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApartmentRatings do
|
4
|
+
describe '.configure' do
|
5
|
+
let(:username) { 'bar' }
|
6
|
+
let(:password) { 'foo' }
|
7
|
+
|
8
|
+
subject { described_class.config }
|
9
|
+
|
10
|
+
before do
|
11
|
+
described_class.configure do |config|
|
12
|
+
config.username = username
|
13
|
+
config.password = password
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when defaults are sets' do
|
18
|
+
let(:format) { 'format' }
|
19
|
+
let(:api_base_path) { 'https://services.apartmentratings.com/services/rms/v2/' }
|
20
|
+
let(:hours_before_token_expiration) { 72 }
|
21
|
+
|
22
|
+
before do
|
23
|
+
described_class.config.format = format
|
24
|
+
described_class.config.api_base_path = api_base_path
|
25
|
+
described_class.config.hours_before_token_expiration = hours_before_token_expiration
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'sets the format' do
|
29
|
+
expect(subject.format).to eq format
|
30
|
+
expect(subject.api_base_path).to eq api_base_path
|
31
|
+
expect(subject.hours_before_token_expiration).to eq hours_before_token_expiration
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'sets the right config' do
|
36
|
+
expect(subject.username).to eq username
|
37
|
+
expect(subject.password).to eq password
|
38
|
+
expect(subject.format).to eq subject.class::DEFAULTS[:format]
|
39
|
+
expect(subject.api_base_path).to eq subject.class::DEFAULTS[:api_base_path]
|
40
|
+
expect(subject.hours_before_token_expiration).to eq subject.class::DEFAULTS[:hours_before_token_expiration]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_adapter 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV['COVERAGE'] && SimpleCov.start do
|
15
|
+
add_filter '/.rvm/'
|
16
|
+
add_filter '/.rbenv/'
|
17
|
+
end
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
+
|
21
|
+
require 'rspec'
|
22
|
+
require 'apartment_ratings'
|
23
|
+
|
24
|
+
# Requires supporting files with custom matchers and macros, etc,
|
25
|
+
# in ./support/ and its subdirectories.
|
26
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.before :suite do
|
30
|
+
ApartmentRatings.configure do
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apartment_ratings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- gregory
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hashie
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.9.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.9.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pry
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rr
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.1.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '3.0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rdoc
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.12'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.12'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: bundler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: jeweler
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 2.0.1
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 2.0.1
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: simplecov
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rubocop
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.21.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.21.0
|
174
|
+
description: Ruby client for ApartmentRating API
|
175
|
+
email: greg2502@gmail.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files:
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.md
|
181
|
+
files:
|
182
|
+
- .document
|
183
|
+
- .rspec
|
184
|
+
- .rubocop.yml
|
185
|
+
- .travis.yml
|
186
|
+
- Gemfile
|
187
|
+
- Gemfile.lock
|
188
|
+
- LICENSE.txt
|
189
|
+
- README.md
|
190
|
+
- Rakefile
|
191
|
+
- VERSION
|
192
|
+
- apartment_ratings.gemspec
|
193
|
+
- lib/apartment_ratings.rb
|
194
|
+
- lib/apartment_ratings/address.rb
|
195
|
+
- lib/apartment_ratings/client.rb
|
196
|
+
- lib/apartment_ratings/complex.rb
|
197
|
+
- lib/apartment_ratings/configuration.rb
|
198
|
+
- lib/apartment_ratings/review.rb
|
199
|
+
- lib/apartment_ratings/reviews/rating.rb
|
200
|
+
- lib/apartment_ratings/reviews/response.rb
|
201
|
+
- spec/apartment_ratings/address_spec.rb
|
202
|
+
- spec/apartment_ratings/client_spec.rb
|
203
|
+
- spec/apartment_ratings/complex_spec.rb
|
204
|
+
- spec/apartment_ratings/review_spec.rb
|
205
|
+
- spec/apartment_ratings/reviews/rating_spec.rb
|
206
|
+
- spec/apartment_ratings/reviews/response_spec.rb
|
207
|
+
- spec/apartment_ratings_spec.rb
|
208
|
+
- spec/spec_helper.rb
|
209
|
+
homepage: http://github.com/gregory/apartment_ratings
|
210
|
+
licenses:
|
211
|
+
- MIT
|
212
|
+
post_install_message:
|
213
|
+
rdoc_options: []
|
214
|
+
require_paths:
|
215
|
+
- lib
|
216
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
segments:
|
223
|
+
- 0
|
224
|
+
hash: 1571250886427044213
|
225
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
+
none: false
|
227
|
+
requirements:
|
228
|
+
- - ! '>='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 1.8.23
|
234
|
+
signing_key:
|
235
|
+
specification_version: 3
|
236
|
+
summary: Ruby client for ApartmentRating API
|
237
|
+
test_files: []
|