diff --git a/README.md b/README.md index d898e100..10fee7b5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Exercism Workspace | Month | Name | Languages | | :--- | :--- | :--- | -| January | Introduction | ✓ | +| January | Introduction | ✓ (jq, Rust) | | February | Functional | Haskell (5/5) | | March | Mechanical | C (2/5), C++ (5/5), Go (3/5), Rust (5/5) | | April | Analytical | Python (5/5) | diff --git a/cpp/isbn-verifier/isbn_verifier.cpp b/cpp/isbn-verifier/isbn_verifier.cpp index 2fbb5a2e..54169295 100644 --- a/cpp/isbn-verifier/isbn_verifier.cpp +++ b/cpp/isbn-verifier/isbn_verifier.cpp @@ -5,11 +5,8 @@ namespace isbn_verifier { bool is_valid(isbn_number_t number) { bool result{false}; - if (number.empty()) { - return result; - } - - const std::string re_valid_str{R"--(^[0-9][0-9-]+[0-9X]$)--"}; + const std::string re_valid_str{ + R"--(^[0-9]-?[0-9]{3}-?[0-9]{5}-?[0-9X]$)--"}; const std::regex re_valid_exp(re_valid_str, std::regex_constants::egrep); if (!std::regex_search(number, re_valid_exp)) { return result; @@ -17,7 +14,6 @@ bool is_valid(isbn_number_t number) { const std::string re_digits_str{R"--([0-9]|X)--"}; const std::regex re_digits_exp(re_digits_str, std::regex_constants::egrep); - auto digits_begin = std::sregex_iterator(number.begin(), number.end(), re_digits_exp); auto digits_end = std::sregex_iterator(); @@ -25,12 +21,6 @@ bool is_valid(isbn_number_t number) { int sum{0}; int pos{10}; - auto digit_count = std::distance(digits_begin, digits_end); - - if (digit_count != 10) { - return result; - } - for (auto iter = digits_begin; iter != digits_end; iter++) { auto re_match = *iter; const std::string digit_str = re_match[0]; @@ -44,7 +34,6 @@ bool is_valid(isbn_number_t number) { } sum += digit * pos; - pos -= 1; } diff --git a/cpp/isbn-verifier/isbn_verifier.plist b/cpp/isbn-verifier/isbn_verifier.plist index 4fa1e477..fb90fda2 100644 --- a/cpp/isbn-verifier/isbn_verifier.plist +++ b/cpp/isbn-verifier/isbn_verifier.plist @@ -3,7 +3,7 @@ clang_version -Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99) +Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105) diagnostics diff --git a/cpp/isbn-verifier/isbn_verifier_test.plist b/cpp/isbn-verifier/isbn_verifier_test.plist index 4fa1e477..fb90fda2 100644 --- a/cpp/isbn-verifier/isbn_verifier_test.plist +++ b/cpp/isbn-verifier/isbn_verifier_test.plist @@ -3,7 +3,7 @@ clang_version -Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99) +Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105) diagnostics diff --git a/cpp/isbn-verifier/run-tests-cpp.txt b/cpp/isbn-verifier/run-tests-cpp.txt index aa32e652..a4e62a27 100644 --- a/cpp/isbn-verifier/run-tests-cpp.txt +++ b/cpp/isbn-verifier/run-tests-cpp.txt @@ -6,9 +6,9 @@ Running automated test file(s): Running: make clean rm -rf ./build -real 0m0.011s -user 0m0.002s -sys 0m0.007s +real 0m0.017s +user 0m0.001s +sys 0m0.016s =============================================================================== @@ -55,12 +55,16 @@ make[1]: Leaving directory '/home/vpayno/git_vpayno/exercism-workspace/cpp/isbn- === All Tests Passed === -find . -regextype posix-egrep -regex "^.*(tests-main|CompilerId).*[.](gcda|gcno)$" -print -delete +find . -regextype posix-egrep -regex '^.*(tests-main|CompilerId).*[.](gcda|gcno)$' -print -delete ./build/CMakeFiles/3.22.2/CompilerIdCXX/CMakeCXXCompilerId.gcno ./build/CMakeFiles/isbn-verifier.dir/test/tests-main.cpp.gcno ./build/CMakeFiles/isbn-verifier.dir/test/tests-main.cpp.gcda -find . -regextype posix-egrep -regex "^.*[.](gcda|gcno)9260" +find . -regextype posix-egrep -regex '^.*[.](gcda|gcno)$' +./build/CMakeFiles/isbn-verifier.dir/isbn_verifier_test.cpp.gcno +./build/CMakeFiles/isbn-verifier.dir/isbn_verifier.cpp.gcno +./build/CMakeFiles/isbn-verifier.dir/isbn_verifier.cpp.gcda +./build/CMakeFiles/isbn-verifier.dir/isbn_verifier_test.cpp.gcda gcovr --print-summary ------------------------------------------------------------------------------ @@ -69,18 +73,18 @@ Directory: . ------------------------------------------------------------------------------ File Lines Exec Cover Missing ------------------------------------------------------------------------------ -isbn_verifier.cpp 29 29 100% +isbn_verifier.cpp 24 24 100% isbn_verifier_test.cpp 51 51 100% test/catch.hpp 34 29 85% 1642-1643,2301-2302,2560 ------------------------------------------------------------------------------ -TOTAL 114 109 95% +TOTAL 109 104 95% ------------------------------------------------------------------------------ -lines: 95.6% (109 out of 114) -branches: 41.1% (156 out of 380) +lines: 95.4% (104 out of 109) +branches: 40.3% (149 out of 370) -real 0m12.048s -user 0m11.206s -sys 0m0.836s +real 0m10.677s +user 0m9.866s +sys 0m0.807s =============================================================================== @@ -88,9 +92,9 @@ cmake-format --in-place CMakeLists.txt WARNING config_util.py:307: The following configuration options were ignored: max_subargs_per_line -real 0m0.158s -user 0m0.117s -sys 0m0.043s +real 0m0.198s +user 0m0.118s +sys 0m0.081s =============================================================================== @@ -110,31 +114,31 @@ found lint: Convention: 3 -real 0m0.173s -user 0m0.139s -sys 0m0.037s +real 0m0.186s +user 0m0.120s +sys 0m0.067s =============================================================================== Running: clang-format-16 -style=file -i ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp -real 0m0.028s -user 0m0.014s -sys 0m0.014s +real 0m0.018s +user 0m0.006s +sys 0m0.012s =============================================================================== Running: ../../.github/citools/cpp/clang-check -clang-check-16 --analyze ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp +Running: clang-check-16 --analyze ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp -real 0m3.501s -user 0m3.396s -sys 0m0.105s +real 0m3.189s +user 0m3.085s +sys 0m0.103s -real 0m3.503s -user 0m3.397s -sys 0m0.106s +real 0m3.191s +user 0m3.085s +sys 0m0.105s =============================================================================== @@ -145,15 +149,15 @@ Running: ../../.github/citools/cpp/clang-tidy | head -n 100 Suppressed 116244 warnings (116239 in non-user code, 5 NOLINT). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. -real 0m21.584s -user 0m21.439s -sys 0m0.142s +real 0m19.478s +user 0m19.345s +sys 0m0.130s Running: clang-tidy-16 ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp -real 0m21.586s -user 0m21.442s -sys 0m0.142s +real 0m19.480s +user 0m19.346s +sys 0m0.132s =============================================================================== diff --git a/cpp/protein-translation/protein_translation.cpp b/cpp/protein-translation/protein_translation.cpp index 0eaa629e..053dd6e9 100644 --- a/cpp/protein-translation/protein_translation.cpp +++ b/cpp/protein-translation/protein_translation.cpp @@ -15,10 +15,6 @@ ProteinList proteins(RnaSequence rna_sequence) { return result; } - if (rna_sequence.length() % k_codon_length != 0) { - return result; - } - const std::string re_str{R"--((\w\w\w))--"}; const std::regex re_exp(re_str); @@ -26,8 +22,6 @@ ProteinList proteins(RnaSequence rna_sequence) { std::sregex_iterator(rna_sequence.begin(), rna_sequence.end(), re_exp); auto words_end = std::sregex_iterator(); - // auto codon_count = std::distance(words_begin, words_end); - for (auto i = words_begin; i != words_end; ++i) { auto match = *i; diff --git a/cpp/protein-translation/protein_translation.plist b/cpp/protein-translation/protein_translation.plist index 4fa1e477..fb90fda2 100644 --- a/cpp/protein-translation/protein_translation.plist +++ b/cpp/protein-translation/protein_translation.plist @@ -3,7 +3,7 @@ clang_version -Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99) +Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105) diagnostics diff --git a/cpp/protein-translation/protein_translation_test.plist b/cpp/protein-translation/protein_translation_test.plist index 4fa1e477..fb90fda2 100644 --- a/cpp/protein-translation/protein_translation_test.plist +++ b/cpp/protein-translation/protein_translation_test.plist @@ -3,7 +3,7 @@ clang_version -Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99) +Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105) diagnostics diff --git a/cpp/protein-translation/run-tests-cpp.txt b/cpp/protein-translation/run-tests-cpp.txt index a5183c4b..5c5f2331 100644 --- a/cpp/protein-translation/run-tests-cpp.txt +++ b/cpp/protein-translation/run-tests-cpp.txt @@ -6,8 +6,8 @@ Running automated test file(s): Running: make clean rm -rf ./build -real 0m0.008s -user 0m0.001s +real 0m0.018s +user 0m0.000s sys 0m0.006s =============================================================================== @@ -55,12 +55,16 @@ make[1]: Leaving directory '/home/vpayno/git_vpayno/exercism-workspace/cpp/prote === All Tests Passed === -find . -regextype posix-egrep -regex "^.*(tests-main|CompilerId).*[.](gcda|gcno)$" -print -delete +find . -regextype posix-egrep -regex '^.*(tests-main|CompilerId).*[.](gcda|gcno)$' -print -delete ./build/CMakeFiles/3.22.2/CompilerIdCXX/CMakeCXXCompilerId.gcno ./build/CMakeFiles/protein-translation.dir/test/tests-main.cpp.gcno ./build/CMakeFiles/protein-translation.dir/test/tests-main.cpp.gcda -find . -regextype posix-egrep -regex "^.*[.](gcda|gcno)6783" +find . -regextype posix-egrep -regex '^.*[.](gcda|gcno)$' +./build/CMakeFiles/protein-translation.dir/protein_translation_test.cpp.gcno +./build/CMakeFiles/protein-translation.dir/protein_translation.cpp.gcno +./build/CMakeFiles/protein-translation.dir/protein_translation.cpp.gcda +./build/CMakeFiles/protein-translation.dir/protein_translation_test.cpp.gcda gcovr --print-summary ------------------------------------------------------------------------------ @@ -69,18 +73,18 @@ Directory: . ------------------------------------------------------------------------------ File Lines Exec Cover Missing ------------------------------------------------------------------------------ -protein_translation.cpp 27 20 74% 11,15,19,40,42,53,55 +protein_translation.cpp 25 19 76% 11,15,34,36,47,49 protein_translation_test.cpp 69 69 100% test/catch.hpp 48 27 56% 1448-1450,1642-1643,1827-1833,1835-1836,2016-2017,2039-2040,2227,2229,2560 ------------------------------------------------------------------------------ -TOTAL 144 116 80% +TOTAL 142 115 81% ------------------------------------------------------------------------------ -lines: 80.6% (116 out of 144) -branches: 40.9% (265 out of 648) +lines: 81.0% (115 out of 142) +branches: 40.9% (264 out of 646) -real 0m12.058s -user 0m11.233s -sys 0m0.822s +real 0m10.987s +user 0m10.156s +sys 0m0.818s =============================================================================== @@ -88,9 +92,9 @@ cmake-format --in-place CMakeLists.txt WARNING config_util.py:307: The following configuration options were ignored: max_subargs_per_line -real 0m0.153s -user 0m0.100s -sys 0m0.055s +real 0m0.189s +user 0m0.114s +sys 0m0.076s =============================================================================== @@ -110,31 +114,31 @@ found lint: Convention: 3 -real 0m0.179s -user 0m0.139s -sys 0m0.042s +real 0m0.180s +user 0m0.122s +sys 0m0.058s =============================================================================== Running: clang-format-16 -style=file -i ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp -real 0m0.020s +real 0m0.021s user 0m0.011s sys 0m0.009s =============================================================================== Running: ../../.github/citools/cpp/clang-check -clang-check-16 --analyze ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp +Running: clang-check-16 --analyze ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp -real 0m3.521s -user 0m3.415s -sys 0m0.106s +real 0m3.146s +user 0m3.056s +sys 0m0.089s -real 0m3.523s -user 0m3.416s -sys 0m0.106s +real 0m3.148s +user 0m3.056s +sys 0m0.091s =============================================================================== @@ -145,15 +149,15 @@ Running: ../../.github/citools/cpp/clang-tidy | head -n 100 Suppressed 116113 warnings (116108 in non-user code, 5 NOLINT). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. -real 0m22.911s -user 0m22.779s -sys 0m0.128s +real 0m20.351s +user 0m20.232s +sys 0m0.114s Running: clang-tidy-16 ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp -real 0m22.913s -user 0m22.780s -sys 0m0.130s +real 0m20.352s +user 0m20.233s +sys 0m0.116s =============================================================================== diff --git a/ruby/README.md b/ruby/README.md index 5327aaa6..5aa00e3a 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -60,3 +60,7 @@ - [matching-brackets](./matching-brackets/README.md) - [perfect-numbers](./perfect-numbers/README.md) - [sum-of-multiples](./sum-of-multiples/README.md) +- [microwave](./microwave/README.md) +- [bob](./bob/README.md) +- [isbn-verifier](./isbn-verifier/README.md) +- [protein-translation](./protein-translation/README.md) diff --git a/ruby/bob/.exercism/config.json b/ruby/bob/.exercism/config.json new file mode 100644 index 00000000..d11feaff --- /dev/null +++ b/ruby/bob/.exercism/config.json @@ -0,0 +1,48 @@ +{ + "authors": [ + "kytrinyx" + ], + "contributors": [ + "ajwann", + "austinlyons", + "avit", + "budmc29", + "cadwallion", + "copiousfreetime", + "doncruse", + "Gaelan", + "hilary", + "iHiD", + "Insti", + "jmay", + "jpotts244", + "koriroys", + "kotp", + "markijbema", + "martyhines", + "Nadrioc", + "Nerian", + "PatrickMcSweeny", + "Pavling", + "prathamesh-sonpatki", + "seeflanigan", + "shingara", + "toddsiegel", + "Tonkpils", + "tryantwit" + ], + "files": { + "solution": [ + "bob.rb" + ], + "test": [ + "bob_test.rb" + ], + "example": [ + ".meta/example.rb" + ] + }, + "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", + "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" +} diff --git a/ruby/bob/.exercism/metadata.json b/ruby/bob/.exercism/metadata.json new file mode 100644 index 00000000..37bd7a7b --- /dev/null +++ b/ruby/bob/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"ruby","exercise":"bob","id":"e0984dbb7a394230a3b77b7790f2c381","url":"https://exercism.org/tracks/ruby/exercises/bob","handle":"vpayno","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/ruby/bob/HELP.md b/ruby/bob/HELP.md new file mode 100644 index 00000000..af473415 --- /dev/null +++ b/ruby/bob/HELP.md @@ -0,0 +1,54 @@ +# Help + +## Running the tests + +For running the tests provided, you will need the Minitest gem. Open a +terminal window and run the following command to install minitest: + +``` +gem install minitest +``` + + +Run the tests from the exercise directory using the following command: + +``` +ruby _test.rb +``` + +Please replace `` with your exercise name in snake_case. + +## Color output + +You can `require 'minitest/pride'` or run the following command to get colored output: + +``` +ruby -r minitest/pride _test.rb +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit bob.rb` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Ruby track's documentation](https://exercism.org/docs/tracks/ruby) +- The [Ruby track's programming category on the forum](https://forum.exercism.org/c/programming/ruby) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Ruby Documentation](http://ruby-doc.org/) +- [StackOverflow](http://stackoverflow.com/questions/tagged/ruby) +- [/r/ruby](https://www.reddit.com/r/ruby) is the Ruby subreddit. \ No newline at end of file diff --git a/ruby/bob/README.md b/ruby/bob/README.md new file mode 100644 index 00000000..e3340df7 --- /dev/null +++ b/ruby/bob/README.md @@ -0,0 +1,80 @@ +# Bob + +Welcome to Bob on Exercism's Ruby Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +Bob is a [lackadaisical][] teenager. +He likes to think that he's very cool. +And he definitely doesn't get excited about things. +That wouldn't be cool. + +When people talk to him, his responses are pretty limited. + +[lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical + +## Instructions + +Your task is to determine what Bob will reply to someone when they say something to him or ask him a question. + +Bob only ever answers one of five things: + +- **"Sure."** + This is his response if you ask him a question, such as "How are you?" + The convention used for questions is that it ends with a question mark. +- **"Whoa, chill out!"** + This is his answer if you YELL AT HIM. + The convention used for yelling is ALL CAPITAL LETTERS. +- **"Calm down, I know what I'm doing!"** + This is what he says if you yell a question at him. +- **"Fine. Be that way!"** + This is how he responds to silence. + The convention used for silence is nothing, or various combinations of whitespace characters. +- **"Whatever."** + This is what he answers to anything else. + +## Source + +### Created by + +- @kytrinyx + +### Contributed to by + +- @ajwann +- @austinlyons +- @avit +- @budmc29 +- @cadwallion +- @copiousfreetime +- @doncruse +- @Gaelan +- @hilary +- @iHiD +- @Insti +- @jmay +- @jpotts244 +- @koriroys +- @kotp +- @markijbema +- @martyhines +- @Nadrioc +- @Nerian +- @PatrickMcSweeny +- @Pavling +- @prathamesh-sonpatki +- @seeflanigan +- @shingara +- @toddsiegel +- @Tonkpils +- @tryantwit + +### Based on + +Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. - https://pine.fm/LearnToProgram/?Chapter=06 + +### My Solution + +- [my solution](./bob.rb) +- [run-tests](./run-tests-ruby.txt) diff --git a/ruby/bob/bob.rb b/ruby/bob/bob.rb new file mode 100644 index 00000000..3168bc24 --- /dev/null +++ b/ruby/bob/bob.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: false + +# https://exercism.org/tracks/ruby/exercises/bob +# Bob exercises +module Bob + def self.hey(remark) + remark.chomp! # remove surrounding newlines + remark.strip! # remove surrounding whitespace + remark.delete!("\n") # remove all remaining newlines + + # Silence + return 'Fine. Be that way!' if remark.match(/^[[:space:]]*$/) + + # Question with only spaces and punctuation + return 'Sure.' if remark.match(/^([[:punct:]]|[[:space:]])+[?]$/) + + # Question with uppercase letters, punctuation and spaces + return "Calm down, I know what I'm doing!" if remark.match(/^([[:upper:]]|[[:punct:]]|[[:space:]])+[?]$/) + + # All remaining questions + return 'Sure.' if remark.match(/^.+[?][[:space:]]*$/) + + # Generic statement + return 'Whatever.' if remark.match(/^([[:digit:]]|[[:punct:]]|[[:space:]])+$/) + + # Yelling statement + return 'Whoa, chill out!' if remark.match(/^([[:upper:]]|[[:digit:]]|[[:punct:]]|[[:space:]])+$/) + + 'Whatever.' + end +end diff --git a/ruby/bob/bob_test.rb b/ruby/bob/bob_test.rb new file mode 100644 index 00000000..c6b657ca --- /dev/null +++ b/ruby/bob/bob_test.rb @@ -0,0 +1,180 @@ +# frozen_string_literal: false + +# https://github.com/simplecov-ruby/simplecov +require 'simplecov' + +# https://about.codecov.io/blog/getting-started-with-code-coverage-for-ruby/ +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + +# line coverage +SimpleCov.start if ENV['COVERAGE'] != 'branch' + +# branch coverage +if ENV['COVERAGE'] == 'branch' + SimpleCov.start do + enable_coverage :branch + primary_coverage :branch + end +end + +# name the test file/group +SimpleCov.command_name 'test:exercism' + +# original exercism tests +require 'minitest/autorun' +require_relative 'bob' + +class BobTest < Minitest::Test + def test_stating_something + # skip + remark = 'Tom-ay-to, tom-aaaah-to.' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears "Tom-ay-to, tom-aaaah-to.", and..' + end + + def test_shouting + # skip + remark = 'WATCH OUT!' + assert_equal 'Whoa, chill out!', Bob.hey(remark), 'Bob hears "WATCH OUT!", and..' + end + + def test_shouting_gibberish + # skip + remark = 'FCECDFCAAB' + assert_equal 'Whoa, chill out!', Bob.hey(remark), 'Bob hears "FCECDFCAAB", and..' + end + + def test_asking_a_question + # skip + remark = 'Does this cryogenic chamber make me look fat?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "Does this cryogenic chamber make me look fat?", and..' + end + + def test_asking_a_numeric_question + # skip + remark = 'You are, what, like 15?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "You are, what, like 15?", and..' + end + + def test_asking_gibberish + # skip + remark = 'fffbbcbeab?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "fffbbcbeab?", and..' + end + + def test_talking_forcefully + # skip + remark = 'Hi there!' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears "Hi there!", and..' + end + + def test_using_acronyms_in_regular_speech + # skip + remark = "It's OK if you don't want to go work for NASA." + assert_equal 'Whatever.', Bob.hey(remark), %q(Bob hears "It's OK if you don't want to go work for NASA.", and..) + end + + def test_forceful_question + # skip + remark = "WHAT'S GOING ON?" + assert_equal "Calm down, I know what I'm doing!", Bob.hey(remark), %q(Bob hears "WHAT'S GOING ON?", and..) + end + + def test_shouting_numbers + # skip + remark = '1, 2, 3 GO!' + assert_equal 'Whoa, chill out!', Bob.hey(remark), 'Bob hears "1, 2, 3 GO!", and..' + end + + def test_no_letters + # skip + remark = '1, 2, 3' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears "1, 2, 3", and..' + end + + def test_question_with_no_letters + # skip + remark = '4?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "4?", and..' + end + + def test_shouting_with_special_characters + # skip + remark = "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!" + assert_equal 'Whoa, chill out!', Bob.hey(remark), + %q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..} + end + + def test_shouting_with_no_exclamation_mark + # skip + remark = 'I HATE THE DENTIST' + assert_equal 'Whoa, chill out!', Bob.hey(remark), 'Bob hears "I HATE THE DENTIST", and..' + end + + def test_statement_containing_question_mark + # skip + remark = 'Ending with ? means a question.' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears "Ending with ? means a question.", and..' + end + + def test_non_letters_with_question + # skip + remark = ':) ?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears ":) ?", and..' + end + + def test_prattling_on + # skip + remark = 'Wait! Hang on. Are you going to be OK?' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "Wait! Hang on. Are you going to be OK?", and..' + end + + def test_silence + # skip + remark = '' + assert_equal 'Fine. Be that way!', Bob.hey(remark), 'Bob hears "", and..' + end + + def test_prolonged_silence + # skip + remark = ' ' + assert_equal 'Fine. Be that way!', Bob.hey(remark), 'Bob hears " ", and..' + end + + def test_alternate_silence + # skip + remark = "\t\t\t\t\t\t\t\t\t\t" + assert_equal 'Fine. Be that way!', Bob.hey(remark), %q(Bob hears "\t\t\t\t\t\t\t\t\t\t", and..) + end + + def test_multiple_line_question + # skip + remark = "\nDoes this cryogenic chamber make me look fat?\nNo." + assert_equal 'Whatever.', Bob.hey(remark), + %q(Bob hears "\nDoes this cryogenic chamber make me look fat?\nNo.", and..) + end + + def test_starting_with_whitespace + # skip + remark = ' hmmmmmmm...' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears " hmmmmmmm...", and..' + end + + def test_ending_with_whitespace + # skip + remark = 'Okay if like my spacebar quite a bit? ' + assert_equal 'Sure.', Bob.hey(remark), 'Bob hears "Okay if like my spacebar quite a bit? ", and..' + end + + def test_other_whitespace + # skip + remark = "\n\r \t" + assert_equal 'Fine. Be that way!', Bob.hey(remark), %q(Bob hears "\n\r \t", and..) + end + + def test_non_question_ending_with_whitespace + # skip + remark = 'This is a statement ending with whitespace ' + assert_equal 'Whatever.', Bob.hey(remark), 'Bob hears "This is a statement ending with whitespace ", and..' + end +end diff --git a/ruby/bob/coverage/.last_run.json b/ruby/bob/coverage/.last_run.json new file mode 100644 index 00000000..52d2bf29 --- /dev/null +++ b/ruby/bob/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "line": 100.0 + } +} diff --git a/ruby/bob/coverage/.resultset.json b/ruby/bob/coverage/.resultset.json new file mode 100644 index 00000000..27ff925f --- /dev/null +++ b/ruby/bob/coverage/.resultset.json @@ -0,0 +1,42 @@ +{ + "test:exercism": { + "coverage": { + "/home/vpayno/git_vpayno/exercism-workspace/ruby/bob/bob.rb": { + "lines": [ + null, + null, + null, + null, + 1, + 1, + 25, + 25, + 25, + null, + null, + 25, + null, + null, + 21, + null, + null, + 20, + null, + null, + 19, + null, + null, + 13, + null, + null, + 12, + null, + 7, + null, + null + ] + } + }, + "timestamp": 1698287045 + } +} diff --git a/ruby/bob/coverage/.resultset.json.lock b/ruby/bob/coverage/.resultset.json.lock new file mode 100644 index 00000000..e69de29b diff --git a/ruby/bob/coverage/coverage.xml b/ruby/bob/coverage/coverage.xml new file mode 100644 index 00000000..602fd720 --- /dev/null +++ b/ruby/bob/coverage/coverage.xml @@ -0,0 +1,31 @@ + + + + + + /home/vpayno/git_vpayno/exercism-workspace/ruby/bob + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruby/bob/run-tests-ruby.txt b/ruby/bob/run-tests-ruby.txt new file mode 100644 index 00000000..0fd56818 --- /dev/null +++ b/ruby/bob/run-tests-ruby.txt @@ -0,0 +1,363 @@ +Running automated test file(s): + + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-rubycritic + +Running RubyCritic + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubycritic --path .rubycritic --format console --no-browser . + +running flay smells + +running flog smells +.. +running reek smells +.. +running complexity +.. +running attributes +.. +running churn +.. +running simple_cov +.. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. +Bob: + Rating: A + Churn: 0 + Complexity: 10.82 + Duplication: 0 + Smells: 1 + * (TooManyStatements) Bob#self.hey has approx 10 statements + - bob.rb:6 + +BobTest: + Rating: B + Churn: 0 + Complexity: 66.0 + Duplication: 0 + Smells: 2 + * (IrresponsibleModule) BobTest has no descriptive comment + - bob_test.rb:28 + * (TooManyMethods) BobTest has at least 25 methods + - bob_test.rb:28 +Score: 90.4 + +real 0m0.691s +user 0m0.589s +sys 0m0.099s + + + ============================================================================== + +Exit code: 0 + +real 0m0.738s +user 0m0.610s +sys 0m0.127s + +real 0m0.742s +user 0m0.610s +sys 0m0.131s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-formatter + +Running Ruby Formatter + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubocop -a . + +Inspecting 2 files +.C + +Offenses: + +bob_test.rb:28:1: C: Metrics/ClassLength: Class has too many lines. [102/100] +class BobTest < Minitest::Test ... +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:28:1: C: Style/Documentation: Missing top-level documentation comment for class BobTest. +class BobTest < Minitest::Test +^^^^^^^^^^^^^ +bob_test.rb:31:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Tom-ay-to, tom-aaaah-to." + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:32:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears "Tom-ay-to, tom-aaaah-to.", and..' + ^^^^^^^^^^^ +bob_test.rb:37:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "WATCH OUT!" + ^^^^^^^^^^^^ +bob_test.rb:38:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whoa, chill out!", Bob.hey(remark), 'Bob hears "WATCH OUT!", and..' + ^^^^^^^^^^^^^^^^^^ +bob_test.rb:43:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "FCECDFCAAB" + ^^^^^^^^^^^^ +bob_test.rb:44:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whoa, chill out!", Bob.hey(remark), 'Bob hears "FCECDFCAAB", and..' + ^^^^^^^^^^^^^^^^^^ +bob_test.rb:49:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Does this cryogenic chamber make me look fat?" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:50:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "Does this cryogenic chamber make me look fat?", and..' + ^^^^^^^ +bob_test.rb:55:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "You are, what, like 15?" + ^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:56:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "You are, what, like 15?", and..' + ^^^^^^^ +bob_test.rb:61:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "fffbbcbeab?" + ^^^^^^^^^^^^^ +bob_test.rb:62:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "fffbbcbeab?", and..' + ^^^^^^^ +bob_test.rb:67:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Hi there!" + ^^^^^^^^^^^ +bob_test.rb:68:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears "Hi there!", and..' + ^^^^^^^^^^^ +bob_test.rb:74:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), %q(Bob hears "It's OK if you don't want to go work for NASA.", and..) + ^^^^^^^^^^^ +bob_test.rb:85:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "1, 2, 3 GO!" + ^^^^^^^^^^^^^ +bob_test.rb:86:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whoa, chill out!", Bob.hey(remark), 'Bob hears "1, 2, 3 GO!", and..' + ^^^^^^^^^^^^^^^^^^ +bob_test.rb:91:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "1, 2, 3" + ^^^^^^^^^ +bob_test.rb:92:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears "1, 2, 3", and..' + ^^^^^^^^^^^ +bob_test.rb:97:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "4?" + ^^^^ +bob_test.rb:98:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "4?", and..' + ^^^^^^^ +bob_test.rb:104:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..} + ^^^^^^^^^^^^^^^^^^ +bob_test.rb:104:54: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. + assert_equal 'Whoa, chill out!', Bob.hey(remark), + ^ +bob_test.rb:104:121: C: [Corrected] Layout/LineLength: Line is too long. [123/120] + assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..} + ^^^ +bob_test.rb:105:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. +%q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:109:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "I HATE THE DENTIST" + ^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:110:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whoa, chill out!", Bob.hey(remark), 'Bob hears "I HATE THE DENTIST", and..' + ^^^^^^^^^^^^^^^^^^ +bob_test.rb:115:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Ending with ? means a question." + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:116:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears "Ending with ? means a question.", and..' + ^^^^^^^^^^^ +bob_test.rb:121:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = ":) ?" + ^^^^^^ +bob_test.rb:122:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears ":) ?", and..' + ^^^^^^^ +bob_test.rb:127:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Wait! Hang on. Are you going to be OK?" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:128:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "Wait! Hang on. Are you going to be OK?", and..' + ^^^^^^^ +bob_test.rb:133:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "" + ^^ +bob_test.rb:134:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Fine. Be that way!", Bob.hey(remark), 'Bob hears "", and..' + ^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:139:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = " " + ^^^^^^^^^^^^ +bob_test.rb:140:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Fine. Be that way!", Bob.hey(remark), 'Bob hears " ", and..' + ^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:146:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Fine. Be that way!", Bob.hey(remark), %q(Bob hears "\t\t\t\t\t\t\t\t\t\t", and..) + ^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:152:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), %q(Bob hears "\nDoes this cryogenic chamber make me look fat?\nNo.", and..) + ^^^^^^^^^^^ +bob_test.rb:152:121: C: [Corrected] Layout/LineLength: Line is too long. [122/120] + assert_equal "Whatever.", Bob.hey(remark), %q(Bob hears "\nDoes this cryogenic chamber make me look fat?\nNo.", and..) + ^^ +bob_test.rb:153:47: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. + assert_equal 'Whatever.', Bob.hey(remark), + ^ +bob_test.rb:154:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. +%q(Bob hears "\nDoes this cryogenic chamber make me look fat?\nNo.", and..) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:157:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = " hmmmmmmm..." + ^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:158:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears " hmmmmmmm...", and..' + ^^^^^^^^^^^ +bob_test.rb:163:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "Okay if like my spacebar quite a bit? " + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:164:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Sure.", Bob.hey(remark), 'Bob hears "Okay if like my spacebar quite a bit? ", and..' + ^^^^^^^ +bob_test.rb:170:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Fine. Be that way!", Bob.hey(remark), %q(Bob hears "\n\r \t", and..) + ^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:175:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + remark = "This is a statement ending with whitespace " + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +bob_test.rb:176:18: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + assert_equal "Whatever.", Bob.hey(remark), 'Bob hears "This is a statement ending with whitespace ", and..' + ^^^^^^^^^^^ + +2 files inspected, 51 offenses detected, 49 offenses corrected + +real 0m0.992s +user 0m0.875s +sys 0m0.202s + + + ============================================================================== + +Exit code: -1 + +real 0m1.065s +user 0m0.910s +sys 0m0.245s + +real 0m1.067s +user 0m0.910s +sys 0m0.246s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-test-with-coverage + +Running Ruby Tests With Coverage + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rm -rf ./coverage + + +real 0m0.001s +user 0m0.000s +sys 0m0.001s + + + ============================================================================== + +Running: ruby ./bob_test.rb -v + +Run options: -v --seed 23871 + +# Running: + +BobTest#test_no_letters = 0.00 s = . +BobTest#test_silence = 0.00 s = . +BobTest#test_non_question_ending_with_whitespace = 0.00 s = . +BobTest#test_using_acronyms_in_regular_speech = 0.00 s = . +BobTest#test_ending_with_whitespace = 0.00 s = . +BobTest#test_prattling_on = 0.00 s = . +BobTest#test_alternate_silence = 0.00 s = . +BobTest#test_asking_gibberish = 0.00 s = . +BobTest#test_forceful_question = 0.00 s = . +BobTest#test_asking_a_numeric_question = 0.00 s = . +BobTest#test_multiple_line_question = 0.00 s = . +BobTest#test_non_letters_with_question = 0.00 s = . +BobTest#test_stating_something = 0.00 s = . +BobTest#test_shouting_numbers = 0.00 s = . +BobTest#test_shouting_with_no_exclamation_mark = 0.00 s = . +BobTest#test_statement_containing_question_mark = 0.00 s = . +BobTest#test_other_whitespace = 0.00 s = . +BobTest#test_question_with_no_letters = 0.00 s = . +BobTest#test_talking_forcefully = 0.00 s = . +BobTest#test_shouting = 0.00 s = . +BobTest#test_starting_with_whitespace = 0.00 s = . +BobTest#test_prolonged_silence = 0.00 s = . +BobTest#test_shouting_gibberish = 0.00 s = . +BobTest#test_shouting_with_special_characters = 0.00 s = . +BobTest#test_asking_a_question = 0.00 s = . + +Finished in 0.001967s, 12708.8056 runs/s, 12708.8056 assertions/s. + +25 runs, 25 assertions, 0 failures, 0 errors, 0 skips +Coverage report generated for test:exercism to /home/vpayno/git_vpayno/exercism-workspace/ruby/bob/coverage/coverage.xml. 12 / 12 LOC (100.00%) covered + +real 0m0.182s +user 0m0.131s +sys 0m0.051s + + + ============================================================================== + +Coverage: 100.0% + + ============================================================================== + +Exit code: 0 + +real 0m0.254s +user 0m0.171s +sys 0m0.089s + +real 0m0.256s +user 0m0.173s +sys 0m0.090s + +=============================================================================== + +Running: misspell . + +real 0m0.021s +user 0m0.019s +sys 0m0.014s + +=============================================================================== + +/home/vpayno/git_vpayno/exercism-workspace/ruby + +=============================================================================== + diff --git a/ruby/isbn-verifier/.exercism/config.json b/ruby/isbn-verifier/.exercism/config.json new file mode 100644 index 00000000..2769652b --- /dev/null +++ b/ruby/isbn-verifier/.exercism/config.json @@ -0,0 +1,29 @@ +{ + "authors": [ + "bmkiefer" + ], + "contributors": [ + "cadwallion", + "iHiD", + "Insti", + "jpotts244", + "kotp", + "pgaspar", + "tryantwit", + "kytrinyx" + ], + "files": { + "solution": [ + "isbn_verifier.rb" + ], + "test": [ + "isbn_verifier_test.rb" + ], + "example": [ + ".meta/example.rb" + ] + }, + "blurb": "Check if a given string is a valid ISBN-10 number.", + "source": "Converting a string into a number and some basic processing utilizing a relatable real world example.", + "source_url": "https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation" +} diff --git a/ruby/isbn-verifier/.exercism/metadata.json b/ruby/isbn-verifier/.exercism/metadata.json new file mode 100644 index 00000000..fe34a2ba --- /dev/null +++ b/ruby/isbn-verifier/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"ruby","exercise":"isbn-verifier","id":"9173bf5cfa5e43a68cd7327b596b1ca3","url":"https://exercism.org/tracks/ruby/exercises/isbn-verifier","handle":"vpayno","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/ruby/isbn-verifier/HELP.md b/ruby/isbn-verifier/HELP.md new file mode 100644 index 00000000..7a5b329f --- /dev/null +++ b/ruby/isbn-verifier/HELP.md @@ -0,0 +1,54 @@ +# Help + +## Running the tests + +For running the tests provided, you will need the Minitest gem. Open a +terminal window and run the following command to install minitest: + +``` +gem install minitest +``` + + +Run the tests from the exercise directory using the following command: + +``` +ruby _test.rb +``` + +Please replace `` with your exercise name in snake_case. + +## Color output + +You can `require 'minitest/pride'` or run the following command to get colored output: + +``` +ruby -r minitest/pride _test.rb +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit isbn_verifier.rb` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Ruby track's documentation](https://exercism.org/docs/tracks/ruby) +- The [Ruby track's programming category on the forum](https://forum.exercism.org/c/programming/ruby) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Ruby Documentation](http://ruby-doc.org/) +- [StackOverflow](http://stackoverflow.com/questions/tagged/ruby) +- [/r/ruby](https://www.reddit.com/r/ruby) is the Ruby subreddit. \ No newline at end of file diff --git a/ruby/isbn-verifier/README.md b/ruby/isbn-verifier/README.md new file mode 100644 index 00000000..94ca97cb --- /dev/null +++ b/ruby/isbn-verifier/README.md @@ -0,0 +1,73 @@ +# ISBN Verifier + +Welcome to ISBN Verifier on Exercism's Ruby Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +The [ISBN-10 verification process][isbn-verification] is used to validate book identification numbers. +These normally contain dashes and look like: `3-598-21508-8` + +## ISBN + +The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). +In the case the check character is an X, this represents the value '10'. +These may be communicated with or without hyphens, and can be checked for their validity by the following formula: + +```text +(d₁ * 10 + d₂ * 9 + d₃ * 8 + d₄ * 7 + d₅ * 6 + d₆ * 5 + d₇ * 4 + d₈ * 3 + d₉ * 2 + d₁₀ * 1) mod 11 == 0 +``` + +If the result is 0, then it is a valid ISBN-10, otherwise it is invalid. + +## Example + +Let's take the ISBN-10 `3-598-21508-8`. +We plug it in to the formula, and get: + +```text +(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0 +``` + +Since the result is 0, this proves that our ISBN is valid. + +## Task + +Given a string the program should check if the provided string is a valid ISBN-10. +Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN. + +The program should be able to verify ISBN-10 both with and without separating dashes. + +## Caveats + +Converting from strings to numbers can be tricky in certain languages. +Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). +For instance `3-598-21507-X` is a valid ISBN-10. + +[isbn-verification]: https://en.wikipedia.org/wiki/International_Standard_Book_Number + +## Source + +### Created by + +- @bmkiefer + +### Contributed to by + +- @cadwallion +- @iHiD +- @Insti +- @jpotts244 +- @kotp +- @pgaspar +- @tryantwit +- @kytrinyx + +### Based on + +Converting a string into a number and some basic processing utilizing a relatable real world example. - https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation + +### My Solution + +- [my solution](./isbn_verifier.rb) +- [run-tests](./run-tests-ruby.txt) diff --git a/ruby/isbn-verifier/coverage/.last_run.json b/ruby/isbn-verifier/coverage/.last_run.json new file mode 100644 index 00000000..52d2bf29 --- /dev/null +++ b/ruby/isbn-verifier/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "line": 100.0 + } +} diff --git a/ruby/isbn-verifier/coverage/.resultset.json b/ruby/isbn-verifier/coverage/.resultset.json new file mode 100644 index 00000000..47f53039 --- /dev/null +++ b/ruby/isbn-verifier/coverage/.resultset.json @@ -0,0 +1,33 @@ +{ + "test:exercism": { + "coverage": { + "/home/vpayno/git_vpayno/exercism-workspace/ruby/isbn-verifier/isbn_verifier.rb": { + "lines": [ + null, + null, + null, + null, + 1, + 1, + 19, + null, + 6, + null, + 6, + 66, + 6, + null, + null, + 1, + 78, + 66, + null, + null, + 1, + null + ] + } + }, + "timestamp": 1698294736 + } +} diff --git a/ruby/isbn-verifier/coverage/.resultset.json.lock b/ruby/isbn-verifier/coverage/.resultset.json.lock new file mode 100644 index 00000000..e69de29b diff --git a/ruby/isbn-verifier/coverage/coverage.xml b/ruby/isbn-verifier/coverage/coverage.xml new file mode 100644 index 00000000..f96af8bf --- /dev/null +++ b/ruby/isbn-verifier/coverage/coverage.xml @@ -0,0 +1,30 @@ + + + + + + /home/vpayno/git_vpayno/exercism-workspace/ruby/isbn-verifier + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruby/isbn-verifier/isbn_verifier.rb b/ruby/isbn-verifier/isbn_verifier.rb new file mode 100644 index 00000000..f4047e33 --- /dev/null +++ b/ruby/isbn-verifier/isbn_verifier.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: false + +# https://exercism.org/tracks/ruby/exercises/isbn-verifier +# ISBN Verifier exercise +module IsbnVerifier + def self.valid?(input) + return false if input !~ /^[0-9]-?[0-9]{3}-?[0-9]{5}-?[0-9X]$/ + + digits = string2digits(input) + + pos = 11 + digits.map! { |rune| (pos -= 1) * rune } + digits.sum.modulo(11).zero? + end + + def self.string2digits(string) + digits = string.chars.select { |rune| rune.match(/[0-9]|X/) } + digits.map { |rune| rune.eql?('X') ? 10 : rune.to_i } + end + + private_class_method :string2digits +end diff --git a/ruby/isbn-verifier/isbn_verifier_test.rb b/ruby/isbn-verifier/isbn_verifier_test.rb new file mode 100644 index 00000000..969f7dc9 --- /dev/null +++ b/ruby/isbn-verifier/isbn_verifier_test.rb @@ -0,0 +1,142 @@ +# frozen_string_literal: false + +# https://github.com/simplecov-ruby/simplecov +require 'simplecov' + +# https://about.codecov.io/blog/getting-started-with-code-coverage-for-ruby/ +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + +# line coverage +SimpleCov.start if ENV['COVERAGE'] != 'branch' + +# branch coverage +if ENV['COVERAGE'] == 'branch' + SimpleCov.start do + enable_coverage :branch + primary_coverage :branch + end +end + +# name the test file/group +SimpleCov.command_name 'test:exercism' + +# original exercism tests +require 'minitest/autorun' +require_relative 'isbn_verifier' + +class IsbnVerifierTest < Minitest::Test + def test_valid_isbn + # skip + string = '3-598-21508-8' + assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn" + end + + def test_invalid_isbn_check_digit + # skip + string = '3-598-21508-9' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_valid_isbn_with_a_check_digit_of_10 + # skip + string = '3-598-21507-X' + assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn" + end + + def test_check_digit_is_a_character_other_than_x + # skip + string = '3-598-21507-A' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_invalid_check_digit_in_isbn_is_not_treated_as_zero + # skip + string = '4-598-21507-B' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_invalid_character_in_isbn_is_not_treated_as_zero + # skip + string = '3-598-P1581-X' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_x_is_only_valid_as_a_check_digit + # skip + string = '3-598-2X507-9' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_valid_isbn_without_separating_dashes + # skip + string = '3598215088' + assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn" + end + + def test_isbn_without_separating_dashes_and_x_as_check_digit + # skip + string = '359821507X' + assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn" + end + + def test_isbn_without_check_digit_and_dashes + # skip + string = '359821507' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_too_long_isbn_and_no_dashes + # skip + string = '3598215078X' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_too_short_isbn + # skip + string = '00' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_isbn_without_check_digit + # skip + string = '3-598-21507' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_check_digit_of_x_should_not_be_used_for_0 + # skip + string = '3-598-21515-X' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_empty_isbn + # skip + string = '' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_input_is_9_characters + # skip + string = '134456729' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_invalid_characters_are_not_ignored_after_checking_length + # skip + string = '3132P34035' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_invalid_characters_are_not_ignored_before_checking_length + # skip + string = '3598P215088' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end + + def test_input_is_too_long_but_contains_a_valid_isbn + # skip + string = '98245726788' + refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn" + end +end diff --git a/ruby/isbn-verifier/run-tests-ruby.txt b/ruby/isbn-verifier/run-tests-ruby.txt new file mode 100644 index 00000000..38371435 --- /dev/null +++ b/ruby/isbn-verifier/run-tests-ruby.txt @@ -0,0 +1,274 @@ +Running automated test file(s): + + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-rubycritic + +Running RubyCritic + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubycritic --path .rubycritic --format console --no-browser . + +running flay smells + +running flog smells +.. +running reek smells +.. +running complexity +.. +running attributes +.. +running churn +.. +running simple_cov +.. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. +IsbnVerifier: + Rating: A + Churn: 0 + Complexity: 17.4 + Duplication: 0 + Smells: 1 + * (TooManyStatements) IsbnVerifier#self.valid? has approx 6 statements + - isbn_verifier.rb:6 + +IsbnVerifierTest: + Rating: B + Churn: 0 + Complexity: 50.16 + Duplication: 0 + Smells: 4 + * (IrresponsibleModule) IsbnVerifierTest has no descriptive comment + - isbn_verifier_test.rb:28 + * (TooManyMethods) IsbnVerifierTest has at least 19 methods + - isbn_verifier_test.rb:28 + * (UncommunicativeMethodName) IsbnVerifierTest#test_check_digit_of_x_should_not_be_used_for_0 has the name 'test_check_digit_of_x_should_not_be_used_for_0' + - isbn_verifier_test.rb:107 + * (UncommunicativeMethodName) IsbnVerifierTest#test_valid_isbn_with_a_check_digit_of_10 has the name 'test_valid_isbn_with_a_check_digit_of_10' + - isbn_verifier_test.rb:41 +Score: 91.56 + +real 0m0.667s +user 0m0.552s +sys 0m0.113s + + + ============================================================================== + +Exit code: 0 + +real 0m0.726s +user 0m0.584s +sys 0m0.143s + +real 0m0.729s +user 0m0.584s +sys 0m0.146s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-formatter + +Running Ruby Formatter + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubocop -a . + +Inspecting 2 files +.C + +Offenses: + +isbn_verifier_test.rb:28:1: C: Style/Documentation: Missing top-level documentation comment for class IsbnVerifierTest. +class IsbnVerifierTest < Minitest::Test +^^^^^^^^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:31:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21508-8" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:37:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21508-9" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:41:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_valid_isbn_with_a_check_digit_of_10 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:43:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21507-X" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:49:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21507-A" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:55:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "4-598-21507-B" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:61:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-P1581-X" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:67:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-2X507-9" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:73:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3598215088" + ^^^^^^^^^^^^ +isbn_verifier_test.rb:79:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "359821507X" + ^^^^^^^^^^^^ +isbn_verifier_test.rb:85:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "359821507" + ^^^^^^^^^^^ +isbn_verifier_test.rb:91:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3598215078X" + ^^^^^^^^^^^^^ +isbn_verifier_test.rb:97:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "00" + ^^^^ +isbn_verifier_test.rb:103:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21507" + ^^^^^^^^^^^^^ +isbn_verifier_test.rb:107:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_check_digit_of_x_should_not_be_used_for_0 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:109:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3-598-21515-X" + ^^^^^^^^^^^^^^^ +isbn_verifier_test.rb:115:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "" + ^^ +isbn_verifier_test.rb:121:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "134456729" + ^^^^^^^^^^^ +isbn_verifier_test.rb:127:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3132P34035" + ^^^^^^^^^^^^ +isbn_verifier_test.rb:133:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "3598P215088" + ^^^^^^^^^^^^^ +isbn_verifier_test.rb:139:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + string = "98245726788" + ^^^^^^^^^^^^^ + +2 files inspected, 22 offenses detected, 19 offenses corrected + +real 0m1.019s +user 0m0.894s +sys 0m0.214s + + + ============================================================================== + +Exit code: -1 + +real 0m1.085s +user 0m0.926s +sys 0m0.252s + +real 0m1.087s +user 0m0.926s +sys 0m0.254s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-test-with-coverage + +Running Ruby Tests With Coverage + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rm -rf ./coverage + + +real 0m0.001s +user 0m0.000s +sys 0m0.001s + + + ============================================================================== + +Running: ruby ./isbn_verifier_test.rb -v + +Run options: -v --seed 27669 + +# Running: + +IsbnVerifierTest#test_check_digit_of_x_should_not_be_used_for_0 = 0.00 s = . +IsbnVerifierTest#test_isbn_without_check_digit_and_dashes = 0.00 s = . +IsbnVerifierTest#test_x_is_only_valid_as_a_check_digit = 0.00 s = . +IsbnVerifierTest#test_invalid_characters_are_not_ignored_before_checking_length = 0.00 s = . +IsbnVerifierTest#test_check_digit_is_a_character_other_than_x = 0.00 s = . +IsbnVerifierTest#test_valid_isbn = 0.00 s = . +IsbnVerifierTest#test_valid_isbn_without_separating_dashes = 0.00 s = . +IsbnVerifierTest#test_input_is_9_characters = 0.00 s = . +IsbnVerifierTest#test_isbn_without_check_digit = 0.00 s = . +IsbnVerifierTest#test_isbn_without_separating_dashes_and_x_as_check_digit = 0.00 s = . +IsbnVerifierTest#test_invalid_check_digit_in_isbn_is_not_treated_as_zero = 0.00 s = . +IsbnVerifierTest#test_valid_isbn_with_a_check_digit_of_10 = 0.00 s = . +IsbnVerifierTest#test_empty_isbn = 0.00 s = . +IsbnVerifierTest#test_input_is_too_long_but_contains_a_valid_isbn = 0.00 s = . +IsbnVerifierTest#test_invalid_isbn_check_digit = 0.00 s = . +IsbnVerifierTest#test_invalid_character_in_isbn_is_not_treated_as_zero = 0.00 s = . +IsbnVerifierTest#test_too_short_isbn = 0.00 s = . +IsbnVerifierTest#test_invalid_characters_are_not_ignored_after_checking_length = 0.00 s = . +IsbnVerifierTest#test_too_long_isbn_and_no_dashes = 0.00 s = . + +Finished in 0.005723s, 3319.9174 runs/s, 3319.9174 assertions/s. + +19 runs, 19 assertions, 0 failures, 0 errors, 0 skips +Coverage report generated for test:exercism to /home/vpayno/git_vpayno/exercism-workspace/ruby/isbn-verifier/coverage/coverage.xml. 11 / 11 LOC (100.00%) covered + +real 0m0.192s +user 0m0.130s +sys 0m0.063s + + + ============================================================================== + +Coverage: 100.0% + + ============================================================================== + +Exit code: 0 + +real 0m0.274s +user 0m0.162s +sys 0m0.117s + +real 0m0.276s +user 0m0.163s +sys 0m0.118s + +=============================================================================== + +Running: misspell . + +real 0m0.025s +user 0m0.031s +sys 0m0.011s + +=============================================================================== + +/home/vpayno/git_vpayno/exercism-workspace/ruby + +=============================================================================== + diff --git a/ruby/microwave/.exercism/config.json b/ruby/microwave/.exercism/config.json new file mode 100644 index 00000000..39cdb7f2 --- /dev/null +++ b/ruby/microwave/.exercism/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "gatorjuice" + ], + "contributors": [ + "aleksandrilyin", + "petertseng" + ], + "files": { + "solution": [ + "microwave.rb" + ], + "test": [ + "microwave_test.rb" + ], + "example": [ + ".meta/example.rb" + ] + }, + "blurb": "Convert the buttons entered on the microwave panel to their timer equivalent" +} diff --git a/ruby/microwave/.exercism/metadata.json b/ruby/microwave/.exercism/metadata.json new file mode 100644 index 00000000..c64320c4 --- /dev/null +++ b/ruby/microwave/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"ruby","exercise":"microwave","id":"c29405a2f94c4853a03b9e334f94b5f3","url":"https://exercism.org/tracks/ruby/exercises/microwave","handle":"vpayno","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/ruby/microwave/HELP.md b/ruby/microwave/HELP.md new file mode 100644 index 00000000..4e6c9820 --- /dev/null +++ b/ruby/microwave/HELP.md @@ -0,0 +1,54 @@ +# Help + +## Running the tests + +For running the tests provided, you will need the Minitest gem. Open a +terminal window and run the following command to install minitest: + +``` +gem install minitest +``` + + +Run the tests from the exercise directory using the following command: + +``` +ruby _test.rb +``` + +Please replace `` with your exercise name in snake_case. + +## Color output + +You can `require 'minitest/pride'` or run the following command to get colored output: + +``` +ruby -r minitest/pride _test.rb +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit microwave.rb` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Ruby track's documentation](https://exercism.org/docs/tracks/ruby) +- The [Ruby track's programming category on the forum](https://forum.exercism.org/c/programming/ruby) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Ruby Documentation](http://ruby-doc.org/) +- [StackOverflow](http://stackoverflow.com/questions/tagged/ruby) +- [/r/ruby](https://www.reddit.com/r/ruby) is the Ruby subreddit. \ No newline at end of file diff --git a/ruby/microwave/README.md b/ruby/microwave/README.md new file mode 100644 index 00000000..0489e2c4 --- /dev/null +++ b/ruby/microwave/README.md @@ -0,0 +1,28 @@ +# Microwave + +Welcome to Microwave on Exercism's Ruby Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Convert the buttons entered on the microwave panel to their timer equivalent. + +Microwave timers are smart enough to know that when you press 90 for seconds, you mean '01:30', which is 90 seconds. We want to have a "smart display" that will convert this to the lowest form of minutes and seconds, rather than leaving it as 90 seconds. + +Build a class that accepts buttons entered and converts them to the proper display panel time. + +## Source + +### Created by + +- @gatorjuice + +### Contributed to by + +- @aleksandrilyin +- @petertseng + +### My Solution + +- [my solution](./microwave.rb) +- [run-tests](./run-tests-ruby.txt) diff --git a/ruby/microwave/coverage/.last_run.json b/ruby/microwave/coverage/.last_run.json new file mode 100644 index 00000000..52d2bf29 --- /dev/null +++ b/ruby/microwave/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "line": 100.0 + } +} diff --git a/ruby/microwave/coverage/.resultset.json b/ruby/microwave/coverage/.resultset.json new file mode 100644 index 00000000..73b293e3 --- /dev/null +++ b/ruby/microwave/coverage/.resultset.json @@ -0,0 +1,51 @@ +{ + "test:exercism": { + "coverage": { + "/home/vpayno/git_vpayno/exercism-workspace/ruby/microwave/microwave.rb": { + "lines": [ + null, + null, + null, + null, + 1, + 1, + 11, + 11, + 11, + null, + null, + 1, + 11, + null, + null, + 1, + 5, + 5, + null, + 5, + null, + null, + 1, + 6, + 6, + null, + 6, + 1, + 1, + null, + null, + 6, + null, + null, + 1, + 11, + null, + 6, + null, + null + ] + } + }, + "timestamp": 1698264408 + } +} diff --git a/ruby/microwave/coverage/.resultset.json.lock b/ruby/microwave/coverage/.resultset.json.lock new file mode 100644 index 00000000..e69de29b diff --git a/ruby/microwave/coverage/coverage.xml b/ruby/microwave/coverage/coverage.xml new file mode 100644 index 00000000..df7e211c --- /dev/null +++ b/ruby/microwave/coverage/coverage.xml @@ -0,0 +1,40 @@ + + + + + + /home/vpayno/git_vpayno/exercism-workspace/ruby/microwave + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruby/microwave/microwave.rb b/ruby/microwave/microwave.rb new file mode 100644 index 00000000..8d749af6 --- /dev/null +++ b/ruby/microwave/microwave.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# https://exercism.org/tracks/ruby/exercises/microwave +# Microwave exercise +class Microwave + def initialize(input) + @input = input + @minutes = 0 + @seconds = 0 + end + + def display_output + "#{@minutes.to_s.rjust(2, '0')}:#{@seconds.to_s.rjust(2, '0')}" + end + + def timer_under_onehundred + @minutes = (@input / 60) + @seconds = @input.modulo(60) + + display_output + end + + def timer_over_equals_onehundred + @minutes = (@input / 100) + @seconds = (@input - (100 * @minutes)) + + if @seconds >= 60 + @minutes += (@seconds / 60) + @seconds = @seconds.modulo(60) + end + + display_output + end + + def timer + return timer_under_onehundred if @input < 100 + + timer_over_equals_onehundred + end +end diff --git a/ruby/microwave/microwave_test.rb b/ruby/microwave/microwave_test.rb new file mode 100644 index 00000000..6acaefd1 --- /dev/null +++ b/ruby/microwave/microwave_test.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: false + +# https://github.com/simplecov-ruby/simplecov +require 'simplecov' + +# https://about.codecov.io/blog/getting-started-with-code-coverage-for-ruby/ +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + +# line coverage +SimpleCov.start if ENV['COVERAGE'] != 'branch' + +# branch coverage +if ENV['COVERAGE'] == 'branch' + SimpleCov.start do + enable_coverage :branch + primary_coverage :branch + end +end + +# name the test file/group +SimpleCov.command_name 'test:exercism' + +# original exercism tests +require 'minitest/autorun' +require_relative 'microwave' + +class MicrowaveTest < Minitest::Test + def test_one_second + assert_equal '00:01', Microwave.new(1).timer + end + + def test_fifty_nine_seconds + assert_equal '00:59', Microwave.new(59).timer + end + + def test_sixty_seconds + assert_equal '01:00', Microwave.new(60).timer + end + + def test_one_minute + assert_equal '01:00', Microwave.new(100).timer + end + + def test_ninety_seconds + assert_equal '01:30', Microwave.new(90).timer + end + + def test_one_minute_and_one_second + assert_equal '01:01', Microwave.new(101).timer + end + + def test_sixty_one_seconds + assert_equal '01:01', Microwave.new(61).timer + end + + def test_one_minute_and_fifty_nine_seconds + assert_equal '01:59', Microwave.new(159).timer + end + + def test_two_minutes + assert_equal '02:00', Microwave.new(200).timer + end + + def test_over_ten_minutes + assert_equal '10:01', Microwave.new(1001).timer + end + + def test_minute_overflow_adds_to_input_minutes + assert_equal '03:12', Microwave.new(272).timer + end +end diff --git a/ruby/microwave/run-tests-ruby.txt b/ruby/microwave/run-tests-ruby.txt new file mode 100644 index 00000000..a792cde8 --- /dev/null +++ b/ruby/microwave/run-tests-ruby.txt @@ -0,0 +1,195 @@ +Running automated test file(s): + + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-rubycritic + +Running RubyCritic + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubycritic --path .rubycritic --format console --no-browser . + +running flay smells + +running flog smells +.. +running reek smells +.. +running complexity +.. +running attributes +.. +running churn +.. +running simple_cov +.. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. +Microwave: + Rating: A + Churn: 0 + Complexity: 27.27 + Duplication: 0 + Smells: 0 + +MicrowaveTest: + Rating: A + Churn: 0 + Complexity: 47.58 + Duplication: 0 + Smells: 1 + * (IrresponsibleModule) MicrowaveTest has no descriptive comment + - microwave_test.rb:28 +Score: 90.64 + +real 0m0.783s +user 0m0.671s +sys 0m0.110s + + + ============================================================================== + +Exit code: 0 + +real 0m0.847s +user 0m0.705s +sys 0m0.144s + +real 0m0.850s +user 0m0.706s +sys 0m0.145s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-formatter + +Running Ruby Formatter + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubocop -a . + +Inspecting 2 files +.C + +Offenses: + +microwave_test.rb:28:1: C: Style/Documentation: Missing top-level documentation comment for class MicrowaveTest. +class MicrowaveTest < Minitest::Test +^^^^^^^^^^^^^^^^^^^ + +2 files inspected, 1 offense detected + +real 0m1.208s +user 0m1.114s +sys 0m0.246s + + + ============================================================================== + +Exit code: -1 + +real 0m1.279s +user 0m1.142s +sys 0m0.293s + +real 0m1.281s +user 0m1.144s +sys 0m0.293s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-test-with-coverage + +Running Ruby Tests With Coverage + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rm -rf ./coverage + + +real 0m0.001s +user 0m0.000s +sys 0m0.001s + + + ============================================================================== + +Running: ruby ./microwave_test.rb -v + +Run options: -v --seed 56734 + +# Running: + +MicrowaveTest#test_ninety_seconds = 0.00 s = . +MicrowaveTest#test_one_minute_and_one_second = 0.00 s = . +MicrowaveTest#test_minute_overflow_adds_to_input_minutes = 0.00 s = . +MicrowaveTest#test_over_ten_minutes = 0.00 s = . +MicrowaveTest#test_one_minute_and_fifty_nine_seconds = 0.00 s = . +MicrowaveTest#test_fifty_nine_seconds = 0.00 s = . +MicrowaveTest#test_one_second = 0.00 s = . +MicrowaveTest#test_one_minute = 0.00 s = . +MicrowaveTest#test_sixty_one_seconds = 0.00 s = . +MicrowaveTest#test_two_minutes = 0.00 s = . +MicrowaveTest#test_sixty_seconds = 0.00 s = . + +Finished in 0.007673s, 1433.5531 runs/s, 1433.5531 assertions/s. + +11 runs, 11 assertions, 0 failures, 0 errors, 0 skips +Coverage report generated for test:exercism to /home/vpayno/git_vpayno/exercism-workspace/ruby/microwave/coverage/coverage.xml. 21 / 21 LOC (100.00%) covered + +real 0m0.199s +user 0m0.149s +sys 0m0.049s + + + ============================================================================== + +Coverage: 100.0% + + ============================================================================== + +Exit code: 0 + +real 0m0.261s +user 0m0.178s +sys 0m0.086s + +real 0m0.264s +user 0m0.179s +sys 0m0.087s + +=============================================================================== + +Running: misspell . + +real 0m0.028s +user 0m0.032s +sys 0m0.011s + +=============================================================================== + +/home/vpayno/git_vpayno/exercism-workspace/ruby + +=============================================================================== + diff --git a/ruby/protein-translation/.exercism/config.json b/ruby/protein-translation/.exercism/config.json new file mode 100644 index 00000000..e49cba1c --- /dev/null +++ b/ruby/protein-translation/.exercism/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "Teapane" + ], + "contributors": [ + "budmc29", + "chrisvroberts", + "dkinzer", + "hilary", + "iHiD", + "Insti", + "kotp", + "kytrinyx", + "mamenama", + "pendletons", + "tryantwit" + ], + "files": { + "solution": [ + "protein_translation.rb" + ], + "test": [ + "protein_translation_test.rb" + ], + "example": [ + ".meta/example.rb" + ] + }, + "blurb": "Translate RNA sequences into proteins.", + "source": "Tyler Long" +} diff --git a/ruby/protein-translation/.exercism/metadata.json b/ruby/protein-translation/.exercism/metadata.json new file mode 100644 index 00000000..bbe10ce9 --- /dev/null +++ b/ruby/protein-translation/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"ruby","exercise":"protein-translation","id":"96e3a535f3414bc285c1c05c66826cce","url":"https://exercism.org/tracks/ruby/exercises/protein-translation","handle":"vpayno","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/ruby/protein-translation/HELP.md b/ruby/protein-translation/HELP.md new file mode 100644 index 00000000..47bea17f --- /dev/null +++ b/ruby/protein-translation/HELP.md @@ -0,0 +1,54 @@ +# Help + +## Running the tests + +For running the tests provided, you will need the Minitest gem. Open a +terminal window and run the following command to install minitest: + +``` +gem install minitest +``` + + +Run the tests from the exercise directory using the following command: + +``` +ruby _test.rb +``` + +Please replace `` with your exercise name in snake_case. + +## Color output + +You can `require 'minitest/pride'` or run the following command to get colored output: + +``` +ruby -r minitest/pride _test.rb +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit protein_translation.rb` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Ruby track's documentation](https://exercism.org/docs/tracks/ruby) +- The [Ruby track's programming category on the forum](https://forum.exercism.org/c/programming/ruby) +- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Ruby Documentation](http://ruby-doc.org/) +- [StackOverflow](http://stackoverflow.com/questions/tagged/ruby) +- [/r/ruby](https://www.reddit.com/r/ruby) is the Ruby subreddit. \ No newline at end of file diff --git a/ruby/protein-translation/README.md b/ruby/protein-translation/README.md new file mode 100644 index 00000000..7729c429 --- /dev/null +++ b/ruby/protein-translation/README.md @@ -0,0 +1,79 @@ +# Protein Translation + +Welcome to Protein Translation on Exercism's Ruby Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Translate RNA sequences into proteins. + +RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: + +RNA: `"AUGUUUUCU"` => translates to + +Codons: `"AUG", "UUU", "UCU"` +=> which become a polypeptide with the following sequence => + +Protein: `"Methionine", "Phenylalanine", "Serine"` + +There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. +If it works for one codon, the program should work for all of them. +However, feel free to expand the list in the test suite to include them all. + +There are also three terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated. + +All subsequent codons after are ignored, like this: + +RNA: `"AUGUUUUCUUAAAUG"` => + +Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` => + +Protein: `"Methionine", "Phenylalanine", "Serine"` + +Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence. + +Below are the codons and resulting Amino Acids needed for the exercise. + +Codon | Protein +:--- | :--- +AUG | Methionine +UUU, UUC | Phenylalanine +UUA, UUG | Leucine +UCU, UCC, UCA, UCG | Serine +UAU, UAC | Tyrosine +UGU, UGC | Cysteine +UGG | Tryptophan +UAA, UAG, UGA | STOP + +Learn more about [protein translation on Wikipedia][protein-translation]. + +[protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology) + +## Source + +### Created by + +- @Teapane + +### Contributed to by + +- @budmc29 +- @chrisvroberts +- @dkinzer +- @hilary +- @iHiD +- @Insti +- @kotp +- @kytrinyx +- @mamenama +- @pendletons +- @tryantwit + +### Based on + +Tyler Long + +### My Solution + +- [my solution](./protein_translation.rb) +- [run-tests](./run-tests-ruby.txt) diff --git a/ruby/protein-translation/coverage/.last_run.json b/ruby/protein-translation/coverage/.last_run.json new file mode 100644 index 00000000..52d2bf29 --- /dev/null +++ b/ruby/protein-translation/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "line": 100.0 + } +} diff --git a/ruby/protein-translation/coverage/.resultset.json b/ruby/protein-translation/coverage/.resultset.json new file mode 100644 index 00000000..299b619f --- /dev/null +++ b/ruby/protein-translation/coverage/.resultset.json @@ -0,0 +1,75 @@ +{ + "test:exercism": { + "coverage": { + "/home/vpayno/git_vpayno/exercism-workspace/ruby/protein-translation/protein_translation.rb": { + "lines": [ + null, + null, + null, + null, + 1, + 1, + null, + 1, + null, + 32, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 32, + null, + 30, + null, + null, + 1, + 30, + null, + 29, + 29, + 29, + 42, + null, + 42, + 9, + 9, + null, + null, + 33, + null, + null, + 29, + null, + 60, + null, + null, + null, + null, + 1, + 1, + null, + 1, + 3, + 3, + null, + null + ] + } + }, + "timestamp": 1698299820 + } +} diff --git a/ruby/protein-translation/coverage/.resultset.json.lock b/ruby/protein-translation/coverage/.resultset.json.lock new file mode 100644 index 00000000..e69de29b diff --git a/ruby/protein-translation/coverage/coverage.xml b/ruby/protein-translation/coverage/coverage.xml new file mode 100644 index 00000000..3b14fb16 --- /dev/null +++ b/ruby/protein-translation/coverage/coverage.xml @@ -0,0 +1,42 @@ + + + + + + /home/vpayno/git_vpayno/exercism-workspace/ruby/protein-translation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruby/protein-translation/protein_translation.rb b/ruby/protein-translation/protein_translation.rb new file mode 100644 index 00000000..f04927a9 --- /dev/null +++ b/ruby/protein-translation/protein_translation.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: false + +# https://exercism.org/tracks/ruby/exercises/protein-translation +# Protein Translation exercise +module Translation + CODON_LENGTH = 3 + + def self.to_protein(codon) + codon2protein = { + 'AUG' => 'Methionine', + 'UUU' => 'Phenylalanine', + 'UUC' => 'Phenylalanine', + 'UUA' => 'Leucine', + 'UUG' => 'Leucine', + 'UCU' => 'Serine', + 'UCC' => 'Serine', + 'UCA' => 'Serine', + 'UCG' => 'Serine', + 'UAU' => 'Tyrosine', + 'UAC' => 'Tyrosine', + 'UGU' => 'Cysteine', + 'UGC' => 'Cysteine', + 'UGG' => 'Tryptophan', + 'UAA' => 'STOP', + 'UAG' => 'STOP', + 'UGA' => 'STOP' + } + + raise InvalidCodonError, 'invalid codon' unless codon2protein.key?(codon) + + codon2protein[codon] + end + + def self.of_rna(rna_sequence) + return [] if rna_sequence.empty? + + has_stop = false + codons = [] + rna_sequence.scan(/([A-Z]{3})/) do |match| + codon = match[0] + + if %w[UAA UAG UGA].include?(codon) + has_stop = true + break + end + + codons.push(codon) + end + + raise InvalidCodonError, 'invalid codon' if !has_stop && rna_sequence.length.modulo(CODON_LENGTH).positive? + + codons.map { |codon| to_protein(codon) } + end +end + +# InvalidCodonError exception +class InvalidCodonError < StandardError + attr_reader :data + + def initialize(data) + super + @data = data + end +end diff --git a/ruby/protein-translation/protein_translation_test.rb b/ruby/protein-translation/protein_translation_test.rb new file mode 100644 index 00000000..acc80c34 --- /dev/null +++ b/ruby/protein-translation/protein_translation_test.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: false + +# https://github.com/simplecov-ruby/simplecov +require 'simplecov' + +# https://about.codecov.io/blog/getting-started-with-code-coverage-for-ruby/ +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + +# line coverage +SimpleCov.start if ENV['COVERAGE'] != 'branch' + +# branch coverage +if ENV['COVERAGE'] == 'branch' + SimpleCov.start do + enable_coverage :branch + primary_coverage :branch + end +end + +# name the test file/group +SimpleCov.command_name 'test:exercism' + +# original exercism tests +require 'minitest/autorun' +require_relative 'protein_translation' + +class ProteinTranslationTest < Minitest::Test + def test_empty_rna_sequence_results_in_no_proteins + # skip + strand = '' + expected = [] + assert_equal expected, Translation.of_rna(strand) + end + + def test_methionine_rna_sequence + # skip + strand = 'AUG' + expected = ['Methionine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_phenylalanine_rna_sequence_1 + # skip + strand = 'UUU' + expected = ['Phenylalanine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_phenylalanine_rna_sequence_2 + # skip + strand = 'UUC' + expected = ['Phenylalanine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_leucine_rna_sequence_1 + # skip + strand = 'UUA' + expected = ['Leucine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_leucine_rna_sequence_2 + # skip + strand = 'UUG' + expected = ['Leucine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_serine_rna_sequence_1 + # skip + strand = 'UCU' + expected = ['Serine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_serine_rna_sequence_2 + # skip + strand = 'UCC' + expected = ['Serine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_serine_rna_sequence_3 + # skip + strand = 'UCA' + expected = ['Serine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_serine_rna_sequence_4 + # skip + strand = 'UCG' + expected = ['Serine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_tyrosine_rna_sequence_1 + # skip + strand = 'UAU' + expected = ['Tyrosine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_tyrosine_rna_sequence_2 + # skip + strand = 'UAC' + expected = ['Tyrosine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_cysteine_rna_sequence_1 + # skip + strand = 'UGU' + expected = ['Cysteine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_cysteine_rna_sequence_2 + # skip + strand = 'UGC' + expected = ['Cysteine'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_tryptophan_rna_sequence + # skip + strand = 'UGG' + expected = ['Tryptophan'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_stop_codon_rna_sequence_1 + # skip + strand = 'UAA' + expected = [] + assert_equal expected, Translation.of_rna(strand) + end + + def test_stop_codon_rna_sequence_2 + # skip + strand = 'UAG' + expected = [] + assert_equal expected, Translation.of_rna(strand) + end + + def test_stop_codon_rna_sequence_3 + # skip + strand = 'UGA' + expected = [] + assert_equal expected, Translation.of_rna(strand) + end + + def test_sequence_of_two_protein_codons_translates_into_proteins + # skip + strand = 'UUUUUU' + expected = %w[Phenylalanine Phenylalanine] + assert_equal expected, Translation.of_rna(strand) + end + + def test_sequence_of_two_different_protein_codons_translates_into_proteins + # skip + strand = 'UUAUUG' + expected = %w[Leucine Leucine] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translate_rna_strand_into_correct_protein_list + # skip + strand = 'AUGUUUUGG' + expected = %w[Methionine Phenylalanine Tryptophan] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translation_stops_if_stop_codon_at_beginning_of_sequence + # skip + strand = 'UAGUGG' + expected = [] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translation_stops_if_stop_codon_at_end_of_two_codon_sequence + # skip + strand = 'UGGUAG' + expected = ['Tryptophan'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translation_stops_if_stop_codon_at_end_of_three_codon_sequence + # skip + strand = 'AUGUUUUAA' + expected = %w[Methionine Phenylalanine] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translation_stops_if_stop_codon_in_middle_of_three_codon_sequence + # skip + strand = 'UGGUAGUGG' + expected = ['Tryptophan'] + assert_equal expected, Translation.of_rna(strand) + end + + def test_translation_stops_if_stop_codon_in_middle_of_six_codon_sequence + # skip + strand = 'UGGUGUUAUUAAUGGUUU' + expected = %w[Tryptophan Cysteine Tyrosine] + assert_equal expected, Translation.of_rna(strand) + end + + def test_non_existing_codon_cant_translate + # skip + strand = 'AAA' + assert_raises(InvalidCodonError) do + Translation.of_rna(strand) + end + end + + def test_unknown_amino_acids_not_part_of_a_codon_cant_translate + # skip + strand = 'XYZ' + assert_raises(InvalidCodonError) do + Translation.of_rna(strand) + end + end + + def test_incomplete_rna_sequence_cant_translate + # skip + strand = 'AUGU' + assert_raises(InvalidCodonError) do + Translation.of_rna(strand) + end + end + + def test_incomplete_rna_sequence_can_translate_if_valid_until_a_stop_codon + # skip + strand = 'UUCUUCUAAUGGU' + expected = %w[Phenylalanine Phenylalanine] + assert_equal expected, Translation.of_rna(strand) + end +end diff --git a/ruby/protein-translation/run-tests-ruby.txt b/ruby/protein-translation/run-tests-ruby.txt new file mode 100644 index 00000000..6c2b5829 --- /dev/null +++ b/ruby/protein-translation/run-tests-ruby.txt @@ -0,0 +1,440 @@ +Running automated test file(s): + + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-rubycritic + +Running RubyCritic + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubycritic --path .rubycritic --format console --no-browser . + +running flay smells + +running flog smells +.. +running reek smells +.. +running complexity +.. +running attributes +.. +running churn +.. +running simple_cov +.. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. +/home/vpayno/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubycritic-4.6.1/lib/rubycritic/generators/text/list.rb:13: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. +Translation: + Rating: A + Churn: 0 + Complexity: 22.05 + Duplication: 0 + Smells: 1 + * (TooManyStatements) Translation#self.of_rna has approx 11 statements + - protein_translation.rb:34 + +ProteinTranslationTest: + Rating: B + Churn: 0 + Complexity: 96.24 + Duplication: 0 + Smells: 17 + * (IrresponsibleModule) ProteinTranslationTest has no descriptive comment + - protein_translation_test.rb:28 + * (TooManyMethods) ProteinTranslationTest has at least 30 methods + - protein_translation_test.rb:28 + * (UncommunicativeMethodName) ProteinTranslationTest#test_cysteine_rna_sequence_1 has the name 'test_cysteine_rna_sequence_1' + - protein_translation_test.rb:113 + * (UncommunicativeMethodName) ProteinTranslationTest#test_cysteine_rna_sequence_2 has the name 'test_cysteine_rna_sequence_2' + - protein_translation_test.rb:120 + * (UncommunicativeMethodName) ProteinTranslationTest#test_leucine_rna_sequence_1 has the name 'test_leucine_rna_sequence_1' + - protein_translation_test.rb:57 + * (UncommunicativeMethodName) ProteinTranslationTest#test_leucine_rna_sequence_2 has the name 'test_leucine_rna_sequence_2' + - protein_translation_test.rb:64 + * (UncommunicativeMethodName) ProteinTranslationTest#test_phenylalanine_rna_sequence_1 has the name 'test_phenylalanine_rna_sequence_1' + - protein_translation_test.rb:43 + * (UncommunicativeMethodName) ProteinTranslationTest#test_phenylalanine_rna_sequence_2 has the name 'test_phenylalanine_rna_sequence_2' + - protein_translation_test.rb:50 + * (UncommunicativeMethodName) ProteinTranslationTest#test_serine_rna_sequence_1 has the name 'test_serine_rna_sequence_1' + - protein_translation_test.rb:71 + * (UncommunicativeMethodName) ProteinTranslationTest#test_serine_rna_sequence_2 has the name 'test_serine_rna_sequence_2' + - protein_translation_test.rb:78 + * (UncommunicativeMethodName) ProteinTranslationTest#test_serine_rna_sequence_3 has the name 'test_serine_rna_sequence_3' + - protein_translation_test.rb:85 + * (UncommunicativeMethodName) ProteinTranslationTest#test_serine_rna_sequence_4 has the name 'test_serine_rna_sequence_4' + - protein_translation_test.rb:92 + * (UncommunicativeMethodName) ProteinTranslationTest#test_stop_codon_rna_sequence_1 has the name 'test_stop_codon_rna_sequence_1' + - protein_translation_test.rb:134 + * (UncommunicativeMethodName) ProteinTranslationTest#test_stop_codon_rna_sequence_2 has the name 'test_stop_codon_rna_sequence_2' + - protein_translation_test.rb:141 + * (UncommunicativeMethodName) ProteinTranslationTest#test_stop_codon_rna_sequence_3 has the name 'test_stop_codon_rna_sequence_3' + - protein_translation_test.rb:148 + * (UncommunicativeMethodName) ProteinTranslationTest#test_tyrosine_rna_sequence_1 has the name 'test_tyrosine_rna_sequence_1' + - protein_translation_test.rb:99 + * (UncommunicativeMethodName) ProteinTranslationTest#test_tyrosine_rna_sequence_2 has the name 'test_tyrosine_rna_sequence_2' + - protein_translation_test.rb:106 +Score: 85.21 + +real 0m0.652s +user 0m0.551s +sys 0m0.098s + + + ============================================================================== + +Exit code: 0 + +real 0m0.733s +user 0m0.582s +sys 0m0.153s + +real 0m0.736s +user 0m0.583s +sys 0m0.155s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-lint-formatter + +Running Ruby Formatter + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rubocop -a . + +Inspecting 2 files +CC + +Offenses: + +protein_translation.rb:8:3: C: Metrics/MethodLength: Method has too many lines. [21/10] + def self.to_protein(codon) ... + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation.rb:34:3: C: Metrics/MethodLength: Method has too many lines. [13/10] + def self.of_rna(rna_sequence) ... + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:28:1: C: Metrics/ClassLength: Class has too many lines. [153/100] +class ProteinTranslationTest < Minitest::Test ... +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:28:1: C: Style/Documentation: Missing top-level documentation comment for class ProteinTranslationTest. +class ProteinTranslationTest < Minitest::Test +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:31:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "" + ^^ +protein_translation_test.rb:38:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "AUG" + ^^^^^ +protein_translation_test.rb:39:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Methionine"] + ^^^^^^^^^^^^ +protein_translation_test.rb:43:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_phenylalanine_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:45:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUU" + ^^^^^ +protein_translation_test.rb:46:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Phenylalanine"] + ^^^^^^^^^^^^^^^ +protein_translation_test.rb:50:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_phenylalanine_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:52:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUC" + ^^^^^ +protein_translation_test.rb:53:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Phenylalanine"] + ^^^^^^^^^^^^^^^ +protein_translation_test.rb:57:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_leucine_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:59:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUA" + ^^^^^ +protein_translation_test.rb:60:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Leucine"] + ^^^^^^^^^ +protein_translation_test.rb:64:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_leucine_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:66:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUG" + ^^^^^ +protein_translation_test.rb:67:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Leucine"] + ^^^^^^^^^ +protein_translation_test.rb:71:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_serine_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:73:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UCU" + ^^^^^ +protein_translation_test.rb:74:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Serine"] + ^^^^^^^^ +protein_translation_test.rb:78:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_serine_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:80:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UCC" + ^^^^^ +protein_translation_test.rb:81:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Serine"] + ^^^^^^^^ +protein_translation_test.rb:85:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_serine_rna_sequence_3 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:87:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UCA" + ^^^^^ +protein_translation_test.rb:88:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Serine"] + ^^^^^^^^ +protein_translation_test.rb:92:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_serine_rna_sequence_4 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:94:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UCG" + ^^^^^ +protein_translation_test.rb:95:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Serine"] + ^^^^^^^^ +protein_translation_test.rb:99:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_tyrosine_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:101:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UAU" + ^^^^^ +protein_translation_test.rb:102:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Tyrosine"] + ^^^^^^^^^^ +protein_translation_test.rb:106:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_tyrosine_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:108:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UAC" + ^^^^^ +protein_translation_test.rb:109:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Tyrosine"] + ^^^^^^^^^^ +protein_translation_test.rb:113:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_cysteine_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:115:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGU" + ^^^^^ +protein_translation_test.rb:116:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Cysteine"] + ^^^^^^^^^^ +protein_translation_test.rb:120:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_cysteine_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:122:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGC" + ^^^^^ +protein_translation_test.rb:123:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Cysteine"] + ^^^^^^^^^^ +protein_translation_test.rb:129:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGG" + ^^^^^ +protein_translation_test.rb:130:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Tryptophan"] + ^^^^^^^^^^^^ +protein_translation_test.rb:134:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_stop_codon_rna_sequence_1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:136:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UAA" + ^^^^^ +protein_translation_test.rb:141:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_stop_codon_rna_sequence_2 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:143:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UAG" + ^^^^^ +protein_translation_test.rb:148:7: C: Naming/VariableNumber: Use normalcase for method name numbers. + def test_stop_codon_rna_sequence_3 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:150:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGA" + ^^^^^ +protein_translation_test.rb:157:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUUUUU" + ^^^^^^^^ +protein_translation_test.rb:164:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUAUUG" + ^^^^^^^^ +protein_translation_test.rb:171:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "AUGUUUUGG" + ^^^^^^^^^^^ +protein_translation_test.rb:178:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UAGUGG" + ^^^^^^^^ +protein_translation_test.rb:185:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGGUAG" + ^^^^^^^^ +protein_translation_test.rb:186:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Tryptophan"] + ^^^^^^^^^^^^ +protein_translation_test.rb:192:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "AUGUUUUAA" + ^^^^^^^^^^^ +protein_translation_test.rb:199:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGGUAGUGG" + ^^^^^^^^^^^ +protein_translation_test.rb:200:17: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + expected = ["Tryptophan"] + ^^^^^^^^^^^^ +protein_translation_test.rb:206:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UGGUGUUAUUAAUGGUUU" + ^^^^^^^^^^^^^^^^^^^^ +protein_translation_test.rb:213:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "AAA" + ^^^^^ +protein_translation_test.rb:221:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "XYZ" + ^^^^^ +protein_translation_test.rb:229:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "AUGU" + ^^^^^^ +protein_translation_test.rb:237:14: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. + strand = "UUCUUCUAAUGGU" + ^^^^^^^^^^^^^^^ + +2 files inspected, 65 offenses detected, 46 offenses corrected + +real 0m1.080s +user 0m0.949s +sys 0m0.230s + + + ============================================================================== + +Exit code: -1 + +real 0m1.151s +user 0m0.983s +sys 0m0.271s + +real 0m1.152s +user 0m0.984s +sys 0m0.272s + +=============================================================================== + +Running: ../../.github/citools/ruby/ruby-test-with-coverage + +Running Ruby Tests With Coverage + +Ruby version: + + ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] + rbenv 1.2.0-11-ge4f61e6 + + + ============================================================================== + +Running: rm -rf ./coverage + + +real 0m0.001s +user 0m0.001s +sys 0m0.000s + + + ============================================================================== + +Running: ruby ./protein_translation_test.rb -v + +Run options: -v --seed 13077 + +# Running: + +ProteinTranslationTest#test_serine_rna_sequence_3 = 0.00 s = . +ProteinTranslationTest#test_stop_codon_rna_sequence_3 = 0.00 s = . +ProteinTranslationTest#test_translation_stops_if_stop_codon_in_middle_of_three_codon_sequence = 0.00 s = . +ProteinTranslationTest#test_serine_rna_sequence_4 = 0.00 s = . +ProteinTranslationTest#test_translation_stops_if_stop_codon_at_end_of_three_codon_sequence = 0.00 s = . +ProteinTranslationTest#test_leucine_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_tyrosine_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_cysteine_rna_sequence_2 = 0.00 s = . +ProteinTranslationTest#test_methionine_rna_sequence = 0.00 s = . +ProteinTranslationTest#test_leucine_rna_sequence_2 = 0.00 s = . +ProteinTranslationTest#test_serine_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_empty_rna_sequence_results_in_no_proteins = 0.00 s = . +ProteinTranslationTest#test_tryptophan_rna_sequence = 0.00 s = . +ProteinTranslationTest#test_phenylalanine_rna_sequence_2 = 0.00 s = . +ProteinTranslationTest#test_sequence_of_two_different_protein_codons_translates_into_proteins = 0.00 s = . +ProteinTranslationTest#test_translation_stops_if_stop_codon_at_end_of_two_codon_sequence = 0.00 s = . +ProteinTranslationTest#test_translation_stops_if_stop_codon_at_beginning_of_sequence = 0.00 s = . +ProteinTranslationTest#test_incomplete_rna_sequence_can_translate_if_valid_until_a_stop_codon = 0.00 s = . +ProteinTranslationTest#test_non_existing_codon_cant_translate = 0.00 s = . +ProteinTranslationTest#test_stop_codon_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_sequence_of_two_protein_codons_translates_into_proteins = 0.00 s = . +ProteinTranslationTest#test_serine_rna_sequence_2 = 0.00 s = . +ProteinTranslationTest#test_stop_codon_rna_sequence_2 = 0.00 s = . +ProteinTranslationTest#test_translation_stops_if_stop_codon_in_middle_of_six_codon_sequence = 0.00 s = . +ProteinTranslationTest#test_translate_rna_strand_into_correct_protein_list = 0.00 s = . +ProteinTranslationTest#test_incomplete_rna_sequence_cant_translate = 0.00 s = . +ProteinTranslationTest#test_unknown_amino_acids_not_part_of_a_codon_cant_translate = 0.00 s = . +ProteinTranslationTest#test_cysteine_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_phenylalanine_rna_sequence_1 = 0.00 s = . +ProteinTranslationTest#test_tyrosine_rna_sequence_2 = 0.00 s = . + +Finished in 0.002871s, 10451.0863 runs/s, 10451.0863 assertions/s. + +30 runs, 30 assertions, 0 failures, 0 errors, 0 skips +Coverage report generated for test:exercism to /home/vpayno/git_vpayno/exercism-workspace/ruby/protein-translation/coverage/coverage.xml. 23 / 23 LOC (100.00%) covered + +real 0m0.186s +user 0m0.135s +sys 0m0.049s + + + ============================================================================== + +Coverage: 100.0% + + ============================================================================== + +Exit code: 0 + +real 0m0.267s +user 0m0.171s +sys 0m0.098s + +real 0m0.269s +user 0m0.173s +sys 0m0.099s + +=============================================================================== + +Running: misspell . + +real 0m0.025s +user 0m0.023s +sys 0m0.016s + +=============================================================================== + +/home/vpayno/git_vpayno/exercism-workspace/ruby + +=============================================================================== +