twtail 0.1.2

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/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = twtail
2
+
3
+ * http://github.com/caffo/twtail/tree/master
4
+
5
+ == DESCRIPTION:
6
+
7
+ twitter tail based on search.twitter.com works perfectly with crappy
8
+ internet connections usually available at tech conferences.
9
+
10
+ == SYNOPSIS:
11
+
12
+ $ twtail
13
+
14
+ Usage: twtail [xbox+live | from:caffo | '#barcamp']
15
+
16
+ == REQUIREMENTS:
17
+
18
+ * simple-rss
19
+ * htmlentities
20
+
21
+ == INSTALL:
22
+
23
+ * gem install twtail
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2008 caffo
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,78 @@
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_development_dependency "htmlentities", ">= 4.2.1"
27
+ gem.add_development_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
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
data/bin/twtail ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
4
+ require 'twtail'
5
+
6
+ puts (Twtail.execute(ARGV[0]))
data/lib/twtail.rb ADDED
@@ -0,0 +1,60 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+
5
+ require 'rubygems'
6
+ require 'simple-rss'
7
+ require 'open-uri'
8
+ require 'time'
9
+ require 'cgi'
10
+ require 'htmlentities'
11
+
12
+ module Twtail
13
+
14
+ def self.execute(params=nil)
15
+ trap("INT") { exit }
16
+ params ? self.search(params) : self.help
17
+ end
18
+
19
+ def self.help
20
+ return("Usage: twtail [xbox+live | from:caffo | '#barcamp']")
21
+ end
22
+
23
+ def self.search(params)
24
+ begin
25
+ pointer = Time.now-86400
26
+ parameter = CGI::escape(params)
27
+ url = "http://search.twitter.com/search.atom?q=#{parameter}"
28
+ feed = SimpleRSS.parse open(url)
29
+ coder = HTMLEntities.new
30
+
31
+ puts "\033[37m==\033[0m \033[1;32m#{feed.channel.title}\033[0m \033[37m==\033[0m\n\n" unless Module.constants.include?("DEBUG")
32
+
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)
42
+ feed.items.each do |item|
43
+ next if item.published < pointer
44
+ unless Module.constants.include?("DEBUG")
45
+ puts "\033[32m#{item.author.sub(/(\w+).+\n.+/,'\1')}: \033[0m\033[37m#{coder.decode(item.title)}\033[0m"
46
+ new_items = true
47
+ end
48
+ end
49
+ rescue
50
+ end
51
+ puts "\n\n" if new_items == true
52
+ pointer = feed.items[0].published + 1
53
+ break if Module.constants.include?("DEBUG")
54
+ sleep(60)
55
+ end
56
+ rescue
57
+ puts "No data was found for this criteria. please try with other keywords."
58
+ end
59
+ end
60
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'twtail'
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "A call without parameters" do
4
+ it "should return the application usage" do
5
+ Twtail.execute(nil).should == "Usage: twtail [xbox+live | from:caffo | '#barcamp']"
6
+ end
7
+ end
8
+
9
+ describe "A call with a parameter" do
10
+ it "should display some results" do
11
+ DEBUG=true
12
+ Twtail.execute("xbox").should ==~ /xbox/
13
+ end
14
+ end
data/twtail.gemspec ADDED
@@ -0,0 +1,57 @@
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{twtail}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["rodrigo franco (caffo)"]
12
+ s.date = %q{2010-08-06}
13
+ s.default_executable = %q{twtail}
14
+ s.description = %q{twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences}
15
+ s.email = %q{caffeine@gmail.com}
16
+ s.executables = ["twtail"]
17
+ s.extra_rdoc_files = [
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "bin/twtail",
25
+ "lib/twtail.rb",
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 = [
37
+ "spec/spec_helper.rb",
38
+ "spec/twtail_spec.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<htmlentities>, [">= 4.2.1"])
47
+ s.add_development_dependency(%q<simple-rss>, [">= 1.2.2"])
48
+ else
49
+ s.add_dependency(%q<htmlentities>, [">= 4.2.1"])
50
+ s.add_dependency(%q<simple-rss>, [">= 1.2.2"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<htmlentities>, [">= 4.2.1"])
54
+ s.add_dependency(%q<simple-rss>, [">= 1.2.2"])
55
+ end
56
+ end
57
+
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twtail
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - rodrigo franco (caffo)
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-06 00:00:00 -03:00
19
+ default_executable: twtail
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: htmlentities
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 53
30
+ segments:
31
+ - 4
32
+ - 2
33
+ - 1
34
+ version: 4.2.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: simple-rss
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 27
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 2
50
+ version: 1.2.2
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences
54
+ email: caffeine@gmail.com
55
+ executables:
56
+ - twtail
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.rdoc
61
+ files:
62
+ - README.rdoc
63
+ - Rakefile
64
+ - VERSION
65
+ - bin/twtail
66
+ - lib/twtail.rb
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
69
+ - spec/twtail_spec.rb
70
+ - twtail.gemspec
71
+ has_rdoc: true
72
+ homepage: http://github.com/caffo/twtail
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options:
77
+ - --charset=UTF-8
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: twitter tail based on search.twitter.com - works perfectly with crappy internet connections usually available at tech conferences
105
+ test_files:
106
+ - spec/spec_helper.rb
107
+ - spec/twtail_spec.rb