yaesu 1.0.3.beta → 1.1.4.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ab00e14099e0e558dce2b7a8584cff3f54b93cf03ff69f8dab50e18c51dbb2f
4
- data.tar.gz: 207ef0ce0e6ba9ed1017815e6e4d5dcc233fbf087df3164cef33576c723fc64c
3
+ metadata.gz: eecf9e14aa072bfed2394a371c17ef138760ab7b5bce10acc0f451c99bded022
4
+ data.tar.gz: a672df0cd55755d0a42a8166666cdd7d0721be1f771c9235feee0d55eb55d27a
5
5
  SHA512:
6
- metadata.gz: d89e616f9fc5f15019956dcb2550623e9af79394201f788fc7a0af1399edb3d2af737d5efcd3a9e1f66bc21d0ddb74d10c32c9a7f7d69994a76c648f601c7e9c
7
- data.tar.gz: be12ce66a27ef201107244a99ee81b4a53b481e5f525857caca53405210c5b96896300532c4521d7b7579fd126da51c685f900fb4fb1f8858354057ab362c551
6
+ metadata.gz: d4cfee8f5b35d9444a5f201a78158540f524ee6c35c062ded3a57bef580309fd670dde8d65bf5e5680b9fe2f6778e3a31a3d882d53ba1210510445d17412aca5
7
+ data.tar.gz: 7a90c56a554e996c178d535310e05c42ffe3d85683c4e64a886f6a55fc52fe2f21f01c6b10b16c311461d9a7cba2208e3c13bc2eecaa826ff9ab662f181c6d54
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/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",10_000_000)
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.3.beta"
4
+ VERSION = "1.1.4.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.3.beta
4
+ version: 1.1.4.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