From 8f7138ed3067ad5274e02f4ca82f1f64d517acfb Mon Sep 17 00:00:00 2001 From: Abdul Ali Noori Date: Thu, 20 Jul 2023 10:20:04 +0330 Subject: [PATCH 01/10] Update README.md to add project description. --- README.md | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b96a7f..2d1b6b3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,211 @@ -# Marse-Code-Decoder -The Ruby-based Morse Decoder is a handy utility designed to transform Morse code into easily readable text. By taking a string of Morse code as input, this tool facilitates communication using a combination of dots and dashes to represent letters, numbers, and symbols. + + + + + +# 📗 Table of Contents + +- [📖 About the Project](#about-project) + - [🛠 Built With](#built-with) + - [Tech Stack](#tech-stack) + - [Key Features](#key-features) + - [🚀 Schema Diagram](#live-demo) +- [💻 Getting Started](#getting-started) + - [Setup](#setup) + - [Prerequisites](#prerequisites) + - [Install](#install) + - [Usage](#usage) + - [Run tests](#run-tests) + - [Deployment](#triangular_flag_on_post-deployment) +- [👥 Authors](#authors) +- [🔭 Future Features](#future-features) +- [🤝 Contributing](#contributing) +- [⭐️ Show your support](#support) +- [🙏 Acknowledgements](#acknowledgements) +- [❓ FAQ](#faq) +- [📝 License](#license) + + + +# 📖 [Marse Code Decoder] + +> **[Marse-Code-Decoder]** The Ruby-based Morse Decoder is a handy utility designed to transform Morse code into easily readable text. By taking a string of Morse code as input, this tool facilitates communication using a combination of dots and dashes to represent letters, numbers, and symbols. + +## 🛠 Built With + +### Tech Stack + +
+ Client + +
+ +
+ Server + +
+ +
+Database + +
+ + + +### Key Features + +- **[create patients table]** +- **[create all the necessary foreign keys]** +- **[Create a many to many relational table]** + +

(back to top)

+ + + +## 🚀 Schema Diagram + +

(back to top)

+ + + +## 💻 Getting Started + +To get a local copy up and running, follow these steps. + +### Prerequisites + +In order to run this project you need: + +Example command: + +```sh + Install PostgreSQL +``` + +### Setup + +Clone this repository to your desired folder: + +```sh + cd my-folder + git clone https://github.com/ab-noori/clinic.git +``` + +### Install + +Install this project with: + +```sh + cd my-folder + git clone https://github.com/ab-noori/clinic.git +``` + +### Usage + +To run the project, execute the following command: + +```sh + cd my-folder + git clone https://github.com/ab-noori/clinic.git +``` + +### Run tests + +To run tests, run the following command: + +```sh + npm test +``` + +### Deployment + +You can deploy this project using: + +```sh + npm run deploy +``` + +

(back to top)

+ + + +## 👥 Authors + +👤 **Abdul Ali Noori** + +- GitHub: [@ab-noori](https://github.com/ab-noori) +- Twitter: [@AbdulAliNoori4](https://twitter.com/AbdulAliNoori4) +- LinkedIn: [abdulali-noori](https://www.linkedin.com/in/abdulali-noori) + +👤 **Otmane Echchafyky** + +- GitHub: [@otmaneechchafyky](https://github.com/otmaneechchafyky) +- Twitter: [@EchchafykyO](https://twitter.com/EchchafykyO) +- LinkedIn: [otmaneechchafyky](https://www.linkedin.com/in/otmane-echchafyky-125801248/) + +

(back to top)

+ + + +## 🔭 Future Features + +- [ ] **[Normalize the database]** +- [ ] **[Displaying data on a UI]** + +

(back to top)

+ + + +## 🤝 Contributing + + Contributions, issues, and feature requests are welcome! + + Feel free to check the [issues page](https://github.com/ab-noori/clinic/issues). + +

(back to top)

+ + + +## ⭐️ Show your support + + If you like this project, give it a star. + +

(back to top)

+ + + +## 🙏 Acknowledgments + + First, I would like to thank Microverse and my coding partners. + +

(back to top)

+ + + +## ❓ FAQ (OPTIONAL) + +- **How to optimize database performance?** + + - Use indexes on frequently queried columns to improve search speed. + - Normalize the database structure to minimize data redundancy and improve data integrity. + +- **How to ensure database security?** + + - Implement proper authentication and authorization mechanisms to control access to the database. + - Regularly update and patch the database software to address security vulnerabilities. + +

(back to top)

+ + +## 📝 License + +This project is [MIT](./LICENSE) licensed. + +

(back to top)

+ From 1c4ddf4652df324eebdefc89afe1542d2242d75c Mon Sep 17 00:00:00 2001 From: echchafykyotmane Date: Thu, 20 Jul 2023 11:29:51 +0100 Subject: [PATCH 02/10] Update README file --- README.md | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 2d1b6b3..73e0b99 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ - [🤝 Contributing](#contributing) - [⭐️ Show your support](#support) - [🙏 Acknowledgements](#acknowledgements) -- [❓ FAQ](#faq) - [📝 License](#license) @@ -45,14 +44,14 @@
Server
Database
@@ -60,9 +59,9 @@ ### Key Features -- **[create patients table]** -- **[create all the necessary foreign keys]** -- **[Create a many to many relational table]** +- **[Decode morse codes]** +- **[words decoding]** +- **[Senteces decoding]**

(back to top)

@@ -85,7 +84,7 @@ In order to run this project you need: Example command: ```sh - Install PostgreSQL + Install Ruby ``` ### Setup @@ -94,7 +93,7 @@ Clone this repository to your desired folder: ```sh cd my-folder - git clone https://github.com/ab-noori/clinic.git + git clone https://github.com/ab-noori/Marse-Code-Decoder.git ``` ### Install @@ -103,7 +102,7 @@ Install this project with: ```sh cd my-folder - git clone https://github.com/ab-noori/clinic.git + git clone https://github.com/ab-noori/Marse-Code-Decoder.git ``` ### Usage @@ -112,7 +111,7 @@ To run the project, execute the following command: ```sh cd my-folder - git clone https://github.com/ab-noori/clinic.git + git clone https://github.com/ab-noori/Marse-Code-Decoder.git ``` ### Run tests @@ -155,8 +154,8 @@ You can deploy this project using: ## 🔭 Future Features -- [ ] **[Normalize the database]** -- [ ] **[Displaying data on a UI]** +- [ ] **[Adding possibility ro decode numbers]** +- [ ] **[Creating UI so users can decode Morse codes]**

(back to top)

@@ -166,7 +165,7 @@ You can deploy this project using: Contributions, issues, and feature requests are welcome! - Feel free to check the [issues page](https://github.com/ab-noori/clinic/issues). + Feel free to check the [issues page](https://github.com/ab-noori/Marse-Code-Decoder/issues).

(back to top)

@@ -186,22 +185,6 @@ You can deploy this project using:

(back to top)

- - -## ❓ FAQ (OPTIONAL) - -- **How to optimize database performance?** - - - Use indexes on frequently queried columns to improve search speed. - - Normalize the database structure to minimize data redundancy and improve data integrity. - -- **How to ensure database security?** - - - Implement proper authentication and authorization mechanisms to control access to the database. - - Regularly update and patch the database software to address security vulnerabilities. - -

(back to top)

- ## 📝 License From 8ea1836c85636806fc5955ca9c9ca6b3b4ed797d Mon Sep 17 00:00:00 2001 From: Abdul Ali Noori Date: Thu, 20 Jul 2023 14:33:29 +0330 Subject: [PATCH 03/10] Add linters local env comfigurations. --- .github/workflows/linters.yml | 20 ++++++++++++++ .github/workflows/tests.yml | 19 +++++++++++++ .rubocop.yml | 52 +++++++++++++++++++++++++++++++++++ Gemfile | 2 ++ Gemfile.lock | 38 +++++++++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 .github/workflows/linters.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .rubocop.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..9984f01 --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,20 @@ +name: Linters + +on: pull_request + +jobs: + rubocop: + name: Rubocop + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-ruby@v1 + with: + ruby-version: ">=3.1.x" + - name: Setup Rubocop + run: | + gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/ + [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ruby/.rubocop.yml + - name: Rubocop Report + run: rubocop --color diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..61bcaab --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,19 @@ +name: Tests + +on: pull_request + +jobs: + rspec: + name: RSpec + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-ruby@v1 + with: + ruby-version: 3.1.x + - name: Setup RSpec + run: | + [ -f Gemfile ] && bundle + gem install --no-document rspec -v '>=3.0, < 4.0' + - name: RSpec Report + run: rspec --force-color --format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..4948d48 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,52 @@ +AllCops: + NewCops: enable + Exclude: + - "Guardfile" + - "Rakefile" + - "node_modules/**/*" + + DisplayCopNames: true + +Layout/LineLength: + Max: 120 +Metrics/MethodLength: + Max: 20 +Metrics/AbcSize: + Max: 50 +Metrics/ClassLength: + Max: 150 +Metrics/BlockLength: + IgnoredMethods: ['describe'] + Max: 30 + + +Style/Documentation: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/EachForSimpleLoop: + Enabled: false +Style/AndOr: + Enabled: false +Style/DefWithParentheses: + Enabled: false +Style/FrozenStringLiteralComment: + EnforcedStyle: never + +Layout/HashAlignment: + EnforcedColonStyle: key +Layout/ExtraSpacing: + AllowForAlignment: false +Layout/MultilineMethodCallIndentation: + Enabled: true + EnforcedStyle: indented +Lint/RaiseException: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Style/HashEachMethods: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3fe9350 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'rubocop', '>= 1.0', '< 2.0' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..afdb6e7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,38 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.2) + json (2.6.3) + language_server-protocol (3.17.0.3) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + racc (1.7.1) + rainbow (3.1.1) + regexp_parser (2.8.1) + rexml (3.2.5) + rubocop (1.54.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + unicode-display_width (2.4.2) + +PLATFORMS + x64-mingw-ucrt + +DEPENDENCIES + rubocop (>= 1.0, < 2.0) + +BUNDLED WITH + 2.4.17 From 6c67468096a046f8f57c836875b91e33cb83e1f9 Mon Sep 17 00:00:00 2001 From: Abdul Ali Noori Date: Thu, 20 Jul 2023 14:36:05 +0330 Subject: [PATCH 04/10] Create the MorseDecoder class and add the MORSE_CODE dictionary. --- morse_decoder.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 morse_decoder.rb diff --git a/morse_decoder.rb b/morse_decoder.rb new file mode 100644 index 0000000..4358d03 --- /dev/null +++ b/morse_decoder.rb @@ -0,0 +1,12 @@ +class MorseDecoder + MORSE_CODE = { + ".-" => "A", "-..." => "B", "-.-." => "C", "-.." => "D", "." => "E", + "..-." => "F", "--." => "G", "...." => "H", ".." => "I", ".---" => "J", + "-.-" => "K", ".-.." => "L", "--" => "M", "-." => "N", "---" => "O", + ".--." => "P", "--.-" => "Q", ".-." => "R", "..." => "S", "-" => "T", + "..-" => "U", "...-" => "V", ".--" => "W", "-..-" => "X", "-.--" => "Y", + "--.." => "Z" + }.freeze +end + + From 19e5f42ac2c492ef618dce219d7fe6c4f852c571 Mon Sep 17 00:00:00 2001 From: echchafykyotmane Date: Thu, 20 Jul 2023 12:11:07 +0100 Subject: [PATCH 05/10] Decode char using decode_char method --- morse_decoder.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/morse_decoder.rb b/morse_decoder.rb index 4358d03..4b23565 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -9,4 +9,6 @@ class MorseDecoder }.freeze end - +def self.decode_char(morse_char) + MORSE_CODE[morse_char] || " " +end From ba34bfa7b246a258f75ace9f175bf68ed64e3b4c Mon Sep 17 00:00:00 2001 From: echchafykyotmane Date: Thu, 20 Jul 2023 12:11:47 +0100 Subject: [PATCH 06/10] Decode word using decode_word method --- morse_decoder.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/morse_decoder.rb b/morse_decoder.rb index 4b23565..746d965 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -12,3 +12,7 @@ class MorseDecoder def self.decode_char(morse_char) MORSE_CODE[morse_char] || " " end + +def self.decode_word(morse_word) + morse_word.split.map { |morse_char| decode_char(morse_char) }.join +end \ No newline at end of file From b91935ecbf34954e446199026bac78a1b952aaca Mon Sep 17 00:00:00 2001 From: echchafykyotmane Date: Thu, 20 Jul 2023 12:12:27 +0100 Subject: [PATCH 07/10] Decode all the message using decode_message method --- morse_decoder.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/morse_decoder.rb b/morse_decoder.rb index 746d965..6085a47 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -15,4 +15,10 @@ def self.decode_char(morse_char) def self.decode_word(morse_word) morse_word.split.map { |morse_char| decode_char(morse_char) }.join +end + +def self.decode_message(morse_message) + morse_words = morse_message.split(" ") + decoded_words = morse_words.map { |morse_word| decode_word(morse_word) } + decoded_words.join(" ") end \ No newline at end of file From 18e34b9f1a93f9a25db511af0c5c53a07801cedb Mon Sep 17 00:00:00 2001 From: echchafykyotmane Date: Thu, 20 Jul 2023 12:25:01 +0100 Subject: [PATCH 08/10] Fixing linters --- morse_decoder.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/morse_decoder.rb b/morse_decoder.rb index 6085a47..5007870 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -7,18 +7,22 @@ class MorseDecoder "..-" => "U", "...-" => "V", ".--" => "W", "-..-" => "X", "-.--" => "Y", "--.." => "Z" }.freeze -end -def self.decode_char(morse_char) - MORSE_CODE[morse_char] || " " -end + def self.decode_char(morse_char) + MORSE_CODE[morse_char] || " " + end + + def self.decode_word(morse_word) + morse_word.split.map { |morse_char| decode_char(morse_char) }.join + end -def self.decode_word(morse_word) - morse_word.split.map { |morse_char| decode_char(morse_char) }.join + def self.decode_message(morse_message) + morse_words = morse_message.split(" ") + decoded_words = morse_words.map { |morse_word| decode_word(morse_word) } + decoded_words.join(" ") + end end -def self.decode_message(morse_message) - morse_words = morse_message.split(" ") - decoded_words = morse_words.map { |morse_word| decode_word(morse_word) } - decoded_words.join(" ") -end \ No newline at end of file +morse_message = ".- -... --- -..- ..-. ..- .-.. .-.. --- ..-. .-. ..- -... .. . ..." +decoded_message = MorseDecoder.decode_message(morse_message) +puts decoded_message From 7560226f201d91dda3580c8c721d44e6c6d43714 Mon Sep 17 00:00:00 2001 From: Abdul Ali Noori Date: Thu, 20 Jul 2023 15:00:13 +0330 Subject: [PATCH 09/10] Remove linter errors. --- morse_decoder.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/morse_decoder.rb b/morse_decoder.rb index 5007870..c9159af 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -23,6 +23,7 @@ def self.decode_message(morse_message) end end +# Test with the provided Morse code message morse_message = ".- -... --- -..- ..-. ..- .-.. .-.. --- ..-. .-. ..- -... .. . ..." decoded_message = MorseDecoder.decode_message(morse_message) puts decoded_message From 90a6352ef3a47e8e081f20baf5ddbe7abf5d65f7 Mon Sep 17 00:00:00 2001 From: Abdul Ali Noori Date: Thu, 20 Jul 2023 15:05:18 +0330 Subject: [PATCH 10/10] Remove linter errors. --- morse_decoder.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/morse_decoder.rb b/morse_decoder.rb index c9159af..0408cd1 100644 --- a/morse_decoder.rb +++ b/morse_decoder.rb @@ -1,15 +1,15 @@ class MorseDecoder MORSE_CODE = { - ".-" => "A", "-..." => "B", "-.-." => "C", "-.." => "D", "." => "E", - "..-." => "F", "--." => "G", "...." => "H", ".." => "I", ".---" => "J", - "-.-" => "K", ".-.." => "L", "--" => "M", "-." => "N", "---" => "O", - ".--." => "P", "--.-" => "Q", ".-." => "R", "..." => "S", "-" => "T", - "..-" => "U", "...-" => "V", ".--" => "W", "-..-" => "X", "-.--" => "Y", - "--.." => "Z" + '.-' => 'A', '-...' => 'B', '-.-.' => 'C', '-..' => 'D', '.' => 'E', + '..-.' => 'F', '--.' => 'G', '....' => 'H', '..' => 'I', '.---' => 'J', + '-.-' => 'K', '.-..' => 'L', '--' => 'M', '-.' => 'N', '---' => 'O', + '.--.' => 'P', '--.-' => 'Q', '.-.' => 'R', '...' => 'S', '-' => 'T', + '..-' => 'U', '...-' => 'V', '.--' => 'W', '-..-' => 'X', '-.--' => 'Y', + '--..' => 'Z' }.freeze def self.decode_char(morse_char) - MORSE_CODE[morse_char] || " " + MORSE_CODE[morse_char] || ' ' end def self.decode_word(morse_word) @@ -17,13 +17,13 @@ def self.decode_word(morse_word) end def self.decode_message(morse_message) - morse_words = morse_message.split(" ") + morse_words = morse_message.split(' ') decoded_words = morse_words.map { |morse_word| decode_word(morse_word) } - decoded_words.join(" ") + decoded_words.join(' ') end end # Test with the provided Morse code message -morse_message = ".- -... --- -..- ..-. ..- .-.. .-.. --- ..-. .-. ..- -... .. . ..." +morse_message = '.- -... --- -..- ..-. ..- .-.. .-.. --- ..-. .-. ..- -... .. . ...' decoded_message = MorseDecoder.decode_message(morse_message) puts decoded_message