yaesu 1.0.1.beta → 1.1.2.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.data/poop.dir +0 -0
- data/.data/poop.pag +0 -0
- data/Gemfile.lock +5 -1
- data/bin/console +7 -1
- data/exe/yaesu +26 -6
- data/lib/yaesu.rb +28 -6
- data/lib/yaesu/version.rb +1 -1
- data/yaesu.gemspec +1 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7cef539cd6bc3ffb80a9ecfb9f7461b7bb2aab8891afe9344910b5ffd9e11aa
|
4
|
+
data.tar.gz: ce6a9b5cf81c10ddb63f5d36148744a95a44b4886fd3f4694f0ea2b3a62bfbcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4de16486dad915b6038a4911a4c9f51a3c8d2af7f1eaa15f73dc7a5aaedf450ea8151114ea3f83625a7e11699acf8988b2e147e6e7aa3ef0e7b6879993ec3994
|
7
|
+
data.tar.gz: 242ea2c98c9f6c1a9c73fd94458dd26f13d2cb1ca50b53e58d786b7967e4ab64e0ca4387149f798c9dbfb55841842a024cb23bb3a5ed6d0d75bdf6576caa01bc
|
data/.data/poop.dir
ADDED
File without changes
|
data/.data/poop.pag
ADDED
File without changes
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yaesu (
|
4
|
+
yaesu (1.1.1.beta)
|
5
5
|
msgpack
|
6
6
|
ohm
|
7
7
|
ost
|
8
8
|
sdbm
|
9
|
+
terminal-table
|
9
10
|
thor
|
10
11
|
uuid
|
11
12
|
|
@@ -33,7 +34,10 @@ GEM
|
|
33
34
|
stal (0.3.0)
|
34
35
|
redic (~> 1.5)
|
35
36
|
systemu (2.6.5)
|
37
|
+
terminal-table (3.0.0)
|
38
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
36
39
|
thor (1.1.0)
|
40
|
+
unicode-display_width (1.7.0)
|
37
41
|
uuid (2.3.9)
|
38
42
|
macaddr (~> 1.0)
|
39
43
|
|
data/bin/console
CHANGED
@@ -13,7 +13,13 @@ require "yaesu"
|
|
13
13
|
|
14
14
|
#require "irb"
|
15
15
|
#IRB.start(__FILE__)
|
16
|
-
|
16
|
+
|
17
|
+
Yaesu.configure do |config|
|
18
|
+
config.name = "poop"
|
19
|
+
config.channel ="so.fa.dog"
|
20
|
+
end
|
21
|
+
|
22
|
+
Yaesu.listen! do |msg|
|
17
23
|
puts msg
|
18
24
|
end
|
19
25
|
|
data/exe/yaesu
CHANGED
@@ -3,24 +3,44 @@ require 'rubygems'
|
|
3
3
|
require 'thor'
|
4
4
|
require 'yaesu'
|
5
5
|
require 'msgpack'
|
6
|
+
require 'terminal-table'
|
6
7
|
|
7
8
|
|
8
9
|
module Yaesu
|
9
10
|
class Cli < Thor
|
10
11
|
desc "log", "Last 10 transmissions"
|
11
12
|
def log(on)
|
12
|
-
|
13
|
-
if
|
13
|
+
items = Ost[on].items.first(10)
|
14
|
+
if items.count > 0
|
14
15
|
puts ""
|
15
|
-
puts "
|
16
|
+
puts "#{Ost[on].size} transmissions on #{on}\n"
|
16
17
|
puts ""
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
rows = []
|
19
|
+
columns = ['UID','Event','Data']
|
20
|
+
items.reverse.each do |item|
|
21
|
+
datum = OpenStruct.new(MessagePack.unpack(item))
|
22
|
+
rows << [datum.uid.split("-").first,datum.event,datum.data]
|
20
23
|
end
|
24
|
+
table = Terminal::Table.new :headings => columns, :rows => rows
|
25
|
+
puts table
|
21
26
|
puts ""
|
22
27
|
end
|
23
28
|
end
|
29
|
+
|
30
|
+
desc "channels", "summary of channels"
|
31
|
+
def channels
|
32
|
+
puts ""
|
33
|
+
rows = []
|
34
|
+
columns = ['Name','Total']
|
35
|
+
Ost.redis.call("KEYS","*ost*").each do |key|
|
36
|
+
rows << [key.gsub("ost:",""),Ost[key.gsub("ost:","")].size]
|
37
|
+
end
|
38
|
+
|
39
|
+
table = Terminal::Table.new :headings => columns, :rows => rows
|
40
|
+
puts table
|
41
|
+
puts ""
|
42
|
+
end
|
43
|
+
|
24
44
|
desc "transmit ON EVENT DATA", "Transmit ON EVENT DATA"
|
25
45
|
def transmit(on,event,data)
|
26
46
|
Yaesu.transmit on: on, event: event, data: data
|
data/lib/yaesu.rb
CHANGED
@@ -13,25 +13,47 @@ require 'fileutils'
|
|
13
13
|
require_relative "yaesu/version"
|
14
14
|
|
15
15
|
module Yaesu
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= OpenStruct.new(
|
19
|
+
{
|
20
|
+
channel: "yaesu.local",
|
21
|
+
name: "base",
|
22
|
+
data_dir: "./.data"
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.configure
|
28
|
+
yield(configuration)
|
29
|
+
end
|
30
|
+
|
16
31
|
class Error < StandardError; end
|
17
|
-
def self.transmit on
|
32
|
+
def self.transmit on: Yaesu.configuration.channel, event:, data:
|
18
33
|
Ost[on] << {uid: UUID.new.generate,event:event, data: data}.to_msgpack
|
19
34
|
end
|
35
|
+
|
36
|
+
def self.listen!
|
37
|
+
self.listen name:Yaesu.configuration.name, on: Yaesu.configuration.channel do |msg|
|
38
|
+
yield msg if block_given?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
20
42
|
def self.listen name:, on:
|
21
43
|
|
22
|
-
FileUtils.mkdir_p(".
|
44
|
+
FileUtils.mkdir_p("#{Yaesu.configuration.data_dir}/#{name}") unless Dir.exists? ".data"
|
23
45
|
|
24
|
-
puts "listening on #{on}
|
46
|
+
puts "#{name} is listening on #{on} -> Ok!"
|
25
47
|
|
26
48
|
begin
|
27
49
|
loop do
|
28
50
|
Ost[on].items.each do |data|
|
29
|
-
SDBM.open "
|
51
|
+
SDBM.open "#{Yaesu.configuration.data_dir}/#{name}" do |db|
|
30
52
|
o = MessagePack.unpack(data)
|
31
53
|
message =OpenStruct.new(o)
|
32
54
|
next if db.has_key? message.uid
|
33
55
|
begin
|
34
|
-
yield message if block_given?
|
56
|
+
yield message if block_given?
|
35
57
|
db[message.uid] = message.payload
|
36
58
|
rescue => exception
|
37
59
|
p exception
|
@@ -41,7 +63,7 @@ module Yaesu
|
|
41
63
|
sleep 0.200
|
42
64
|
end
|
43
65
|
rescue Interrupt => e
|
44
|
-
puts "listening on #{on}
|
66
|
+
puts "#{name} stopped listening on #{on} -> Ok!"
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
data/lib/yaesu/version.rb
CHANGED
data/yaesu.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'uuid'
|
28
28
|
spec.add_dependency 'sdbm'
|
29
29
|
spec.add_dependency 'thor'
|
30
|
+
spec.add_dependency 'terminal-table'
|
30
31
|
|
31
32
|
# For more information and examples about making a new gem, checkout our
|
32
33
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaesu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coco Coder
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: terminal-table
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Yaesu message bus
|
98
112
|
email:
|
99
113
|
- shout@cococoder.com
|
@@ -102,6 +116,8 @@ executables:
|
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
119
|
+
- ".data/poop.dir"
|
120
|
+
- ".data/poop.pag"
|
105
121
|
- ".gitignore"
|
106
122
|
- ".ruby-version"
|
107
123
|
- Gemfile
|