meshchat 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c964bd41eba72bdb632f46e5ea1a0f6d84b22984
4
- data.tar.gz: 3e904fa0c4f90708457a176658c473dd0f398509
3
+ metadata.gz: fca3ee7e9b96b4f3c908452a8431b30439f677af
4
+ data.tar.gz: c83a3c29a2e306b82ac9eeec85a92012001cf010
5
5
  SHA512:
6
- metadata.gz: 4929079025f53a876db2978628bccf9af4cfac2a7429e6ce365264369fc8bfea6636fcf334e987401ff38d11b9abe427de2784cded6831d43fa984107cb5231a
7
- data.tar.gz: db5b1424bfa7c9fbecaf1cdae7cbe93d63f394826a41113908f484a94c86c9c9a02fbe11f9aae30ce16610ab77159fe45c603082b5908715157f5f67c4d7bb03
6
+ metadata.gz: 18c8c043f8ac60af265de57719d76ff2bf6aea30d6474f9d9a6d6621f6a49768a646b5b2d97c4342b09203e56e98e2bd1129492c86f7bbec39c6da6cb19b3243
7
+ data.tar.gz: 1213ce77facbfb2263afd1a5b89a3288a2ded7074c05fdb3996e0631d25eaac79fe3b5435ff7d7f4c10d267aab3eec1e2b83364f9fa4985f23fa59013f74dfd7
data/lib/meshchat/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'meshchat/cli/input'
2
2
  require 'meshchat/cli/base'
3
3
  require 'meshchat/command/base'
4
+ require 'meshchat/command/chat'
4
5
  require 'meshchat/command/identity'
5
6
  require 'meshchat/command/irb'
6
7
  require 'meshchat/command/config'
@@ -19,6 +20,7 @@ require 'meshchat/command/offline'
19
20
  require 'meshchat/command/init'
20
21
  require 'meshchat/command/share'
21
22
  require 'meshchat/command/import'
23
+ require 'meshchat/command/emote'
22
24
 
23
25
 
24
26
  module MeshChat
@@ -45,7 +47,10 @@ module MeshChat
45
47
  MeshChat::Command::Base::OFFLINE => MeshChat::Command::Offline,
46
48
  MeshChat::Command::Base::HELP => MeshChat::Command::Help,
47
49
  MeshChat::Command::Base::BIND => MeshChat::Command::Bind,
48
- MeshChat::Command::Base::SEND_DISCONNECT => MeshChat::Command::SendDisconnect
50
+ MeshChat::Command::Base::SEND_DISCONNECT => MeshChat::Command::SendDisconnect,
51
+ MeshChat::Command::Base::EMOTE => MeshChat::Command::Emote,
52
+ MeshChat::Command::Base::CHAT => MeshChat::Command::Chat
53
+
49
54
  }
50
55
 
51
56
 
@@ -21,41 +21,17 @@ module MeshChat
21
21
  elsif is_whisper?(input)
22
22
  Command::Whisper
23
23
  else
24
- # TODO: maybe change this to a chat command?
25
- CLI::Input
24
+ Command::Chat
26
25
  end
27
26
 
27
+ Display.debug("INPUT: Detected '#{klass.name}' from '#{input}'")
28
28
  klass.new(input)
29
29
  end
30
-
31
30
  end
32
31
 
33
32
  def initialize(input)
34
33
  self._input = input.chomp
35
34
  end
36
-
37
- def handle
38
- return if _input.empty?
39
-
40
- servers = Node.online
41
- if !servers.empty?
42
- m = Message::Chat.new(
43
- message: _input
44
- )
45
-
46
- Display.chat m.display
47
-
48
- # if sending to all, iterate thorugh list of
49
- # servers, and send to each one
50
- # TODO: do this async so that one server doesn't block
51
- # the rest of the servers from receiving the messages
52
- servers.each do |entry|
53
- Net::Client.send(node: entry, message: m)
54
- end
55
- else
56
- Display.warning 'you have no servers'
57
- end
58
- end
59
35
  end
60
36
  end
61
37
  end
@@ -32,9 +32,11 @@ module MeshChat
32
32
  HELP = 'help'
33
33
  BIND = 'bind'
34
34
  SEND_DISCONNECT = 'senddisconnect'
35
+ EMOTE = 'me'
35
36
 
36
37
  def handle
37
38
  klass = CLI::COMMAND_MAP[command]
39
+ Display.debug("INPUT: #{klass.name} from #{command} derived from #{_input}")
38
40
  if klass
39
41
  klass.new(_input).handle
40
42
  else
@@ -44,6 +46,16 @@ module MeshChat
44
46
 
45
47
  protected
46
48
 
49
+ def corresponding_message_class
50
+ my_kind = self.class.name.demodulize
51
+ message_root_name = MeshChat::Message.name
52
+ message_class_name = "#{message_root_name}::#{my_kind}"
53
+
54
+ Display.debug("Corresponding: #{message_class_name}")
55
+
56
+ message_class_name.constantize
57
+ end
58
+
47
59
  def command_string
48
60
  @command_string ||= _input[1, _input.length]
49
61
  end
@@ -0,0 +1,30 @@
1
+ module MeshChat
2
+ class Command
3
+ class Chat < Command::Base
4
+ def handle
5
+ servers = Node.online
6
+ if !servers.empty?
7
+ m = corresponding_message_class.new(
8
+ message: _input
9
+ )
10
+
11
+ show_myself(m)
12
+
13
+ # if sending to all, iterate thorugh list of
14
+ # servers, and send to each one
15
+ # TODO: do this async so that one server doesn't block
16
+ # the rest of the servers from receiving the messages
17
+ servers.each do |entry|
18
+ Net::Client.send(node: entry, message: m)
19
+ end
20
+ else
21
+ Display.warning 'you have no servers'
22
+ end
23
+ end
24
+
25
+ def show_myself(message)
26
+ Display.chat message.display
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module MeshChat
2
+ class Command
3
+ class Emote < Command::Chat
4
+ def self.description
5
+ 'send an emote to the current chat'
6
+ end
7
+
8
+ def initialize(input)
9
+ input = input.chomp
10
+ emote_message = input.gsub(/\A\/me /, '').chomp
11
+ self._input = emote_message
12
+ end
13
+
14
+ def show_myself(message)
15
+ Display.info message.display
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -7,7 +7,9 @@ module MeshChat
7
7
 
8
8
  def handle
9
9
  MeshChat::CLI::COMMAND_MAP.each do |key, klass|
10
- Display.info "/#{key}\t\t" + klass.description
10
+ if klass.respond_to?(:description)
11
+ Display.info "/#{key}\t\t" + klass.description
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -1,12 +1,13 @@
1
1
  module MeshChat
2
2
  class Command
3
- def self.description
4
- 'runs ruby commands (useful for debugging)'
5
- end
6
3
 
7
4
  # TODO: only include this and awesome_print when booted with
8
5
  # debug=true in the config
9
6
  class IRB < Command::Base
7
+ def self.description
8
+ 'runs ruby commands (useful for debugging)'
9
+ end
10
+
10
11
  def handle
11
12
  begin
12
13
  code = command_args[1..command_args.length].join(' ')
@@ -11,6 +11,7 @@ module MeshChat
11
11
  def start(*args); current.start(*args); end
12
12
  def add_line(*args); current.add_line(*args); end
13
13
  def info(*args); current.info(*args); end
14
+ def emote(*args); current.emote(*args); end
14
15
  def warning(*args); current.warning(*args); end
15
16
  def alert(*args); current.alert(*args); end
16
17
  def success(*args); current.success(*args); end
@@ -17,6 +17,13 @@ module MeshChat
17
17
  fail 'overload this method'
18
18
  end
19
19
 
20
+
21
+ # an emote
22
+ def emote(_line)
23
+ fail 'overload this method'
24
+ end
25
+
26
+
20
27
  # server info or other ignorable information
21
28
  def info(_line)
22
29
  fail 'overload this method'
@@ -9,6 +9,7 @@ module MeshChat
9
9
  delegate :start, to: :_ui
10
10
  delegate :add_line, to: :_ui
11
11
  delegate :info, to: :_ui
12
+ delegate :emote, to: :_ui
12
13
  delegate :warning, to: :_ui
13
14
  delegate :alert, to: :_ui
14
15
  delegate :success, to: :_ui
@@ -36,6 +37,9 @@ module MeshChat
36
37
  when Message::Whisper.name
37
38
  whisper result
38
39
  Notify.show(summary: message.sender_name, body: message.message)
40
+ when Message::Emote.name
41
+ emote result
42
+ Notify.show(summary: message.sender_name, body: message.message)
39
43
  when Message::PingReply.name, Message::Ping.name
40
44
  info result
41
45
  when Message::NodeList.name,
@@ -1,5 +1,6 @@
1
1
  require 'meshchat/message/base'
2
2
  require 'meshchat/message/chat'
3
+ require 'meshchat/message/emote'
3
4
  require 'meshchat/message/ping'
4
5
  require 'meshchat/message/ping_reply'
5
6
  require 'meshchat/message/disconnect'
@@ -12,6 +13,7 @@ require 'meshchat/message/node_list_hash'
12
13
  module MeshChat
13
14
  module Message
14
15
  CHAT = 'chat'
16
+ EMOTE = 'emote'
15
17
  PING = 'ping'
16
18
  PING_REPLY = 'pingreply'
17
19
  WHISPER = 'whisper'
@@ -24,6 +26,7 @@ module MeshChat
24
26
 
25
27
  TYPES = {
26
28
  CHAT => Chat,
29
+ EMOTE => Emote,
27
30
  WHISPER => Whisper,
28
31
  DISCONNECT => Disconnect,
29
32
  PING => Ping,
@@ -7,7 +7,12 @@ module MeshChat
7
7
  name = payload['sender']['alias']
8
8
  message = payload['message']
9
9
 
10
- "#{time_recieved} #{name} > #{message}"
10
+ format_display(time_recieved, name, message)
11
+ end
12
+
13
+
14
+ def format_display(time, name, message)
15
+ "#{time} #{name} > #{message}"
11
16
  end
12
17
  end
13
18
  end
@@ -0,0 +1,9 @@
1
+ module MeshChat
2
+ module Message
3
+ class Emote < Chat
4
+ def format_display(time, name, message)
5
+ "#{time} #{name} #{message}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -77,7 +77,7 @@ module MeshChat
77
77
 
78
78
  def status_of(s)
79
79
  status s
80
- Display.debug('SERVER: ' + s)
80
+ Display.debug('SERVER: ' + s.inspect)
81
81
  body ''
82
82
  end
83
83
 
@@ -1,3 +1,3 @@
1
1
  module MeshChat
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meshchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - L. Preston Sego III
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-11 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -192,7 +192,9 @@ files:
192
192
  - lib/meshchat/cli/input.rb
193
193
  - lib/meshchat/command/base.rb
194
194
  - lib/meshchat/command/bind.rb
195
+ - lib/meshchat/command/chat.rb
195
196
  - lib/meshchat/command/config.rb
197
+ - lib/meshchat/command/emote.rb
196
198
  - lib/meshchat/command/exit.rb
197
199
  - lib/meshchat/command/help.rb
198
200
  - lib/meshchat/command/identity.rb
@@ -223,6 +225,7 @@ files:
223
225
  - lib/meshchat/message/base.rb
224
226
  - lib/meshchat/message/chat.rb
225
227
  - lib/meshchat/message/disconnect.rb
228
+ - lib/meshchat/message/emote.rb
226
229
  - lib/meshchat/message/node_list.rb
227
230
  - lib/meshchat/message/node_list_diff.rb
228
231
  - lib/meshchat/message/node_list_hash.rb
@@ -262,5 +265,5 @@ rubyforge_project:
262
265
  rubygems_version: 2.4.8
263
266
  signing_key:
264
267
  specification_version: 4
265
- summary: MeshChat-0.7.1
268
+ summary: MeshChat-0.8.0
266
269
  test_files: []