yaesu 1.0.0.beta → 1.1.1.beta

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
  SHA256:
3
- metadata.gz: 52df524d9c78f69cd9a57fb17bb3a3b0b6a6561e3942561b2b14664473ee4527
4
- data.tar.gz: c42fa530a77167d32465c55d2113c733bef3b0b17a2709376a774a6d5a317b52
3
+ metadata.gz: 58691205e330ecd92ad69dc7a786ac83520add7dc5bc634e25b8ee372335dc62
4
+ data.tar.gz: 927d198941c6c0aa610bf8b82108248b776a24c2c38894faf3fdc7f1e2463889
5
5
  SHA512:
6
- metadata.gz: c8f1fc4e839d9b7a169119f992dee67db198009cb5f7d30d78ff7f5f8287707b6a066722d7b1265c88091b586e7c3c6b1d6a54805a3da80350c2ce863fd9e53d
7
- data.tar.gz: 270b669a78189a9cd747a216061c5d53a0f4c4f7d50b2d59a322752ac38795f0f1491d107710346f86d5d5fb3ecbbca9cc73ca72f1d717fbe7177b442b1ae506
6
+ metadata.gz: 785de5a6431c3f6b3fd48e85434fdd2c666a435fbb6de8f2245f49f4f2181465d8e35f5756952e793a582b507cb7ad8987e01438f8fbbe18e6b1cac99b0adca6
7
+ data.tar.gz: 981687fd60d5a27d0684ecf9ed572e4485f2a41b6b2ca349e7760a4989eaa76604611ec95042617565443406be2f2c7d28ef4427446f4e29e9f2da9a468ea526
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaesu (0.0.3.alpha)
4
+ yaesu (1.0.3.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
- Yaesu.listen on: "so.fa.dog" do |msg|
16
+
17
+ Yaesu.configure do |config|
18
+ config.name = "poop"
19
+ config.channel ="delane.burke.me.com"
20
+ end
21
+
22
+ Yaesu.listen! do |msg|
17
23
  puts msg
18
24
  end
19
25
 
data/exe/yaesu CHANGED
@@ -3,27 +3,47 @@ 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
- data = Ost[on].items.first(10)
13
- if data.count > 0
13
+ items = Ost[on].items.first(10)
14
+ if items.count > 0
14
15
  puts ""
15
- puts "last 10 of #{Ost[on].items.count} messages on #{on}\n"
16
+ puts "#{Ost[on].size} transmissions on #{on}\n"
16
17
  puts ""
17
- Ost[on].items.first(10).reverse.each do |data|
18
- o = OpenStruct.new(MessagePack.unpack(data))
19
- puts ">> #{o.payload}"
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
24
- desc "transmit ON DATA", "Transmit ON DATA"
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
+
44
+ desc "transmit ON EVENT DATA", "Transmit ON EVENT DATA"
25
45
  def transmit(on,event,data)
26
- Yaesu.transmit on: on, data: data
46
+ Yaesu.transmit on: on, event: event, data: data
27
47
  end
28
48
  desc "reset CHANNEL", "reset CHANNEL"
29
49
  def reset(channel)
data/lib/yaesu.rb CHANGED
@@ -13,20 +13,40 @@ 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:, event:, data:
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
38
+ end
39
+
20
40
  def self.listen name:, on:
21
41
 
22
- FileUtils.mkdir_p(".data/#{name}") unless Dir.exists? ".data"
42
+ FileUtils.mkdir_p("#{Yaesu.configuration.data_dir}/#{name}") unless Dir.exists? ".data"
23
43
 
24
- puts "listening on #{on}...."
44
+ puts "#{name} is listening on #{on} -> Ok!"
25
45
 
26
46
  begin
27
47
  loop do
28
48
  Ost[on].items.each do |data|
29
- SDBM.open "./.data/#{name}" do |db|
49
+ SDBM.open "#{Yaesu.configuration.data_dir}/#{name}" do |db|
30
50
  o = MessagePack.unpack(data)
31
51
  message =OpenStruct.new(o)
32
52
  next if db.has_key? message.uid
@@ -41,7 +61,7 @@ module Yaesu
41
61
  sleep 0.200
42
62
  end
43
63
  rescue Interrupt => e
44
- puts "listening on #{on}....finished!"
64
+ puts "#{name} stopped listening on #{on} -> Ok!"
45
65
  end
46
66
  end
47
67
  end
data/lib/yaesu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yaesu
4
- VERSION = "1.0.0.beta"
4
+ VERSION = "1.1.1.beta"
5
5
  end
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaesu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta
4
+ version: 1.1.1.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coco Coder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-27 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ohm
@@ -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