vanity-source 0.5 → 0.6
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/CHANGELOG +2 -0
- data/lib/vanity/sources/backtweets.rb +49 -0
- data/lib/vanity/sources/github.rb +0 -2
- data/vanity-source.gemspec +1 -1
- metadata +6 -5
data/CHANGELOG
CHANGED
|
@@ -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
|
data/vanity-source.gemspec
CHANGED
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:
|
|
4
|
+
hash: 7
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: "0.
|
|
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-
|
|
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.
|
|
49
|
+
- Vanity::Source 0.6
|
|
49
50
|
- --main
|
|
50
51
|
- README.rdoc
|
|
51
52
|
- --webcvs
|