hayato1980-clitwitter 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README +0 -0
- data/README.rdoc +18 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/clitwit-get +39 -0
- data/bin/clitwit-post +23 -0
- data/clitwitter.gemspec +68 -0
- data/lib/ruby-clitwitter.rb +0 -0
- data/lib/twit.rb +44 -0
- data/spec/ruby-clitwitter_spec.rb +4 -0
- data/spec/spec_helper.rb +9 -0
- metadata +112 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Hayato
|
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
ADDED
File without changes
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= ruby-clitwitter
|
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
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Hayato. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "clitwitter"
|
8
|
+
gem.summary = %Q{command line twitter client}
|
9
|
+
gem.description = %Q{command line twitter client}
|
10
|
+
gem.email = "haya10.ito+github@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/hayato1980/ruby-clitwitter"
|
12
|
+
gem.authors = ["Hayato"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_development_dependency "pit"
|
15
|
+
gem.add_development_dependency "twitter"
|
16
|
+
gem.add_development_dependency "term-ansicolor"
|
17
|
+
gem.executables << 'clitwit-get'
|
18
|
+
gem.executables << 'clitwit-post'
|
19
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
task :spec => :check_dependencies
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
if File.exist?('VERSION')
|
44
|
+
version = File.read('VERSION')
|
45
|
+
else
|
46
|
+
version = ""
|
47
|
+
end
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "ruby-clitwitter #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.4
|
data/bin/clitwit-get
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'clitwitter'
|
3
|
+
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
require 'term/ansicolor'
|
7
|
+
class String
|
8
|
+
include Term::ANSIColor
|
9
|
+
end
|
10
|
+
|
11
|
+
include Term::ANSIColor
|
12
|
+
|
13
|
+
class Color
|
14
|
+
class << self
|
15
|
+
include Term::ANSIColor
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
twit = Clitwitter::Twit.new
|
20
|
+
loop do
|
21
|
+
begin
|
22
|
+
timeline = twit.friends_timeline({})
|
23
|
+
rescue Twitter::Unavailable
|
24
|
+
puts "Twitter Service Unavailable #{Time.now}"
|
25
|
+
timeline = []
|
26
|
+
rescue Timeout::Error
|
27
|
+
puts "Twitter Timeout #{Time.now}"
|
28
|
+
timeline = []
|
29
|
+
end
|
30
|
+
timeline.each do |s|
|
31
|
+
username = s.user.name.red
|
32
|
+
username = s.user.name.yellow if twit.close_friends.include? s.user.screen_name
|
33
|
+
text = s.text.gsub(/(@[\w]+)/, Color.green { '\1' } )
|
34
|
+
text = CGI.unescapeHTML(text)
|
35
|
+
puts "-- #{username} : #{text}"
|
36
|
+
end
|
37
|
+
sleep 180
|
38
|
+
end
|
39
|
+
|
data/bin/clitwit-post
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'clitwitter'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
message = nil
|
6
|
+
OptionParser.new {|opts|
|
7
|
+
opts.on("--mail") {|v|
|
8
|
+
require 'tmail'
|
9
|
+
message = Proc.new do
|
10
|
+
stdin = STDIN.readlines.join
|
11
|
+
mail = TMail::Mail.parse stdin
|
12
|
+
mail.body
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
opts.on("--message MESSAGE") {|v|
|
17
|
+
message = Proc.new { v }
|
18
|
+
}
|
19
|
+
opts.parse!(ARGV)
|
20
|
+
}
|
21
|
+
|
22
|
+
Clitwitter::Twit.new.post message.call
|
23
|
+
|
data/clitwitter.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{clitwitter}
|
8
|
+
s.version = "0.0.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Hayato"]
|
12
|
+
s.date = %q{2009-08-12}
|
13
|
+
s.description = %q{command line twitter client}
|
14
|
+
s.email = %q{haya10.ito+github@gmail.com}
|
15
|
+
s.executables = ["clitwit-get", "clitwit-post", "clitwit-get", "clitwit-post"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/clitwit-get",
|
30
|
+
"bin/clitwit-post",
|
31
|
+
"clitwitter.gemspec",
|
32
|
+
"lib/ruby-clitwitter.rb",
|
33
|
+
"lib/twit.rb",
|
34
|
+
"spec/ruby-clitwitter_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/hayato1980/ruby-clitwitter}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.5}
|
41
|
+
s.summary = %q{command line twitter client}
|
42
|
+
s.test_files = [
|
43
|
+
"spec/ruby-clitwitter_spec.rb",
|
44
|
+
"spec/spec_helper.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<pit>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<twitter>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<term-ansicolor>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_dependency(%q<pit>, [">= 0"])
|
59
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
60
|
+
s.add_dependency(%q<term-ansicolor>, [">= 0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
64
|
+
s.add_dependency(%q<pit>, [">= 0"])
|
65
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
66
|
+
s.add_dependency(%q<term-ansicolor>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
File without changes
|
data/lib/twit.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'twitter'
|
3
|
+
require 'pit'
|
4
|
+
|
5
|
+
module Clitwitter
|
6
|
+
class Twitter
|
7
|
+
attr_accessor :message
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@tw = Pit.get("twitter.com")
|
11
|
+
|
12
|
+
if ENV.include?('HTTP_PROXY')
|
13
|
+
host,port= ENV['HTTP_PROXY'].sub(/^http:\/\//,"").split /:/
|
14
|
+
Twitter::HTTPAuth.http_proxy( host, port)
|
15
|
+
end
|
16
|
+
|
17
|
+
client = ::Twitter::HTTPAuth.new(@tw["username"], @tw["password"])
|
18
|
+
@twitter = ::Twitter::Base.new(client)
|
19
|
+
end
|
20
|
+
|
21
|
+
def post message
|
22
|
+
@twitter.update(message)
|
23
|
+
end
|
24
|
+
|
25
|
+
def friends_timeline query
|
26
|
+
query[:since_id] = @last_id if @last_id
|
27
|
+
result = @twitter.friends_timeline(query).reverse
|
28
|
+
|
29
|
+
@last_id = result.last.id unless result.empty?
|
30
|
+
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
def close_friends
|
35
|
+
if @tw["close_friends"]
|
36
|
+
@tw["close_friends"]
|
37
|
+
else
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hayato1980-clitwitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hayato
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-12 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: pit
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: twitter
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: term-ansicolor
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description: command line twitter client
|
56
|
+
email: haya10.ito+github@gmail.com
|
57
|
+
executables:
|
58
|
+
- clitwit-get
|
59
|
+
- clitwit-post
|
60
|
+
- clitwit-get
|
61
|
+
- clitwit-post
|
62
|
+
extensions: []
|
63
|
+
|
64
|
+
extra_rdoc_files:
|
65
|
+
- LICENSE
|
66
|
+
- README
|
67
|
+
- README.rdoc
|
68
|
+
files:
|
69
|
+
- .document
|
70
|
+
- .gitignore
|
71
|
+
- LICENSE
|
72
|
+
- README
|
73
|
+
- README.rdoc
|
74
|
+
- Rakefile
|
75
|
+
- VERSION
|
76
|
+
- bin/clitwit-get
|
77
|
+
- bin/clitwit-post
|
78
|
+
- clitwitter.gemspec
|
79
|
+
- lib/ruby-clitwitter.rb
|
80
|
+
- lib/twit.rb
|
81
|
+
- spec/ruby-clitwitter_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
has_rdoc: false
|
84
|
+
homepage: http://github.com/hayato1980/ruby-clitwitter
|
85
|
+
licenses:
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- --charset=UTF-8
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: command line twitter client
|
110
|
+
test_files:
|
111
|
+
- spec/ruby-clitwitter_spec.rb
|
112
|
+
- spec/spec_helper.rb
|