PerfectlyNormal-Twitorious 0.2.5 → 0.2.6
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/TODO +6 -1
- data/bin/twit +28 -10
- data/lib/twitorious.rb +1 -1
- data/lib/twitorious/api/twitter.rb +2 -1
- data/lib/twitorious/image.rb +12 -8
- data/lib/twitorious/timeline.rb +3 -1
- data/twitorious.gemspec +2 -2
- metadata +2 -2
data/TODO
CHANGED
@@ -8,5 +8,10 @@
|
|
8
8
|
* Support other forms of notification (libnotify?)
|
9
9
|
* Configuration generation tool
|
10
10
|
* Error handling
|
11
|
+
* Configuration missing
|
11
12
|
* Daemon that runs in the background
|
12
|
-
*
|
13
|
+
* Let the app run in a loop where it constantly prompts for new tweets
|
14
|
+
* Make more of a CLI
|
15
|
+
* Update the timeline and get text-tweets in the app
|
16
|
+
* Add a user-agent string
|
17
|
+
* Open profile pages if there's a username in the tweet
|
data/bin/twit
CHANGED
@@ -2,27 +2,45 @@
|
|
2
2
|
require 'twitorious'
|
3
3
|
require 'readline'
|
4
4
|
|
5
|
+
Thread.abort_on_exception = true
|
6
|
+
|
5
7
|
module Twitorious
|
6
8
|
class Twit
|
7
9
|
def initialize
|
10
|
+
@config = Twitorious::Config.new
|
11
|
+
@timeline = Twitorious::Timeline.new(@config)
|
12
|
+
|
8
13
|
File.open(File.expand_path(File.join(%w{~ twit}))) do |f|
|
9
14
|
f.each_line do |line|
|
10
15
|
Readline::HISTORY.push(line.split("\t")[1])
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
while true
|
20
|
+
begin
|
21
|
+
status = Readline.readline("> ", true)
|
22
|
+
raise Twitorious::TooLongUpdate.new(status) if status.length > 140
|
23
|
+
|
24
|
+
cmd, args = status.split(" ")
|
25
|
+
case cmd
|
26
|
+
when "!update": update
|
27
|
+
when "!quit": exit
|
28
|
+
when "!exit": exit
|
29
|
+
else Twitorious::Update.new(status)
|
30
|
+
end
|
31
|
+
rescue Twitorious::TooLongUpdate => e
|
32
|
+
puts "Ooops, you entered more than 140 characters. #{e.message.length} to be exact."
|
33
|
+
Readline::HISTORY.push(e.message)
|
34
|
+
retry
|
35
|
+
rescue Interrupt
|
36
|
+
exit
|
37
|
+
end
|
24
38
|
end
|
25
39
|
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
@timeline.fetch_timeline
|
43
|
+
end
|
26
44
|
end
|
27
45
|
end
|
28
46
|
|
data/lib/twitorious.rb
CHANGED
data/lib/twitorious/image.rb
CHANGED
@@ -11,23 +11,27 @@ module Twitorious
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.from_url(url, store)
|
14
|
-
|
15
|
-
path = File.expand_path(
|
14
|
+
hash = Digest::MD5.hexdigest(url).to_s
|
15
|
+
path = File.expand_path(store)
|
16
|
+
file = File.join(path, hash)
|
17
|
+
site = URI.parse(url)
|
16
18
|
|
17
|
-
if
|
18
|
-
return Image.new(path)
|
19
|
-
end
|
19
|
+
return Image.new(file) if File.exists?(file)
|
20
20
|
|
21
|
-
site = URI.parse(url)
|
21
|
+
site = URI.parse(url)
|
22
22
|
res = Net::HTTP.start(site.host, site.port) do |http|
|
23
23
|
http.get(site.path)
|
24
24
|
end
|
25
|
+
puts res.class
|
26
|
+
|
27
|
+
return Image.new(File.join([path, "default.png"])) unless res.class == Net::HTTPOK
|
28
|
+
File.mkdirs(path) if !File.exists?(path)
|
25
29
|
|
26
|
-
File.open(
|
30
|
+
File.open(file, "wb+") do |f|
|
27
31
|
f.puts res.body
|
28
32
|
end
|
29
33
|
|
30
|
-
return Image.new(
|
34
|
+
return Image.new(file)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/twitorious/timeline.rb
CHANGED
@@ -7,7 +7,9 @@ module Twitorious
|
|
7
7
|
def fetch_timeline
|
8
8
|
@config.sites.each do |site|
|
9
9
|
case site[:api]
|
10
|
-
when "Twitter":
|
10
|
+
when "Twitter":
|
11
|
+
since_id = Twitorious::API::Twitter.new(@config, site).fetch_timeline
|
12
|
+
site[:since_id] = since_id if since_id
|
11
13
|
else puts "Unknown API #{site[:api]} for site #{site[:name]}"
|
12
14
|
end
|
13
15
|
end
|
data/twitorious.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "Twitorious"
|
3
|
-
s.version = "0.2.
|
4
|
-
s.date = "2009-03-
|
3
|
+
s.version = "0.2.6"
|
4
|
+
s.date = "2009-03-26"
|
5
5
|
s.author = "Per Christian B. Viken"
|
6
6
|
s.email = "perchr@northblue.org"
|
7
7
|
s.homepage = "http://eastblue.org/projects/twitorious/"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PerfectlyNormal-Twitorious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Per Christian B. Viken
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|