morsecode_listener 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1791d7e14d7833006633323329e96c26f7a07817
4
+ data.tar.gz: 97b378a14d85ecb139d8e7a5cedb56152263faa3
5
+ SHA512:
6
+ metadata.gz: 55999a0c2cc790010e0246a8d561e82e96efa3b0877022f7a6d3b26fcd8fed62bff1eb6f2e8985df2665ba8097d036d8afa7522a54081d15ce9255cc8c92693f
7
+ data.tar.gz: 3e7c066a0de01eef751e7c5565cb8d32a7d548ba031691f9af170b4dada80f61ae142ddfa3d5a9601c7b260da1c37dc762e9bc8d7e7beb7f43141e5432b35432
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ $L#�rrb�{:���>�dE��[:oo]��}�mo�n���akD�����96A�Q���P�(匊f߅�6�
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: morsecode_listener.rb
4
+
5
+ class MorseCodeListener
6
+
7
+ def initialize(short_delay: 0.35, long_delay: 1, dot: 2, dash: 1,
8
+ separator: 4, timeout: 2, notifier: nil)
9
+
10
+ @short_delay, @long_delay, @timeout = short_delay, long_delay, timeout
11
+ @h = { dot: dot, dash: dash, separator: separator }
12
+ @notifier = notifier
13
+ @t, @a = nil, []
14
+ end
15
+
16
+ def on_keydown()
17
+
18
+ @thread.exit if @thread
19
+ @t = Time.now
20
+ end
21
+
22
+ def on_keyup()
23
+
24
+ t = Time.now - @t
25
+
26
+ if t < @short_delay then
27
+ @a << @h[:dot]
28
+ elsif t < @long_delay
29
+ @a << @h[:dash]
30
+ elsif t < @timeout
31
+ @a << @h[:separator]
32
+ end
33
+
34
+ @thread = Thread.new do
35
+
36
+ sleep @long_delay
37
+ @a << @h[:separator]
38
+ sleep @timeout - @long_delay
39
+ @a.pop
40
+
41
+ s = @a.join
42
+
43
+ if @notifier then
44
+ @notifier.message s
45
+ else
46
+ puts '>> ' + s
47
+ end
48
+
49
+ @a = []
50
+
51
+ end
52
+
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: morsecode_listener
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE2MDIwNDE2MzI1NVoXDTE3MDIwMzE2MzI1NVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBALUH+PSeuvJOYGC9+g1LBbgTsrzSc/JU6234zc2dq/O6wXCO2uHCp/iC4t5X
19
+ rpQxHrExj6qbnS8xEsKVfzPYegd5pDxOThylR49bheZ3YJ2BM34vwnVbgVkQi7EM
20
+ sELXLYrZ3e5ZBaP1LFdKlSfFL7VSikDUI6FXu3V2YPXZt4j5n01cJE/Jl82dO4zQ
21
+ GkaplX6aJAgbPmaA1Ke/T3v3nQEWjW7aJqRagM7Ye5NWuxaxVUeF7/2Hth0v9zt7
22
+ rsUrGM43kf3+HObWyeSLzakWG7XEdJLv2ewzMnuyLH8LEFfBlII3l45bns9LN9uQ
23
+ lf0nJIdyo/EeJED/OeExCErbK8cCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQU03DPvPJZ4MApkS6h2KeQSWQU8KcwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAUBHxi8vE
27
+ 9yTTrpMMccSquNfMM/pgqiw5CdFThG7oPRxcU9SfcKNUzf0ELUOKQRB0o9s2f3kJ
28
+ Gacrz2JNaRTrYM3RBaw+LVGYP4VkZTy0ZihMJpjIR9lVCTjfhfws5bMC35PV2goo
29
+ uBjelqyPwkSBuf25E2eZgprLSU6rRPdOQUCm/GAaSJFGeL4p1PzKbaZyR8t15/5H
30
+ Rav7Da+uEFXsKpoYQ+v87ddD2a/Y5V+HII9vz7vd/0Z2z6Pif4MZWrBzdmQs60n2
31
+ QeOlrjRHjaoX6Fe0+97mHWeIWmS5UJg/HAPFoN5/rloT18fQU5aOdCI0xYs8iGnN
32
+ djAZGJFKf67W+w==
33
+ -----END CERTIFICATE-----
34
+ date: 2016-02-04 00:00:00.000000000 Z
35
+ dependencies: []
36
+ description:
37
+ email: james@r0bertson.co.uk
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - lib/morsecode_listener.rb
43
+ homepage: https://github.com/jrobertson/morsecode_listener
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.8
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Use in conjunction with an event driven application to listen for a morse
67
+ code message.
68
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ |~L�ȿ-Ud:����d���\� ��
2
+ ,�*��:Q�f��]� ���x��2�8��s�1ȼ�^dmpʩ�:a������ߊ���A+���q� Uwb��I3P�Y�+un�~��|�\؟�,�?�~ܚ.� �vG�tM�m~:�| J;�$+�h��B���K2���<��YW�\��b}3�lt߻�x)]���G��,�*�఻� $�ܵe6���f��|�)�,�d"��yX�Bc*�T!=p��o�$f���2�