snafu 0.1.1 → 0.1.2
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/CHANGELOG.textile +3 -0
- data/lib/snafu/locations.rb +9 -0
- data/lib/snafu/models/location.rb +5 -2
- data/lib/snafu/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Snafu_Models_Street_new/should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml +40 -0
- data/spec/snafu/models/street_spec.rb +7 -2
- data/spec/snafu/models_spec.rb +1 -5
- metadata +16 -14
data/CHANGELOG.textile
CHANGED
data/lib/snafu/locations.rb
CHANGED
@@ -13,6 +13,15 @@ module Snafu
|
|
13
13
|
hubs
|
14
14
|
end
|
15
15
|
|
16
|
+
# A variant of the get_hubs method which makes two calls to the Glitch API:
|
17
|
+
#
|
18
|
+
# 1. locations.getHubs to retrieve all hubs in Glitch
|
19
|
+
# 2. locations.getStreets for each hub returned from locations.getHubs
|
20
|
+
#
|
21
|
+
def get_hubs!
|
22
|
+
# TODO
|
23
|
+
end
|
24
|
+
|
16
25
|
# Accesses the "locations.getStreets" method from the Glitch API passing in
|
17
26
|
# the supplied Hub ID.
|
18
27
|
#
|
@@ -3,15 +3,18 @@ module Snafu
|
|
3
3
|
# Defines a generic location class with <tt>id</tt> and <tt>name</tt>
|
4
4
|
# properties.
|
5
5
|
class Location
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :name
|
7
7
|
# Accepts an options hash with <tt>:id</tt> or <tt>:name</tt>
|
8
8
|
def initializer(options={})
|
9
|
-
@id = options[:id]
|
9
|
+
@id = options[:id].to_s
|
10
10
|
@name = options[:name]
|
11
11
|
end
|
12
12
|
def to_s
|
13
13
|
"#{self.id} - #{self.name}"
|
14
14
|
end
|
15
|
+
def id
|
16
|
+
@id.to_s
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/snafu/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.glitch.com:80/simple/locations.streetInfo?street_tsid=LM416LNIKVLM1
|
6
|
+
body: !!null
|
7
|
+
headers: !!null
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
access-control-allow-credentials:
|
14
|
+
- 'false'
|
15
|
+
access-control-allow-methods:
|
16
|
+
- POST, GET, OPTIONS
|
17
|
+
access-control-allow-origin:
|
18
|
+
- ! '*'
|
19
|
+
access-control-max-age:
|
20
|
+
- '1728000'
|
21
|
+
cache-control:
|
22
|
+
- no-cache="set-cookie"
|
23
|
+
content-type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
date:
|
26
|
+
- Sun, 11 Dec 2011 07:06:46 GMT
|
27
|
+
server:
|
28
|
+
- Apache/2.2.17
|
29
|
+
set-cookie:
|
30
|
+
- AWSELB=F7715B6B10BD5947A6E9DAE19D6F6DD7D91A271FB7C136A73584C8A9C7D99844891B9CE4098DC7B1C7896C3495C0321477EE3FFB6D062BCC604E27B432E4350AD26F2A097D;PATH=/;MAX-AGE=600
|
31
|
+
content-length:
|
32
|
+
- '665'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body: ! '{"ok":1,"tsid":"LM416LNIKVLM1","name":"Baby Steppes","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"},"active_project":false,"features":["<b>13
|
36
|
+
Piggies<\/b>, <b>6 Butterflies<\/b>, <b>5 Chickens<\/b>, and <b>6 Spice Plants<\/b>."],"connections":{"LM4115NJ46G8M":{"name":"Groddle
|
37
|
+
Ladder","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}},"LM410TMR0S2S1":{"name":"Ruta
|
38
|
+
Asuncion","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}},"LM4109NI2R640":{"name":"Guillermo
|
39
|
+
Gamera Way","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}}},"image":{"url":"http:\/\/c2.glitch.bz\/streets\/2011-11-27\/LM416LNIKVLM1_main_1322382945.jpg","w":720,"h":120}}'
|
40
|
+
http_version: '1.1'
|
@@ -5,12 +5,17 @@ module Snafu
|
|
5
5
|
describe Snafu::Models::Street do
|
6
6
|
before(:each) do
|
7
7
|
@snafu = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
8
|
-
@test_hub_id = 27
|
8
|
+
@test_hub_id = "27"
|
9
9
|
@test_hub_name = "Ix"
|
10
10
|
@test_street_id = "LM416LNIKVLM1"
|
11
11
|
@test_street_name = "Baby Steppes"
|
12
12
|
end
|
13
|
-
context "
|
13
|
+
context "#new" do
|
14
|
+
it "should return ID as a string" do
|
15
|
+
new_street = Street.new(:id => @test_hub_id)
|
16
|
+
new_street.id.should be_a String
|
17
|
+
end
|
18
|
+
|
14
19
|
it "should populate values if given an options hash", :vcr do
|
15
20
|
expected_id = "1"
|
16
21
|
expected_name = "Some street"
|
data/spec/snafu/models_spec.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Snafu::Models::Hub do
|
4
|
-
|
5
|
-
hub = Snafu::Models::Hub.new(:id => @test_hub_id, :name => @test_hub_name)
|
6
|
-
hub.id.should eql(@test_hub_id)
|
7
|
-
hub.name.should eql(@test_hub_name)
|
8
|
-
end
|
4
|
+
|
9
5
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snafu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70277761501020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70277761501020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard-rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70277761496860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70277761496860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vcr
|
38
|
-
requirement: &
|
38
|
+
requirement: &70277761493740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70277761493740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fakeweb
|
49
|
-
requirement: &
|
49
|
+
requirement: &70277761480920 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70277761480920
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70277761479300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70277761479300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
|
-
requirement: &
|
71
|
+
requirement: &70277761478120 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0.8'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70277761478120
|
80
80
|
description: ! "Snafu is an interface to API for Glitch, an online multi-player\n
|
81
81
|
\ game created by Tiny Speck."
|
82
82
|
email:
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
120
120
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_response_from_Glitch.yml
|
121
121
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Street/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
122
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Street_new/should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
122
123
|
- spec/fixtures/vcr_cassettes/calendar_getHoldays/valid_calendar.yml
|
123
124
|
- spec/snafu/client_spec.rb
|
124
125
|
- spec/snafu/locations_spec.rb
|
@@ -171,6 +172,7 @@ test_files:
|
|
171
172
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
172
173
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_response_from_Glitch.yml
|
173
174
|
- spec/fixtures/vcr_cassettes/Snafu_Models_Street/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
175
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Street_new/should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
174
176
|
- spec/fixtures/vcr_cassettes/calendar_getHoldays/valid_calendar.yml
|
175
177
|
- spec/snafu/client_spec.rb
|
176
178
|
- spec/snafu/locations_spec.rb
|