yaesu 1.0.2.beta → 1.1.3.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: ce0649625d3ab0cfa7eda5a740067be65bb2de4a8ec04cfb7298e437942d6af8
4
- data.tar.gz: eacd193288e25da3325c25f213cdaf13b8c49f88d974d52e322845066828f3c7
3
+ metadata.gz: a8bde741c8fd84f88284ad174f1d5422409d5a139ab5d7f897330982099b1c79
4
+ data.tar.gz: 2d25bc775b3ffe0d12e46f06e086ad4f0792a31b3c43a9ffcc90c3fb0e9d544c
5
5
  SHA512:
6
- metadata.gz: 8f9475c9f2eda96a666a756502589f28e22b343e0c1b52c2523574644c02a97a13c20ce164862d53adc82373b093241c5c253ea9f25538a1aa6cfad2710cbf4d
7
- data.tar.gz: 99173c31d60765e442dde7c0ece34aeb5158bb297a22bfeb9a6695aede114a567b3c01a454a575e7ea27203fca4024852f87427168a9de24998ca64a2c50d5fe
6
+ metadata.gz: 4c19c3be0dfb72888263bb7f7ed32308213b6fa999376fe124de6a50a24e099f2a1afb5532b7474be52ca010fb334236ea685b719a3eddd02ad72f7c0aa2f240
7
+ data.tar.gz: 9b8f92acf81c694b65cf3a5bd1552c53ee8c813c69ef57963e5c96278a633d558ccb2675f98ef14f3132e6d74c5ff76619586a9a37bb0f9c0a54a4423354dd3e
data/.data/poop.dir ADDED
File without changes
data/.data/poop.pag ADDED
File without changes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaesu (1.0.1.beta)
4
+ yaesu (1.1.1.beta)
5
5
  msgpack
6
6
  ohm
7
7
  ost
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 ="so.fa.dog"
20
+ end
21
+
22
+ Yaesu.listen! do |msg|
17
23
  puts msg
18
24
  end
19
25
 
data/exe/yaesu CHANGED
@@ -26,6 +26,21 @@ module Yaesu
26
26
  puts ""
27
27
  end
28
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
+
29
44
  desc "transmit ON EVENT DATA", "Transmit ON EVENT DATA"
30
45
  def transmit(on,event,data)
31
46
  Yaesu.transmit on: on, event: event, data: data
data/lib/yaesu.rb CHANGED
@@ -13,25 +13,53 @@ require 'fileutils'
13
13
  require_relative "yaesu/version"
14
14
 
15
15
  module Yaesu
16
+ REDIS_HOST = ENV.fetch("REDIS_HOST","127.0.0.1")
17
+ REDIS_PORT = ENV.fetch("REDIS_PORT","6379")
18
+ REDIS_URL = ENV.fetch("REDIS_URL","redis://#{REDIS_HOST}:#{REDIS_PORT}")
19
+ REDIS_TIMEOUT = ENV.fetch("REDIS_TIMEOUT")
20
+
21
+ Ost.redis = Redic.new(REDIS_URL, REDIS_TIMEOUT)
22
+
23
+ def self.configuration
24
+ @configuration ||= OpenStruct.new(
25
+ {
26
+ channel: "yaesu.local",
27
+ name: "base",
28
+ data_dir: "./.data",
29
+ }
30
+ )
31
+ end
32
+
33
+ def self.configure
34
+ yield(configuration)
35
+ end
36
+
16
37
  class Error < StandardError; end
17
- def self.transmit on:, event:, data:
38
+ def self.transmit on: Yaesu.configuration.channel, event:, data:
18
39
  Ost[on] << {uid: UUID.new.generate,event:event, data: data}.to_msgpack
19
40
  end
41
+
42
+ def self.listen!
43
+ self.listen name:Yaesu.configuration.name, on: Yaesu.configuration.channel do |msg|
44
+ yield msg if block_given?
45
+ end
46
+ end
47
+
20
48
  def self.listen name:, on:
21
-
22
- FileUtils.mkdir_p(".data/#{name}") unless Dir.exists? ".data"
23
-
24
- puts "listening on #{on}...."
49
+
50
+ FileUtils.mkdir_p("#{Yaesu.configuration.data_dir}/#{name}") unless Dir.exists? ".data"
51
+
52
+ puts "#{name} is listening on #{on} -> Ok!"
25
53
 
26
54
  begin
27
55
  loop do
28
56
  Ost[on].items.each do |data|
29
- SDBM.open "./.data/#{name}" do |db|
57
+ SDBM.open "#{Yaesu.configuration.data_dir}/#{name}" do |db|
30
58
  o = MessagePack.unpack(data)
31
59
  message =OpenStruct.new(o)
32
60
  next if db.has_key? message.uid
33
61
  begin
34
- yield message if block_given?
62
+ yield message if block_given?
35
63
  db[message.uid] = message.payload
36
64
  rescue => exception
37
65
  p exception
@@ -41,7 +69,7 @@ module Yaesu
41
69
  sleep 0.200
42
70
  end
43
71
  rescue Interrupt => e
44
- puts "listening on #{on}....finished!"
72
+ puts "#{name} stopped listening on #{on} -> Ok!"
45
73
  end
46
74
  end
47
75
  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.2.beta"
4
+ VERSION = "1.1.3.beta"
5
5
  end
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.2.beta
4
+ version: 1.1.3.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-28 00:00:00.000000000 Z
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ohm
@@ -116,6 +116,8 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".data/poop.dir"
120
+ - ".data/poop.pag"
119
121
  - ".gitignore"
120
122
  - ".ruby-version"
121
123
  - Gemfile