g5_updatable 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -34
  3. data/app/concerns/g5_updatable/belongs_to_location.rb +14 -0
  4. data/app/concerns/g5_updatable/first_class_properties.rb +25 -0
  5. data/app/concerns/g5_updatable/urn_as_parameter.rb +7 -0
  6. data/app/controllers/g5_updatable/feed_controller.rb +1 -1
  7. data/app/models/g5_updatable/client.rb +12 -0
  8. data/app/models/g5_updatable/integration_setting.rb +20 -0
  9. data/app/models/g5_updatable/location.rb +16 -0
  10. data/app/serializers/g5_updatable/location_serializer.rb +12 -0
  11. data/db/migrate/20140709222005_create_g5_updatable_clients_and_locations.rb +24 -0
  12. data/db/migrate/20141030211945_create_integration_setting.rb +18 -0
  13. data/lib/g5_updatable/client_feed_processor.rb +34 -12
  14. data/lib/g5_updatable/client_updater.rb +7 -16
  15. data/lib/g5_updatable/engine.rb +2 -13
  16. data/lib/g5_updatable/integration_settings_updater.rb +21 -0
  17. data/lib/g5_updatable/locations_updater.rb +14 -21
  18. data/lib/g5_updatable/rspec/factories.rb +19 -0
  19. data/lib/g5_updatable/rspec.rb +3 -0
  20. data/lib/g5_updatable/version.rb +1 -1
  21. data/lib/g5_updatable.rb +2 -1
  22. data/lib/generators/g5_updatable/install/USAGE +0 -3
  23. data/lib/generators/g5_updatable/install/install_generator.rb +0 -6
  24. data/lib/tasks/g5_updatable_tasks.rake +12 -4
  25. data/spec/concerns/g5_updatable/belongs_to_location_spec.rb +30 -0
  26. data/spec/dummy/app/models/favorite_food.rb +3 -0
  27. data/spec/dummy/config/database.sample.yml +9 -0
  28. data/spec/dummy/config/database.travis.yml +4 -0
  29. data/spec/dummy/db/migrate/20140709220627_drop_clients_and_locations.rb +10 -0
  30. data/spec/dummy/db/migrate/20140714225203_create_favorite_foods.rb +10 -0
  31. data/spec/dummy/db/schema.rb +39 -21
  32. data/spec/dummy/log/test.log +18589 -920
  33. data/spec/lib/g5_updatable/client_feed_processor_spec.rb +77 -22
  34. data/spec/lib/g5_updatable/client_updater_spec.rb +28 -41
  35. data/spec/lib/g5_updatable/integration_settings_updater_spec.rb +48 -0
  36. data/spec/lib/g5_updatable/locations_updater_spec.rb +29 -52
  37. data/spec/lib/generators/g5_updatable/install_generator_spec.rb +0 -12
  38. data/spec/models/g5_updatable/client_spec.rb +25 -0
  39. data/spec/models/g5_updatable/integration_setting_spec.rb +33 -0
  40. data/spec/models/g5_updatable/location_spec.rb +34 -0
  41. data/spec/serializers/g5_updatable/location_serializer_spec.rb +21 -0
  42. data/spec/spec_helper.rb +13 -5
  43. data/spec/support/shared_example_for_urn_as_parameter.rb +7 -0
  44. data/spec/support/shared_examples_for_first_class_properties_json.rb +29 -0
  45. metadata +104 -42
  46. data/lib/g5_updatable/feed_mapper.rb +0 -58
  47. data/lib/g5_updatable/g5_client.rb +0 -10
  48. data/lib/g5_updatable/g5_location.rb +0 -22
  49. data/lib/generators/g5_updatable/install/templates/g5_updatable.rb +0 -25
  50. data/spec/dummy/config/database.yml +0 -25
  51. data/spec/dummy/config/initializers/g5_updatable.rb +0 -4
  52. data/spec/dummy/db/development.sqlite3 +0 -0
  53. data/spec/dummy/log/development.log +0 -6434
  54. data/spec/dummy/spec/fabricators/client_fabricator.rb +0 -6
  55. data/spec/dummy/spec/fabricators/location_fabricator.rb +0 -9
  56. data/spec/dummy/spec/models/client_spec.rb +0 -0
  57. data/spec/dummy/spec/models/location_spec.rb +0 -0
  58. data/spec/dummy/spec/support/client_feed.html +0 -97
  59. data/spec/dummy/spec/support/updated_client_feed.html +0 -148
  60. data/spec/fabricators/client_fabricator.rb +0 -6
  61. data/spec/fabricators/location_fabricator.rb +0 -9
  62. data/spec/lib/g5_updatable/feed_mapper_spec.rb +0 -119
  63. data/spec/lib/tmp/config/initializers/g5_updatable.rb +0 -25
@@ -1,6 +0,0 @@
1
- Fabricator :client do
2
- uid { "http://foo.com" }
3
- name { Faker::Name.name }
4
- vertical { "Apartments" }
5
- domain { "http://bar.com" }
6
- end
@@ -1,9 +0,0 @@
1
- Fabricator :location do
2
- uid { "http://foo.com" }
3
- urn { "g5-cl-2398223-#{Faker::Name.name.parameterize}" }
4
- name { Faker::Name.name }
5
- state { Faker::Address.state_abbr }
6
- city { Faker::Address.city }
7
- domain { "http://bar.com" }
8
- corporate { false }
9
- end
File without changes
File without changes
@@ -1,97 +0,0 @@
1
- <html>
2
- <head>
3
- <title>G5 Hub - Client</title>
4
- <meta charset="utf8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link href="/assets/application-9bb7384fc91bf9e1412069c1d99dbd70.css" media="screen" rel="stylesheet" type="text/css">
7
- <script src="/assets/application-d9073b018f0f15c31a207f25c1ab520d.js" type="text/javascript"></script>
8
- </head>
9
- <body>
10
- <div class="container">
11
- <div class="page-header clearfix">
12
- <h1>
13
- Client
14
- </h1>
15
- </div>
16
- <article>
17
- <div class="h-card">
18
- <h2>
19
- <a href="http://g5-hub.herokuapp.com/clients/g5-c-69xp2x0-farmhouse" class="p-name u-uid u-url">Farmhouse</a>
20
- <small class="p-g5-vertical">Apartments</small> |
21
- <small class="u-g5-domain">http://farmhouseapartments.com</small> |
22
- <small class="p-g5-domain-type">MultiDomainClient</small>
23
- </h2>
24
- <p class="h-adr p-adr">
25
- <span class="p-street-address">
26
- 123 Rainbow Lane
27
- Apt. 1
28
- </span>
29
- <span>
30
- <span class="p-locality">San Francisco</span>
31
- <span class="p-region">CA</span>
32
- <span class="p-postal-code">94115</span>
33
- </span>
34
- <span class="p-tel p-fax">333-333-3333</span>
35
- <span class="u-email">email@example.com</span>
36
- </p>
37
-
38
- <div>
39
- <h4>Locations</h4>
40
- <ul class="list-unstyled">
41
- <li class="p-org h-card">
42
- <a href="http://g5-hub.herokuapp.com/clients/g5-c-69xp2x0-farmhouse/locations/g5-cl-1qrcyt46-hollywood" class="p-name u-uid u-url">Hollywood</a>
43
- <a href="http://www.hollywood.com/" class="u-g5-domain u-url">http://www.hollywood.com/</a>
44
- <p class="p-adr h-adr">
45
- <span class="p-street-address">
46
- 4567 Storage Drive
47
- Unit 5
48
- </span>
49
- <span class="p-g5-neighborhood">Westwood</span>
50
- <span>
51
- <span class="p-locality">Hollywood</span>
52
- <span class="p-region">CA</span>
53
- <span class="p-postal-code">80229</span>
54
- </span>
55
- <span class="p-tel">555-555-5555</span>
56
- <span class="p-tel p-fax">123-456-7890</span>
57
- <span class="u-email">email@example.com</span>
58
- </p>
59
- <p>
60
- <span class="p-g5-corporate">False</span>
61
- </p>
62
- <p>
63
- <strong>Floor Plans:</strong>
64
- <br />
65
- <span class="p-g5-floorplan">2 Bedroom 2 Bath, Studio</span>
66
- </p>
67
- <p>
68
- <strong>Landmarks:</strong>
69
- <br />
70
- <span class="p-g5-landmark-1">Seattle Grace Hospital</span>
71
- <br />
72
- <span class="p-g5-landmark-2">McDonald's</span>
73
- </p>
74
- <p>
75
- <strong>Property Features or Qualifiers:</strong>
76
- <br />
77
- <span class="p-g5-aparment-feature-1">Luxury</span>
78
- <br />
79
- <span class="p-g5-aparment-feature-2">Affordable</span>
80
- <br />
81
- <span class="p-g5-aparment-feature-3">Gated</span>
82
- </p>
83
- <p>
84
- <strong>Primary Amenities:</strong>
85
- <br />
86
- <span class="p-g5-aparment-amenity-1">Secret Passages</span>
87
- <br />
88
- <span class="p-g5-community-amenity-1">Ball Pit</span>
89
- </p>
90
- </li>
91
- </ul>
92
- </div>
93
- </div>
94
- </article>
95
- </div>
96
- </body>
97
- </html>
@@ -1,148 +0,0 @@
1
- <html>
2
- <head>
3
- <title>G5 Hub - Client</title>
4
- <meta charset="utf8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link href="/assets/application-9bb7384fc91bf9e1412069c1d99dbd70.css" media="screen" rel="stylesheet" type="text/css">
7
- <script src="/assets/application-d9073b018f0f15c31a207f25c1ab520d.js" type="text/javascript"></script>
8
- </head>
9
- <body>
10
- <div class="container">
11
- <div class="page-header clearfix">
12
- <h1>
13
- Client
14
- </h1>
15
- </div>
16
- <article>
17
- <div class="h-card">
18
- <h2>
19
- <a href="http://g5-hub.herokuapp.com/clients/g5-c-69xp2x0-farmhouse" class="p-name u-uid u-url">Farmhouse Apartments</a>
20
- <small class="p-g5-vertical">Apartments</small> |
21
- <small class="u-g5-domain">http://farmhouseapartmentsfoo.com</small> |
22
- <small class="p-g5-domain-type">MultiDomainClient</small>
23
- </h2>
24
- <p class="h-adr p-adr">
25
- <span class="p-street-address">
26
- 123 Rainbow Lane
27
- Apt. 1
28
- </span>
29
- <span>
30
- <span class="p-locality">San Francisco</span>
31
- <span class="p-region">CA</span>
32
- <span class="p-postal-code">94115</span>
33
- </span>
34
- <span class="p-tel p-fax">333-333-3333</span>
35
- <span class="u-email">email@example.com</span>
36
- </p>
37
-
38
- <div>
39
- <h4>Locations</h4>
40
- <ul class="list-unstyled">
41
- <li class="p-org h-card">
42
- <a href="http://g5-hub.herokuapp.com/clients/g5-c-69xp2x0-farmhouse/locations/g5-cl-1qrcyt46-hollywood" class="p-name u-uid u-url">Hollywood</a>
43
- <a href="http://www.hollywood.com/" class="u-g5-domain u-url">http://www.hollywood.com/</a>
44
- <p class="p-adr h-adr">
45
- <span class="p-street-address">
46
- 4567 Storage Drive
47
- Unit 5
48
- </span>
49
- <span class="p-g5-neighborhood">River West</span>
50
- <span>
51
- <span class="p-locality">Hollywood</span>
52
- <span class="p-region">CA</span>
53
- <span class="p-postal-code">80229</span>
54
- </span>
55
- <span class="p-tel">555-555-5555</span>
56
- <span class="p-tel p-fax">123-456-7890</span>
57
- <span class="u-email">email@example.com</span>
58
- </p>
59
- <p>
60
- <span class="p-g5-corporate">False</span>
61
- </p>
62
- <p>
63
- <strong>Floor Plans:</strong>
64
- <br />
65
- <span class="p-g5-floorplan">2 Bedroom 2 Bath, Studio</span>
66
- </p>
67
- <p>
68
- <strong>Landmarks:</strong>
69
- <br />
70
- <span class="p-g5-landmark-1">Seattle Grace Hospital</span>
71
- <br />
72
- <span class="p-g5-landmark-2">McDonald's</span>
73
- </p>
74
- <p>
75
- <strong>Property Features or Qualifiers:</strong>
76
- <br />
77
- <span class="p-g5-aparment-feature-1">Luxury</span>
78
- <br />
79
- <span class="p-g5-aparment-feature-2">Affordable</span>
80
- <br />
81
- <span class="p-g5-aparment-feature-3">Gated</span>
82
- </p>
83
- <p>
84
- <strong>Primary Amenities:</strong>
85
- <br />
86
- <span class="p-g5-aparment-amenity-1">Secret Passages</span>
87
- <br />
88
- <span class="p-g5-community-amenity-1">Ball Pit</span>
89
- </p>
90
- </li>
91
- <li class="p-org h-card">
92
- <a href="http://g5-hub.herokuapp.com/clients/g5-c-69xp2x0-farmhouse/locations/g5-cl-1qrcyt47-north-shore-oahu" class="p-name u-uid u-url">North Shore Oahu</a>
93
- <a href="http://www.northshoreoahu.com/" class="u-g5-domain u-url">http://www.northshoreoahu.com/</a>
94
- <p class="p-adr h-adr">
95
- <span class="p-street-address">
96
- 4567 Storage Drive
97
- Unit 5
98
- </span>
99
- <span class="p-g5-neighborhood">Westwood</span>
100
- <span>
101
- <span class="p-locality">Los Angeles</span>
102
- <span class="p-region">CA</span>
103
- <span class="p-postal-code">80229</span>
104
- </span>
105
- <span class="p-tel">555-555-5555</span>
106
- <span class="p-tel p-fax">123-456-7890</span>
107
- <span class="u-email">email@example.com</span>
108
- </p>
109
- <p>
110
- <span class="p-g5-corporate">false</span>
111
- </p>
112
- <p>
113
- <strong>Floor Plans:</strong>
114
- <br />
115
- <span class="p-g5-floorplan">2 Bedroom 2 Bath, Studio</span>
116
- </p>
117
- <p>
118
- <strong>Landmarks:</strong>
119
- <br />
120
- <span class="p-g5-landmark-1">Seattle Grace Hospital</span>
121
- <br />
122
- <span class="p-g5-landmark-2">McDonald's</span>
123
- </p>
124
- <p>
125
- <strong>Property Features or Qualifiers:</strong>
126
- <br />
127
- <span class="p-g5-aparment-feature-1">Luxury</span>
128
- <br />
129
- <span class="p-g5-aparment-feature-2">Affordable</span>
130
- <br />
131
- <span class="p-g5-aparment-feature-3">Gated</span>
132
- </p>
133
- <p>
134
- <strong>Primary Amenities:</strong>
135
- <br />
136
- <span class="p-g5-aparment-amenity-1">Secret Passages</span>
137
- <br />
138
- <span class="p-g5-community-amenity-1">Ball Pit</span>
139
- </p>
140
- </li>
141
- </ul>
142
- </div>
143
- </div>
144
- </article>
145
- </div>
146
- </body>
147
- </html>
148
-
@@ -1,6 +0,0 @@
1
- Fabricator :client do
2
- uid { "http://foo.com" }
3
- name { Faker::Name.name }
4
- vertical { "Apartments" }
5
- domain { "http://bar.com" }
6
- end
@@ -1,9 +0,0 @@
1
- Fabricator :location do
2
- uid { Faker::Internet.url }
3
- urn { "g5-cl-2398223-#{Faker::Name.name.parameterize}" }
4
- name { Faker::Name.name }
5
- state { Faker::Address.state_abbr }
6
- city { Faker::Address.city }
7
- domain { Faker::Internet.url }
8
- corporate { false }
9
- end
@@ -1,119 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe G5Updatable::FeedMapper do
4
- let(:feed_endpoint) { "#{Rails.root}/spec/support/" }
5
-
6
- before { allow(G5Updatable).to receive(:feed_endpoint) { feed_endpoint } }
7
-
8
- describe "#client" do
9
- subject(:client_mapper) { described_class.new(client_identifier).client }
10
-
11
- context "a nil identifier" do
12
- let(:client_identifier) { nil }
13
-
14
- before { allow(G5Updatable).to receive(:client_identifier) { nil } }
15
-
16
- it "does nothing" do
17
- expect(client_mapper).to be_nil
18
- end
19
- end
20
-
21
- context "a given identifier" do
22
- let(:client_identifier) { "client_feed.html" }
23
-
24
- it "maps to the correct name" do
25
- expect(client_mapper.name).to eq("Farmhouse")
26
- end
27
-
28
- it "maps to the correct vertical" do
29
- expect(client_mapper.vertical).to eq("Apartments")
30
- end
31
-
32
- it "maps to the correct domain" do
33
- expect(client_mapper.domain).to eq("http://farmhouseapartments.com/")
34
- end
35
-
36
- it "maps to the correct type" do
37
- expect(client_mapper.type).to eq("MultiDomainClient")
38
- end
39
- end
40
- end
41
-
42
- describe "#locations" do
43
- subject(:location_mapper) { described_class.new(client_identifier).locations.first }
44
-
45
- context "a nil identifier" do
46
- let(:client_identifier) { nil }
47
-
48
- before { allow(G5Updatable).to receive(:client_identifier) { nil } }
49
-
50
- it "does nothing" do
51
- expect(location_mapper).to be_nil
52
- end
53
- end
54
-
55
- context "a given identifier" do
56
- let(:client_identifier) { "client_feed.html" }
57
-
58
- it "maps to the correct urn" do
59
- expect(location_mapper.urn).to eq("g5-cl-1qrcyt46-hollywood")
60
- end
61
-
62
- it "maps to the correct name" do
63
- expect(location_mapper.name).to eq("Hollywood")
64
- end
65
-
66
- it "maps to the correct domain" do
67
- expect(location_mapper.domain).to eq("http://www.hollywood.com/")
68
- end
69
-
70
- it "maps to the correct street_address" do
71
- expect(location_mapper.street_address).to eq("4567 Storage Drive Unit 5")
72
- end
73
-
74
- it "maps to the correct state" do
75
- expect(location_mapper.state).to eq("CA")
76
- end
77
-
78
- it "maps to the correct city" do
79
- expect(location_mapper.city).to eq("Hollywood")
80
- end
81
-
82
- it "maps to the correct neighborhood" do
83
- expect(location_mapper.neighborhood).to eq("Westwood")
84
- end
85
-
86
- it "maps to the correct postal_code" do
87
- expect(location_mapper.postal_code).to eq("80229")
88
- end
89
-
90
- it "maps to the correct phone_number" do
91
- expect(location_mapper.phone_number).to eq("555-555-5555")
92
- end
93
-
94
- it "maps to the correct default_number" do
95
- expect(location_mapper.default_number).to eq("555-555-5555")
96
- end
97
-
98
- it "maps to the correct corporate" do
99
- expect(location_mapper.corporate).to eq("False")
100
- end
101
-
102
- it "maps to the correct floor_plans" do
103
- expect(location_mapper.floor_plans).to eq("2 Bedroom 2 Bath, Studio")
104
- end
105
-
106
- it "maps to the correct primary_amenity" do
107
- expect(location_mapper.primary_amenity).to eq("Secret Passages")
108
- end
109
-
110
- it "maps to the correct qualifier" do
111
- expect(location_mapper.qualifier).to eq("Luxury")
112
- end
113
-
114
- it "maps to the correct primary_landmark" do
115
- expect(location_mapper.primary_landmark).to eq("Seattle Grace Hospital")
116
- end
117
- end
118
- end
119
- end
@@ -1,25 +0,0 @@
1
- G5Updatable.setup do |config|
2
- # base path to the G5 Hub
3
- #
4
- #config.feed_endpoint = "..."
5
-
6
- # identifier of the client (urn)
7
- #
8
- #config.client_identifier = "..."
9
-
10
- # default is true. When set to true, existing locations in your app will be
11
- # updated with any changes made to the hub. If set to false, existing locations
12
- # will be skipped and only newly added locations will be created.
13
- #
14
- #config.update_locations = true
15
-
16
- # default is false. When set to true, client data will update.
17
- #
18
- #config.update_client = false
19
-
20
- # default is [:name]. A whitlist of parameters to create/update on the model
21
- #config.location_parameters = [:name]
22
-
23
- # default is [:name]. A whitlist of parameters to update on the model
24
- #config.client_parameters = [:name]
25
- end