hobostove 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/hobostove CHANGED
@@ -15,6 +15,12 @@ command :start do |c|
15
15
  Hobostove::Setup.new($stdin, $stdout).run
16
16
  end
17
17
 
18
+ if Hobostove::Upgrade.upgrade_config?
19
+ Hobostove::Upgrade.perform
20
+ end
21
+
22
+ Hobostove::RoomPicker.new($stdin, $stdout).run
23
+
18
24
  Hobostove::Window.new.connect
19
25
  end
20
26
  end
@@ -3,12 +3,14 @@ require 'etc'
3
3
  module Hobostove
4
4
  class Configuration
5
5
  class << self
6
+ attr_accessor :current_room
7
+
6
8
  def method_missing(method)
7
9
  config[method.to_s]
8
10
  end
9
11
 
10
12
  def config
11
- @config ||= YAML.load(File.open(config_file))
13
+ @config ||= YAML.load(File.open(config_file))[current_room]
12
14
  end
13
15
 
14
16
  def config_file
@@ -3,7 +3,9 @@ module Hobostove
3
3
  def <<(string)
4
4
  @strings = []
5
5
 
6
- super
6
+ string = string.last(width - 4)
7
+
8
+ super(string)
7
9
  end
8
10
 
9
11
  def message
@@ -0,0 +1,32 @@
1
+ module Hobostove
2
+ class RoomPicker
3
+ def initialize(stdin, stdout)
4
+ @stdin = stdin
5
+ @stdout = stdout
6
+ end
7
+
8
+ def run
9
+ @stdout.puts "Which room would you like to connect to?"
10
+
11
+ @config = YAML.load(File.read(Hobostove::Configuration.config_file))
12
+
13
+ if @config.count == 1
14
+ Hobostove::Configuration.current_room = 0
15
+ else
16
+ pick_room
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def pick_room
23
+ @config.each_with_index do |account, index|
24
+ @stdout.puts "#{index + 1}. #{account["subdomain"]} - #{account["room"]}"
25
+ end
26
+
27
+ room_index = @stdin.gets.chomp
28
+
29
+ Hobostove::Configuration.current_room = room_index.to_i - 1
30
+ end
31
+ end
32
+ end
@@ -22,7 +22,7 @@ module Hobostove
22
22
  @stdout.puts "Room (full name)?"
23
23
  @settings["room"] = @stdin.gets.chomp
24
24
 
25
- file.write @settings.to_yaml
25
+ file.write [@settings].to_yaml
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,14 @@
1
+ module Hobostove
2
+ class Upgrade
3
+ def self.upgrade_config?
4
+ !YAML.load(File.read(Hobostove::Configuration.config_file)).is_a?(Array)
5
+ end
6
+
7
+ def self.perform
8
+ settings = YAML.load(File.read(Hobostove::Configuration.config_file))
9
+ File.open(Hobostove::Configuration.config_file, "w") do |file|
10
+ file.write [settings].to_yaml
11
+ end
12
+ end
13
+ end
14
+ end
@@ -70,7 +70,9 @@ module Hobostove
70
70
  def handle_message(message)
71
71
  case message.type
72
72
  when "TextMessage"
73
- @messages_panel << "#{user(message[:user_id])[:name]}: #{message[:body]}"
73
+ username = user(message[:user_id])[:name]
74
+ Notify.notify username, message[:body]
75
+ @messages_panel << "#{username}: #{message[:body]}"
74
76
  when "EnterMessage"
75
77
  @messages_panel << "\t#{user(message[:user_id])[:name]} joined"
76
78
  when "LeaveMessage"
data/lib/hobostove.rb CHANGED
@@ -10,3 +10,5 @@ require 'hobostove/panel'
10
10
  require 'hobostove/input_panel'
11
11
  require 'hobostove/window'
12
12
  require 'hobostove/setup'
13
+ require 'hobostove/upgrade'
14
+ require 'hobostove/room_picker'
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.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tinder
@@ -134,7 +134,9 @@ files:
134
134
  - lib/hobostove/configuration.rb
135
135
  - lib/hobostove/input_panel.rb
136
136
  - lib/hobostove/panel.rb
137
+ - lib/hobostove/room_picker.rb
137
138
  - lib/hobostove/setup.rb
139
+ - lib/hobostove/upgrade.rb
138
140
  - lib/hobostove/window.rb
139
141
  - lib/hobostove.rb
140
142
  - bin/hobostove