tappy 1.0.0 → 1.0.1

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/bin/tappy CHANGED
@@ -1,8 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
3
4
  require 'tappy'
4
5
 
5
- host = ARGV[1] resuce "localhost"
6
- port = ARGV[2].to_i rescue 9090
6
+ host = ARGV[0] || "localhost"
7
+ port = ARGV[1].to_i
8
+ port = 9090 if port == 0
9
+ filter_option = ARGV[2] || "foursquare"
7
10
 
8
- Tappy::TappyBase.run! :host => host, :port => :port
11
+ module Tappy
12
+ class MyTappy < TappyBase
13
+ set :twitter_host, "http://api.twitter.com"
14
+ set :filter, "Tappy::AgentFilter"
15
+ set :filter_options, filter_option
16
+ end
17
+ end
18
+
19
+ puts "Start Tappy server on #{host}:#{port}, options: #{filter_option}"
20
+
21
+ Tappy::TappyBase.run! :host => host, :port => port
@@ -2,15 +2,23 @@ module Tappy
2
2
  class AgentFilter < Filter
3
3
  def filter(response)
4
4
  json = JSON.parse(response.body)
5
- statues = json["statues"]
6
- if statues
7
- statues.each do |item|
8
- if item["source"].match(options)
9
- statues.delete(item)
5
+ begin
6
+ if json.class == Array
7
+ json.each do |item|
8
+ source = item["source"]
9
+ if source.nil?
10
+ elsif source.match(options)
11
+ puts "filterer: #{item["source"]}"
12
+ json.delete(item)
13
+ else
14
+ puts "not filtered: #{source}"
15
+ end
10
16
  end
17
+ statues.to_s
18
+ else
19
+ response.body
11
20
  end
12
- statues.to_s
13
- else
21
+ rescue
14
22
  response.body
15
23
  end
16
24
  end
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.0'
9
+ VERSION = '1.0.1'
10
10
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Francis Chong