who_is_it 0.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/.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
+ = who_is_it
2
+
3
+ Description goes here.
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 = "who_is_it"
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/who_is_it"
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 = "who_is_it #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
data/bin/whoisit ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib/", __FILE__)
4
+ require 'who_is_it'
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 WhoIsIt.tags_for(service, username).inspect
@@ -0,0 +1,14 @@
1
+ module WhoIsIt
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 WhoIsIt
2
+ class Flickr < WhoIsIt::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 WhoIsIt
2
+ class Github < WhoIsIt::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 WhoIsIt
2
+ class Ohloh < WhoIsIt::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,20 @@
1
+ module WhoIsIt
2
+ class Twitter < WhoIsIt::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 WhoIsIt
2
+ class Youtube < WhoIsIt::Base
3
+
4
+ end
5
+ end
data/lib/who_is_it.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+ require 'set'
5
+ require 'mechanize'
6
+
7
+ require 'who_is_it/base'
8
+ require 'who_is_it/github'
9
+ require 'who_is_it/flickr'
10
+ require 'who_is_it/ohloh'
11
+ require 'who_is_it/twitter'
12
+ require 'who_is_it/youtube'
13
+
14
+ module WhoIsIt
15
+ def self.tags_for(net, username, opts = {})
16
+ service = self.service_for(net, username, opts)
17
+ service ? service.tags : []
18
+ end
19
+
20
+ def self.service_for(net, username, opts = {})
21
+ case net.to_s
22
+ when "youtube"
23
+ WhoIsIt::Youtube.new(username, opts)
24
+ when "github"
25
+ WhoIsIt::Github.new(username, opts)
26
+ when "flickr"
27
+ WhoIsIt::Flickr.new(username, opts)
28
+ when "twitter"
29
+ WhoIsIt::Twitter.new(username, opts)
30
+ when "ohloh"
31
+ WhoIsIt::Ohloh.new(username, opts)
32
+ else
33
+ raise ArgumentError, "unknown service: #{net}"
34
+ end
35
+ end
36
+ end
37
+
38
+
data/lib/whoisit.rb ADDED
@@ -0,0 +1 @@
1
+ require 'who_is_it'
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 'who_is_it'
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 "WhoIsIt" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: who_is_it
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - David A. Cuadrado
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-23 00:00:00 -05:00
18
+ default_executable: whoisit
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
+ - whoisit
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
+ - bin/whoisit
77
+ - lib/who_is_it.rb
78
+ - lib/who_is_it/base.rb
79
+ - lib/who_is_it/flickr.rb
80
+ - lib/who_is_it/github.rb
81
+ - lib/who_is_it/ohloh.rb
82
+ - lib/who_is_it/twitter.rb
83
+ - lib/who_is_it/youtube.rb
84
+ - lib/whoisit.rb
85
+ - spec/spec.opts
86
+ - spec/spec_helper.rb
87
+ - spec/who_is_it_spec.rb
88
+ has_rdoc: true
89
+ homepage: http://github.com/dcu/who_is_it
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options:
94
+ - --charset=UTF-8
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.3.7
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: auto tag social people
120
+ test_files:
121
+ - spec/who_is_it_spec.rb
122
+ - spec/spec_helper.rb