byul 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/byul.rb +73 -0
- data/lib/twitter/document.rb +14 -0
- data/lib/twitter/tag.rb +3 -0
- data/test/helper.rb +10 -0
- data/test/test_byul.rb +7 -0
- metadata +139 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 darwinian
|
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
|
+
= byul
|
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 darwinian. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "byul"
|
8
|
+
gem.summary = %Q{byul is a twitter data search library}
|
9
|
+
gem.description = %Q{twitter data search library}
|
10
|
+
gem.email = "darwinian@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/darwinian@gmail.com/byul"
|
12
|
+
gem.authors = ["darwinian"]
|
13
|
+
gem.files = FileList["[A-Z]*", "{lib,test}/**/*"]
|
14
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
|
+
gem.add_dependency("mongo", "~> 0.19.1")
|
16
|
+
gem.add_dependency("mongo_ext", "~> 0.19.1")
|
17
|
+
gem.add_dependency("mongo_mapper", "~> 0.7.2")
|
18
|
+
gem.add_dependency("acts_as_mongo_taggable", "~> 0.2.1")
|
19
|
+
# gem.executables = ["byul"]
|
20
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
+
end
|
22
|
+
Jeweler::GemcutterTasks.new
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
task :rcov do
|
43
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
task :test => :check_dependencies
|
48
|
+
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rake/rdoctask'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "byul #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/lib/byul.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mongo'
|
3
|
+
require 'mongo_mapper'
|
4
|
+
require 'twitter'
|
5
|
+
require 'acts_as_mongo_taggable'
|
6
|
+
|
7
|
+
MongoMapper.connection = Mongo::Connection.new('localhost')
|
8
|
+
MongoMapper.database = 'mydb1'
|
9
|
+
|
10
|
+
directory = File.expand_path(File.dirname(__FILE__))
|
11
|
+
require File.join(directory, "twitter", "document")
|
12
|
+
|
13
|
+
module BCG
|
14
|
+
|
15
|
+
def self.current
|
16
|
+
Twitter::Trends.current.each do |c|
|
17
|
+
BCG.search(c)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.weekly
|
22
|
+
Twitter::Trends.weekly.each do |w|
|
23
|
+
BCG.search(w)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.daily
|
28
|
+
Twitter::Trends.daily.each do |d|
|
29
|
+
BCG.search(d)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.all_with_tag(q)
|
34
|
+
Document.all_with_tag(q)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.all_tags_with_counts()
|
38
|
+
Document.all_tags_with_counts
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.most_tagged_with(q)
|
42
|
+
Document.most_tagged_with(q)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.top_25_tags
|
46
|
+
Document.top_25_tags
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.search(q=nil)
|
50
|
+
if q
|
51
|
+
begin
|
52
|
+
res = Twitter::Search.new(q.query)
|
53
|
+
res.each do |s|
|
54
|
+
t = Document.new(:twit_id => s.id, :from_user => s.from_user, :from_user_id => s.from_user_id,
|
55
|
+
:profile_image_url => s.profile_image_url, :text => s.text, :source => s.source,
|
56
|
+
:to_user_id => s.to_user_id)
|
57
|
+
t.tag(q.name, t)
|
58
|
+
t.save
|
59
|
+
end
|
60
|
+
rescue Exception => e
|
61
|
+
puts e
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
# BCG.current
|
69
|
+
# BCG.daily
|
70
|
+
# p Tag.first
|
71
|
+
# BCG.all_with_tag('#nowplaying').each do |t|
|
72
|
+
# p t.text
|
73
|
+
# end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Document
|
2
|
+
include MongoMapper::Document
|
3
|
+
include ActsAsMongoTaggable
|
4
|
+
|
5
|
+
key :twit_id, String, :unique => true
|
6
|
+
key :text, String
|
7
|
+
key :to_user_id, String
|
8
|
+
key :from_user, String
|
9
|
+
key :from_user_id, String
|
10
|
+
key :source, String
|
11
|
+
key :profile_image_url, String
|
12
|
+
key :query, String
|
13
|
+
timestamps!
|
14
|
+
end
|
data/lib/twitter/tag.rb
ADDED
data/test/helper.rb
ADDED
data/test/test_byul.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: byul
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- darwinian
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-31 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: mongo
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
- 19
|
42
|
+
- 1
|
43
|
+
version: 0.19.1
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mongo_ext
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
- 19
|
56
|
+
- 1
|
57
|
+
version: 0.19.1
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: mongo_mapper
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
- 7
|
70
|
+
- 2
|
71
|
+
version: 0.7.2
|
72
|
+
type: :runtime
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: acts_as_mongo_taggable
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
- 2
|
84
|
+
- 1
|
85
|
+
version: 0.2.1
|
86
|
+
type: :runtime
|
87
|
+
version_requirements: *id005
|
88
|
+
description: twitter data search library
|
89
|
+
email: darwinian@gmail.com
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- LICENSE
|
96
|
+
- README.rdoc
|
97
|
+
files:
|
98
|
+
- LICENSE
|
99
|
+
- README.rdoc
|
100
|
+
- Rakefile
|
101
|
+
- VERSION
|
102
|
+
- lib/byul.rb
|
103
|
+
- lib/twitter/document.rb
|
104
|
+
- lib/twitter/tag.rb
|
105
|
+
- test/helper.rb
|
106
|
+
- test/test_byul.rb
|
107
|
+
has_rdoc: true
|
108
|
+
homepage: http://github.com/darwinian@gmail.com/byul
|
109
|
+
licenses: []
|
110
|
+
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options:
|
113
|
+
- --charset=UTF-8
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
requirements: []
|
131
|
+
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.3.6
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: byul is a twitter data search library
|
137
|
+
test_files:
|
138
|
+
- test/helper.rb
|
139
|
+
- test/test_byul.rb
|