commit 53f9df8f75e9b8d44488b58d3f773a3ddc53ba5c
parent 728869ca17873b2c0804dcb4570285f74f91597c
Author: Samir Parikh <noreply@samirparikh.com>
Date: Tue, 17 May 2022 14:02:06 +0000
initial commit for etl
Diffstat:
A | etl/ETL.pm | | | 12 | ++++++++++++ |
A | etl/HELP.md | | | 36 | ++++++++++++++++++++++++++++++++++++ |
A | etl/README.md | | | 70 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | etl/etl.t | | | 159 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 277 insertions(+), 0 deletions(-)
diff --git a/etl/ETL.pm b/etl/ETL.pm
@@ -0,0 +1,12 @@
+package ETL;
+use strict;
+use warnings;
+use Exporter qw<import>;
+our @EXPORT_OK = qw<transform>;
+
+sub transform {
+ my ($data) = @_;
+ return undef;
+}
+
+1;
diff --git a/etl/HELP.md b/etl/HELP.md
@@ -0,0 +1,35 @@
+# Help
+
+## Running the tests
+
+There is a Perl 5 script with the extension `.t`, which will be used to test
+your solution. You can run through the tests by using the command:
+
+```bash
+`prove .`
+```
+
+## Submitting your solution
+
+You can submit your solution using the `exercism submit ETL.pm` 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 [Perl 5 track's documentation](https://exercism.org/docs/tracks/perl5)
+- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
+- 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:
+
+- [/r/perl5](https://www.reddit.com/r/perl5) is the perl5 subreddit.
+- [StackOverflow](http://stackoverflow.com/questions/tagged/perl5) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
+\ No newline at end of file
diff --git a/etl/README.md b/etl/README.md
@@ -0,0 +1,69 @@
+# Etl
+
+Welcome to Etl on Exercism's Perl 5 Track.
+If you need help running the tests or submitting your code, check out `HELP.md`.
+
+## Instructions
+
+We are going to do the `Transform` step of an Extract-Transform-Load.
+
+## ETL
+
+Extract-Transform-Load (ETL) is a fancy way of saying, "We have some crufty, legacy data over in this system, and now we need it in this shiny new system over here, so
+we're going to migrate this."
+
+(Typically, this is followed by, "We're only going to need to run this
+once." That's then typically followed by much forehead slapping and
+moaning about how stupid we could possibly be.)
+
+## The goal
+
+We're going to extract some Scrabble scores from a legacy system.
+
+The old system stored a list of letters per score:
+
+- 1 point: "A", "E", "I", "O", "U", "L", "N", "R", "S", "T",
+- 2 points: "D", "G",
+- 3 points: "B", "C", "M", "P",
+- 4 points: "F", "H", "V", "W", "Y",
+- 5 points: "K",
+- 8 points: "J", "X",
+- 10 points: "Q", "Z",
+
+The shiny new Scrabble system instead stores the score per letter, which
+makes it much faster and easier to calculate the score for a word. It
+also stores the letters in lower-case regardless of the case of the
+input letters:
+
+- "a" is worth 1 point.
+- "b" is worth 3 points.
+- "c" is worth 3 points.
+- "d" is worth 2 points.
+- Etc.
+
+Your mission, should you choose to accept it, is to transform the legacy data
+format to the shiny new format.
+
+## Notes
+
+A final note about scoring, Scrabble is played around the world in a
+variety of languages, each with its own unique scoring table. For
+example, an "E" is scored at 2 in the Māori-language version of the
+game while being scored at 4 in the Hawaiian-language version.
+
+## Source
+
+### Created by
+
+- @bistik
+
+### Contributed to by
+
+- @darksuji
+- @kytrinyx
+- @m-dango
+- @rfilipo
+
+### Based on
+
+The Jumpstart Lab team - http://jumpstartlab.com
+\ No newline at end of file
diff --git a/etl/etl.t b/etl/etl.t
@@ -0,0 +1,159 @@
+#!/usr/bin/env perl
+use Test2::V0;
+use JSON::PP;
+use constant JSON => JSON::PP->new;
+
+use FindBin qw<$Bin>;
+use lib $Bin, "$Bin/local/lib/perl5";
+
+use ETL qw<transform>;
+
+my @test_cases = do { local $/; @{ JSON->decode(<DATA>) }; };
+plan 5;
+
+imported_ok qw<transform> or bail_out;
+
+for my $case (@test_cases) {
+ &is(
+ transform( $case->{input}{legacy} ),
+ @{$case}{qw<expected description>}
+ );
+}
+
+__DATA__
+[
+ {
+ "description": "single letter",
+ "expected": {
+ "a": 1
+ },
+ "input": {
+ "legacy": {
+ "1": [
+ "A"
+ ]
+ }
+ },
+ "property": "transform"
+ },
+ {
+ "description": "single score with multiple letters",
+ "expected": {
+ "a": 1,
+ "e": 1,
+ "i": 1,
+ "o": 1,
+ "u": 1
+ },
+ "input": {
+ "legacy": {
+ "1": [
+ "A",
+ "E",
+ "I",
+ "O",
+ "U"
+ ]
+ }
+ },
+ "property": "transform"
+ },
+ {
+ "description": "multiple scores with multiple letters",
+ "expected": {
+ "a": 1,
+ "d": 2,
+ "e": 1,
+ "g": 2
+ },
+ "input": {
+ "legacy": {
+ "1": [
+ "A",
+ "E"
+ ],
+ "2": [
+ "D",
+ "G"
+ ]
+ }
+ },
+ "property": "transform"
+ },
+ {
+ "description": "multiple scores with differing numbers of letters",
+ "expected": {
+ "a": 1,
+ "b": 3,
+ "c": 3,
+ "d": 2,
+ "e": 1,
+ "f": 4,
+ "g": 2,
+ "h": 4,
+ "i": 1,
+ "j": 8,
+ "k": 5,
+ "l": 1,
+ "m": 3,
+ "n": 1,
+ "o": 1,
+ "p": 3,
+ "q": 10,
+ "r": 1,
+ "s": 1,
+ "t": 1,
+ "u": 1,
+ "v": 4,
+ "w": 4,
+ "x": 8,
+ "y": 4,
+ "z": 10
+ },
+ "input": {
+ "legacy": {
+ "1": [
+ "A",
+ "E",
+ "I",
+ "O",
+ "U",
+ "L",
+ "N",
+ "R",
+ "S",
+ "T"
+ ],
+ "10": [
+ "Q",
+ "Z"
+ ],
+ "2": [
+ "D",
+ "G"
+ ],
+ "3": [
+ "B",
+ "C",
+ "M",
+ "P"
+ ],
+ "4": [
+ "F",
+ "H",
+ "V",
+ "W",
+ "Y"
+ ],
+ "5": [
+ "K"
+ ],
+ "8": [
+ "J",
+ "X"
+ ]
+ }
+ },
+ "property": "transform"
+ }
+]