hobostove 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,9 @@ module Hobostove
20
20
  if wrap_lines?
21
21
  @strings << string.first(width - 4)
22
22
  else
23
- @strings << string
23
+ word_wrap(string, width - 5).each do |line|
24
+ @strings << line
25
+ end
24
26
  end
25
27
 
26
28
  Ncurses.werase(@win)
@@ -35,5 +37,15 @@ module Hobostove
35
37
  Ncurses.doupdate
36
38
  Ncurses.refresh
37
39
  end
40
+
41
+ def word_wrap(text, line_width)
42
+ text.scan(/.{1,#{line_width}}/).each_with_index.map do |line, index|
43
+ if index > 0
44
+ " #{line}"
45
+ else
46
+ line
47
+ end
48
+ end
49
+ end
38
50
  end
39
51
  end
@@ -5,7 +5,7 @@ module Hobostove
5
5
  def connect
6
6
  @current_message = ""
7
7
  @running = true
8
- @users = []
8
+ @user_names = []
9
9
  @messages = []
10
10
 
11
11
  start_ncurses
@@ -27,7 +27,7 @@ module Hobostove
27
27
  when 127 # backspace
28
28
  @current_message = @current_message.first(@current_message.size - 1)
29
29
  when 9 # tab
30
- @current_message = "#{@users.find { |user| user =~ /^#@current_message/ }}: "
30
+ @current_message = "#{@user_names.find { |user| user =~ /^#@current_message/ }}: "
31
31
  else
32
32
  @current_message << ch.chr
33
33
  end
@@ -50,16 +50,16 @@ module Hobostove
50
50
  def stream
51
51
  Thread.new do
52
52
  while true do
53
- transcript = room.transcript(Date.today)
54
- transcript.each do |message|
55
- next unless message[:message]
53
+ recent = room.recent(10)
54
+ recent.each do |message|
55
+ next unless message[:body]
56
56
  next if messages.include?(message[:id])
57
57
  messages << message[:id]
58
- message = "#{user(message[:user_id])[:name]}: #{message[:message]}"
58
+ message = "#{user(message[:user_id])[:name]}: #{message[:body]}"
59
59
  @messages_panel << message
60
60
  end
61
61
 
62
- sleep 3
62
+ sleep 1
63
63
  end
64
64
  end
65
65
  end
@@ -94,7 +94,7 @@ module Hobostove
94
94
 
95
95
  def load_users
96
96
  room.users.each do |user|
97
- @users << user["name"]
97
+ @user_names << user["name"]
98
98
  @users_panel << user["name"]
99
99
  end
100
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobostove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: