hobostove 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86c7295b9bbe575c31eb65da98a8fe03550f6208
4
+ data.tar.gz: 931f5f3e8b558e871950dda4736c1794ddda0b22
5
+ SHA512:
6
+ metadata.gz: c604d75ce1366ba30b857da0ca58797625bfb62779db89cf0d940513fdb622fe6d15c0dc3764be4e8686ab1ce03903eefcad2fd098137731ebfea2403839db4c
7
+ data.tar.gz: ec9ecffc302cde28fc91eeca3a9459ea296520dcf39dddbc6dabe525c59325e5aae31f5e8af82f7e624fa57df4f08c0d4bfc4e15ba91e48fac636421757962e7
data/bin/hobostove CHANGED
@@ -11,15 +11,15 @@ program_desc "A command line Campfire client"
11
11
  desc "Start hobostove"
12
12
  command :start do |c|
13
13
  c.action do
14
- if Hobostove::Setup.run_setup?
15
- Hobostove::Setup.new($stdin, $stdout).run
14
+ if Hobostove::Cli::Setup.run_setup?
15
+ Hobostove::Cli::Setup.new($stdin, $stdout).run
16
16
  end
17
17
 
18
- if Hobostove::Upgrade.upgrade_config?
19
- Hobostove::Upgrade.perform
18
+ if Hobostove::Cli::Upgrade.upgrade_config?
19
+ Hobostove::Cli::Upgrade.perform
20
20
  end
21
21
 
22
- Hobostove::RoomPicker.new($stdin, $stdout).run
22
+ Hobostove::Cli::RoomPicker.new($stdin, $stdout).run
23
23
 
24
24
  Hobostove::Window.new.connect
25
25
  end
@@ -0,0 +1,34 @@
1
+ module Hobostove
2
+ module Cli
3
+ class RoomPicker
4
+ def initialize(stdin, stdout)
5
+ @stdin = stdin
6
+ @stdout = stdout
7
+ end
8
+
9
+ def run
10
+ @config = YAML.load(File.read(Hobostove::Configuration.config_file))
11
+
12
+ if @config.count == 1
13
+ Hobostove::Configuration.current_room = 0
14
+ else
15
+ pick_room
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def pick_room
22
+ @stdout.puts "Which room would you like to connect to?"
23
+
24
+ @config.each_with_index do |account, index|
25
+ @stdout.puts "#{index + 1}. #{account["subdomain"]} - #{account["room"]}"
26
+ end
27
+
28
+ room_index = @stdin.gets.chomp
29
+
30
+ Hobostove::Configuration.current_room = room_index.to_i - 1
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ module Hobostove
2
+ module Cli
3
+ class Setup
4
+ def self.run_setup?
5
+ !File.exists?(Hobostove::Configuration.config_file)
6
+ end
7
+
8
+ def initialize(stdin, stdout)
9
+ @stdin = stdin
10
+ @stdout = stdout
11
+ @settings = {}
12
+ end
13
+
14
+ def run
15
+ File.open(Hobostove::Configuration.config_file, "w") do |file|
16
+ @stdout.puts "~/.hobostove.yml not found. Running setup"
17
+ @stdout.puts "Subdomain?"
18
+ @settings["subdomain"] = @stdin.gets.chomp
19
+
20
+ @stdout.puts "Token?"
21
+ @settings["token"] = @stdin.gets.chomp
22
+
23
+ @stdout.puts "Room (full name)?"
24
+ @settings["room"] = @stdin.gets.chomp
25
+
26
+ file.write [@settings].to_yaml
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ module Hobostove
2
+ module Cli
3
+ class Upgrade
4
+ def self.upgrade_config?
5
+ !YAML.load(File.read(Hobostove::Configuration.config_file)).is_a?(Array)
6
+ end
7
+
8
+ def self.perform
9
+ settings = YAML.load(File.read(Hobostove::Configuration.config_file))
10
+ File.open(Hobostove::Configuration.config_file, "w") do |file|
11
+ file.write [settings].to_yaml
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -17,6 +17,11 @@ module Hobostove
17
17
  user = Etc.getlogin
18
18
  File.join(Dir.home(user), ".hobostove.yml")
19
19
  end
20
+
21
+ def log_file
22
+ user = Etc.getlogin
23
+ File.join(Dir.home(user), ".hobostove.log")
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -13,7 +13,7 @@ module Hobostove
13
13
  end
14
14
 
15
15
  def update_cursor
16
- Ncurses.move(Ncurses.LINES - 2, message.size + 2)
16
+ Curses.setpos(Curses.lines - 2, message.size + 2)
17
17
  end
18
18
  end
19
19
  end
@@ -0,0 +1,28 @@
1
+ module Hobostove
2
+ class MessageRenderer < Struct.new(:subdomain, :room_id, :window_size)
3
+ def render_lines(message)
4
+ message = render(message)
5
+ return [] if message.nil?
6
+ message.scan(/.{1,#{window_size}}/)
7
+ end
8
+
9
+ def render(message)
10
+ case message.type
11
+ when "TextMessage"
12
+ "#{message.username}: #{message.body}"
13
+ when "EnterMessage"
14
+ "\t#{message.username} joined"
15
+ when "LeaveMessage"
16
+ "\t#{message.username} left"
17
+ when "TimestampMessage"
18
+ "\t#{message.timestamp.strftime("%H:%M")}"
19
+ when "PasteMessage"
20
+ "#{message.username} (paste message):\n#{message.body}"
21
+ when "TweetMessage"
22
+ "#{message.username} (tweet message): #{message.body}"
23
+ when "UploadMessage"
24
+ "#{message.username} (upload message): #{message.body}"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ module Hobostove
2
+ module Models
3
+ class Message < Value.new(:id, :timestamp, :type, :user, :body)
4
+ def self.convert(tinder_message)
5
+ # Tinder explicitly sets nil for "user"
6
+ tinder_user = tinder_message.fetch("user", {}) || {}
7
+ user = User.convert(tinder_user)
8
+
9
+ new(
10
+ tinder_message["id"],
11
+ tinder_message["created_at"],
12
+ tinder_message["type"],
13
+ user,
14
+ tinder_message["body"]
15
+ )
16
+ end
17
+
18
+ def username
19
+ user.name
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Hobostove
2
+ module Models
3
+ class User < Value.new(:id, :name)
4
+ def self.convert(tinder_user)
5
+ new(
6
+ tinder_user[:id],
7
+ tinder_user[:name]
8
+ )
9
+ end
10
+
11
+ def eql?(other)
12
+ id == other.id
13
+ end
14
+
15
+ def hash
16
+ id.hash
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,10 +2,15 @@ module Hobostove
2
2
  class Panel < Struct.new(:height, :width, :starty, :startx, :options)
3
3
  def initialize(*args)
4
4
  super
5
- @win = Ncurses.newwin(height, width, starty, startx)
6
- Ncurses.box(@win, 0, 0)
7
- @panel = Ncurses::Panel.new_panel(@win)
5
+
6
+ @win = Curses::Window.new(height, width, starty, startx)
7
+ @win.box(0, 0)
8
+
9
+ Curses.refresh
10
+ @win.refresh
11
+
8
12
  @strings = []
13
+ @scroll = 0
9
14
  end
10
15
 
11
16
  def options
@@ -16,42 +21,51 @@ module Hobostove
16
21
  !options[:nowrap]
17
22
  end
18
23
 
19
- def <<(string)
24
+ def <<(string, do_update = true)
20
25
  if wrap_lines?
21
26
  @strings << string.first(width - 4)
22
27
  else
23
- word_wrap(string, width - 5).each do |line|
24
- @strings << line
25
- end
28
+ @strings << string
26
29
  end
27
30
 
31
+ refresh if do_update
32
+ end
33
+
34
+ def scroll_up
35
+ if @strings.size > printable_area + @scroll
36
+ @scroll += 1
37
+ end
28
38
  refresh
29
39
  end
30
40
 
31
- private
41
+ def scroll_down
42
+ if @scroll > 0
43
+ @scroll -= 1
44
+ end
45
+ refresh
46
+ end
47
+
48
+ def refresh!
49
+ @win.refresh
50
+ end
32
51
 
33
52
  def refresh
34
- Ncurses.werase(@win)
53
+ @win.clear
35
54
 
36
- @strings.last(height - 2).each_with_index do |string, i|
37
- @win.mvaddstr(i + 1, 2, string)
38
- end
55
+ @win.box(0, 0)
39
56
 
40
- Ncurses.box(@win, 0, 0)
57
+ @strings.last(printable_area + @scroll).first(printable_area).each_with_index do |string, i|
58
+ @win.setpos(i + 1, 2)
59
+ @win.addstr(string)
60
+ end
41
61
 
42
- Ncurses::Panel.update_panels
43
- Ncurses.doupdate
44
- Ncurses.refresh
62
+ refresh!
45
63
  end
46
64
 
47
- def word_wrap(text, line_width)
48
- text.scan(/.{1,#{line_width}}/).each_with_index.map do |line, index|
49
- if index > 0
50
- " #{line}"
51
- else
52
- line
53
- end
54
- end
65
+ private
66
+
67
+ def printable_area
68
+ height - 2
55
69
  end
56
70
  end
57
71
  end
@@ -1,15 +1,32 @@
1
1
  module Hobostove
2
2
  class UserPanel < Panel
3
- def add_user(username)
4
- @strings.push(username)
5
- @strings.sort!
6
- refresh
3
+ def initialize(*args)
4
+ super
5
+
6
+ @users = Set.new
7
+ end
8
+
9
+ def user_names
10
+ @users.map(&:name)
7
11
  end
8
12
 
9
- def remove_user(username)
10
- @strings.delete(username)
13
+ def add_user(user, do_refresh = true)
14
+ @users.add(user)
15
+
16
+ refresh if do_refresh
17
+ end
18
+
19
+ def remove_user(user, do_refresh = true)
20
+ @users.delete(user)
21
+
22
+ refresh if do_refresh
23
+ end
24
+
25
+ def refresh
26
+ @strings = @users.map(&:name)
11
27
  @strings.sort!
12
- refresh
28
+
29
+ super
13
30
  end
14
31
  end
15
32
  end
@@ -5,31 +5,38 @@ module Hobostove
5
5
  def connect
6
6
  @current_message = ""
7
7
  @running = true
8
- @user_names = []
9
8
  @messages = []
10
9
 
11
- start_ncurses
12
-
13
- load_users
14
-
15
- stream
16
-
17
- main
18
-
19
- stop_ncurses
10
+ begin
11
+ start_curses
12
+ load_users
13
+ stream
14
+ main
15
+ ensure
16
+ Hobostove.logger.debug("terminated")
17
+ stop_curses
18
+ end
20
19
  end
21
20
 
22
21
  def main
23
22
  room.join
24
23
 
25
- while @running && (ch = Ncurses.getch)
24
+ while @running && (ch = Curses.getch)
25
+ Hobostove.logger.debug("#{ch} - #{ch.chr.inspect} pressed")
26
+
26
27
  case ch
28
+ when 14 # C+n
29
+ @messages_panel.scroll_down
30
+ when 16 # C+p
31
+ @messages_panel.scroll_up
27
32
  when 10 # enter
28
33
  speak
34
+ when 21 # C-u
35
+ @current_message = ""
29
36
  when 127 # backspace
30
37
  @current_message = @current_message.first(@current_message.size - 1)
31
38
  when 9 # tab
32
- @current_message = "#{@user_names.find { |user| user =~ /^#@current_message/ }}: "
39
+ @current_message = "#{@users_panel.user_names.find { |user| user =~ /^#@current_message/ }}: "
33
40
  else
34
41
  @current_message << ch.chr
35
42
  end
@@ -53,7 +60,7 @@ module Hobostove
53
60
 
54
61
  def stream
55
62
  Thread.new do
56
- while true do
63
+ loop do
57
64
  recent = room.recent(10)
58
65
  recent.each do |message|
59
66
  next if messages.include?(message[:id])
@@ -62,26 +69,41 @@ module Hobostove
62
69
  handle_message(message)
63
70
  end
64
71
 
72
+ @messages_panel.refresh
73
+
65
74
  sleep 1
66
75
  end
67
76
  end
68
77
  end
69
78
 
70
79
  def handle_message(message)
80
+ Hobostove.logger.debug(message.inspect)
81
+ message = Models::Message.convert(message)
82
+
71
83
  case message.type
72
84
  when "TextMessage"
73
- username = user(message[:user_id])[:name]
74
- Notify.notify username, message[:body]
75
- @messages_panel << "#{username}: #{message[:body]}"
85
+ Notify.notify message.username, message.body
76
86
  when "EnterMessage"
77
- username = user(message[:user_id])[:name]
78
- @messages_panel << "\t#{username} joined"
79
- @users_panel.add_user(username)
87
+ @users_panel.add_user(message.user)
80
88
  when "LeaveMessage"
81
- username = user(message[:user_id])[:name]
82
- @messages_panel << "\t#{username} left"
83
- @users_panel.remove_user(username)
89
+ @users_panel.remove_user(message.user)
90
+ when "UploadMessage"
91
+ upload = room.send(:get, "messages/#{message.id}/upload")
92
+ Hobostove.logger.debug(upload.inspect)
93
+ message = Models::Message.new(
94
+ message.id,
95
+ message.timestamp,
96
+ message.type,
97
+ message.user,
98
+ upload.upload.full_url
99
+ )
100
+ end
101
+
102
+ message_renderer.render_lines(message).each do |line|
103
+ @messages_panel.<<(line, false)
84
104
  end
105
+ rescue => e
106
+ Hobostove.logger.fatal(e.inspect)
85
107
  end
86
108
 
87
109
  def room
@@ -90,38 +112,37 @@ module Hobostove
90
112
 
91
113
  private
92
114
 
93
- def start_ncurses
94
- Ncurses.initscr
95
- Ncurses.cbreak
96
- Ncurses.noecho
115
+ def message_renderer
116
+ @message_renderer ||=
117
+ MessageRenderer.new(Configuration.subdomain, room.id, Curses.cols - 25)
118
+ end
97
119
 
98
- @users_panel = UserPanel.new(Ncurses.LINES, 20, 0, Ncurses.COLS - 20)
99
- @messages_panel = Panel.new(Ncurses.LINES - 3, Ncurses.COLS - 20, 0, 0, :nowrap => true)
100
- @message_panel = InputPanel.new(3, Ncurses.COLS - 20, Ncurses.LINES - 3, 0)
120
+ def start_curses
121
+ Curses.init_screen
122
+ Curses.cbreak
123
+ Curses.noecho
101
124
 
102
- Ncurses::Panel.update_panels
125
+ @users_panel = UserPanel.new(Curses.lines, 20, 0, Curses.cols - 20)
126
+ @messages_panel = Panel.new(Curses.lines - 3, Curses.cols - 20, 0, 0, :nowrap => true)
127
+ @message_panel = InputPanel.new(3, Curses.cols - 20, Curses.lines - 3, 0)
103
128
 
104
- Ncurses.move(Ncurses.LINES - 2, 2)
129
+ Curses.setpos(Curses.lines - 2, 2)
105
130
 
106
- Ncurses.doupdate
107
- Ncurses.refresh
131
+ @users_panel.refresh!
132
+ @messages_panel.refresh!
133
+ @message_panel.refresh!
108
134
  end
109
135
 
110
- def stop_ncurses
111
- Ncurses.echo
112
- Ncurses.endwin
136
+ def stop_curses
137
+ Curses.echo
113
138
  end
114
139
 
115
140
  def load_users
116
141
  room.users.each do |user|
117
- @user_names << user["name"]
118
- @users_panel.add_user(user["name"])
142
+ Hobostove.logger.info user.name
143
+ @users_panel.add_user(Models::User.convert(user), false)
119
144
  end
120
- end
121
-
122
- def user(user_id)
123
- @users ||= {}
124
- @users[user_id] ||= room.user(user_id)
145
+ @users_panel.refresh
125
146
  end
126
147
 
127
148
  def campfire
data/lib/hobostove.rb CHANGED
@@ -1,15 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'tinder'
4
+ require 'active_support'
4
5
  require 'active_support/core_ext'
5
- require 'ncurses'
6
+ require 'curses'
6
7
  require 'notify'
8
+ require 'values'
9
+ require 'yaml'
10
+
11
+ require 'hobostove/models/message'
12
+ require 'hobostove/models/user'
13
+
14
+ require 'hobostove/message_renderer'
15
+
16
+ require 'hobostove/cli/setup'
17
+ require 'hobostove/cli/upgrade'
18
+ require 'hobostove/cli/room_picker'
7
19
 
8
20
  require 'hobostove/configuration'
9
21
  require 'hobostove/panel'
10
22
  require 'hobostove/input_panel'
11
23
  require 'hobostove/user_panel'
12
24
  require 'hobostove/window'
13
- require 'hobostove/setup'
14
- require 'hobostove/upgrade'
15
- require 'hobostove/room_picker'
25
+
26
+ module Hobostove
27
+ def self.logger
28
+ @logger ||= Logger.new(Configuration.log_file, 1, 1024000)
29
+ end
30
+ end
metadata CHANGED
@@ -1,126 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobostove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Eric Oestrich
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-30 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: tinder
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1.9'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '1.9'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '4.0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '4.0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: ncurses-ruby
42
+ name: notify
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '0.5'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '0.5'
62
55
  - !ruby/object:Gem::Dependency
63
- name: notify
56
+ name: gli
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: '0'
61
+ version: '2.11'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '0'
68
+ version: '2.11'
78
69
  - !ruby/object:Gem::Dependency
79
- name: gli
70
+ name: values
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
- version: '0'
75
+ version: '1.5'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
- version: '0'
82
+ version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: curses
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
94
97
  - !ruby/object:Gem::Dependency
95
98
  name: rspec
96
99
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
100
  requirements:
99
- - - ! '>='
101
+ - - ">="
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
107
  requirements:
107
- - - ! '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  - !ruby/object:Gem::Dependency
111
112
  name: fakefs
112
113
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
121
  requirements:
123
- - - ! '>='
122
+ - - ">="
124
123
  - !ruby/object:Gem::Version
125
124
  version: '0'
126
125
  description: Command line client for campfire
@@ -131,39 +130,41 @@ executables:
131
130
  extensions: []
132
131
  extra_rdoc_files: []
133
132
  files:
133
+ - bin/hobostove
134
+ - lib/hobostove.rb
135
+ - lib/hobostove/cli/room_picker.rb
136
+ - lib/hobostove/cli/setup.rb
137
+ - lib/hobostove/cli/upgrade.rb
134
138
  - lib/hobostove/configuration.rb
135
139
  - lib/hobostove/input_panel.rb
140
+ - lib/hobostove/message_renderer.rb
141
+ - lib/hobostove/models/message.rb
142
+ - lib/hobostove/models/user.rb
136
143
  - lib/hobostove/panel.rb
137
- - lib/hobostove/room_picker.rb
138
- - lib/hobostove/setup.rb
139
- - lib/hobostove/upgrade.rb
140
144
  - lib/hobostove/user_panel.rb
141
145
  - lib/hobostove/window.rb
142
- - lib/hobostove.rb
143
- - bin/hobostove
144
146
  homepage: http://github.com/oestrich/hobostove
145
147
  licenses:
146
148
  - MIT
149
+ metadata: {}
147
150
  post_install_message:
148
151
  rdoc_options: []
149
152
  require_paths:
150
153
  - lib
151
154
  required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
155
  requirements:
154
- - - ! '>='
156
+ - - ">="
155
157
  - !ruby/object:Gem::Version
156
158
  version: '0'
157
159
  required_rubygems_version: !ruby/object:Gem::Requirement
158
- none: false
159
160
  requirements:
160
- - - ! '>='
161
+ - - ">="
161
162
  - !ruby/object:Gem::Version
162
163
  version: 1.3.6
163
164
  requirements: []
164
165
  rubyforge_project:
165
- rubygems_version: 1.8.24
166
+ rubygems_version: 2.2.2
166
167
  signing_key:
167
- specification_version: 3
168
+ specification_version: 4
168
169
  summary: Command line client for campfire
169
170
  test_files: []
@@ -1,32 +0,0 @@
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
@@ -1,29 +0,0 @@
1
- module Hobostove
2
- class Setup
3
- def self.run_setup?
4
- !File.exists?(Hobostove::Configuration.config_file)
5
- end
6
-
7
- def initialize(stdin, stdout)
8
- @stdin = stdin
9
- @stdout = stdout
10
- @settings = {}
11
- end
12
-
13
- def run
14
- File.open(Hobostove::Configuration.config_file, "w") do |file|
15
- @stdout.puts "~/.hobostove.yml not found. Running setup"
16
- @stdout.puts "Subdomain?"
17
- @settings["subdomain"] = @stdin.gets.chomp
18
-
19
- @stdout.puts "Token?"
20
- @settings["token"] = @stdin.gets.chomp
21
-
22
- @stdout.puts "Room (full name)?"
23
- @settings["room"] = @stdin.gets.chomp
24
-
25
- file.write [@settings].to_yaml
26
- end
27
- end
28
- end
29
- end
@@ -1,14 +0,0 @@
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