tappy 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -16,6 +16,9 @@ Twitter API Proxy in ruby.
16
16
 
17
17
  == USAGE:
18
18
 
19
+ * To filter twitter client "foursuqare"
20
+ ** tappy 0.0.0.0 3000 "foursuqare"
21
+
19
22
  == DEVELOPERS:
20
23
 
21
24
  * Francis Chong, francis at ignition dot hk
@@ -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
- elsif source.match(options)
11
- puts "filterer: #{item["source"]}"
12
- json.delete(item)
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
- statues.to_s
24
+ result = filtered.to_json
25
+ result
18
26
  else
19
27
  response.body
20
28
  end
@@ -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
@@ -6,5 +6,5 @@ require 'tappy/filter/filter'
6
6
  require 'tappy/filter/agent_filter'
7
7
 
8
8
  module Tappy
9
- VERSION = '1.0.3'
9
+ VERSION = '1.0.4'
10
10
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 3
9
- version: 1.0.3
8
+ - 4
9
+ version: 1.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Francis Chong