morse_me_nicely 0.0.1 → 0.1.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 +4 -4
- data/LICENSE +22 -0
- data/README.md +74 -0
- data/lib/morse_me_nicely/cli.rb +28 -14
- data/lib/morse_me_nicely/encoder.rb +0 -1
- data/morse_me_nicely.gemspec +21 -0
- data/spec/morse_me_nicely/encoder_spec.rb +0 -12
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11725480689a2c0d7e3257085bf6e8cd8c7bfba
|
4
|
+
data.tar.gz: 04acb135021250615fd8780f841a0079ac325bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34762c9a8323808473510ae9fd98841c85f7ccaed2930ad223f38d22ffdef30b37c8e9bdffc2ebb1053e79f08c4387fe9543c1e17560ea8f515adbfcee1dcba
|
7
|
+
data.tar.gz: d29edce759a07e86ac29185424be691fc4fdc47ed68fb62722dc1a68b468a4647cdfb37a325f69d8f6653240d0a6d6a828d51022fa78895483a8088617e0eb0f
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jared McFarland
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Morse Me Nicely
|
2
|
+
|
3
|
+
A simple command line tool for text encoding from a file/stdin using Morse code with/without obfuscation.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'morse_me_nicely'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it manually:
|
16
|
+
|
17
|
+
$ gem install morse_me_nicely
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
When no `--input-file` option passed the input data comes from standard input:
|
22
|
+
|
23
|
+
Example usage:
|
24
|
+
|
25
|
+
$ morse_me_nicely encode
|
26
|
+
$ Write the message: I NEED HELP
|
27
|
+
Encoded message:
|
28
|
+
2/A1|1|1|A2/4|1|1A2|1B1
|
29
|
+
|
30
|
+
Without obfuscation:
|
31
|
+
|
32
|
+
$ morse_me_nicely encode --without-obfuscation
|
33
|
+
$ Write the message: I NEED HELP
|
34
|
+
Encoded message:
|
35
|
+
../-.|.|.|-../....|.|.-..|.--.
|
36
|
+
|
37
|
+
With input file option:
|
38
|
+
|
39
|
+
$ touch source.txt
|
40
|
+
$ echo "I NEED HELP" > source.txt
|
41
|
+
$ morse_me_nicely encode --input-file=source.txt
|
42
|
+
Encoded message:
|
43
|
+
2/A1|1|1|A2/4|1|1A2|1B1
|
44
|
+
|
45
|
+
With output file option:
|
46
|
+
|
47
|
+
$ morse_me_nicely encode --output-file=output.txt
|
48
|
+
$ Write the message: I NEED HELP
|
49
|
+
Encoded message has been saved to selected file.
|
50
|
+
$ cat output.txt
|
51
|
+
2/A1|1|1|A2/4|1|1A2|1B1
|
52
|
+
|
53
|
+
### Compatibility
|
54
|
+
|
55
|
+
Library currently supports only case insensitive alphanumeric characters, spaces, commas and full-stops in source text.
|
56
|
+
For more information see: Development section.
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
### Downloading repositoty
|
61
|
+
|
62
|
+
$ git clone https://github.com/railis/morse_me_nicely.git
|
63
|
+
$ cd morse_me_nicely
|
64
|
+
$ bundle install
|
65
|
+
|
66
|
+
### Running tests
|
67
|
+
|
68
|
+
$ rake
|
69
|
+
|
70
|
+
### Updating allowed characters set
|
71
|
+
|
72
|
+
Edit the YAML file in:
|
73
|
+
|
74
|
+
data/morse_reference.ytml
|
data/lib/morse_me_nicely/cli.rb
CHANGED
@@ -8,23 +8,37 @@ module MorseMeNicely
|
|
8
8
|
method_options :output_file => :string
|
9
9
|
|
10
10
|
def encode
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
begin
|
12
|
+
if options[:input_file]
|
13
|
+
input_text = File.read(options[:input_file])
|
14
|
+
else
|
15
|
+
input_text = ask(set_color("Write the message:", Thor::Shell::Color::GREEN))
|
16
|
+
end
|
17
|
+
encoded_text = MorseMeNicely::Processor::encode(input_text, options[:without_obfuscation])
|
18
|
+
if options[:output_file]
|
19
|
+
output_file = File.new(options[:output_file], "w+")
|
20
|
+
output_file << encoded_text
|
21
|
+
output_file.close
|
22
|
+
say("Encoded message has been saved to selected file.", Thor::Shell::Color::GREEN)
|
23
|
+
else
|
24
|
+
say("Encoded message:", Thor::Shell::Color::GREEN)
|
25
|
+
say(encoded_text)
|
26
|
+
end
|
27
|
+
rescue MorseMeNicely::InvalidInputError => e
|
28
|
+
say_error(e)
|
29
|
+
rescue Errno::ENOENT
|
30
|
+
say_error("Input file '#{options[:input_file]}' does not exist")
|
31
|
+
rescue Errno::EACCES
|
32
|
+
say_error("You don't have permissions to read file '#{options[:input_file] || options[:output_file]}'")
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
36
|
+
private
|
37
|
+
|
38
|
+
def say_error(msg)
|
39
|
+
say("Error: #{msg}", Thor::Shell::Color::RED)
|
40
|
+
end
|
41
|
+
|
28
42
|
end
|
29
43
|
|
30
44
|
end
|
@@ -21,7 +21,6 @@ module MorseMeNicely
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def validate_input_text
|
24
|
-
raise InvalidInputError, "No text input found" unless @input_text.is_a?(String)
|
25
24
|
invalid_characters = get_input_invalid_characters
|
26
25
|
unless invalid_characters.empty?
|
27
26
|
raise InvalidInputError, "Input text contains invalid characters: #{invalid_characters.join(" ")}"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.authors = ["Dominik Sito"]
|
3
|
+
s.email = "dominik.sito@gmail.com"
|
4
|
+
s.homepage = "https://github.com/railis/morse_me_nicely"
|
5
|
+
|
6
|
+
s.name = "morse_me_nicely"
|
7
|
+
s.version = "0.1.2"
|
8
|
+
s.date = '2017-08-11'
|
9
|
+
s.summary = "Morse Me Nicely!"
|
10
|
+
s.description = "A simple gem to encode and obfuscate text input using morse code"
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split($\)
|
13
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
|
+
|
16
|
+
s.license = "MIT"
|
17
|
+
|
18
|
+
s.add_dependency "thor", "~> 0.19"
|
19
|
+
s.add_development_dependency "rspec", "~> 3.6"
|
20
|
+
s.add_development_dependency "rake", "~> 12.0"
|
21
|
+
end
|
@@ -4,18 +4,6 @@ RSpec.describe MorseMeNicely::Encoder, "#encoded_input" do
|
|
4
4
|
|
5
5
|
context "when input text is not valid" do
|
6
6
|
|
7
|
-
context "when input is not a string" do
|
8
|
-
|
9
|
-
subject do
|
10
|
-
described_class.new(true)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "raises InvalidInput error" do
|
14
|
-
expect { subject.encoded_input }.to raise_error(MorseMeNicely::InvalidInputError, "No text input found")
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
7
|
context "when input text contains ambiguous characters" do
|
20
8
|
|
21
9
|
subject do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morse_me_nicely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Sito
|
@@ -61,6 +61,8 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- Gemfile
|
63
63
|
- Gemfile.lock
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
64
66
|
- Rakefile
|
65
67
|
- bin/morse_me_nicely
|
66
68
|
- data/morse_reference.yml
|
@@ -68,6 +70,7 @@ files:
|
|
68
70
|
- lib/morse_me_nicely/cli.rb
|
69
71
|
- lib/morse_me_nicely/encoder.rb
|
70
72
|
- lib/morse_me_nicely/obfuscator.rb
|
73
|
+
- morse_me_nicely.gemspec
|
71
74
|
- spec/morse_me_nicely/encoder_spec.rb
|
72
75
|
- spec/morse_me_nicely/obfuscator_spec.rb
|
73
76
|
- spec/spec_helper.rb
|