lonely_coder 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/lonely_coder.rb CHANGED
@@ -11,7 +11,7 @@ require 'mechanize'
11
11
 
12
12
  class OKCupid
13
13
  BaseUrl = 'http://www.okcupid.com'
14
- VERSION = '0.1.1'
14
+ VERSION = '0.1.2'
15
15
 
16
16
  def initialize(username=nil, password=nil)
17
17
  @browser = Mechanize.new
@@ -254,7 +254,7 @@ class OKCupid
254
254
  if @value.downcase == 'near me'
255
255
  "locid=0"
256
256
  else
257
- "lquery=#{URI.escape(@value)}"
257
+ "locid=#{Search.location_id_for(@value)}&lquery=#{URI.escape(@value)}"
258
258
  end
259
259
  else
260
260
  "locid=#{@value}"
data/lonely_coder.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "lonely_coder"
4
- s.version = '0.1.1'
4
+ s.version = '0.1.2'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Trek Glowacki"]
7
7
  s.email = ["trek.glowacki@gmail.com"]
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.okcupid.com/locquery?func=query&query=Cincinnati,%20Ohio
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Sun, 25 Mar 2012 04:56:31 GMT
21
+ Content-Type:
22
+ - text/javascript
23
+ Connection:
24
+ - close
25
+ Cache-Control:
26
+ - private
27
+ Server:
28
+ - OKWS/3.1.15.5
29
+ P3p:
30
+ - CP="NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT", policyref="http://www.okcupid.com/w3c/p3p.xml"
31
+ Content-Length:
32
+ - '160'
33
+ Set-Cookie:
34
+ - guest=14433467885058850318; expires=Mon, 25 Mar 2013 04:56:31 GMT; path=/;
35
+ domain=okcupid.com
36
+ body:
37
+ encoding: US-ASCII
38
+ string: ! '{"status" : 0, "query" : "Cincinnati, Ohio", "results" : [{"locid"
39
+ : 4164146, "text" : "Cincinnati"}, {"locid" : 4344665, "text" : "Cincinnati"}],
40
+ "locid" : 0}
41
+
42
+ '
43
+ http_version:
44
+ recorded_at: Sun, 25 Mar 2012 04:56:31 GMT
45
+ recorded_with: VCR 2.0.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.okcupid.com/locquery?func=query&query=Boise,%20Idaho
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Sun, 25 Mar 2012 04:53:35 GMT
21
+ Content-Type:
22
+ - text/javascript
23
+ Connection:
24
+ - close
25
+ Cache-Control:
26
+ - private
27
+ Server:
28
+ - OKWS/3.1.15.5
29
+ P3p:
30
+ - CP="NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT", policyref="http://www.okcupid.com/w3c/p3p.xml"
31
+ Content-Length:
32
+ - '129'
33
+ Set-Cookie:
34
+ - guest=17419761723812592274; expires=Mon, 25 Mar 2013 04:53:35 GMT; path=/;
35
+ domain=okcupid.com
36
+ body:
37
+ encoding: US-ASCII
38
+ string: ! '{"status" : 0, "ZipCode" : "", "query" : "Boise, Idaho", "locid"
39
+ : 4356487, "results" : [{"locid" : 4356487, "text" : "Boise"}]}
40
+
41
+ '
42
+ http_version:
43
+ recorded_at: Sun, 25 Mar 2012 04:53:35 GMT
44
+ recorded_with: VCR 2.0.0
data/spec/search_spec.rb CHANGED
@@ -6,6 +6,22 @@ describe "Search" do
6
6
  lambda { OKCupid::Search.new({}) }.should raise_error(OKCupid::Search::FilterError)
7
7
  end
8
8
 
9
+ it "with a location query looks up the location id" do
10
+ VCR.use_cassette('search_that_includes_a_location') do
11
+ OKCupid::Search.new({
12
+ :min_age => 33,
13
+ :max_age => 34,
14
+ :order_by => 'Match %',
15
+ :last_login => 'last decade',
16
+ :gentation => 'Guys who like guys',
17
+ :location => 'Boise, Idaho',
18
+ :radius => 25,
19
+ :require_photo => false,
20
+ :relationship_status => 'any'
21
+ }).url.should =='/match?filter1=5,315360000&filter2=3,25&filter3=1,0&filter4=35,0&filter5=0,20&filter6=2,33,34&low=1&count=10&matchOrderBy=MATCH&locid=4356487&lquery=Boise,%20Idaho&timekey=1&custom_search=0'
22
+ end
23
+ end
24
+
9
25
  it "complains about malformed key values" do
10
26
  lambda { OKCupid::Search.new({
11
27
  :gentation => 'Cats who like laser beams',
@@ -20,8 +36,8 @@ describe "Search" do
20
36
  :order_by => 'Match %',
21
37
  :last_login => 'last decade',
22
38
  :gentation => 'Guys who like guys',
23
- :location => 'near me', # can be 'near me', 'anywhere', a location name (e.g. 'Ann Arbor, MI'), or a location id
24
- :radius => 25, # acceptable values are 25, 50, 100, 250, 500
39
+ :location => 'near me',
40
+ :radius => 25,
25
41
  :require_photo => false,
26
42
  :relationship_status => 'any'
27
43
  }).url.should =='/match?filter1=5,315360000&filter2=3,25&filter3=1,0&filter4=35,0&filter5=0,20&filter6=2,33,34&low=1&count=10&matchOrderBy=MATCH&locid=0&timekey=1&custom_search=0'
@@ -43,7 +59,7 @@ describe "Results" do
43
59
  end
44
60
  end
45
61
 
46
- describe "Filters" do
62
+ describe "Options" do
47
63
  describe "lookup" do
48
64
  it "finds the encoded value" do
49
65
  OKCupid::Filter.new('relationship_status', 'single').lookup('single').should == 2
@@ -91,7 +107,9 @@ describe "Filters" do
91
107
  end
92
108
 
93
109
  it 'can use a location query' do
94
- OKCupid::LocationParameter.new('Cincinnati, Ohio').to_param.should == 'lquery=Cincinnati,%20Ohio'
110
+ VCR.use_cassette('location_filter_looks_up_location_id') do
111
+ OKCupid::LocationParameter.new('Cincinnati, Ohio').to_param.should == 'locid=4164146&lquery=Cincinnati,%20Ohio'
112
+ end
95
113
  end
96
114
 
97
115
  it "can use a location_id" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lonely_coder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -63,9 +63,11 @@ files:
63
63
  - spec/cassettes/failed_authentication.yml
64
64
  - spec/cassettes/find_location.yml
65
65
  - spec/cassettes/load_profile_from_search.yml
66
+ - spec/cassettes/location_filter_looks_up_location_id.yml
66
67
  - spec/cassettes/paginate_search_results_by_10.yml
67
68
  - spec/cassettes/search_by_filters.yml
68
69
  - spec/cassettes/search_by_username.yml
70
+ - spec/cassettes/search_that_includes_a_location.yml
69
71
  - spec/cassettes/successful_authentication.yml
70
72
  - spec/helper_spec.rb
71
73
  - spec/location_id_spec.rb
@@ -104,9 +106,11 @@ test_files:
104
106
  - spec/cassettes/failed_authentication.yml
105
107
  - spec/cassettes/find_location.yml
106
108
  - spec/cassettes/load_profile_from_search.yml
109
+ - spec/cassettes/location_filter_looks_up_location_id.yml
107
110
  - spec/cassettes/paginate_search_results_by_10.yml
108
111
  - spec/cassettes/search_by_filters.yml
109
112
  - spec/cassettes/search_by_username.yml
113
+ - spec/cassettes/search_that_includes_a_location.yml
110
114
  - spec/cassettes/successful_authentication.yml
111
115
  - spec/helper_spec.rb
112
116
  - spec/location_id_spec.rb