-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathRakefile
71 lines (64 loc) · 3.36 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'rake'
require 'rake/testtask'
require 'date'
test_files_pattern = 'test/rails_root/test/{unit,functional,other}/**/*_test.rb'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = test_files_pattern
t.verbose = false
end
desc "Run the test suite"
task :default => :test
spec = Gem::Specification.new do |s|
s.name = "twitter-search"
s.summary = "Ruby client for Twitter Search."
s.email = "[email protected]"
s.homepage = "http://github.com/dancroak/twitter-search"
s.description = "Ruby client for Twitter Search."
s.authors = ["Dustin Sallings", "Dan Croak"]
s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
s.add_dependency('json', '>= 1.1.2')
end
begin
require 'rubygems'
require 'jeweler'
Jeweler.gemspec = spec
rescue LoadError
puts "Jeweler not available. sudo gem install technicalpickles-jeweler --source=http://gems.github.com"
end
require File.expand_path('lib/twitter_search', File.dirname(__FILE__))
require 'rubygems'
require 'yaml'
namespace :yaml do
desc "Write Twitter Search results to yaml file so API is not hit every test."
task :write do
write_yaml :tweets => 'Obama', :file => 'obama'
write_yaml :tweets => 'twitter search', :file => 'twitter_search'
write_yaml :tweets => {:q => 'twitter search'}, :file => 'twitter_search_and'
write_yaml :tweets => {:q => '"happy hour"'}, :file => 'happy_hour_exact'
write_yaml :tweets => {:q => 'obama OR hillary'}, :file => 'obama_or_hillary'
write_yaml :tweets => {:q => 'beer -root'}, :file => 'beer_minus_root'
write_yaml :tweets => {:q => '#haiku'}, :file => 'hashtag_haiku'
write_yaml :tweets => {:q => 'from:alexiskold'}, :file => 'from_alexiskold'
write_yaml :tweets => {:q => 'to:techcrunch'}, :file => 'to_techcrunch'
write_yaml :tweets => {:q => '@mashable'}, :file => 'reference_mashable'
write_yaml :tweets => {:q => '"happy hour" near:"san francisco"'}, :file => 'happy_hour_near_sf'
write_yaml :tweets => {:q => 'near:NYC within:15mi'}, :file => 'within_15mi_nyc'
write_yaml :tweets => {:q => 'superhero since:2008-05-01'}, :file => 'superhero_since'
write_yaml :tweets => {:q => 'ftw until:2008-05-03'}, :file => 'ftw_until'
write_yaml :tweets => {:q => 'movie -scary :)'}, :file => 'movie_positive_tude'
write_yaml :tweets => {:q => 'flight :('}, :file => 'flight_negative_tude'
write_yaml :tweets => {:q => 'traffic ?'}, :file => 'traffic_question'
write_yaml :tweets => {:q => 'hilarious filter:links'}, :file => 'hilarious_links'
write_yaml :tweets => {:q => 'congratulations', :lang => 'en'}, :file => 'english'
write_yaml :tweets => {:q => 'با', :lang => 'ar'}, :file => 'arabic'
write_yaml :tweets => {:q => 'Boston Celtics', :rpp => '30'}, :file => 'results_per_page'
end
end
def write_yaml(opts = {})
@client = TwitterSearch::Client.new 'twitter-search'
tweets = @client.query(opts[:tweets])
File.open(File.join(File.dirname(__FILE__), 'test', 'yaml', "#{opts[:file]}.yaml"), 'w+') do |file|
file.puts tweets.to_yaml
end
end