webstalker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David A. Cuadrado
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = web stalker
2
+
3
+ auto tag social people
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 David A. Cuadrado. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "webstalker"
8
+ gem.summary = %Q{auto tag social people}
9
+ gem.description = %Q{auto tag social people}
10
+ gem.email = "krawek@gmail.com"
11
+ gem.homepage = "http://github.com/dcu/webstalker"
12
+ gem.authors = ["David A. Cuadrado"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "nokogiri"
15
+ gem.add_dependency "mechanize"
16
+
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "webstalker #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/webstalker ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib/", __FILE__)
4
+ require 'webstalker'
5
+
6
+ if ARGV.size < 2
7
+ puts "Usage: #{$0} <service> <username>"
8
+ exit 1
9
+ end
10
+
11
+ service = ARGV[0]
12
+ username = ARGV[1]
13
+
14
+ puts Webstalker.tags_for(service, username).to_a.inspect
data/lib/webstalker.rb ADDED
@@ -0,0 +1,45 @@
1
+ if RUBY_VERSION < '1.9.0'
2
+ require 'rubygems'
3
+ end
4
+
5
+ require 'json'
6
+ require 'open-uri'
7
+ require 'nokogiri'
8
+ require 'set'
9
+ require 'mechanize'
10
+
11
+ require 'webstalker/base'
12
+ require 'webstalker/github'
13
+ require 'webstalker/flickr'
14
+ require 'webstalker/ohloh'
15
+ require 'webstalker/twitter'
16
+ require 'webstalker/youtube'
17
+ require 'webstalker/reddit'
18
+
19
+ module Webstalker
20
+ def self.tags_for(net, username, opts = {})
21
+ service = self.service_for(net, username, opts)
22
+ service ? service.tags : []
23
+ end
24
+
25
+ def self.service_for(net, username, opts = {})
26
+ case net.to_s
27
+ when "youtube"
28
+ Webstalker::Youtube.new(username, opts)
29
+ when "github"
30
+ Webstalker::Github.new(username, opts)
31
+ when "flickr"
32
+ Webstalker::Flickr.new(username, opts)
33
+ when "twitter"
34
+ Webstalker::Twitter.new(username, opts)
35
+ when "ohloh"
36
+ Webstalker::Ohloh.new(username, opts)
37
+ when "reddit"
38
+ Webstalker::Reddit.new(username, opts)
39
+ else
40
+ raise ArgumentError, "unknown service: #{net}"
41
+ end
42
+ end
43
+ end
44
+
45
+
@@ -0,0 +1,14 @@
1
+ module Webstalker
2
+ class Base
3
+ attr_reader :username, :options
4
+
5
+ def initialize(username, opts = {})
6
+ @username = username
7
+ @options = opts
8
+ end
9
+
10
+ def tags
11
+ []
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ module Webstalker
2
+ class Flickr < Webstalker::Base
3
+ def tags
4
+ url = "http://www.flickr.com/photos/#{username}/tags/"
5
+
6
+ doc = Nokogiri::HTML(open(url))
7
+ w=[]
8
+ doc.css("#TagCloud a").each do |link|
9
+ t = link.text.strip
10
+ if t !~ /#{Regexp.escape(username)}/
11
+ w << [link.text.strip, link.attr("style").match(/(\d+)/)[0].to_i ]
12
+ end
13
+ end
14
+ w=w.sort_by {|e| e.last*-1}
15
+
16
+ tags = Set.new(w[0,options[:limit]||3].map{|e| e.first})
17
+ if w.size > 10
18
+ 6.times do
19
+ tags << w.at(rand(w.size)).first
20
+ end
21
+ end
22
+
23
+ tags
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module Webstalker
2
+ class Github < Webstalker::Base
3
+ def tags
4
+ url = "http://github.com/api/v2/json/repos/show/#{username}"
5
+
6
+ data = JSON.parse(open(url).read)
7
+
8
+ tags = Set.new
9
+ data["repositories"].each do |repo|
10
+ langs = JSON.parse(open("http://github.com/api/v2/json/repos/show/#{repo["owner"]}/#{repo["name"]}/languages").read)
11
+ langs["languages"].each do |k,v|
12
+ tags << k.downcase
13
+ end
14
+ end
15
+
16
+ tags << "developer"
17
+
18
+ tags
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module Webstalker
2
+ class Ohloh < Webstalker::Base
3
+ def tags
4
+ url = "http://www.ohloh.net/accounts/#{username}"
5
+
6
+ doc = Nokogiri::HTML(open(url))
7
+
8
+ r=Set.new
9
+ doc.css("#page a.position").each do |link|
10
+ r<< link["href"].match(/\/p\/([^\/]+)/)[1].downcase
11
+ end
12
+
13
+ doc.css("#page th.lang.small a").each do |link|
14
+ r<< link.text.strip.downcase
15
+ end
16
+
17
+ r << "developer"
18
+
19
+ r
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module Webstalker
2
+ class Reddit < Webstalker::Base
3
+ def tags
4
+ url = "http://reddit.com/user/#{username}.json"
5
+
6
+ doc = JSON.parse(open(url).read)
7
+
8
+ r = Set.new
9
+ doc['data']['children'].each do |t|
10
+ r << t['data']['subreddit']
11
+ end
12
+
13
+ r
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Webstalker
2
+ class Twitter < Webstalker::Base
3
+ def tags
4
+ url = "http://api.twitter.com/1/favorites/#{username}.json"
5
+
6
+ doc = JSON.parse(open(url).read)
7
+
8
+ r = Set.new
9
+ doc.each do |t|
10
+ t["text"].split(/\s+/).each do |w|
11
+ if w=~/^#(.+)/
12
+ r << $1
13
+ end
14
+ end
15
+ end
16
+
17
+ r
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Webstalker
2
+ class Youtube < Webstalker::Base
3
+
4
+ end
5
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'webstalker'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Webstalker" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{webstalker}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David A. Cuadrado"]
12
+ s.date = %q{2010-10-15}
13
+ s.default_executable = %q{webstalker}
14
+ s.description = %q{auto tag social people}
15
+ s.email = %q{krawek@gmail.com}
16
+ s.executables = ["webstalker"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/webstalker",
29
+ "lib/webstalker.rb",
30
+ "lib/webstalker/base.rb",
31
+ "lib/webstalker/flickr.rb",
32
+ "lib/webstalker/github.rb",
33
+ "lib/webstalker/ohloh.rb",
34
+ "lib/webstalker/reddit.rb",
35
+ "lib/webstalker/twitter.rb",
36
+ "lib/webstalker/youtube.rb",
37
+ "spec/spec.opts",
38
+ "spec/spec_helper.rb",
39
+ "spec/webstalker_spec.rb",
40
+ "webstalker.gemspec"
41
+ ]
42
+ s.homepage = %q{http://github.com/dcu/webstalker}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{auto tag social people}
47
+ s.test_files = [
48
+ "spec/webstalker_spec.rb",
49
+ "spec/spec_helper.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
58
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
59
+ s.add_runtime_dependency(%q<mechanize>, [">= 0"])
60
+ else
61
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
62
+ s.add_dependency(%q<nokogiri>, [">= 0"])
63
+ s.add_dependency(%q<mechanize>, [">= 0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
67
+ s.add_dependency(%q<nokogiri>, [">= 0"])
68
+ s.add_dependency(%q<mechanize>, [">= 0"])
69
+ end
70
+ end
71
+
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webstalker
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - David A. Cuadrado
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-15 00:00:00 -05:00
18
+ default_executable: webstalker
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 2
31
+ - 9
32
+ version: 1.2.9
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: nokogiri
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mechanize
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :runtime
60
+ version_requirements: *id003
61
+ description: auto tag social people
62
+ email: krawek@gmail.com
63
+ executables:
64
+ - webstalker
65
+ extensions: []
66
+
67
+ extra_rdoc_files:
68
+ - LICENSE
69
+ - README.rdoc
70
+ files:
71
+ - .document
72
+ - .gitignore
73
+ - LICENSE
74
+ - README.rdoc
75
+ - Rakefile
76
+ - VERSION
77
+ - bin/webstalker
78
+ - lib/webstalker.rb
79
+ - lib/webstalker/base.rb
80
+ - lib/webstalker/flickr.rb
81
+ - lib/webstalker/github.rb
82
+ - lib/webstalker/ohloh.rb
83
+ - lib/webstalker/reddit.rb
84
+ - lib/webstalker/twitter.rb
85
+ - lib/webstalker/youtube.rb
86
+ - spec/spec.opts
87
+ - spec/spec_helper.rb
88
+ - spec/webstalker_spec.rb
89
+ - webstalker.gemspec
90
+ has_rdoc: true
91
+ homepage: http://github.com/dcu/webstalker
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.7
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: auto tag social people
122
+ test_files:
123
+ - spec/webstalker_spec.rb
124
+ - spec/spec_helper.rb