eaternet 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eaternet/agencies/snhd_lives.rb +4 -3
- data/lib/eaternet/util.rb +2 -1
- data/lib/eaternet/version.rb +1 -1
- data/lib/ext/enumerator.rb +4 -0
- data/test/eaternet/agencies/snhd_lives_test.rb +1 -1
- data/test/eaternet/util_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f09792a0e3e7fe94b6c3379288c8e49093792f2
|
4
|
+
data.tar.gz: 4aa2df5d05299c963e82f774540cad1f54d5a0c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c7e7427fc67460dcca75658313f734534574dd77fb40fdadd94e73bf6d0be4425b44daf82233004d217b1cac11e123b2c798c56e1c8b3a1c58f07e3ac60b2e4
|
7
|
+
data.tar.gz: 87a118b0c3a3ce819f81b92c94b645ed413a09d89982468248d308e61b6f842d679e961cbf71c2fcdfcf364f3717a81f3fdf76f050b6091d398d5c112ef36090
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'eaternet/loggable'
|
3
|
+
require 'eaternet/util'
|
3
4
|
|
4
5
|
module Eaternet
|
5
6
|
module Agencies
|
@@ -42,9 +43,9 @@ module Eaternet
|
|
42
43
|
def business(proto)
|
43
44
|
Business.new do |b|
|
44
45
|
b.business_id = proto.orig_key
|
45
|
-
b.name =
|
46
|
-
b.address = proto.address
|
47
|
-
b.city =
|
46
|
+
b.name = Eaternet::Util.cleanup_title(proto.name)
|
47
|
+
b.address = Eaternet::Util.cleanup_title(proto.address)
|
48
|
+
b.city = Eaternet::Util.cleanup_title(proto.city)
|
48
49
|
b.postal_code = proto.zipcode
|
49
50
|
b.state = 'NV'
|
50
51
|
end
|
data/lib/eaternet/util.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'zip'
|
3
3
|
require 'httparty'
|
4
|
+
require 'active_support/core_ext/string/inflections'
|
4
5
|
|
5
6
|
module Eaternet
|
6
7
|
module Util
|
@@ -66,7 +67,7 @@ module Eaternet
|
|
66
67
|
# @return [String] the cleaned up string
|
67
68
|
def self.cleanup_title(a_string)
|
68
69
|
return nil if a_string.nil?
|
69
|
-
cleanup(a_string).titleize
|
70
|
+
cleanup(a_string).titleize.sub("Mc Donald's", "McDonald's")
|
70
71
|
end
|
71
72
|
|
72
73
|
# Remove extraneous whitespace from the string
|
data/lib/eaternet/version.rb
CHANGED
data/lib/ext/enumerator.rb
CHANGED
@@ -6,6 +6,10 @@ class Enumerator
|
|
6
6
|
reject(&:nil?)
|
7
7
|
end
|
8
8
|
|
9
|
+
# Thanks to u/0x0dea for the lazy implementation.
|
10
|
+
#
|
11
|
+
# @author u/0x0dea
|
12
|
+
# @see http://www.reddit.com/r/ruby/comments/37jpnz/is_this_the_best_laziest_way_to_add_compact_and/crnckrv Discussion thread
|
9
13
|
# @return [Enumerator] only my unique elements
|
10
14
|
def uniq
|
11
15
|
cache = Set.new
|
@@ -18,7 +18,7 @@ class SnhdLivesTest < Minitest::Test
|
|
18
18
|
VCR.use_cassette(SNHD_CASSETTE) do
|
19
19
|
b = @@snhd.businesses.first
|
20
20
|
assert_equal 'PR0000002', b.business_id
|
21
|
-
assert_equal "McDonald's #3549 D
|
21
|
+
assert_equal "McDonald's #3549 D Hotel", b.name
|
22
22
|
assert_equal '301 Fremont St', b.address
|
23
23
|
assert_equal 'Las Vegas', b.city
|
24
24
|
assert_equal '89101-5600', b.postal_code
|
data/test/eaternet/util_test.rb
CHANGED
@@ -44,4 +44,10 @@ class UtilTest < Minitest::Test
|
|
44
44
|
Timecop.freeze(Time.now + thirteen_hours) { download_and_cache }
|
45
45
|
assert_requested :get, @url, times: 2
|
46
46
|
end
|
47
|
+
|
48
|
+
def test_properly_cleans_up_mcdonalds
|
49
|
+
input = "McDonald's #3549 D HOTEL"
|
50
|
+
desired_output = "McDonald's #3549 D Hotel"
|
51
|
+
assert_equal desired_output, Eaternet::Util.cleanup_title(input)
|
52
|
+
end
|
47
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eaternet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|