ushahidi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/ushahidi.rb CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  require "doodle"
3
3
  require "rest-client"
4
+ require "json"
4
5
 
5
6
  class Ushahidi
6
7
  class Incident < Doodle
@@ -37,6 +38,17 @@ class Ushahidi
37
38
  "latitude" => "#{latitude}"
38
39
  )
39
40
  end
41
+
42
+ def self.approve(id)
43
+ raise "No api base" unless Ushahidi.api_base
44
+
45
+ res = RestClient.post(Ushahidi.api_base, {
46
+ :task => "reports",
47
+ :incident_id => id.to_s,
48
+ :action => "approve"
49
+ })
50
+ return JSON.parse(res)
51
+ end
40
52
  end
41
53
 
42
54
  @@api_base = nil
@@ -59,4 +71,17 @@ class Ushahidi
59
71
 
60
72
  RestClient.post(@@api_base, h)
61
73
  end
74
+
75
+ def self.unapproved_report_ids
76
+ raise "No api base" unless @@api_base
77
+
78
+ res = RestClient.post(@@api_base, {
79
+ :task => "reports",
80
+ :by => "unapproved"
81
+ })
82
+
83
+ r = JSON.parse(res)
84
+
85
+ return r["payload"]["incidents"].map { |x| x["incident"]["incidentid"].to_i }
86
+ end
62
87
  end
@@ -28,6 +28,16 @@ describe "Ushahidi" do
28
28
  response = Ushahidi.post(report)
29
29
  response.code.should == 200
30
30
  end
31
+
32
+ it "can pull the IDs of unapproved reports" do
33
+ Ushahidi.api_base = ENV["USHAHIDI_API_BASE"]
34
+
35
+ ids = Ushahidi.unapproved_report_ids
36
+ ids.should be_kind_of Array
37
+ ids.each do |x|
38
+ x.should be_kind_of Integer
39
+ end
40
+ end
31
41
  end
32
42
  end
33
43
 
@@ -89,4 +99,18 @@ describe "Ushahidi::Report" do
89
99
  "location_name" => "Somewhere Center"
90
100
  }
91
101
  end
102
+
103
+ if ENV["USHAHIDI_API_BASE"]
104
+ it "can approve reports" do
105
+ Ushahidi.api_base = ENV["USHAHIDI_API_BASE"]
106
+
107
+ ids1 = Ushahidi.unapproved_report_ids
108
+
109
+ Ushahidi::Report.approve(ids1[0])
110
+
111
+ ids2 = Ushahidi.unapproved_report_ids
112
+
113
+ ids2.include?(ids1[0]).should be_false
114
+ end
115
+ end
92
116
  end
data/ushahidi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ushahidi}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kang-min Liu}]
12
- s.date = %q{2011-08-24}
12
+ s.date = %q{2011-08-25}
13
13
  s.description = %q{The ruby classes that takls to ushahidi platforms. ref: http://wiki.ushahidi.com/doku.php?id=ushahidi_api}
14
14
  s.email = %q{gugod@gugod.org}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ushahidi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kang-min Liu
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-24 00:00:00 Z
13
+ date: 2011-08-25 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: doodle
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- hash: -2787140060294318662
115
+ hash: 1465170930787972198
116
116
  segments:
117
117
  - 0
118
118
  version: "0"