yaesu 0.0.6.alpha → 1.1.0.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: e2cb0655f7feaea07892843932de02f73af23954338accffffc72d778bdae8aa
4
- data.tar.gz: 3a078934931706751bd1266cf53ae8cb60983e1ffe9cbec41bd2e9b828a34d57
3
+ metadata.gz: 15bb33323a96fda9a06ac63f7bbe1b288fd5055ce53894ed247ad8fdb061de64
4
+ data.tar.gz: 2b445c2e495682d9bfe5a2978bfce11761c5ff70892bdeb3253ba8a7022036e0
5
5
  SHA512:
6
- metadata.gz: 664f22ec3a4926183c4d0d09e38f6398475d34b72dc942afae3570a6cf5f695c5ac738ddc54283407b0231c92bb0f061517e1013087af8c89bcae5e30a527e91
7
- data.tar.gz: 39ddd918444070bce9dce5bd7320205e3ffc12de6f3c620e6e818e257a310b97e9de7c0bb9aa64119b3bd840a5af6f3bdf0ef6301843fdc452448cf248d7d765
6
+ metadata.gz: f50bb0451ab06dc6dab31e7108903da61186463ee32b425ccb2fdb27aa0445b89bd5eb42e77c103dff7e6f714d2dc68000bb60ae5469d50c84fd84ac0aa34984
7
+ data.tar.gz: e72ec71eab45f57e12604421c35da1f15966546da696fa475bfafe6310efb45330d893c0090c972f104d70c8f75d6797a884e03ccb4ef1fffa3b1ba0bf2bb02e
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"
25
- def transmit(on,data)
26
- Yaesu.transmit on: on, data: 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"
45
+ def transmit(on,event,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:, data:
18
- Ost[on] << {uid: UUID.new.generate, payload: data}.to_msgpack
32
+ def self.transmit on:, event:, data:
33
+ Ost[on] << {uid: UUID.new.generate,event:event, data: data}.to_msgpack
34
+ end
35
+
36
+ def self.listen!
37
+ self.listen name:Yaesu.configuration.name, on: Yaesu.configuration.channel
19
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 = "0.0.6.alpha"
4
+ VERSION = "1.1.0.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: 0.0.6.alpha
4
+ version: 1.1.0.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