yaesu 1.0.3.beta → 1.1.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/console +7 -1
- data/lib/yaesu.rb +24 -4
- data/lib/yaesu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15bb33323a96fda9a06ac63f7bbe1b288fd5055ce53894ed247ad8fdb061de64
|
4
|
+
data.tar.gz: 2b445c2e495682d9bfe5a2978bfce11761c5ff70892bdeb3253ba8a7022036e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50bb0451ab06dc6dab31e7108903da61186463ee32b425ccb2fdb27aa0445b89bd5eb42e77c103dff7e6f714d2dc68000bb60ae5469d50c84fd84ac0aa34984
|
7
|
+
data.tar.gz: e72ec71eab45f57e12604421c35da1f15966546da696fa475bfafe6310efb45330d893c0090c972f104d70c8f75d6797a884e03ccb4ef1fffa3b1ba0bf2bb02e
|
data/Gemfile.lock
CHANGED
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 ="delane.burke.me.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
Yaesu.listen! do |msg|
|
17
23
|
puts msg
|
18
24
|
end
|
19
25
|
|
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
32
|
def self.transmit on:, 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(".
|
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 "
|
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}
|
64
|
+
puts "#{name} stopped listening on #{on} -> Ok!"
|
45
65
|
end
|
46
66
|
end
|
47
67
|
end
|
data/lib/yaesu/version.rb
CHANGED