vanity-source 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 2010-08-19 v0.6 Added Backtweet
2
+
1
3
  2010-08-19 v0.5 Added Github and Github issues
2
4
 
3
5
  2010-08-18 v0.4 Metrics that set and increment
@@ -0,0 +1,49 @@
1
+ module Vanity
2
+ module Source
3
+ # Track Twitter links using the Backtype API.
4
+ class Backtweets
5
+ include Vanity::Source
6
+
7
+ INPUTS = <<-HTML
8
+ <label>URL <input type="text" name="source[url]" size="30"></label>
9
+ HTML
10
+
11
+ def description
12
+ "Finds Tweets for any URL"
13
+ end
14
+
15
+ def display
16
+ { :inputs=>INPUTS }
17
+ end
18
+
19
+ def setup(context, params)
20
+ url = params["url"].strip
21
+ context["metric.name"] = "Tweets for #{url}"
22
+ context["metric.columns"] = [{ :id=>"tweets", :label=>"Tweets" }]
23
+ context["metric.totals"] = true
24
+ context["url"] = url
25
+ end
26
+
27
+ def validate(context)
28
+ raise "Missing URL" if context["url"].blank?
29
+ end
30
+
31
+ def update(context, webhook, &block)
32
+ Net::HTTP.start "backtweets.com" do |http|
33
+ get = Net::HTTP::Get.new("/search.json?key=#{::API["backtweet"]}&q=#{URI.escape context["url"]}")
34
+ case response = http.request(get)
35
+ when Net::HTTPOK
36
+ json = JSON.parse(response.body)
37
+ block.call :set=>{ :tweets=>json["totalresults"] }
38
+ else
39
+ raise "#{response.code}: #{response.message}"
40
+ end
41
+ end
42
+ end
43
+
44
+ def meta(context)
45
+ [ { :text=>"Search yourself", :url=>"http://backtweets.com/search?q=#{URI.escape context["url"]}" } ]
46
+ end
47
+ end
48
+ end
49
+ end
@@ -100,5 +100,3 @@ module Vanity
100
100
  end
101
101
  end
102
102
  end
103
-
104
-
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "vanity-source"
3
- spec.version = "0.5"
3
+ spec.version = "0.6"
4
4
  spec.author = "Assaf Arkin"
5
5
  spec.email = "assaf@labnotes.org"
6
6
  spec.homepage = "http://vanitydash.com"
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanity-source
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- version: "0.5"
8
+ - 6
9
+ version: "0.6"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Assaf Arkin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-19 00:00:00 -07:00
17
+ date: 2010-08-20 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -29,6 +29,7 @@ extra_rdoc_files:
29
29
  - CHANGELOG
30
30
  files:
31
31
  - lib/vanity/source.rb
32
+ - lib/vanity/sources/backtweets.rb
32
33
  - lib/vanity/sources/github.rb
33
34
  - lib/vanity/sources/github_issues.rb
34
35
  - lib/vanity/sources/ruby_gems.rb
@@ -45,7 +46,7 @@ licenses: []
45
46
  post_install_message:
46
47
  rdoc_options:
47
48
  - --title
48
- - Vanity::Source 0.5
49
+ - Vanity::Source 0.6
49
50
  - --main
50
51
  - README.rdoc
51
52
  - --webcvs