snafu 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,6 @@
1
+ h2. 0.1.2
2
+ * Glitch Locations (Hubs, Streets, etc.) may have strings or integers for their IDs. Street#id, and Hub#id now always return a String
3
+
1
4
  h2. 0.1.1
2
5
  * Fixed an issue where Hub.new would not populate steet names when given the raw result from Glitch
3
6
 
@@ -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 :id, :name
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
@@ -1,3 +1,3 @@
1
1
  module Snafu
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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 "initialize()" do
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"
@@ -1,9 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Snafu::Models::Hub do
4
- it "should retain the ID & Name of the hub if given a valid " do
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.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-03 00:00:00.000000000Z
12
+ date: 2011-12-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70226305981700 !ruby/object:Gem::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: *70226305981700
24
+ version_requirements: *70277761501020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &70226305980900 !ruby/object:Gem::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: *70226305980900
35
+ version_requirements: *70277761496860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: vcr
38
- requirement: &70226305980060 !ruby/object:Gem::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: *70226305980060
46
+ version_requirements: *70277761493740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeweb
49
- requirement: &70226305979120 !ruby/object:Gem::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: *70226305979120
57
+ version_requirements: *70277761480920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70226305978600 !ruby/object:Gem::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: *70226305978600
68
+ version_requirements: *70277761479300
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httparty
71
- requirement: &70226305977020 !ruby/object:Gem::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: *70226305977020
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