twtail 0.1.5 → 0.2.0
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/VERSION +1 -1
- data/lib/twtail.rb +70 -48
- data/twtail.gemspec +16 -24
- metadata +52 -71
- data/Rakefile +0 -78
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/lib/twtail.rb
CHANGED
|
@@ -8,52 +8,74 @@ require 'open-uri'
|
|
|
8
8
|
require 'time'
|
|
9
9
|
require 'cgi'
|
|
10
10
|
require 'htmlentities'
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
module Twtail
|
|
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
|
-
end
|
|
13
|
+
class << self
|
|
14
|
+
|
|
15
|
+
def execute(params=nil)
|
|
16
|
+
trap("INT") { exit }
|
|
17
|
+
params ? self.search(params) : self.help
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def help
|
|
21
|
+
return("Usage: twtail [xbox+live | from:caffo | '#barcamp' | '-spammed_keyword']")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def search(params)
|
|
25
|
+
begin
|
|
26
|
+
pointer = Time.now-86400
|
|
27
|
+
parameter = CGI::escape(params)
|
|
28
|
+
url = "http://search.twitter.com/search.atom?q=#{parameter}"
|
|
29
|
+
feed = SimpleRSS.parse open(url)
|
|
30
|
+
coder = HTMLEntities.new
|
|
31
|
+
|
|
32
|
+
puts "\033[37m==\033[0m \033[1;32m#{feed.channel.title}\033[0m \033[37m==\033[0m\n\n" unless Module.constants.include?("DEBUG")
|
|
33
|
+
if feed.items[0].published < pointer
|
|
34
|
+
puts "No items found since yesterday"
|
|
35
|
+
exit
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
while 1==1 do
|
|
39
|
+
new_items = false
|
|
40
|
+
begin
|
|
41
|
+
feed = SimpleRSS.parse open(url) rescue nil
|
|
42
|
+
feed.items.each do |item|
|
|
43
|
+
next if item.published < pointer
|
|
44
|
+
unless Module.constants.include?("DEBUG")
|
|
45
|
+
msg = colorize(37, coder.decode(item.title))
|
|
46
|
+
msg = colorize(31, msg, /(#[[\d]]?(\S+))/i)
|
|
47
|
+
msg = colorize(33, msg, /(@[[\d]]?(\S+))/i)
|
|
48
|
+
msg = colorize(34, msg, /(https?:\/\/[\S]+)/i)
|
|
49
|
+
puts "#{coder.decode(from_parser(item.author))} #{msg}"
|
|
50
|
+
new_items = true
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
rescue
|
|
54
|
+
end
|
|
55
|
+
puts "\n\n" if new_items == true
|
|
56
|
+
pointer = feed.items[0].published + 1
|
|
57
|
+
break if Module.constants.include?("DEBUG")
|
|
58
|
+
sleep(60)
|
|
59
|
+
end
|
|
60
|
+
rescue
|
|
61
|
+
"No data was found for this criteria. please try with other keywords."
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def from_parser(from)
|
|
66
|
+
from.sub!(/(\w+).+\n.+/,'\1')
|
|
67
|
+
from.gsub!(/.*(\(.*)/, "\\1")
|
|
68
|
+
from.gsub!(/\)http/, ") - http")
|
|
69
|
+
from = colorize(32, "#{from}: ")
|
|
70
|
+
colorize(4, from, /(https?:\/\/[\S]+)/i)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def colorize(color, text, regex = nil)
|
|
74
|
+
if regex.nil?
|
|
75
|
+
"\033[#{color}m#{text}\033[0m"
|
|
76
|
+
else
|
|
77
|
+
text.gsub(regex, "\033[#{color}m\\1\033[0m")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
data/twtail.gemspec
CHANGED
|
@@ -1,45 +1,37 @@
|
|
|
1
1
|
# Generated by jeweler
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name =
|
|
8
|
-
s.version = "0.
|
|
7
|
+
s.name = "twtail"
|
|
8
|
+
s.version = "0.2.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["rodrigo franco (caffo)"]
|
|
12
|
-
s.date =
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
15
|
-
s.email = %q{caffeine@gmail.com}
|
|
12
|
+
s.date = "2012-08-30"
|
|
13
|
+
s.description = "twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences"
|
|
14
|
+
s.email = "caffeine@gmail.com"
|
|
16
15
|
s.executables = ["twtail"]
|
|
17
16
|
s.extra_rdoc_files = [
|
|
18
17
|
"README.rdoc"
|
|
19
18
|
]
|
|
20
19
|
s.files = [
|
|
21
20
|
"README.rdoc",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"spec/spec.opts",
|
|
27
|
-
"spec/spec_helper.rb",
|
|
28
|
-
"spec/twtail_spec.rb",
|
|
29
|
-
"twtail.gemspec"
|
|
30
|
-
]
|
|
31
|
-
s.homepage = %q{http://github.com/caffo/twtail}
|
|
32
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
33
|
-
s.require_paths = ["lib"]
|
|
34
|
-
s.rubygems_version = %q{1.3.7}
|
|
35
|
-
s.summary = %q{twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences}
|
|
36
|
-
s.test_files = [
|
|
21
|
+
"VERSION",
|
|
22
|
+
"bin/twtail",
|
|
23
|
+
"lib/twtail.rb",
|
|
24
|
+
"spec/spec.opts",
|
|
37
25
|
"spec/spec_helper.rb",
|
|
38
|
-
|
|
26
|
+
"spec/twtail_spec.rb",
|
|
27
|
+
"twtail.gemspec"
|
|
39
28
|
]
|
|
29
|
+
s.homepage = "http://github.com/caffo/twtail"
|
|
30
|
+
s.require_paths = ["lib"]
|
|
31
|
+
s.rubygems_version = "1.8.24"
|
|
32
|
+
s.summary = "twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences"
|
|
40
33
|
|
|
41
34
|
if s.respond_to? :specification_version then
|
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
43
35
|
s.specification_version = 3
|
|
44
36
|
|
|
45
37
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
|
@@ -1,66 +1,58 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twtail
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 1
|
|
9
|
-
- 5
|
|
10
|
-
version: 0.1.5
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
prerelease:
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- rodrigo franco (caffo)
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dependencies:
|
|
21
|
-
- !ruby/object:Gem::Dependency
|
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
22
15
|
name: htmlentities
|
|
23
|
-
|
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
25
17
|
none: false
|
|
26
|
-
requirements:
|
|
27
|
-
- -
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
hash: 53
|
|
30
|
-
segments:
|
|
31
|
-
- 4
|
|
32
|
-
- 2
|
|
33
|
-
- 1
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
34
21
|
version: 4.2.1
|
|
35
22
|
type: :runtime
|
|
36
|
-
version_requirements: *id001
|
|
37
|
-
- !ruby/object:Gem::Dependency
|
|
38
|
-
name: simple-rss
|
|
39
23
|
prerelease: false
|
|
40
|
-
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 4.2.1
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: simple-rss
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
41
33
|
none: false
|
|
42
|
-
requirements:
|
|
43
|
-
- -
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
hash: 27
|
|
46
|
-
segments:
|
|
47
|
-
- 1
|
|
48
|
-
- 2
|
|
49
|
-
- 2
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
50
37
|
version: 1.2.2
|
|
51
38
|
type: :runtime
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 1.2.2
|
|
46
|
+
description: twitter tail based on search.twitter.com - works perfectly with crappy
|
|
47
|
+
internet connections usually available at tech conferences
|
|
54
48
|
email: caffeine@gmail.com
|
|
55
|
-
executables:
|
|
49
|
+
executables:
|
|
56
50
|
- twtail
|
|
57
51
|
extensions: []
|
|
58
|
-
|
|
59
|
-
extra_rdoc_files:
|
|
52
|
+
extra_rdoc_files:
|
|
60
53
|
- README.rdoc
|
|
61
|
-
files:
|
|
54
|
+
files:
|
|
62
55
|
- README.rdoc
|
|
63
|
-
- Rakefile
|
|
64
56
|
- VERSION
|
|
65
57
|
- bin/twtail
|
|
66
58
|
- lib/twtail.rb
|
|
@@ -68,40 +60,29 @@ files:
|
|
|
68
60
|
- spec/spec_helper.rb
|
|
69
61
|
- spec/twtail_spec.rb
|
|
70
62
|
- twtail.gemspec
|
|
71
|
-
has_rdoc: true
|
|
72
63
|
homepage: http://github.com/caffo/twtail
|
|
73
64
|
licenses: []
|
|
74
|
-
|
|
75
65
|
post_install_message:
|
|
76
|
-
rdoc_options:
|
|
77
|
-
|
|
78
|
-
require_paths:
|
|
66
|
+
rdoc_options: []
|
|
67
|
+
require_paths:
|
|
79
68
|
- lib
|
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
70
|
none: false
|
|
82
|
-
requirements:
|
|
83
|
-
- -
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- 0
|
|
88
|
-
version: "0"
|
|
89
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ! '>='
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
76
|
none: false
|
|
91
|
-
requirements:
|
|
92
|
-
- -
|
|
93
|
-
- !ruby/object:Gem::Version
|
|
94
|
-
|
|
95
|
-
segments:
|
|
96
|
-
- 0
|
|
97
|
-
version: "0"
|
|
77
|
+
requirements:
|
|
78
|
+
- - ! '>='
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
98
81
|
requirements: []
|
|
99
|
-
|
|
100
82
|
rubyforge_project:
|
|
101
|
-
rubygems_version: 1.
|
|
83
|
+
rubygems_version: 1.8.24
|
|
102
84
|
signing_key:
|
|
103
85
|
specification_version: 3
|
|
104
|
-
summary: twitter tail based on search.twitter.com - works perfectly with crappy internet
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- spec/twtail_spec.rb
|
|
86
|
+
summary: twitter tail based on search.twitter.com - works perfectly with crappy internet
|
|
87
|
+
connections usually available at tech conferences
|
|
88
|
+
test_files: []
|
data/Rakefile
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'spec'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
require 'rubygems'
|
|
5
|
-
require 'spec'
|
|
6
|
-
end
|
|
7
|
-
begin
|
|
8
|
-
require 'spec/rake/spectask'
|
|
9
|
-
rescue LoadError
|
|
10
|
-
puts <<-EOS
|
|
11
|
-
To use rspec for testing you must install rspec gem:
|
|
12
|
-
gem install rspec
|
|
13
|
-
EOS
|
|
14
|
-
exit(0)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
require 'jeweler'
|
|
19
|
-
Jeweler::Tasks.new do |gem|
|
|
20
|
-
gem.name = "twtail"
|
|
21
|
-
gem.summary = "twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences"
|
|
22
|
-
gem.description = "twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences"
|
|
23
|
-
gem.email = "caffeine@gmail.com"
|
|
24
|
-
gem.homepage = "http://github.com/caffo/twtail"
|
|
25
|
-
gem.authors = ["rodrigo franco (caffo)"]
|
|
26
|
-
gem.add_dependency "htmlentities", ">= 4.2.1"
|
|
27
|
-
gem.add_dependency "simple-rss", ">= 1.2.2"
|
|
28
|
-
end
|
|
29
|
-
Jeweler::GemcutterTasks.new
|
|
30
|
-
rescue LoadError
|
|
31
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
require 'rake/testtask'
|
|
35
|
-
Rake::TestTask.new(:test) do |test|
|
|
36
|
-
test.libs << 'lib' << 'test'
|
|
37
|
-
test.pattern = 'test/**/test_*.rb'
|
|
38
|
-
test.verbose = true
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
begin
|
|
42
|
-
require 'rcov/rcovtask'
|
|
43
|
-
Rcov::RcovTask.new do |test|
|
|
44
|
-
test.libs << 'test'
|
|
45
|
-
test.pattern = 'test/**/test_*.rb'
|
|
46
|
-
test.verbose = true
|
|
47
|
-
end
|
|
48
|
-
rescue LoadError
|
|
49
|
-
task :rcov do
|
|
50
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
task :test => :check_dependencies
|
|
55
|
-
|
|
56
|
-
task :default => :test
|
|
57
|
-
|
|
58
|
-
require 'rake/rdoctask'
|
|
59
|
-
Rake::RDocTask.new do |rdoc|
|
|
60
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
61
|
-
|
|
62
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
63
|
-
rdoc.title = "twtail #{version}"
|
|
64
|
-
rdoc.rdoc_files.include('README*')
|
|
65
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
desc "Run the specs under spec/models"
|
|
70
|
-
Spec::Rake::SpecTask.new do |t|
|
|
71
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
72
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
task :default do
|
|
76
|
-
puts "\nAvailable tasks: #{Rake.application.tasks.to_a.join(', ')}"
|
|
77
|
-
puts "Use rake -T for more info.\n\n"
|
|
78
|
-
end
|