g5_foundation_client 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -38,7 +38,7 @@ require 'g5_foundation_client/rspec'
38
38
 
39
39
  If your environment includes FactoryGirl, this will also require some factory definitions. You probably want this.
40
40
 
41
- This will give you a method to stub finding a `G5FoundationClient::Location`. Basic example:
41
+ This will give you a method to stub finding a `G5FoundationClient::Location` and `G5FoundationClient::Client`. Basic example:
42
42
  ```ruby
43
43
  stub_location_for_uid(
44
44
  "http://example.com/location_uid",
@@ -46,7 +46,7 @@ stub_location_for_uid(
46
46
  )
47
47
  ```
48
48
 
49
- If you have FactoryGirl, you can omit the second argument and it will build one for you. The `stub_location_for_uid` method will return the built location, which can pair nicely with a `let!` call to both build and stub in one shot.
49
+ If you have FactoryGirl, you can omit the second argument and it will build one for you. The `stub_location_for_uid` method (as well as its counterpart for clients) will return the built model, which can pair nicely with a `let!` call to both build and stub in one shot.
50
50
 
51
51
  ### Contributing
52
52
 
@@ -25,7 +25,8 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.5"
27
27
  spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec"
28
+ # 2.99+ is a release to help with upgrading, which... thanks, but not now.
29
+ spec.add_development_dependency "rspec", "< 2.99"
29
30
  spec.add_development_dependency "webmock"
30
31
  spec.add_development_dependency "pry"
31
32
  end
@@ -19,5 +19,10 @@ end
19
19
 
20
20
  require 'g5_foundation_client/fetcher'
21
21
 
22
+ require 'g5_foundation_client/models/findable_by_uid'
22
23
  require 'g5_foundation_client/models/location'
24
+ require 'g5_foundation_client/models/client'
25
+
26
+ require 'g5_foundation_client/deserializers/safe_access'
23
27
  require 'g5_foundation_client/deserializers/location'
28
+ require 'g5_foundation_client/deserializers/client'
@@ -0,0 +1,25 @@
1
+ module G5FoundationClient::Deserializers
2
+ module Client
3
+ extend SafeAccess
4
+
5
+ def self.from_markup(markup)
6
+ h = Microformats2.parse(markup).cards.first
7
+ client = G5FoundationClient::Client.new(
8
+ uid: with_safe_access { h.uid },
9
+ urn: with_safe_access { h.g5_urn },
10
+ name: with_safe_access { h.name },
11
+ vertical: with_safe_access { h.g5_vertical },
12
+ domain: with_safe_access { h.g5_domain },
13
+ domain_type: with_safe_access { h.g5_domain_type }
14
+ )
15
+
16
+ location_formats = with_safe_access(stringify: false) { h.orgs.map(&:format) }
17
+ location_formats ||= []
18
+ location_formats.each do |hcard|
19
+ client.locations << G5FoundationClient::Deserializers::Location.from_hcard(hcard)
20
+ end
21
+
22
+ client
23
+ end
24
+ end
25
+ end
@@ -1,14 +1,37 @@
1
1
  module G5FoundationClient::Deserializers
2
2
  module Location
3
+ extend SafeAccess
4
+
3
5
  def self.from_markup(markup)
4
6
  hcard = Microformats2.parse(markup).cards.first
5
- G5FoundationClient::Location.new(
6
- uid: hcard.uid.to_s,
7
- name: hcard.name.to_s,
8
- phone: hcard.adr.format.tel.to_s,
9
- ga_tracking_id: hcard.ga_tracking_id.to_s,
10
- ga_profile_id: hcard.ga_profile_id.to_s
11
- )
7
+ from_hcard(hcard)
8
+ end
9
+
10
+ def self.from_hcard(hcard)
11
+ G5FoundationClient::Location.new(hcard_to_hash(hcard))
12
+ end
13
+
14
+ def self.hcard_to_hash(h)
15
+ {
16
+ uid: with_safe_access { h.uid },
17
+ urn: with_safe_access { h.g5_urn },
18
+ client_uid: with_safe_access { h.org.format.uid.to_s},
19
+ name: with_safe_access { h.name },
20
+ phone: with_safe_access { h.adr.format.tel },
21
+ domain: with_safe_access { h.g5_domain },
22
+ corporate: with_safe_access { h.g5_corporate },
23
+ floor_plans: with_safe_access { h.g5_floorplan },
24
+ primary_amenity: with_safe_access { h.g5_aparment_amenity_1 },
25
+ qualifier: with_safe_access { h.g5_aparment_feature_1 },
26
+ primary_landmark: with_safe_access { h.g5_landmark_1 },
27
+ ga_tracking_id: with_safe_access { h.ga_tracking_id },
28
+ ga_profile_id: with_safe_access { h.ga_profile_id },
29
+ neighborhood: with_safe_access { h.adr.format.g5_neighborhood },
30
+ street_address: with_safe_access { h.adr.format.street_address },
31
+ region: with_safe_access { h.adr.format.region },
32
+ locality: with_safe_access { h.adr.format.locality },
33
+ postal_code: with_safe_access { h.adr.format.postal_code }
34
+ }
12
35
  end
13
36
  end
14
37
  end
@@ -0,0 +1,12 @@
1
+ module G5FoundationClient::Deserializers
2
+ module SafeAccess
3
+ def with_safe_access(options = {}, &block)
4
+ options[:stringify] = true if options[:stringify] == nil
5
+
6
+ result = block.call
7
+ options[:stringify] ? result.to_s : result
8
+ rescue NoMethodError
9
+ nil
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ class G5FoundationClient::Client
2
+ include Virtus.model
3
+ extend G5FoundationClient::FindableByUid
4
+
5
+ def self.deserializer_class
6
+ G5FoundationClient::Deserializers::Client
7
+ end
8
+
9
+ attribute :locations, Array[G5FoundationClient::Location]
10
+ attribute :uid, String
11
+ attribute :urn, String
12
+ attribute :name, String
13
+ attribute :vertical, String
14
+ attribute :domain, String
15
+ attribute :domain_type, String
16
+ end
@@ -0,0 +1,7 @@
1
+ module G5FoundationClient::FindableByUid
2
+ def find_by_uid(uid)
3
+ G5FoundationClient::Fetcher.fetch_url(uid) do |markup|
4
+ deserializer_class.from_markup(markup)
5
+ end
6
+ end
7
+ end
@@ -1,15 +1,27 @@
1
1
  class G5FoundationClient::Location
2
2
  include Virtus.model
3
+ extend G5FoundationClient::FindableByUid
4
+
5
+ def self.deserializer_class
6
+ G5FoundationClient::Deserializers::Location
7
+ end
3
8
 
4
9
  attribute :uid, String
10
+ attribute :urn, String
11
+ attribute :client_uid, String
5
12
  attribute :name, String
6
13
  attribute :phone, String
14
+ attribute :domain, String
15
+ attribute :corporate, Boolean
16
+ attribute :floor_plans, String
17
+ attribute :primary_amenity, String
18
+ attribute :qualifier, String
19
+ attribute :primary_landmark, String
7
20
  attribute :ga_tracking_id, String
8
21
  attribute :ga_profile_id, String
9
-
10
- def self.find_by_uid(uid)
11
- G5FoundationClient::Fetcher.fetch_url(uid) do |markup|
12
- G5FoundationClient::Deserializers::Location.from_markup(markup)
13
- end
14
- end
22
+ attribute :neighborhood, String
23
+ attribute :street_address, String
24
+ attribute :region, String
25
+ attribute :locality, String
26
+ attribute :postal_code, String
15
27
  end
@@ -9,6 +9,17 @@ module G5FoundationClient::RspecHelpers
9
9
 
10
10
  location
11
11
  end
12
+
13
+ def stub_client_for_uid(uid, client = nil)
14
+ client ||= FactoryGirl.build(:g5_client)
15
+
16
+ G5FoundationClient::Client.
17
+ stub(:find_by_uid).
18
+ with(uid).
19
+ and_return(client)
20
+
21
+ client
22
+ end
12
23
  end
13
24
 
14
25
  RSpec.configure do |config|
@@ -3,4 +3,8 @@ FactoryGirl.define do
3
3
  name "Test Location"
4
4
  phone "123-123-1234"
5
5
  end
6
+
7
+ factory :g5_client, class: G5FoundationClient::Client do
8
+ name "Test Client"
9
+ end
6
10
  end
@@ -1,3 +1,3 @@
1
1
  module G5FoundationClient
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,150 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <article>
6
+ <div class="h-card">
7
+ <h2>
8
+ <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client">Test Client</a>
9
+ <small class="p-g5-vertical">Apartments</small> |
10
+ <small class="u-g5-domain">http://example.com/</small> |
11
+ <small class="p-g5-domain-type">MultiDomainClient</small>
12
+ <small class="p-g5-urn">g5-c-1234-client</small>
13
+ </h2>
14
+ <p class="p-adr h-adr">
15
+ <span class="p-street-address">
16
+ 455 NW Franklin
17
+
18
+ </span>
19
+ <span>
20
+ <span class="p-locality">Bend</span>
21
+ <span class="p-region">OR</span>
22
+ <span class="p-postal-code">97701</span>
23
+ </span>
24
+ <span class="p-tel p-fax"></span>
25
+ <span class="u-email"></span>
26
+ </p>
27
+ <div>
28
+ <h4>Locations</h4>
29
+ <ul class="list-unstyled">
30
+ <li class="p-org h-card">
31
+ <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client/locations/g5-cl-1234-location">Test Location 1</a>
32
+ <a class="u-url u-g5-domain" href="http://www.salidadelsolapartments.com">http://www.salidadelsolapartments.com</a>
33
+ <p class="p-adr h-adr">
34
+ <span class="p-street-address">
35
+ 1125 Sunrise Blvd.
36
+
37
+ </span>
38
+ <span class="p-g5-neighborhood">West</span>
39
+ <span>
40
+ <span class="p-locality">Ventura</span>
41
+ <span class="p-region">CA</span>
42
+ <span class="p-postal-code">93001</span>
43
+ </span>
44
+ <span class="p-tel">805-798-1256</span>
45
+ <span class="p-tel p-fax"></span>
46
+ <span class="u-email">info@salidadelsolapts.com</span>
47
+ </p>
48
+ <p>
49
+ <strong>Corporate:</strong>
50
+ <br />
51
+ <span class="p-g5-corporate">false</span>
52
+ </p>
53
+ <p>
54
+ <strong>Floor Plans:</strong>
55
+ <br />
56
+ <span class="p-g5-floorplan">1, 2, 3, studio Apartments</span>
57
+ </p>
58
+ <p>
59
+ <strong>Landmarks:</strong>
60
+ <br />
61
+ <span class="p-g5-landmark-1">Venture Marina</span>
62
+ <br />
63
+ <span class="p-g5-landmark-2">River Ridge Golf Course</span>
64
+ </p>
65
+ <p>
66
+ <strong>Property Features or Qualifiers:</strong>
67
+ <br />
68
+ <span class="p-g5-aparment-feature-1">Luxury</span>
69
+ <br />
70
+ <span class="p-g5-aparment-feature-2">Gated</span>
71
+ <br />
72
+ <span class="p-g5-aparment-feature-3"></span>
73
+ </p>
74
+ <p>
75
+ <strong>Primary Amenities:</strong>
76
+ <br />
77
+ <span class="p-g5-aparment-amenity-1">Stainless Steel Appliances</span>
78
+ <br />
79
+ <span class="p-g5-community-amenity-1">Fitness Center</span>
80
+ </p>
81
+
82
+ <h4>Client</h4>
83
+ <p class="p-org h-card">
84
+ <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client">Test Client</a>
85
+ </p>
86
+ </li>
87
+ <li class="p-org h-card">
88
+ <a class="p-name u-uid u-url" href="http://g5-hub.herokuapp.com/clients/g5-c-1servrzr-luxe-apartment-company/locations/g5-cl-1servrzz-depot-17">Depot 17</a>
89
+ <a class="u-url u-g5-domain" href="http://www.depot17apartments.com">http://www.depot17apartments.com</a>
90
+ <p class="p-adr h-adr">
91
+ <span class="p-street-address">
92
+ 2675 Station St.
93
+
94
+ </span>
95
+ <span class="p-g5-neighborhood">Park Slope</span>
96
+ <span>
97
+ <span class="p-locality">Brooklyn</span>
98
+ <span class="p-region">NY</span>
99
+ <span class="p-postal-code">11215</span>
100
+ </span>
101
+ <span class="p-tel">718-639-3915</span>
102
+ <span class="p-tel p-fax"></span>
103
+ <span class="u-email">info@depot17.com</span>
104
+ </p>
105
+ <p>
106
+ <strong>Corporate:</strong>
107
+ <br />
108
+ <span class="p-g5-corporate">false</span>
109
+ </p>
110
+ <p>
111
+ <strong>Floor Plans:</strong>
112
+ <br />
113
+ <span class="p-g5-floorplan"> Apartments</span>
114
+ </p>
115
+ <p>
116
+ <strong>Landmarks:</strong>
117
+ <br />
118
+ <span class="p-g5-landmark-1"></span>
119
+ <br />
120
+ <span class="p-g5-landmark-2"></span>
121
+ </p>
122
+ <p>
123
+ <strong>Property Features or Qualifiers:</strong>
124
+ <br />
125
+ <span class="p-g5-aparment-feature-1"></span>
126
+ <br />
127
+ <span class="p-g5-aparment-feature-2"></span>
128
+ <br />
129
+ <span class="p-g5-aparment-feature-3"></span>
130
+ </p>
131
+ <p>
132
+ <strong>Primary Amenities:</strong>
133
+ <br />
134
+ <span class="p-g5-aparment-amenity-1"></span>
135
+ <br />
136
+ <span class="p-g5-community-amenity-1"></span>
137
+ </p>
138
+
139
+ <h4>Client</h4>
140
+ <p class="p-org h-card">
141
+ <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client">Test Client</a>
142
+ </p>
143
+ </li>
144
+ </ul>
145
+ </div>
146
+ </div>
147
+
148
+ </article>
149
+ </body>
150
+ </html>
@@ -0,0 +1,8 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <section class="h-card">
6
+ </section>
7
+ </body>
8
+ </html>
@@ -1,4 +1,3 @@
1
-
2
1
  <!DOCTYPE html>
3
2
  <html>
4
3
  <head></head>
@@ -6,24 +5,66 @@
6
5
  <section class="h-card">
7
6
  <h2>
8
7
  <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client/locations/g5-cl-1234-location">Test Location</a>
8
+ <small class="p-g5-urn">g5-cl-1234-location</small>
9
9
  </h2>
10
10
 
11
- <h4>Domain</h4>
12
- <a class="u-url u-g5-domain" href="http://www.examplelocation.com/">http://www.examplelocation.com/</a>
11
+ <h4>Domain</h4>
12
+ <a class="u-url u-g5-domain" href="http://example.com/">http://example.com/</a>
13
13
 
14
14
  <h4>Address</h4>
15
15
  <p class="p-adr h-adr">
16
16
  <span class="p-street-address">
17
17
  123 Test Way
18
+
18
19
  </span>
20
+ <span class="p-g5-neighborhood">West</span>
19
21
  <span>
20
22
  <span class="p-locality">Testville</span>
21
- <span class="p-region">GA</span>
22
- <span class="p-postal-code">12345</span>
23
+ <span class="p-region">TK</span>
24
+ <span class="p-postal-code">31324</span>
23
25
  </span>
24
26
  <span class="p-tel">123-123-1234</span>
25
27
  <span class="p-tel p-fax"></span>
26
- <span class="u-email"></span>
28
+ <span class="u-email">info@salidadelsolapts.com</span>
29
+ </p>
30
+
31
+ <p>
32
+ <strong>Corporate:</strong>
33
+ <br />
34
+ <span class="p-g5-corporate">true</span>
35
+ </p>
36
+ <p>
37
+ <strong>Hours:</strong>
38
+ <br />
39
+ <pre class="p-g5-hour">Mon-Fri: 7am - 6pm, Sat: 8am - 3pm, Sunday: Closed</pre>
40
+ </p>
41
+ <p>
42
+ <strong>Floor Plans:</strong>
43
+ <br />
44
+ <span class="p-g5-floorplan">1, 2, 3, studio apartments</span>
45
+ </p>
46
+ <p>
47
+ <strong>Landmarks:</strong>
48
+ <br />
49
+ <span class="p-g5-landmark-1">Venture Marina</span>
50
+ <br />
51
+ <span class="p-g5-landmark-2">River Ridge Golf Course</span>
52
+ </p>
53
+ <p>
54
+ <strong>Property Features or Qualifiers:</strong>
55
+ <br />
56
+ <span class="p-g5-aparment-feature-1">Luxury</span>
57
+ <br />
58
+ <span class="p-g5-aparment-feature-2">Gated</span>
59
+ <br />
60
+ <span class="p-g5-aparment-feature-3"></span>
61
+ </p>
62
+ <p>
63
+ <strong>Primary Amenities:</strong>
64
+ <br />
65
+ <span class="p-g5-aparment-amenity-1">Stainless Steel Appliances</span>
66
+ <br />
67
+ <span class="p-g5-community-amenity-1">Fitness Center</span>
27
68
  </p>
28
69
 
29
70
  <h4>Google Analytics</h4>
@@ -35,10 +76,22 @@
35
76
  <dd class="p-ga-profile-id">ga:1234</dd>
36
77
  </dl>
37
78
 
79
+ <dl>
80
+ <dt>Twitter</dt>
81
+ <dd class="p-nickname p-g5-nickname-twitter">G5Platform</dd>
82
+ <dt>Facebook</dt>
83
+ <dd class="p-nickname p-g5-nickname-facebook">GetG5</dd>
84
+ <dt>Yelp</dt>
85
+ <dd class="p-nickname p-g5-nickname-yelp">g5-bend</dd>
86
+ <dt>Foursquare</dt>
87
+ <dd class="p-nickname p-g5-nickname-foursquare">https://foursquare.com/v/g5-search-marketing/4b720385f964a5201b6a2de3</dd>
88
+ </dl>
89
+
38
90
  <h4>Client</h4>
39
91
  <p class="p-org h-card">
40
92
  <a class="p-name u-uid u-url" href="http://example.com/clients/g5-c-1234-client">Test Client</a>
41
93
  </p>
42
94
  </section>
95
+
43
96
  </body>
44
97
  </html>
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe G5FoundationClient::Deserializers::Client do
4
+ describe ".from_markup" do
5
+ subject(:client) { G5FoundationClient::Deserializers::Client.from_markup(markup) }
6
+
7
+ context "with many fields provided" do
8
+ let(:markup) { fixture("client_detail.html") }
9
+
10
+ its(:uid) { should eq("http://example.com/clients/g5-c-1234-client") }
11
+ its(:urn) { should eq("g5-c-1234-client") }
12
+ its(:name) { should eq("Test Client") }
13
+ its(:vertical) { should eq("Apartments") }
14
+ its(:domain) { should eq("http://example.com/") }
15
+ its(:domain_type) { should eq("MultiDomainClient") }
16
+
17
+ describe "#locations" do
18
+ it "instantiates associated Locations" do
19
+ expect(client.locations.length).to eq(2)
20
+ expect(client.locations.first.name).to eq("Test Location 1")
21
+ expect(client.locations.first.uid).to eq("http://example.com/clients/g5-c-1234-client/locations/g5-cl-1234-location")
22
+ end
23
+ end
24
+ end
25
+
26
+ context "missing many fields" do
27
+ let(:markup) { fixture("empty_hcard.html") }
28
+ its(:uid) { should be_nil }
29
+ end
30
+ end
31
+ end
@@ -2,13 +2,34 @@ require 'spec_helper'
2
2
 
3
3
  describe G5FoundationClient::Deserializers::Location do
4
4
  describe ".from_markup" do
5
- let(:markup) { fixture("location_detail.html") }
6
5
  subject { G5FoundationClient::Deserializers::Location.from_markup(markup) }
7
6
 
8
- its(:uid) { should eq("http://example.com/clients/g5-c-1234-client/locations/g5-cl-1234-location") }
9
- its(:name) { should eq("Test Location") }
10
- its(:phone) { should eq("123-123-1234") }
11
- its(:ga_tracking_id) { should eq("UA-1234-1") }
12
- its(:ga_profile_id) { should eq("ga:1234") }
7
+ context "with many fields provided" do
8
+ let(:markup) { fixture("location_detail.html") }
9
+
10
+ its(:uid) { should eq("http://example.com/clients/g5-c-1234-client/locations/g5-cl-1234-location") }
11
+ its(:urn) { should eq("g5-cl-1234-location") }
12
+ its(:client_uid) { should eq("http://example.com/clients/g5-c-1234-client") }
13
+ its(:name) { should eq("Test Location") }
14
+ its(:phone) { should eq("123-123-1234") }
15
+ its(:domain) { should eq("http://example.com/") }
16
+ its(:corporate) { should be_true }
17
+ its(:floor_plans) { should eq("1, 2, 3, studio apartments") }
18
+ its(:primary_amenity) { should eq("Stainless Steel Appliances") }
19
+ its(:qualifier) { should eq("Luxury") }
20
+ its(:primary_landmark) { should eq("Venture Marina") }
21
+ its(:ga_tracking_id) { should eq("UA-1234-1") }
22
+ its(:ga_profile_id) { should eq("ga:1234") }
23
+ its(:neighborhood) { should eq("West") }
24
+ its(:street_address) { should eq("123 Test Way") }
25
+ its(:locality) { should eq("Testville") }
26
+ its(:region) { should eq("TK") }
27
+ its(:postal_code) { should eq("31324") }
28
+ end
29
+
30
+ context "missing many fields" do
31
+ let(:markup) { fixture("empty_hcard.html") }
32
+ its(:uid) { should be_nil }
33
+ end
13
34
  end
14
35
  end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe G5FoundationClient::Client do
4
+ before { G5FoundationClient.access_token = "token" }
5
+
6
+ describe "instantiating with a hash" do
7
+ subject do
8
+ G5FoundationClient::Client.new(
9
+ uid: "http://example.com/urn",
10
+ urn: "urn",
11
+ name: "Test Name",
12
+ vertical: "Senior",
13
+ domain: "example.com",
14
+ domain_type: "MultiDomainClient"
15
+ )
16
+ end
17
+
18
+ its(:uid) { should eql("http://example.com/urn") }
19
+ its(:urn) { should eql("urn") }
20
+ its(:name) { should eql("Test Name") }
21
+ its(:vertical) { should eql("Senior") }
22
+ its(:domain) { should eql("example.com") }
23
+ its(:domain_type) { should eql("MultiDomainClient") }
24
+ end
25
+
26
+ describe "instantiating with nested hash of Locations" do
27
+ subject(:client) { G5FoundationClient::Client.new(attributes) }
28
+
29
+ context "when the nested parameters are correct" do
30
+ let(:attributes) do
31
+ {
32
+ name: "Client Name",
33
+ locations: [
34
+ { name: "Location 1" },
35
+ { name: "Location 2" }
36
+ ]
37
+ }
38
+ end
39
+
40
+ its(:name) { should eq("Client Name") }
41
+
42
+ it "instantiates associated Locations" do
43
+ expect(client.locations.length).to eq(2)
44
+ expect(client.locations.all? { |l| l.is_a?(G5FoundationClient::Location) }).to be_true
45
+ expect(client.locations.map(&:name)).to eq([ "Location 1", "Location 2" ])
46
+ end
47
+ end
48
+ end
49
+
50
+ describe ".find_by_uid" do
51
+ let(:uid) { "http://example.com/clients/g5-c-1234-client" }
52
+ let(:response) { fixture("client_detail.html") }
53
+ before { stub_json(uid + "?access_token=token", response) }
54
+ subject(:find) { G5FoundationClient::Client.find_by_uid(uid) }
55
+
56
+ its(:name) { should eq("Test Client") }
57
+ end
58
+ end
@@ -6,19 +6,45 @@ describe G5FoundationClient::Location do
6
6
  describe "instantiating with a hash" do
7
7
  subject do
8
8
  G5FoundationClient::Location.new(
9
- uid: "http://example.com/uid",
9
+ uid: "http://example.com/urn",
10
+ urn: "urn",
11
+ client_uid: "http://example.com/client_uid",
10
12
  name: "Test Name",
11
13
  phone: "123-123-1234",
14
+ domain: "example.com",
15
+ corporate: "true",
16
+ floor_plans: "Apartments",
17
+ primary_amenity: "Pony Rides",
18
+ primary_landmark: "An enormous bust of Brett Favre",
19
+ qualifier: "I have no idea what a qualifier is",
12
20
  ga_tracking_id: "UA-1234-5",
13
- ga_profile_id: "ga:1234"
21
+ ga_profile_id: "ga:1234",
22
+ neighborhood: "Wrong side of the tracks",
23
+ street_address: "123 Test Way",
24
+ region: "South Testakota",
25
+ locality: "Testville",
26
+ postal_code: "31337"
14
27
  )
15
28
  end
16
29
 
17
- its(:uid) { should eql("http://example.com/uid") }
30
+ its(:uid) { should eql("http://example.com/urn") }
31
+ its(:urn) { should eql("urn") }
32
+ its(:client_uid) { should eql("http://example.com/client_uid") }
18
33
  its(:name) { should eql("Test Name") }
19
34
  its(:phone) { should eql("123-123-1234") }
35
+ its(:domain) { should eql("example.com") }
36
+ its(:corporate) { should be_true }
37
+ its(:floor_plans) { should eql("Apartments") }
38
+ its(:primary_amenity) { should eql("Pony Rides") }
39
+ its(:primary_landmark) { should eql("An enormous bust of Brett Favre") }
40
+ its(:qualifier) { should eql("I have no idea what a qualifier is") }
20
41
  its(:ga_tracking_id) { should eql("UA-1234-5") }
21
42
  its(:ga_profile_id) { should eql("ga:1234") }
43
+ its(:neighborhood) { should eql("Wrong side of the tracks") }
44
+ its(:street_address) { should eql("123 Test Way") }
45
+ its(:region) { should eql("South Testakota") }
46
+ its(:locality) { should eql("Testville") }
47
+ its(:postal_code) { should eql("31337") }
22
48
  end
23
49
 
24
50
  describe ".find_by_uid" do
metadata CHANGED
@@ -1,139 +1,158 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g5_foundation_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Don Petersen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
12
+ date: 2014-07-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: virtus
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: httparty
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: microformats2
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: g5_authentication_client
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - ">="
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0.2'
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - ">="
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0.2'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: bundler
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - "~>"
83
+ - - ~>
74
84
  - !ruby/object:Gem::Version
75
85
  version: '1.5'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - "~>"
91
+ - - ~>
81
92
  - !ruby/object:Gem::Version
82
93
  version: '1.5'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rake
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - ">="
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - ">="
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rspec
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - ">="
115
+ - - <
102
116
  - !ruby/object:Gem::Version
103
- version: '0'
117
+ version: '2.99'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - ">="
123
+ - - <
109
124
  - !ruby/object:Gem::Version
110
- version: '0'
125
+ version: '2.99'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: webmock
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - ">="
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - ">="
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: pry
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
- - - ">="
147
+ - - ! '>='
130
148
  - !ruby/object:Gem::Version
131
149
  version: '0'
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
- - - ">="
155
+ - - ! '>='
137
156
  - !ruby/object:Gem::Version
138
157
  version: '0'
139
158
  description: Client gem to interact with G5 services.
@@ -143,56 +162,69 @@ executables: []
143
162
  extensions: []
144
163
  extra_rdoc_files: []
145
164
  files:
146
- - ".gitignore"
147
- - ".rspec"
148
- - ".travis.yml"
165
+ - .gitignore
166
+ - .rspec
167
+ - .travis.yml
149
168
  - Gemfile
150
169
  - LICENSE.txt
151
170
  - README.md
152
171
  - Rakefile
153
172
  - g5_foundation_client.gemspec
154
173
  - lib/g5_foundation_client.rb
174
+ - lib/g5_foundation_client/deserializers/client.rb
155
175
  - lib/g5_foundation_client/deserializers/location.rb
176
+ - lib/g5_foundation_client/deserializers/safe_access.rb
156
177
  - lib/g5_foundation_client/fetcher.rb
178
+ - lib/g5_foundation_client/models/client.rb
179
+ - lib/g5_foundation_client/models/findable_by_uid.rb
157
180
  - lib/g5_foundation_client/models/location.rb
158
181
  - lib/g5_foundation_client/record_not_found_exception.rb
159
182
  - lib/g5_foundation_client/rspec.rb
160
183
  - lib/g5_foundation_client/rspec/factories.rb
161
184
  - lib/g5_foundation_client/version.rb
185
+ - spec/fixtures/client_detail.html
186
+ - spec/fixtures/empty_hcard.html
162
187
  - spec/fixtures/location_detail.html
188
+ - spec/lib/g5_foundation_client/deserializers/client_spec.rb
163
189
  - spec/lib/g5_foundation_client/deserializers/location_spec.rb
164
190
  - spec/lib/g5_foundation_client/fetcher_spec.rb
191
+ - spec/lib/g5_foundation_client/models/client_spec.rb
165
192
  - spec/lib/g5_foundation_client/models/location_spec.rb
166
193
  - spec/lib/g5_foundation_client_spec.rb
167
194
  - spec/spec_helper.rb
168
195
  homepage: https://github.com/g5/g5_foundation_client
169
196
  licenses:
170
197
  - MIT
171
- metadata: {}
172
198
  post_install_message:
173
199
  rdoc_options: []
174
200
  require_paths:
175
201
  - lib
176
202
  required_ruby_version: !ruby/object:Gem::Requirement
203
+ none: false
177
204
  requirements:
178
- - - ">="
205
+ - - ! '>='
179
206
  - !ruby/object:Gem::Version
180
207
  version: '0'
181
208
  required_rubygems_version: !ruby/object:Gem::Requirement
209
+ none: false
182
210
  requirements:
183
- - - ">="
211
+ - - ! '>='
184
212
  - !ruby/object:Gem::Version
185
213
  version: '0'
186
214
  requirements: []
187
215
  rubyforge_project:
188
- rubygems_version: 2.2.2
216
+ rubygems_version: 1.8.23
189
217
  signing_key:
190
- specification_version: 4
218
+ specification_version: 3
191
219
  summary: Client gem to interact with G5 services.
192
220
  test_files:
221
+ - spec/fixtures/client_detail.html
222
+ - spec/fixtures/empty_hcard.html
193
223
  - spec/fixtures/location_detail.html
224
+ - spec/lib/g5_foundation_client/deserializers/client_spec.rb
194
225
  - spec/lib/g5_foundation_client/deserializers/location_spec.rb
195
226
  - spec/lib/g5_foundation_client/fetcher_spec.rb
227
+ - spec/lib/g5_foundation_client/models/client_spec.rb
196
228
  - spec/lib/g5_foundation_client/models/location_spec.rb
197
229
  - spec/lib/g5_foundation_client_spec.rb
198
230
  - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 9d3b6df46834c3a8f1250528ac377b77a36f4cd1
4
- data.tar.gz: ab362282521fbdba9361ee9a231fe734034f2bbf
5
- SHA512:
6
- metadata.gz: 7c2f61ee0703f0abf6807391e4c6a63966e6008b3dccd1fa290b0388d0bdbae400fe0849a1ab2b733aaf9b23425872da390d867922ee2274d82c821e619b1dd3
7
- data.tar.gz: 308ca96c321105771c4239f897ce9213dc2946506f02f50b4c6547ec4ee71eb77d117ed1811d25f1667492a993f94117376f7732e9557a9ce03387b301675a05