bolseragency-just-giving 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -0
- data/VERSION +1 -1
- data/lib/just-giving.rb +5 -2
- data/spec/just-giving_spec.rb +2 -2
- metadata +1 -1
data/README
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
just-giving
|
2
2
|
|
3
|
+
This Gem allows you to scrape details of donations from a Just Giving page, as they do not currently provide any RSS feed foor donations
|
4
|
+
|
3
5
|
#Install the gem
|
4
6
|
gem sources -a http://gems.github.com
|
5
7
|
gem install bolseragency-just-giving
|
6
8
|
|
9
|
+
#include the library
|
10
|
+
require 'rubygems'
|
11
|
+
require 'just-giving'
|
12
|
+
|
7
13
|
#To get the donations from the just giving page http://www.justgiving.com/abac2c
|
8
14
|
donations = JustGiving::Donations.new(event_name = "abac2c")
|
9
15
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/lib/just-giving.rb
CHANGED
@@ -2,6 +2,8 @@ module JustGiving
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'hpricot'
|
4
4
|
require 'open-uri'
|
5
|
+
require 'htmlentities'
|
6
|
+
|
5
7
|
|
6
8
|
class Donations
|
7
9
|
attr_accessor :doc
|
@@ -11,11 +13,12 @@ module JustGiving
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def each
|
16
|
+
coder = HTMLEntities.new
|
14
17
|
(doc/"tr[@class='sponsorRowEven']|tr[@class='sponsorRowOdd']").each do |table_row|
|
15
|
-
name = (table_row/"td")[0].inner_html.strip
|
18
|
+
name = coder.decode((table_row/"td")[0].inner_html).strip
|
16
19
|
date = Date.strptime( (table_row/"td")[1].inner_html.strip, format = '%d/%m/%Y' )
|
17
20
|
amount = (table_row/"td")[2].inner_html.strip.gsub(/£|\$/, "").to_f
|
18
|
-
comment = (table_row/"td")[4].inner_html.strip
|
21
|
+
comment = coder.decode((table_row/"td")[4].inner_html).strip
|
19
22
|
yield({:name => name, :date => date, :amount => amount, :comment => comment})
|
20
23
|
end
|
21
24
|
end
|
data/spec/just-giving_spec.rb
CHANGED
@@ -11,6 +11,6 @@ describe "JustGiving" do
|
|
11
11
|
donations[5][:name].should eql("Laura")
|
12
12
|
donations[5][:date].to_s.should eql("2009-05-01")
|
13
13
|
donations[5][:amount].should eql(10.0)
|
14
|
-
donations[5][:comment].should eql("Good Luck team ABA!!!!")
|
14
|
+
donations[5][:comment].should eql("Good Luck team ABA!!!! ")
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|