hungry 0.0.1 → 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.rspec +1 -1
- data/.ruby-version +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +7 -1
- data/Gemfile.lock +104 -0
- data/Rakefile +14 -0
- data/hungry.gemspec +0 -5
- data/lib/hungry.rb +20 -8
- data/lib/hungry/collection.rb +43 -9
- data/lib/hungry/collection/pagination.rb +17 -0
- data/lib/hungry/geolocation.rb +22 -2
- data/lib/hungry/location.rb +13 -8
- data/lib/hungry/menu.rb +53 -0
- data/lib/hungry/menu/category.rb +22 -0
- data/lib/hungry/menu/dish.rb +22 -0
- data/lib/hungry/menu/option.rb +9 -0
- data/lib/hungry/resource.rb +80 -12
- data/lib/hungry/response.rb +17 -0
- data/lib/hungry/review.rb +6 -6
- data/lib/hungry/site.rb +20 -6
- data/lib/hungry/tag.rb +6 -7
- data/lib/hungry/user.rb +77 -0
- data/lib/hungry/util.rb +44 -4
- data/lib/hungry/venue.rb +39 -18
- data/lib/hungry/venue/collection.rb +9 -0
- data/spec/hungry/geolocation_spec.rb +43 -43
- data/spec/hungry/util_spec.rb +18 -18
- data/spec/spec_helper.rb +0 -1
- metadata +20 -63
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../collection'
|
2
|
+
|
1
3
|
module Hungry
|
2
4
|
class Venue
|
3
5
|
class Collection < Hungry::Collection
|
@@ -18,6 +20,13 @@ module Hungry
|
|
18
20
|
all tags: (current_tags + tags.flatten).compact.join(',')
|
19
21
|
end
|
20
22
|
|
23
|
+
def maintainable_by(user_or_id)
|
24
|
+
user_id = user_or_id.to_s =~ /^[0-9]+$/ ?
|
25
|
+
user_or_id.to_i : user_or_id.id
|
26
|
+
|
27
|
+
all maintainer_id: user_id
|
28
|
+
end
|
29
|
+
|
21
30
|
def sort_by(subject)
|
22
31
|
all sort_by: subject
|
23
32
|
end
|
@@ -2,121 +2,121 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hungry::Geolocation do
|
4
4
|
let(:geo) { Hungry::Geolocation.new(50.8469397, 5.6927505) }
|
5
|
-
|
5
|
+
|
6
6
|
describe '.parse' do
|
7
7
|
context 'with a Geolocation' do
|
8
8
|
it 'returns the given Geolocation' do
|
9
|
-
Hungry::Geolocation.parse(geo).
|
9
|
+
expect(Hungry::Geolocation.parse(geo)).to eql geo
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
context 'with an Object' do
|
14
14
|
it 'returns a Geolocation object for objects with a latitude and longitude' do
|
15
15
|
object = Class.new do
|
16
16
|
def latitude; 50.8469397; end
|
17
17
|
def longitude; 5.6927505; end
|
18
18
|
end.new
|
19
|
-
|
19
|
+
|
20
20
|
geo = Hungry::Geolocation.parse(object)
|
21
|
-
geo.latitude.
|
22
|
-
geo.longitude.
|
21
|
+
expect(geo.latitude).to eql 50.8469397
|
22
|
+
expect(geo.longitude).to eql 5.6927505
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it 'returns a Geolocation object for objects with a lat and lng' do
|
26
26
|
object = Class.new do
|
27
27
|
def lat; 50.8469397; end
|
28
28
|
def lng; 5.6927505; end
|
29
29
|
end.new
|
30
|
-
|
30
|
+
|
31
31
|
geo = Hungry::Geolocation.parse(object)
|
32
|
-
geo.latitude.
|
33
|
-
geo.longitude.
|
32
|
+
expect(geo.latitude).to eql 50.8469397
|
33
|
+
expect(geo.longitude).to eql 5.6927505
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it 'returns a Geolocation object for objects that have a valid geolocation' do
|
37
37
|
object = Class.new do
|
38
38
|
def geolocation; Hungry::Geolocation.new(50.8469397, 5.6927505); end
|
39
39
|
end.new
|
40
|
-
|
40
|
+
|
41
41
|
geo = Hungry::Geolocation.parse(object)
|
42
|
-
geo.latitude.
|
43
|
-
geo.longitude.
|
42
|
+
expect(geo.latitude).to eql 50.8469397
|
43
|
+
expect(geo.longitude).to eql 5.6927505
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it 'returns nil for objects without geo information' do
|
47
47
|
geo = Hungry::Geolocation.parse(Object.new)
|
48
|
-
geo.
|
48
|
+
expect(geo).to be_nil
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it 'returns nil for objects that have an invalid geolocation' do
|
52
52
|
object = Class.new do
|
53
53
|
def geolocation; "just a string"; end
|
54
54
|
end.new
|
55
|
-
|
55
|
+
|
56
56
|
geo = Hungry::Geolocation.parse(object)
|
57
|
-
geo.
|
57
|
+
expect(geo).to be_nil
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
context 'with a String' do
|
62
62
|
it 'returns a Geolocation object' do
|
63
63
|
geo = Hungry::Geolocation.parse('50.8469397,5.6927505')
|
64
|
-
geo.latitude.
|
65
|
-
geo.longitude.
|
64
|
+
expect(geo.latitude).to eql 50.8469397
|
65
|
+
expect(geo.longitude).to eql 5.6927505
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it 'returns nil if the string can not be parsed' do
|
69
69
|
geo = Hungry::Geolocation.parse('not-a,geolocation')
|
70
|
-
geo.
|
70
|
+
expect(geo).to be_nil
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
context 'with an Array' do
|
75
75
|
it 'returns a Geolocation object' do
|
76
76
|
geo = Hungry::Geolocation.parse([50.8469397, 5.6927505])
|
77
|
-
geo.latitude.
|
78
|
-
geo.longitude.
|
77
|
+
expect(geo.latitude).to eql 50.8469397
|
78
|
+
expect(geo.longitude).to eql 5.6927505
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it 'returns nil if the array can not be parsed' do
|
82
82
|
geo = Hungry::Geolocation.parse(['not a', 'geolocation'])
|
83
|
-
geo.
|
83
|
+
expect(geo).to be_nil
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
context 'with a Hash' do
|
88
88
|
it 'returns a Geolocation object' do
|
89
89
|
geo = Hungry::Geolocation.parse(latitude: 50.8469397, longitude: 5.6927505)
|
90
|
-
geo.latitude.
|
91
|
-
geo.longitude.
|
90
|
+
expect(geo.latitude).to eql 50.8469397
|
91
|
+
expect(geo.longitude).to eql 5.6927505
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it 'supports abbreviated keys' do
|
95
95
|
geo = Hungry::Geolocation.parse(lat: 50.8469397, lng: 5.6927505)
|
96
|
-
geo.latitude.
|
97
|
-
geo.longitude.
|
96
|
+
expect(geo.latitude).to eql 50.8469397
|
97
|
+
expect(geo.longitude).to eql 5.6927505
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
it 'returns nil if the hash can not be parsed' do
|
101
101
|
geo = Hungry::Geolocation.parse(a: 'b', c: 'd')
|
102
|
-
geo.
|
102
|
+
expect(geo).to be_nil
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
describe '#initialize' do
|
108
108
|
it 'sets latitude' do
|
109
|
-
geo.latitude.
|
109
|
+
expect(geo.latitude).to eql 50.8469397
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
it 'sets longitude' do
|
113
|
-
geo.longitude.
|
113
|
+
expect(geo.longitude).to eql 5.6927505
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
describe '#to_s' do
|
118
118
|
it 'joins latitude and longitude with a ","' do
|
119
|
-
geo.to_s.
|
119
|
+
expect(geo.to_s).to eql '50.8469397,5.6927505'
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
data/spec/hungry/util_spec.rb
CHANGED
@@ -4,51 +4,51 @@ describe Hungry::Util do
|
|
4
4
|
describe '#params_from_uri' do
|
5
5
|
it 'returns a hash representing the params in the given URL' do
|
6
6
|
hash = Hungry::Util.params_from_uri 'http://www.google.com/search?q=ruby&lang=en'
|
7
|
-
hash.
|
7
|
+
expect(hash).to include 'q' => 'ruby', 'lang' => 'en'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#uri_with_params' do
|
12
12
|
it 'returns a clean URL if there no hash is given' do
|
13
13
|
url = Hungry::Util.uri_with_params('http://www.google.com/')
|
14
|
-
url.
|
14
|
+
expect(url).to eql 'http://www.google.com/'
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns an URL with params representing the given hash' do
|
18
18
|
url = Hungry::Util.uri_with_params('http://www.google.com/search', 'q' => 'ruby', 'lang' => 'en')
|
19
|
-
url.
|
19
|
+
expect(url).to eql 'http://www.google.com/search?q=ruby&lang=en'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe '#is_numeric?' do
|
24
24
|
it 'returns true for integers' do
|
25
|
-
Hungry::Util.is_numeric?(100).
|
25
|
+
expect(Hungry::Util.is_numeric?(100)).to be true
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'returns true for floats' do
|
29
|
-
Hungry::Util.is_numeric?(10.0).
|
29
|
+
expect(Hungry::Util.is_numeric?(10.0)).to be true
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it 'returns true for integers in strings' do
|
33
|
-
Hungry::Util.is_numeric?('100').
|
33
|
+
expect(Hungry::Util.is_numeric?('100')).to be true
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it 'returns true for floats in strings' do
|
37
|
-
Hungry::Util.is_numeric?('10.0').
|
37
|
+
expect(Hungry::Util.is_numeric?('10.0')).to be true
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it 'returns true for negative integers in strings' do
|
41
|
-
Hungry::Util.is_numeric?('-100').
|
41
|
+
expect(Hungry::Util.is_numeric?('-100')).to be true
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it 'returns true for negative floats in strings' do
|
45
|
-
Hungry::Util.is_numeric?('-10.0').
|
45
|
+
expect(Hungry::Util.is_numeric?('-10.0')).to be true
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it 'returns false for non numeric values' do
|
49
|
-
Hungry::Util.is_numeric?('abc').
|
50
|
-
Hungry::Util.is_numeric?('1a3').
|
51
|
-
Hungry::Util.is_numeric?('1.0.0').
|
49
|
+
expect(Hungry::Util.is_numeric?('abc')).to be false
|
50
|
+
expect(Hungry::Util.is_numeric?('1a3')).to be false
|
51
|
+
expect(Hungry::Util.is_numeric?('1.0.0')).to be false
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,78 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hungry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tom-Eric Gerritsen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: httparty
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rack
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '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'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
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: fakeweb
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
24
|
+
- - ">="
|
76
25
|
- !ruby/object:Gem::Version
|
77
26
|
version: '0'
|
78
27
|
description: An interface to the Eet.nu API.
|
@@ -82,9 +31,12 @@ executables: []
|
|
82
31
|
extensions: []
|
83
32
|
extra_rdoc_files: []
|
84
33
|
files:
|
85
|
-
- .gitignore
|
86
|
-
- .rspec
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".ruby-version"
|
37
|
+
- ".travis.yml"
|
87
38
|
- Gemfile
|
39
|
+
- Gemfile.lock
|
88
40
|
- Guardfile
|
89
41
|
- Rakefile
|
90
42
|
- hungry.gemspec
|
@@ -95,11 +47,17 @@ files:
|
|
95
47
|
- lib/hungry/country.rb
|
96
48
|
- lib/hungry/geolocation.rb
|
97
49
|
- lib/hungry/location.rb
|
50
|
+
- lib/hungry/menu.rb
|
51
|
+
- lib/hungry/menu/category.rb
|
52
|
+
- lib/hungry/menu/dish.rb
|
53
|
+
- lib/hungry/menu/option.rb
|
98
54
|
- lib/hungry/region.rb
|
99
55
|
- lib/hungry/resource.rb
|
56
|
+
- lib/hungry/response.rb
|
100
57
|
- lib/hungry/review.rb
|
101
58
|
- lib/hungry/site.rb
|
102
59
|
- lib/hungry/tag.rb
|
60
|
+
- lib/hungry/user.rb
|
103
61
|
- lib/hungry/util.rb
|
104
62
|
- lib/hungry/venue.rb
|
105
63
|
- lib/hungry/venue/collection.rb
|
@@ -110,27 +68,26 @@ files:
|
|
110
68
|
- spec/spec_helper.rb
|
111
69
|
homepage: http://github.com/eet-nu/hungry
|
112
70
|
licenses: []
|
71
|
+
metadata: {}
|
113
72
|
post_install_message:
|
114
73
|
rdoc_options: []
|
115
74
|
require_paths:
|
116
75
|
- lib
|
117
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
77
|
requirements:
|
120
|
-
- -
|
78
|
+
- - ">="
|
121
79
|
- !ruby/object:Gem::Version
|
122
80
|
version: '0'
|
123
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
82
|
requirements:
|
126
|
-
- -
|
83
|
+
- - ">="
|
127
84
|
- !ruby/object:Gem::Version
|
128
85
|
version: '0'
|
129
86
|
requirements: []
|
130
87
|
rubyforge_project:
|
131
|
-
rubygems_version:
|
88
|
+
rubygems_version: 2.5.1
|
132
89
|
signing_key:
|
133
|
-
specification_version:
|
90
|
+
specification_version: 4
|
134
91
|
summary: An interface to the Eet.nu API.
|
135
92
|
test_files:
|
136
93
|
- spec/hungry/geolocation_spec.rb
|