sigimera 0.0.1.rc1 → 0.0.1.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -1
- data/MIT-LICENSE +1 -1
- data/README.md +2 -0
- data/lib/sigimera/client.rb +19 -3
- data/lib/sigimera/version.rb +1 -1
- data/sigimera.gemspec +3 -2
- data/spec/api/client_spec.rb +20 -0
- data/spec/spec_helper.rb +4 -0
- metadata +18 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sigimera (0.0.1.
|
4
|
+
sigimera (0.0.1.rc2)
|
5
5
|
json
|
6
6
|
nokogiri
|
7
7
|
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.1.3)
|
12
12
|
json (1.7.5)
|
13
|
+
multi_json (1.3.7)
|
13
14
|
nokogiri (1.5.5)
|
14
15
|
rake (10.0.2)
|
15
16
|
rspec (2.12.0)
|
@@ -20,6 +21,10 @@ GEM
|
|
20
21
|
rspec-expectations (2.12.0)
|
21
22
|
diff-lcs (~> 1.1.3)
|
22
23
|
rspec-mocks (2.12.0)
|
24
|
+
simplecov (0.7.1)
|
25
|
+
multi_json (~> 1.0)
|
26
|
+
simplecov-html (~> 0.7.1)
|
27
|
+
simplecov-html (0.7.1)
|
23
28
|
spork (0.9.2)
|
24
29
|
|
25
30
|
PLATFORMS
|
@@ -29,4 +34,5 @@ DEPENDENCIES
|
|
29
34
|
rake
|
30
35
|
rspec
|
31
36
|
sigimera!
|
37
|
+
simplecov
|
32
38
|
spork
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
data/lib/sigimera/client.rb
CHANGED
@@ -19,7 +19,7 @@ module Sigimera
|
|
19
19
|
# @return [String] The first found version string of the API
|
20
20
|
def self.get_api_version
|
21
21
|
client = Sigimera::Client.new
|
22
|
-
response = client.head("/public/crises")
|
22
|
+
response = client.head("/public/crises.json")
|
23
23
|
response.get_fields("X-API-Version").first.to_s if response.key?("X-API-Version")
|
24
24
|
end
|
25
25
|
|
@@ -29,7 +29,7 @@ module Sigimera
|
|
29
29
|
# @return [Array] Returns an array of crises objects in JSON
|
30
30
|
def self.get_public_crises
|
31
31
|
client = Sigimera::Client.new
|
32
|
-
response = client.get("/public/crises")
|
32
|
+
response = client.get("/public/crises.json")
|
33
33
|
JSON.parse response.body if response
|
34
34
|
end
|
35
35
|
|
@@ -48,10 +48,26 @@ module Sigimera
|
|
48
48
|
# @param [String] type The crises type, e.g. earthquake, flood, cyclone, volcanoe
|
49
49
|
# @return [Array] Returns an array of crises objects in JSON
|
50
50
|
def get_latest_crises(type = nil)
|
51
|
-
endpoint = "/v1/crises?auth_token=#{@auth_token}"
|
51
|
+
endpoint = "/v1/crises.json?auth_token=#{@auth_token}"
|
52
52
|
endpoint += "&type=#{type}" if type
|
53
53
|
response = self.get(endpoint)
|
54
54
|
JSON.parse response.body if response
|
55
55
|
end
|
56
|
+
|
57
|
+
# This method returns statistic information about the crises.
|
58
|
+
#
|
59
|
+
# @return [Array] Returns the crises statistic as JSON object
|
60
|
+
def get_crises_stat
|
61
|
+
response = self.get("/v1/stats/crises.json?auth_token=#{@auth_token}")
|
62
|
+
JSON.parse response.body if response
|
63
|
+
end
|
64
|
+
|
65
|
+
# This method returns statistic information about user.
|
66
|
+
#
|
67
|
+
# @return [Array] Returns the user statistic as JSON object
|
68
|
+
def get_user_stat
|
69
|
+
response = self.get("/v1/stats/users.json?auth_token=#{@auth_token}")
|
70
|
+
JSON.parse response.body if response
|
71
|
+
end
|
56
72
|
end
|
57
73
|
end
|
data/lib/sigimera/version.rb
CHANGED
data/sigimera.gemspec
CHANGED
@@ -14,10 +14,11 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.require_paths = [ "lib" ]
|
16
16
|
|
17
|
-
s.
|
18
|
-
s.
|
17
|
+
s.add_runtime_dependency "json"
|
18
|
+
s.add_runtime_dependency "nokogiri" # XML Parsing
|
19
19
|
|
20
20
|
s.add_development_dependency "rake"
|
21
21
|
s.add_development_dependency "rspec"
|
22
22
|
s.add_development_dependency "spork"
|
23
|
+
s.add_development_dependency "simplecov"
|
23
24
|
end
|
data/spec/api/client_spec.rb
CHANGED
@@ -97,4 +97,24 @@ describe Sigimera::Client do
|
|
97
97
|
crisis['_id'].should_not be_empty
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
it "#get_crises_stat" do
|
102
|
+
sleep 1 # Respect the courtesy limit and wait for one second
|
103
|
+
client = Sigimera::Client.new(auth_token = @auth_token)
|
104
|
+
crises_stat = client.get_crises_stat
|
105
|
+
crises_stat['first_crisis_at'].should eql("2012-03-07T00:00:00Z")
|
106
|
+
crises_stat['total_crises'].class.should eql(Fixnum)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "#get_user_stat" do
|
110
|
+
sleep 1 # Respect the courtesy limit and wait for one second
|
111
|
+
client = Sigimera::Client.new(auth_token = @auth_token)
|
112
|
+
user_stat = client.get_user_stat
|
113
|
+
number_of_calls = user_stat['api_calls']['number_of_calls']
|
114
|
+
number_of_calls.should > 0
|
115
|
+
|
116
|
+
sleep 1 # Respect the courtesy limit and wait for one second
|
117
|
+
second_user_stat = client.get_user_stat
|
118
|
+
second_user_stat['api_calls']['number_of_calls'].should == (number_of_calls + 1)
|
119
|
+
end
|
100
120
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sigimera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.rc2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
description: This is a ruby library that encapsulates access to the Sigimera REST
|
95
111
|
API.
|
96
112
|
email:
|
@@ -129,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
145
|
version: '0'
|
130
146
|
segments:
|
131
147
|
- 0
|
132
|
-
hash:
|
148
|
+
hash: -3216827614524362085
|
133
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
150
|
none: false
|
135
151
|
requirements:
|