meshchat 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/meshchat.rb +2 -1
- data/lib/meshchat/cli.rb +45 -50
- data/lib/meshchat/cli/base.rb +13 -0
- data/lib/meshchat/cli/input.rb +2 -2
- data/lib/meshchat/{cli/command.rb → command/base.rb} +2 -2
- data/lib/meshchat/{cli → command}/config.rb +2 -2
- data/lib/meshchat/{cli → command}/exit.rb +2 -2
- data/lib/meshchat/{cli → command}/identity.rb +2 -2
- data/lib/meshchat/{cli → command}/import.rb +2 -2
- data/lib/meshchat/{cli → command}/init.rb +2 -2
- data/lib/meshchat/{cli → command}/irb.rb +2 -2
- data/lib/meshchat/{cli → command}/listen.rb +2 -2
- data/lib/meshchat/{cli → command}/ping.rb +2 -2
- data/lib/meshchat/{cli → command}/ping_all.rb +2 -2
- data/lib/meshchat/{cli → command}/server.rb +2 -2
- data/lib/meshchat/{cli → command}/share.rb +2 -2
- data/lib/meshchat/{cli → command}/stop_listening.rb +2 -2
- data/lib/meshchat/{cli → command}/whisper.rb +2 -2
- data/lib/meshchat/{cli → command}/who.rb +2 -2
- data/lib/meshchat/instance.rb +7 -1
- data/lib/meshchat/version.rb +1 -1
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d133b88895ed07267fb0e6b02806c2ebe998ce59
|
4
|
+
data.tar.gz: b01e8f93f830e3ecc211ff165947479319fd600b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e2789b1f3ad8d44cfba19a8e736f330e78564743530909c94aa036d5b381749775036754f72af6a40bde5b2ff2856be051d61521230a05346ddfae7c0f0b86
|
7
|
+
data.tar.gz: d6678a4ff966e8e5de7a73057f109e8a41badb5baf12387a13b5190ea083221514cf0619915e3d4302a960b803c515b13853c31b19f4418dd675c8d3d0100008
|
data/README.md
CHANGED
@@ -5,3 +5,15 @@ This is the core functionality for implementing a [mesh-chat](https://github.com
|
|
5
5
|
#Usage
|
6
6
|
|
7
7
|
See [Spiced Gracken](https://github.com/NullVoxPopuli/spiced_gracken)
|
8
|
+
|
9
|
+
For now, all that needs to be implemented is the Display.
|
10
|
+
Take a look at `Display::Base` to see what you need to override.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
MeshChat.start(
|
14
|
+
client_name: NAME, # name of your client
|
15
|
+
client_version: VERSION, # version of your client
|
16
|
+
display: ui, # your class of your implementation of `Display::Base`
|
17
|
+
on_display_start: ->{ MeshChat::CLI.check_startup_settings } # optional
|
18
|
+
)
|
19
|
+
```
|
data/lib/meshchat.rb
CHANGED
data/lib/meshchat/cli.rb
CHANGED
@@ -1,44 +1,48 @@
|
|
1
1
|
require 'meshchat/cli/input'
|
2
|
-
require 'meshchat/cli/
|
3
|
-
require 'meshchat/
|
4
|
-
require 'meshchat/
|
5
|
-
require 'meshchat/
|
6
|
-
require 'meshchat/
|
7
|
-
require 'meshchat/
|
8
|
-
require 'meshchat/
|
9
|
-
require 'meshchat/
|
10
|
-
require 'meshchat/
|
11
|
-
require 'meshchat/
|
12
|
-
require 'meshchat/
|
13
|
-
require 'meshchat/
|
14
|
-
require 'meshchat/
|
15
|
-
require 'meshchat/
|
16
|
-
require 'meshchat/
|
2
|
+
require 'meshchat/cli/base'
|
3
|
+
require 'meshchat/command/base'
|
4
|
+
require 'meshchat/command/identity'
|
5
|
+
require 'meshchat/command/irb'
|
6
|
+
require 'meshchat/command/config'
|
7
|
+
require 'meshchat/command/ping'
|
8
|
+
require 'meshchat/command/ping_all'
|
9
|
+
require 'meshchat/command/server'
|
10
|
+
require 'meshchat/command/whisper'
|
11
|
+
require 'meshchat/command/exit'
|
12
|
+
require 'meshchat/command/listen'
|
13
|
+
require 'meshchat/command/stop_listening'
|
14
|
+
require 'meshchat/command/who'
|
15
|
+
require 'meshchat/command/init'
|
16
|
+
require 'meshchat/command/share'
|
17
|
+
require 'meshchat/command/import'
|
18
|
+
|
17
19
|
|
18
20
|
module MeshChat
|
19
21
|
# A user interface is responsible for for creating a client
|
20
22
|
# and sending messages to that client
|
21
23
|
class CLI
|
22
24
|
COMMAND_MAP = {
|
23
|
-
Command::CONFIG =>
|
24
|
-
Command::PING =>
|
25
|
-
Command::PING_ALL =>
|
26
|
-
Command::STOP_LISTENING =>
|
27
|
-
Command::SERVERS =>
|
28
|
-
Command::SERVER =>
|
29
|
-
Command::EXIT =>
|
30
|
-
Command::QUIT =>
|
31
|
-
Command::LISTEN =>
|
32
|
-
Command::WHO =>
|
33
|
-
Command::IDENTITY =>
|
34
|
-
Command::IRB =>
|
35
|
-
Command::INIT =>
|
36
|
-
Command::SHARE =>
|
37
|
-
Command::IMPORT =>
|
38
|
-
Command::EXPORT =>
|
25
|
+
MeshChat::Command::Base::CONFIG => MeshChat::Command::Config,
|
26
|
+
MeshChat::Command::Base::PING => MeshChat::Command::Ping,
|
27
|
+
MeshChat::Command::Base::PING_ALL => MeshChat::Command::PingAll,
|
28
|
+
MeshChat::Command::Base::STOP_LISTENING => MeshChat::Command::StopListening,
|
29
|
+
MeshChat::Command::Base::SERVERS => MeshChat::Command::Server,
|
30
|
+
MeshChat::Command::Base::SERVER => MeshChat::Command::Server,
|
31
|
+
MeshChat::Command::Base::EXIT => MeshChat::Command::Exit,
|
32
|
+
MeshChat::Command::Base::QUIT => MeshChat::Command::Exit,
|
33
|
+
MeshChat::Command::Base::LISTEN => MeshChat::Command::Listen,
|
34
|
+
MeshChat::Command::Base::WHO => MeshChat::Command::Who,
|
35
|
+
MeshChat::Command::Base::IDENTITY => MeshChat::Command::Identity,
|
36
|
+
MeshChat::Command::Base::IRB => MeshChat::Command::IRB,
|
37
|
+
MeshChat::Command::Base::INIT => MeshChat::Command::Init,
|
38
|
+
MeshChat::Command::Base::SHARE => MeshChat::Command::Share,
|
39
|
+
MeshChat::Command::Base::IMPORT => MeshChat::Command::Import,
|
40
|
+
MeshChat::Command::Base::EXPORT => MeshChat::Command::Share
|
39
41
|
}
|
40
42
|
|
41
43
|
|
44
|
+
attr_accessor :_input_device
|
45
|
+
|
42
46
|
class << self
|
43
47
|
|
44
48
|
delegate :server_location, :listen_for_commands,
|
@@ -46,25 +50,21 @@ module MeshChat
|
|
46
50
|
:check_startup_settings, :create_input, :close_server,
|
47
51
|
to: :instance
|
48
52
|
|
49
|
-
def
|
50
|
-
@instance
|
53
|
+
def create(input_klass)
|
54
|
+
@instance = new(input_klass)
|
51
55
|
end
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
aliases = MeshChat::Node.all.map{ |n| "#{n.alias_name}" }
|
57
|
-
commands + aliases
|
57
|
+
def instance
|
58
|
+
# default input collector
|
59
|
+
@instance ||= new
|
58
60
|
end
|
59
|
-
|
60
61
|
end
|
61
62
|
|
62
63
|
|
63
|
-
def initialize
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
def initialize(input_klass = nil)
|
65
|
+
input_klass ||= MeshChat::CLI::Base
|
66
|
+
# instantiate the interface with which we are communicated with
|
67
|
+
self._input_device = input_klass.new
|
68
68
|
# this will allow our listener / server to print exceptions,
|
69
69
|
# rather than silently fail
|
70
70
|
Thread.abort_on_exception = true
|
@@ -75,7 +75,7 @@ module MeshChat
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def process_input
|
78
|
-
msg = get_input
|
78
|
+
msg = _input_device.get_input
|
79
79
|
create_input(msg)
|
80
80
|
rescue SystemExit, Interrupt
|
81
81
|
close_program
|
@@ -94,11 +94,6 @@ module MeshChat
|
|
94
94
|
Display.error e.backtrace.join("\n").colorize(:red)
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
def get_input
|
99
|
-
Readline.readline('> ', true)
|
100
|
-
end
|
101
|
-
|
102
97
|
def start_server
|
103
98
|
|
104
99
|
unless Settings.valid?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module MeshChat
|
2
|
+
class CLI
|
3
|
+
class Base
|
4
|
+
# override this to alter how input is gathered
|
5
|
+
#
|
6
|
+
# the returned value of this method should be a whole line / command
|
7
|
+
# that will be passed to MeshChat::CLI.create_input
|
8
|
+
def get_input
|
9
|
+
gets
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/meshchat/cli/input.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module MeshChat
|
2
|
-
class
|
2
|
+
class Command
|
3
3
|
# TODO: only include this and awesome_print when booted with
|
4
4
|
# debug=true in the config
|
5
|
-
class IRB <
|
5
|
+
class IRB < Command::Base
|
6
6
|
def handle
|
7
7
|
begin
|
8
8
|
code = command_args[1..command_args.length].join(' ')
|
data/lib/meshchat/instance.rb
CHANGED
@@ -9,6 +9,7 @@ module MeshChat
|
|
9
9
|
def start(options)
|
10
10
|
# calling instance to get things going
|
11
11
|
@instance = new(options)
|
12
|
+
@instance.start_input_device(options[:input])
|
12
13
|
@instance.start_ui(options[:display], options[:on_display_start])
|
13
14
|
end
|
14
15
|
|
@@ -22,7 +23,7 @@ module MeshChat
|
|
22
23
|
self.client_version = options[:client_version] || MeshChat::VERSION
|
23
24
|
end
|
24
25
|
|
25
|
-
# @param [
|
26
|
+
# @param [Class] klass should be something that implements Display::Base
|
26
27
|
# @param [Proc] proc what to do when starting the UI
|
27
28
|
def start_ui(klass, on_display_start)
|
28
29
|
self.display = Display::Manager.new(klass)
|
@@ -30,5 +31,10 @@ module MeshChat
|
|
30
31
|
on_display_start.call if on_display_start
|
31
32
|
end
|
32
33
|
end
|
34
|
+
|
35
|
+
def start_input_device(klass)
|
36
|
+
# The CLI is a singleton that takes a method of input
|
37
|
+
MeshChat::CLI.create(klass)
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
data/lib/meshchat/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.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: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -216,22 +216,23 @@ files:
|
|
216
216
|
- README.md
|
217
217
|
- lib/meshchat.rb
|
218
218
|
- lib/meshchat/cli.rb
|
219
|
-
- lib/meshchat/cli/
|
220
|
-
- lib/meshchat/cli/config.rb
|
221
|
-
- lib/meshchat/cli/exit.rb
|
222
|
-
- lib/meshchat/cli/identity.rb
|
223
|
-
- lib/meshchat/cli/import.rb
|
224
|
-
- lib/meshchat/cli/init.rb
|
219
|
+
- lib/meshchat/cli/base.rb
|
225
220
|
- lib/meshchat/cli/input.rb
|
226
|
-
- lib/meshchat/
|
227
|
-
- lib/meshchat/
|
228
|
-
- lib/meshchat/
|
229
|
-
- lib/meshchat/
|
230
|
-
- lib/meshchat/
|
231
|
-
- lib/meshchat/
|
232
|
-
- lib/meshchat/
|
233
|
-
- lib/meshchat/
|
234
|
-
- lib/meshchat/
|
221
|
+
- lib/meshchat/command/base.rb
|
222
|
+
- lib/meshchat/command/config.rb
|
223
|
+
- lib/meshchat/command/exit.rb
|
224
|
+
- lib/meshchat/command/identity.rb
|
225
|
+
- lib/meshchat/command/import.rb
|
226
|
+
- lib/meshchat/command/init.rb
|
227
|
+
- lib/meshchat/command/irb.rb
|
228
|
+
- lib/meshchat/command/listen.rb
|
229
|
+
- lib/meshchat/command/ping.rb
|
230
|
+
- lib/meshchat/command/ping_all.rb
|
231
|
+
- lib/meshchat/command/server.rb
|
232
|
+
- lib/meshchat/command/share.rb
|
233
|
+
- lib/meshchat/command/stop_listening.rb
|
234
|
+
- lib/meshchat/command/whisper.rb
|
235
|
+
- lib/meshchat/command/who.rb
|
235
236
|
- lib/meshchat/config/hash_file.rb
|
236
237
|
- lib/meshchat/config/settings.rb
|
237
238
|
- lib/meshchat/database.rb
|
@@ -284,5 +285,6 @@ rubyforge_project:
|
|
284
285
|
rubygems_version: 2.4.7
|
285
286
|
signing_key:
|
286
287
|
specification_version: 4
|
287
|
-
summary: MeshChat-0.
|
288
|
+
summary: MeshChat-0.6.0
|
288
289
|
test_files: []
|
290
|
+
has_rdoc:
|