tappy 1.0.3 → 1.0.4
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/README.txt +3 -0
- data/lib/tappy/filter/agent_filter.rb +14 -6
- data/lib/tappy/tappy_base.rb +1 -1
- data/lib/tappy.rb +1 -1
- metadata +2 -2
data/README.txt
CHANGED
@@ -1,20 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Tappy
|
2
4
|
class AgentFilter < Filter
|
3
5
|
def filter(response)
|
4
6
|
json = JSON.parse(response.body)
|
5
7
|
begin
|
6
8
|
if json.class == Array
|
9
|
+
filtered = []
|
10
|
+
|
7
11
|
json.each do |item|
|
8
12
|
source = item["source"]
|
9
|
-
if source.nil?
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
if !source.nil?
|
14
|
+
if source.match(options)
|
15
|
+
puts "filterer: #{item["source"]}"
|
16
|
+
else
|
17
|
+
filtered << json
|
18
|
+
end
|
13
19
|
else
|
14
|
-
puts "not filtered: #{source}"
|
20
|
+
puts "not filtered: #{source}"
|
21
|
+
return response.body
|
15
22
|
end
|
16
23
|
end
|
17
|
-
|
24
|
+
result = filtered.to_json
|
25
|
+
result
|
18
26
|
else
|
19
27
|
response.body
|
20
28
|
end
|
data/lib/tappy/tappy_base.rb
CHANGED
@@ -7,7 +7,7 @@ module Tappy
|
|
7
7
|
class TappyBase < Sinatra::Base
|
8
8
|
set :twitter_host, "http://api.twitter.com"
|
9
9
|
set :filter, "Tappy::AgentFilter"
|
10
|
-
set :filter_options, "foursquare"
|
10
|
+
set :filter_options, ENV["TAPPY_OPTIONS"] || "foursquare"
|
11
11
|
|
12
12
|
helpers do
|
13
13
|
def handle_request(url, request_params={}, params={})
|
data/lib/tappy.rb
CHANGED