PerfectlyNormal-Twitorious 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
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
- * Make sure the directory for images is created
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
- begin
15
- status = Readline.readline("> ", true)
16
- raise Twitorious::TooLongUpdate.new(status) if status.length > 140
17
- Twitorious::Update.new(status)
18
- rescue Twitorious::TooLongUpdate => e
19
- puts "Ooops, you entered more than 140 characters. #{e.message.length} to be exact."
20
- Readline::HISTORY.push(e.message)
21
- retry
22
- rescue Interrupt
23
- exit
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
 
@@ -1,5 +1,5 @@
1
1
  module Twitorious
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
 
4
4
  class TooLongUpdate < StandardError; end
5
5
  end
@@ -39,7 +39,8 @@ module Twitorious
39
39
  sleep @config.sleep_between_notifications.to_i
40
40
  end
41
41
 
42
- @site[:since_id] = updates[0]["id"]
42
+ # Returning the last ID we saw, so we can update since_id for the site
43
+ return updates[0]["id"]
43
44
  end
44
45
  end
45
46
  end
@@ -11,23 +11,27 @@ module Twitorious
11
11
  end
12
12
 
13
13
  def self.from_url(url, store)
14
- file = Digest::MD5.hexdigest(url).to_s
15
- path = File.expand_path(File.join([store, file]))
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(File.exists?(path))
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(path, "wb+") do |f|
30
+ File.open(file, "wb+") do |f|
27
31
  f.puts res.body
28
32
  end
29
33
 
30
- return Image.new(path)
34
+ return Image.new(file)
31
35
  end
32
36
  end
33
37
  end
@@ -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": Twitorious::API::Twitter.new(@config, site).fetch_timeline
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
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Twitorious"
3
- s.version = "0.2.5"
4
- s.date = "2009-03-23"
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.5
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-23 00:00:00 -07:00
12
+ date: 2009-03-26 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency