fireeagle 0.0.1
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/History.txt +0 -0
- data/License.txt +20 -0
- data/Manifest.txt +19 -0
- data/README.txt +20 -0
- data/Rakefile +123 -0
- data/lib/fireeagle.rb +65 -0
- data/lib/fireeagle/apibase.rb +6 -0
- data/lib/fireeagle/application.rb +29 -0
- data/lib/fireeagle/base.rb +89 -0
- data/lib/fireeagle/location.rb +74 -0
- data/lib/fireeagle/user.rb +39 -0
- data/lib/fireeagle/version.rb +9 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/test/test_fireeagle.rb +30 -0
- data/test/test_fireeagle_application.rb +46 -0
- data/test/test_fireeagle_location.rb +97 -0
- data/test/test_fireeagle_user.rb +103 -0
- data/test/test_helper.rb +14 -0
- metadata +80 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
context "The FireEagle class" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@f = FireEagle::Base.new(:token => "foo", :secret => "bar")
|
7
|
+
end
|
8
|
+
|
9
|
+
specify "should require a secret and a token" do
|
10
|
+
lambda { FireEagle::Base.new }.should.raise(FireEagle::ArgumentError)
|
11
|
+
lambda { FireEagle::Base.new(:token => "foo") }.should.raise(FireEagle::ArgumentError)
|
12
|
+
lambda { FireEagle::Base.new(:secret => "bar") }.should.raise(FireEagle::ArgumentError)
|
13
|
+
lambda { FireEagle::Base.new(:token => "foo", :secret => "bar") }.should.not.raise(FireEagle::ArgumentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
specify "should have token and secret readers" do
|
17
|
+
@f.token.should.equal "foo"
|
18
|
+
@f.secret.should.equal "bar"
|
19
|
+
end
|
20
|
+
|
21
|
+
specify "should contain FireEagle::Application class accessor" do
|
22
|
+
@f.application.class.should.equal FireEagle::Application
|
23
|
+
end
|
24
|
+
|
25
|
+
specify "is able to stub itself (learning experience here)" do
|
26
|
+
FireEagle::Base.stubs(:foo).returns("bar")
|
27
|
+
FireEagle::Base.foo.should.equal "bar"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
context "The FireEagle::Application class" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@f = FireEagle::Base.new(:token => "foo", :secret => "bar")
|
7
|
+
@application = @f.application
|
8
|
+
@response = MockSuccess.new
|
9
|
+
@error_response = <<-RESPONSE
|
10
|
+
<ResultSet version="1.0">
|
11
|
+
<Error>1</Error>
|
12
|
+
<ErrorMessage>Something bad happened</ErrorMessage>
|
13
|
+
</ResultSet>
|
14
|
+
RESPONSE
|
15
|
+
@token_response = <<-RESPONSE
|
16
|
+
<rsp stat="ok">
|
17
|
+
<token>1234</token>
|
18
|
+
</rsp>
|
19
|
+
RESPONSE
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "should require a token for token exchange" do
|
23
|
+
lambda { user = @application.exchange_token }.should.raise FireEagle::ArgumentError
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "should return a FireEagle::User object when asked for a token exchange" do
|
27
|
+
@response.expects(:body).returns(@token_response)
|
28
|
+
Net::HTTP.expects(:get_response).returns(@response)
|
29
|
+
user = @application.exchange_token(1234)
|
30
|
+
user.should.be.an.instance_of FireEagle::User
|
31
|
+
end
|
32
|
+
|
33
|
+
specify "should raise an Exception for a bad token" do
|
34
|
+
@response.expects(:body).returns(@error_response)
|
35
|
+
Net::HTTP.expects(:get_response).returns(@response)
|
36
|
+
lambda { user = @application.exchange_token(666) }.should.raise FireEagle::FireEagleException
|
37
|
+
end
|
38
|
+
|
39
|
+
specify "should provide a authorization url" do
|
40
|
+
@application.authorize_url.should.equal "http://#{FireEagle::API_DOMAIN}/authorize.php?appid=foo&callback="
|
41
|
+
end
|
42
|
+
|
43
|
+
specify "should escape the callback url provided to authorize_url" do
|
44
|
+
@application.authorize_url("one two").should.equal "http://#{FireEagle::API_DOMAIN}/authorize.php?appid=foo&callback=one+two"
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
context "The FireEagle::Location class" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@location_response = <<-RESPONSE
|
7
|
+
<ResultSet version="1.0">
|
8
|
+
<Error>0</Error>
|
9
|
+
<ErrorMessage>No error</ErrorMessage>
|
10
|
+
<Locale>us_US</Locale>
|
11
|
+
<Quality>0</Quality>
|
12
|
+
<Found>1</Found>
|
13
|
+
<Result>
|
14
|
+
<updatetime> 2007-06-14T22:43:29Z</updatetime>
|
15
|
+
<quality>60</quality>
|
16
|
+
<latitude>37.872236</latitude>
|
17
|
+
<longitude>-122.244972</longitude>
|
18
|
+
<offsetlat>37.872238</offsetlat>
|
19
|
+
<offsetlon>-122.218628</offsetlon>
|
20
|
+
<radius>3200</radius>
|
21
|
+
<boundingbox>
|
22
|
+
<north>37.884701</north>
|
23
|
+
<south>37.859772</south>
|
24
|
+
<east>-122.216743</east>
|
25
|
+
<west>-122.273201</west>
|
26
|
+
</boundingbox>
|
27
|
+
<name/>
|
28
|
+
<line1/>
|
29
|
+
<line2>Berkeley, CA 94704</line2>
|
30
|
+
<line3/>
|
31
|
+
<line4>United States</line4>
|
32
|
+
<house/>
|
33
|
+
<street/>
|
34
|
+
<xstreet/>
|
35
|
+
<unittype/>
|
36
|
+
<unit/>
|
37
|
+
<postal>94704</postal>
|
38
|
+
<neighborhood/>
|
39
|
+
<city>Berkeley</city>
|
40
|
+
<county>Alameda County</county>
|
41
|
+
<state>California</state>
|
42
|
+
<country>United States</country>
|
43
|
+
<countrycode>US</countrycode>
|
44
|
+
<statecode>CA</statecode>
|
45
|
+
<countycode/>
|
46
|
+
<timezone>America/Los_Angeles</timezone>
|
47
|
+
</Result>
|
48
|
+
</ResultSet>
|
49
|
+
RESPONSE
|
50
|
+
@error_response = <<-RESPONSE
|
51
|
+
<ResultSet version="1.0">
|
52
|
+
<Error>1</Error>
|
53
|
+
<ErrorMessage>Something bad happened</ErrorMessage>
|
54
|
+
</ResultSet>
|
55
|
+
RESPONSE
|
56
|
+
end
|
57
|
+
|
58
|
+
specify "Requires all or none of :lat, :long" do
|
59
|
+
lambda { FireEagle::Location.new(:lat => 1) }.should.raise FireEagle::ArgumentError
|
60
|
+
lambda { FireEagle::Location.new(:lat => 1, :long => 2) }.should.not.raise FireEagle::ArgumentError
|
61
|
+
end
|
62
|
+
|
63
|
+
specify "Requires all or none of :mnc, :mcc, :lac, :cellid" do
|
64
|
+
lambda { FireEagle::Location.new(:mcc => 123, :lac => "whatever", :cellid => true) }.should.raise FireEagle::ArgumentError
|
65
|
+
lambda { FireEagle::Location.new(:mcc => 123, :mnc => 123123, :lac => "whatever", :cellid => true) }.should.not.raise FireEagle::ArgumentError
|
66
|
+
end
|
67
|
+
|
68
|
+
specify "Requires all or none of :street1, :street2" do
|
69
|
+
lambda { FireEagle::Location.new(:street1 => "easy street") }.should.raise FireEagle::ArgumentError
|
70
|
+
end
|
71
|
+
|
72
|
+
specify "Requires :postal or :city with :street1 and :street2" do
|
73
|
+
lambda { FireEagle::Location.new(:street1 => "easy street", :street2 => "lazy lane") }.should.raise FireEagle::ArgumentError
|
74
|
+
lambda { FireEagle::Location.new(:street1 => "easy street", :street2 => "lazy lane", :city => "anytown", :country => "US") }.should.not.raise FireEagle::ArgumentError
|
75
|
+
lambda { FireEagle::Location.new(:street1 => "easy street", :street2 => "lazy lane", :postal => 12345) }.should.not.raise FireEagle::ArgumentError
|
76
|
+
end
|
77
|
+
|
78
|
+
specify "Requires :city or :postal with :addr" do
|
79
|
+
lambda { FireEagle::Location.new(:addr => "1 easy street") }.should.raise FireEagle::ArgumentError
|
80
|
+
lambda { FireEagle::Location.new(:addr => "1 easy street", :city => "anytown", :country => "US") }.should.not.raise FireEagle::ArgumentError
|
81
|
+
lambda { FireEagle::Location.new(:addr => "1 easy street", :postal => 12345) }.should.not.raise FireEagle::ArgumentError
|
82
|
+
end
|
83
|
+
|
84
|
+
specify "Requires :state, :country, or :postal with :city" do
|
85
|
+
lambda { FireEagle::Location.new(:city => "armuchee") }.should.raise FireEagle::ArgumentError
|
86
|
+
lambda { FireEagle::Location.new(:city => "armuchee", :state => "GA") }.should.not.raise FireEagle::ArgumentError
|
87
|
+
lambda { FireEagle::Location.new(:city => "armuchee", :postal => 12345) }.should.not.raise FireEagle::ArgumentError
|
88
|
+
lambda { FireEagle::Location.new(:city => "armuchee", :country => "US") }.should.not.raise FireEagle::ArgumentError
|
89
|
+
end
|
90
|
+
|
91
|
+
specify "Requires :country with :postal if not in US" do
|
92
|
+
lambda { FireEagle::Location.new(:postal => "a49", :country => "Armenia") }.should.raise FireEagle::ArgumentError
|
93
|
+
lambda { FireEagle::Location.new(:postal => 30605, :country => "US") }.should.not.raise FireEagle::ArgumentError
|
94
|
+
lambda { FireEagle::Location.new(:postal => 30605) }.should.not.raise FireEagle::ArgumentError
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
context "The FireEagle::User class" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@f = FireEagle::Base.new(:token => "foo", :secret => "bar")
|
7
|
+
@error_response = <<-RESPONSE
|
8
|
+
<ResultSet version="1.0">
|
9
|
+
<Error>1</Error>
|
10
|
+
<ErrorMessage>Something bad happened</ErrorMessage>
|
11
|
+
</ResultSet>
|
12
|
+
RESPONSE
|
13
|
+
@token_response = <<-RESPONSE
|
14
|
+
<rsp stat="ok">
|
15
|
+
<token>1234</token>
|
16
|
+
</rsp>
|
17
|
+
RESPONSE
|
18
|
+
@location_response = <<-RESPONSE
|
19
|
+
<ResultSet version="1.0">
|
20
|
+
<Error>0</Error>
|
21
|
+
<ErrorMessage>No error</ErrorMessage>
|
22
|
+
<Locale>us_US</Locale>
|
23
|
+
<Quality>0</Quality>
|
24
|
+
<Found>1</Found>
|
25
|
+
<Result>
|
26
|
+
<updatetime> 2007-06-14T22:43:29Z</updatetime>
|
27
|
+
<quality>60</quality>
|
28
|
+
<latitude>37.872236</latitude>
|
29
|
+
<longitude>-122.244972</longitude>
|
30
|
+
<offsetlat>37.872238</offsetlat>
|
31
|
+
<offsetlon>-122.218628</offsetlon>
|
32
|
+
<radius>3200</radius>
|
33
|
+
<boundingbox>
|
34
|
+
<north>37.884701</north>
|
35
|
+
<south>37.859772</south>
|
36
|
+
<east>-122.216743</east>
|
37
|
+
<west>-122.273201</west>
|
38
|
+
</boundingbox>
|
39
|
+
<name/>
|
40
|
+
<line1/>
|
41
|
+
<line2>Berkeley, CA 94704</line2>
|
42
|
+
<line3/>
|
43
|
+
<line4>United States</line4>
|
44
|
+
<house/>
|
45
|
+
<street/>
|
46
|
+
<xstreet/>
|
47
|
+
<unittype/>
|
48
|
+
<unit/>
|
49
|
+
<postal>94704</postal>
|
50
|
+
<neighborhood/>
|
51
|
+
<city>Berkeley</city>
|
52
|
+
<county>Alameda County</county>
|
53
|
+
<state>California</state>
|
54
|
+
<country>United States</country>
|
55
|
+
<countrycode>US</countrycode>
|
56
|
+
<statecode>CA</statecode>
|
57
|
+
<countycode/>
|
58
|
+
<timezone>America/Los_Angeles</timezone>
|
59
|
+
</Result>
|
60
|
+
</ResultSet>
|
61
|
+
RESPONSE
|
62
|
+
@update_response = <<-RESPONSE
|
63
|
+
<ResultSet version="1.0">
|
64
|
+
<Error>0</Error>
|
65
|
+
<ErrorMessage>No error</ErrorMessage>
|
66
|
+
</ResultSet>
|
67
|
+
RESPONSE
|
68
|
+
@response = MockSuccess.new
|
69
|
+
@response.expects(:body).returns(@token_response)
|
70
|
+
Net::HTTP.expects(:get_response).returns(@response)
|
71
|
+
@user = @f.application.exchange_token(1234)
|
72
|
+
end
|
73
|
+
|
74
|
+
specify "should have a token accessor" do
|
75
|
+
@user.should.be.an.instance_of FireEagle::User
|
76
|
+
@user.token.should.equal "1234"
|
77
|
+
end
|
78
|
+
|
79
|
+
specify "should be able to create a new user with a token" do
|
80
|
+
@newuser = FireEagle::User.new(@f, 1234)
|
81
|
+
@newuser.token.should.be.equal "1234"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
specify "should return a FireEagle::Location class when asked for a location" do
|
86
|
+
#get the location
|
87
|
+
@response.expects(:body).returns(@location_response)
|
88
|
+
Net::HTTP.expects(:get_response).returns(@response)
|
89
|
+
@user.location.should.be.an.instance_of FireEagle::Location
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
specify "should be able to set a location" do
|
94
|
+
#set the location
|
95
|
+
@response.expects(:body).returns(@update_response)
|
96
|
+
Net::HTTP.expects(:get_response).returns(@response)
|
97
|
+
@l = FireEagle::Location.new(:country => "Belize")
|
98
|
+
@set_location = (@user.location = @l)
|
99
|
+
@set_location.should.be.an.instance_of FireEagle::Location
|
100
|
+
@set_location.should.be.equal @l
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
%w[ test/unit rubygems test/spec mocha hpricot ].each { |f|
|
2
|
+
begin
|
3
|
+
require f
|
4
|
+
rescue LoadError
|
5
|
+
abort "Unable to load required gem for test: #{f}"
|
6
|
+
end
|
7
|
+
}
|
8
|
+
|
9
|
+
require File.dirname(__FILE__) + '/../lib/fireeagle'
|
10
|
+
|
11
|
+
class MockSuccess < Net::HTTPSuccess #:nodoc: all
|
12
|
+
def initialize
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: fireeagle
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-06-21 00:00:00 -04:00
|
8
|
+
summary: Fire Eagle is a site that keeps track of your current location and helps you share it with other sites and services safely. There are hundreds of potential applications. This gem exposes the FireEagle API as Ruby Classes
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: jnewland@gmail.com
|
12
|
+
homepage: http://fireeagle.rubyforge.org
|
13
|
+
rubyforge_project: fireeagle
|
14
|
+
description: Fire Eagle is a site that keeps track of your current location and helps you share it with other sites and services safely. There are hundreds of potential applications. This gem exposes the FireEagle API as Ruby Classes
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Jesse Newland
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- License.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- lib/fireeagle.rb
|
38
|
+
- lib/fireeagle/application.rb
|
39
|
+
- lib/fireeagle/apibase.rb
|
40
|
+
- lib/fireeagle/base.rb
|
41
|
+
- lib/fireeagle/location.rb
|
42
|
+
- lib/fireeagle/user.rb
|
43
|
+
- lib/fireeagle/version.rb
|
44
|
+
- scripts/txt2html
|
45
|
+
- setup.rb
|
46
|
+
- test/test_fireeagle.rb
|
47
|
+
- test/test_fireeagle_application.rb
|
48
|
+
- test/test_fireeagle_location.rb
|
49
|
+
- test/test_fireeagle_user.rb
|
50
|
+
- test/test_helper.rb
|
51
|
+
test_files:
|
52
|
+
- test/test_fireeagle.rb
|
53
|
+
- test/test_fireeagle_application.rb
|
54
|
+
- test/test_fireeagle_location.rb
|
55
|
+
- test/test_fireeagle_user.rb
|
56
|
+
- test/test_helper.rb
|
57
|
+
rdoc_options:
|
58
|
+
- --main
|
59
|
+
- README.txt
|
60
|
+
extra_rdoc_files:
|
61
|
+
- History.txt
|
62
|
+
- License.txt
|
63
|
+
- Manifest.txt
|
64
|
+
- README.txt
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
dependencies:
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: hpricot
|
74
|
+
version_requirement:
|
75
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.5.145
|
80
|
+
version:
|