telegraph 1.0.1 → 1.0.2
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 +7 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.rdoc +24 -21
- data/lib/telegraph.rb +4 -4
- metadata +37 -62
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4aa9828f661a36ae378dcee16653797b441c6027612c744ce9f19dc022afd410
|
4
|
+
data.tar.gz: 064a91fe5c94adfdd7b54ac22b3bcc6d5fc9fb7f03c51878b8e40db90191d68a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60bc82d4f10e66851511d4ec1c1f31b4a1dfec801b7fbbe321a3f0e79166f856cca6ff8c53b214577d156a3d823b21ee75e95b3c42928d54427465741348b54b
|
7
|
+
data.tar.gz: c695ef9af9676bba22e01318fd178f5ac33cb78c01354e3ba3f5c803163a45db902b2f4084c1e900ebb22b3fa5b626eb07708e69eb4287129acb4a472ad583dd
|
data/MIT-LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -2,36 +2,39 @@
|
|
2
2
|
|
3
3
|
Telegraph is a Ruby gem that provides straightforward text-to-morse and morse-to-text translators
|
4
4
|
|
5
|
-
It uses as reference the document 'RECOMMENDATION ITU-R M.1677' from the International Telecommunication Union, Radiocommunication Sector (ITU-R), the United Nations agency for information and communication technology issues.
|
5
|
+
It uses as reference the document {'RECOMMENDATION ITU-R M.1677'}[https://www.itu.int/rec/R-REC-M.1677-1-200910-I] from the International Telecommunication Union, Radiocommunication Sector (ITU-R), the United Nations agency for information and communication technology issues.
|
6
|
+
|
7
|
+
{<img src="https://badge.fury.io/rb/telegraph.png" alt="Gem Version" />}[http://badge.fury.io/rb/telegraph]
|
8
|
+
{<img src="https://github.com/xuanxu/telegraph/actions/workflows/tests.yml/badge.svg" alt="Build status" />}[https://github.com/xuanxu/telegraph/actions/workflows/tests.yml]
|
6
9
|
|
7
10
|
== Getting started
|
8
11
|
|
9
|
-
Install the gem:
|
12
|
+
Install the gem:
|
10
13
|
$ [sudo] gem install telegraph
|
11
14
|
|
12
15
|
Then depending on your project you may:
|
13
16
|
|
14
|
-
require the gem (if a ruby project):
|
17
|
+
require the gem (if a ruby project):
|
15
18
|
require 'telegraph'
|
16
|
-
or add it to your Gemfile (if you're on Rails):
|
19
|
+
or add it to your Gemfile (if you're on Rails):
|
17
20
|
gem 'telegraph', :git => 'git://github.com/xuanxu/telegraph.git'
|
18
|
-
|
21
|
+
|
19
22
|
|
20
23
|
== Usage
|
21
24
|
|
22
25
|
The simplest way to read or write morse code is using directly the two methods defined in Telegraph:
|
23
|
-
|
26
|
+
|
24
27
|
# Converts text to morse characters:
|
25
|
-
Telegraph.text_to_morse("Hello world") #=> ".... . .-.. .-.. ---
|
26
|
-
|
28
|
+
Telegraph.text_to_morse("Hello world") #=> ".... . .-.. .-.. --- .-- --- .-. .-.. -.."
|
29
|
+
|
27
30
|
# Reads morse characters into text:
|
28
|
-
Telegraph.morse_to_text(".... . .-.. .-.. ---
|
29
|
-
|
31
|
+
Telegraph.morse_to_text(".... . .-.. .-.. --- .-- --- .-. .-.. -..") #=> hello world"
|
32
|
+
|
30
33
|
In the Telegraph module you will find defined also the most commonly used prosigns:
|
31
34
|
|
32
35
|
# Error sign:
|
33
36
|
Telegraph::Error #=> "........"
|
34
|
-
|
37
|
+
|
35
38
|
#The complete list of prosigns:
|
36
39
|
Telegraph::Error
|
37
40
|
Telegraph::Understood
|
@@ -39,26 +42,26 @@ In the Telegraph module you will find defined also the most commonly used prosig
|
|
39
42
|
Telegraph::Wait
|
40
43
|
Telegraph::End_of_work
|
41
44
|
Telegraph::Starting_signal
|
42
|
-
|
45
|
+
|
43
46
|
All the generated morse code will use the character '.' as short signal (aka dot) and the character '-' as long signal (aka dash).
|
44
47
|
|
45
|
-
If you need to write or read using different characters as short and long signals you can do it instantiating your own Telegraph::MorseTransmission class:
|
48
|
+
If you need to write or read using different characters as short and long signals you can do it instantiating your own <tt>Telegraph::MorseTransmission</tt> class:
|
46
49
|
|
47
50
|
# User defined dot & dash (:short and :long defaults to '.' and '-')
|
48
51
|
morser = Telegraph::MorseTransmission.new(:short =>'x', :long => '3')
|
49
|
-
|
52
|
+
|
50
53
|
and then using the methods to read/write:
|
51
54
|
|
52
|
-
# write morse code with custom signals
|
53
|
-
morser.text_to_morse("Hello world") #=> "xxxx x x3xx x3xx 333
|
54
|
-
|
55
|
-
# read morse code with custom signals
|
56
|
-
morser.morse_to_text("xxxx x x3xx x3xx 333
|
55
|
+
# write morse code with custom signals
|
56
|
+
morser.text_to_morse("Hello world") #=> "xxxx x x3xx x3xx 333 x33 333 x3x x3xx 3xx"
|
57
|
+
|
58
|
+
# read morse code with custom signals
|
59
|
+
morser.morse_to_text("xxxx x x3xx x3xx 333 x33 333 x3x x3xx 3xx") #=> hello world"
|
57
60
|
morser.error #=> "xxxxxxxx"
|
58
61
|
|
59
62
|
== Credits
|
60
63
|
|
61
|
-
Author:: Juanjo Bazán
|
62
|
-
Copyright:: Copyright (c)
|
64
|
+
Author:: Juanjo Bazán
|
65
|
+
Copyright:: Copyright (c) 2013 - ∞ Juanjo Bazán
|
63
66
|
License:: Released under the MIT license.
|
64
67
|
|
data/lib/telegraph.rb
CHANGED
@@ -16,7 +16,7 @@ module Telegraph
|
|
16
16
|
# The encode is made following the official RECOMMENDATION ITU-R M.1677.
|
17
17
|
# The returned string uses a single space as letter separator and a seven spaces gap as word separator.
|
18
18
|
#
|
19
|
-
# Telegraph.text_to_morse("Hello world") #=> ".... . .-.. .-.. ---
|
19
|
+
# Telegraph.text_to_morse("Hello world") #=> ".... . .-.. .-.. --- .-- --- .-. .-.. -.."
|
20
20
|
#
|
21
21
|
def self.text_to_morse(text)
|
22
22
|
text.strip.downcase.split(" ").inject([]){|morse_words, word|
|
@@ -31,7 +31,7 @@ module Telegraph
|
|
31
31
|
#
|
32
32
|
# The returned string is completly downcased.
|
33
33
|
#
|
34
|
-
# Telegraph.morse_to_text(".... . .-.. .-.. ---
|
34
|
+
# Telegraph.morse_to_text(".... . .-.. .-.. --- .-- --- .-. .-.. -..") #=> hello world"
|
35
35
|
#
|
36
36
|
def self.morse_to_text(morse)
|
37
37
|
morse.split(LETTERS_TO_MORSE[" "]).inject([]){|words, morse_word|
|
@@ -66,7 +66,7 @@ module Telegraph
|
|
66
66
|
# The returned string uses a single space as letter separator and a seven spaces gap as word separator.
|
67
67
|
#
|
68
68
|
# morser = Telegraph::MorseTransmission.new(:short =>'x', :long => '3')
|
69
|
-
# morser.text_to_morse("Hello world") #=> "xxxx x x3xx x3xx 333
|
69
|
+
# morser.text_to_morse("Hello world") #=> "xxxx x x3xx x3xx 333 x33 333 x3x x3xx 3xx"
|
70
70
|
#
|
71
71
|
def text_to_morse(text)
|
72
72
|
morse = Telegraph.text_to_morse(text)
|
@@ -81,7 +81,7 @@ module Telegraph
|
|
81
81
|
# The returned string is completly downcased.
|
82
82
|
#
|
83
83
|
# morser = Telegraph::MorseTransmission.new(:short =>'x', :long => '3')
|
84
|
-
# morser.morse_to_text("xxxx x x3xx x3xx 333
|
84
|
+
# morser.morse_to_text("xxxx x x3xx x3xx 333 x33 333 x3x x3xx 3xx") #=> hello world"
|
85
85
|
#
|
86
86
|
def morse_to_text(morse)
|
87
87
|
morse = undo_dot_dash(morse.strip)
|
metadata
CHANGED
@@ -1,87 +1,62 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegraph
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
14
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Juanjo Bazán
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: rspec
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 1
|
33
|
-
- 0
|
34
|
-
version: 2.1.0
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.10.0
|
35
20
|
type: :development
|
36
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.10.0
|
37
27
|
description: Telegraph provides a simple text-to-morse, morse-to-text translator.
|
38
28
|
email: jjbazan@gmail.com
|
39
29
|
executables: []
|
40
|
-
|
41
30
|
extensions: []
|
42
|
-
|
43
31
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
32
|
+
files:
|
46
33
|
- MIT-LICENSE.txt
|
47
34
|
- README.rdoc
|
48
35
|
- lib/morse_characters.rb
|
49
36
|
- lib/telegraph.rb
|
50
|
-
has_rdoc: true
|
51
37
|
homepage: http://github.com/xuanxu/telegraph
|
52
38
|
licenses: []
|
53
|
-
|
54
|
-
post_install_message:
|
55
|
-
rdoc_options:
|
56
|
-
- --main
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- "--main"
|
57
43
|
- README.rdoc
|
58
|
-
- --charset=UTF-8
|
59
|
-
require_paths:
|
44
|
+
- "--charset=UTF-8"
|
45
|
+
require_paths:
|
60
46
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
|
63
|
-
requirements:
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
64
49
|
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
version: "0"
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
|
-
requirements:
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
73
54
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
79
57
|
requirements: []
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
signing_key:
|
84
|
-
specification_version: 3
|
58
|
+
rubygems_version: 3.2.15
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
85
61
|
summary: Ruby gem to read and write Morse code
|
86
62
|
test_files: []
|
87
|
-
|