trackler 2.1.0.24 → 2.1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/CONTRIBUTING.md +5 -8
- data/README.md +7 -7
- data/common/CONTRIBUTING.md +0 -5
- data/common/exercises/accumulate/description.md +4 -1
- data/common/exercises/acronym/description.md +1 -1
- data/common/exercises/bank-account/description.md +2 -1
- data/common/exercises/book-store/description.md +2 -5
- data/common/exercises/bracket-push/description.md +2 -4
- data/common/exercises/change/description.md +2 -5
- data/common/exercises/circular-buffer/description.md +0 -2
- data/common/exercises/clock/description.md +0 -2
- data/common/exercises/collatz-conjecture/canonical-data.json +36 -0
- data/common/exercises/collatz-conjecture/description.md +25 -0
- data/common/exercises/collatz-conjecture/metadata.yml +4 -0
- data/common/exercises/counter/description.md +1 -2
- data/common/exercises/diamond/description.md +0 -4
- data/common/exercises/flatten-array/description.md +1 -1
- data/common/exercises/grade-school/description.md +2 -1
- data/common/exercises/grains/description.md +2 -1
- data/common/exercises/grep/description.md +3 -2
- data/common/exercises/kindergarten-garden/description.md +2 -1
- data/common/exercises/largest-series-product/description.md +2 -1
- data/common/exercises/matrix/description.md +2 -1
- data/common/exercises/nucleotide-codons/description.md +2 -1
- data/common/exercises/ocr-numbers/description.md +2 -1
- data/common/exercises/octal/description.md +3 -1
- data/common/exercises/pangram/description.md +2 -1
- data/common/exercises/perfect-numbers/description.md +2 -1
- data/common/exercises/poker/description.md +0 -2
- data/common/exercises/protein-translation/description.md +3 -2
- data/common/exercises/proverb/description.md +2 -1
- data/common/exercises/pythagorean-triplet/description.md +4 -2
- data/common/exercises/queen-attack/description.md +2 -1
- data/common/exercises/rectangles/description.md +1 -3
- data/common/exercises/rotational-cipher/description.md +0 -4
- data/common/exercises/scale-generator/description.md +0 -2
- data/common/exercises/secret-handshake/description.md +2 -2
- data/common/exercises/series/description.md +2 -1
- data/common/exercises/sieve/description.md +2 -1
- data/common/exercises/space-age/description.md +0 -2
- data/common/exercises/strain/description.md +4 -5
- data/common/exercises/sublist/description.md +3 -6
- data/common/exercises/sum-of-multiples/description.md +2 -1
- data/common/exercises/tournament/description.md +4 -3
- data/common/exercises/transpose/description.md +1 -3
- data/common/exercises/trinary/description.md +2 -1
- data/common/exercises/two-bucket/description.md +1 -3
- data/common/exercises/two-fer/canonical-data.json +24 -0
- data/common/exercises/two-fer/description.md +40 -0
- data/common/exercises/two-fer/metadata.yml +4 -0
- data/common/exercises/word-search/description.md +2 -4
- data/common/exercises/zebra-puzzle/description.md +1 -1
- data/lib/trackler.rb +10 -5
- data/lib/trackler/description.rb +2 -2
- data/lib/trackler/guaranteed_file.rb +15 -15
- data/lib/trackler/implementation.rb +5 -5
- data/lib/trackler/implementations.rb +2 -2
- data/lib/trackler/metadata.rb +2 -2
- data/lib/trackler/problem.rb +2 -96
- data/lib/trackler/problems.rb +3 -48
- data/lib/trackler/specification.rb +101 -0
- data/lib/trackler/specifications.rb +52 -0
- data/lib/trackler/track.rb +6 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/LICENSE +21 -0
- data/tracks/bash/README.md +0 -5
- data/tracks/c/LICENSE +21 -0
- data/tracks/c/README.md +0 -5
- data/tracks/clojure/LICENSE +2 -2
- data/tracks/clojure/README.org +0 -5
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/sublist/project.clj +4 -0
- data/tracks/clojure/exercises/sublist/src/example.clj +19 -0
- data/tracks/clojure/exercises/sublist/sublist.mustache +9 -0
- data/tracks/clojure/exercises/sublist/test/sublist_test.clj +40 -0
- data/tracks/cpp/LICENSE +2 -2
- data/tracks/cpp/README.md +0 -5
- data/tracks/csharp/LICENSE +2 -2
- data/tracks/csharp/README.md +0 -5
- data/tracks/delphi/LICENSE +2 -2
- data/tracks/delphi/README.md +0 -5
- data/tracks/ecmascript/LICENSE +2 -2
- data/tracks/ecmascript/README.md +0 -5
- data/tracks/elisp/.travis.yml +7 -3
- data/tracks/elisp/LICENSE +2 -2
- data/tracks/elisp/README.org +3 -6
- data/tracks/elisp/bin/test-examples +27 -0
- data/tracks/elisp/config.json +10 -0
- data/tracks/elisp/docs/LEARNING.org +0 -3
- data/tracks/elisp/exercises/grains/example.el +18 -0
- data/tracks/elisp/exercises/grains/grains-test.el +38 -0
- data/tracks/elisp/exercises/grains/grains.el +10 -0
- data/tracks/elisp/exercises/phone-number/example.el +34 -0
- data/tracks/elisp/exercises/phone-number/phone-number-test.el +43 -0
- data/tracks/elisp/exercises/phone-number/phone-number.el +9 -0
- data/tracks/elixir/LICENSE +2 -2
- data/tracks/elixir/README.md +0 -5
- data/tracks/elm/LICENSE +2 -2
- data/tracks/elm/README.md +0 -5
- data/tracks/erlang/LICENSE +2 -2
- data/tracks/erlang/README.md +0 -5
- data/tracks/erlang/SETUP.md +7 -0
- data/tracks/erlang/exercises/rotational-cipher/rebar.config +5 -5
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +18 -18
- data/tracks/factor/LICENSE +2 -2
- data/tracks/fortran/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- data/tracks/fortran/.gitignore +4 -0
- data/tracks/fortran/.travis.yml +17 -0
- data/tracks/fortran/LICENSE +21 -0
- data/tracks/fortran/Makefile +40 -0
- data/tracks/fortran/README.md +72 -0
- data/tracks/fortran/bin/fetch-configlet +32 -0
- data/tracks/fortran/config.json +32 -0
- data/tracks/{kotlin/SETUP.md → fortran/docs/ABOUT.md} +0 -0
- data/tracks/fortran/docs/INSTALLATION.md +0 -0
- data/tracks/fortran/docs/LEARNING.md +0 -0
- data/tracks/fortran/docs/RESOURCES.md +0 -0
- data/tracks/fortran/docs/TESTS.md +0 -0
- data/tracks/fortran/exercises/TRACK_HINTS.md +0 -0
- data/tracks/fortran/exercises/bob/bob.fun +114 -0
- data/tracks/fortran/exercises/bob/example.f90 +61 -0
- data/tracks/fortran/exercises/hello_world/example.f90 +9 -0
- data/tracks/fortran/exercises/hello_world/hello_world.fun +10 -0
- data/tracks/fortran/img/.keep +0 -0
- data/tracks/fsharp/LICENSE +2 -2
- data/tracks/fsharp/README.md +0 -5
- data/tracks/go/LICENSE +2 -2
- data/tracks/go/README.md +0 -5
- data/tracks/haskell/LICENSE +2 -2
- data/tracks/haskell/README.md +0 -5
- data/tracks/idris/LICENSE +2 -2
- data/tracks/idris/README.md +0 -5
- data/tracks/java/LICENSE +2 -2
- data/tracks/java/README.md +0 -7
- data/tracks/java/{SETUP.md → TRACK_HINTS.md} +0 -0
- data/tracks/java/config.json +5 -0
- data/tracks/java/exercises/_template/build.gradle +1 -0
- data/tracks/java/exercises/accumulate/build.gradle +1 -0
- data/tracks/java/exercises/acronym/build.gradle +1 -0
- data/tracks/java/exercises/all-your-base/build.gradle +1 -0
- data/tracks/java/exercises/allergies/build.gradle +1 -0
- data/tracks/java/exercises/anagram/build.gradle +1 -0
- data/tracks/java/exercises/atbash-cipher/build.gradle +1 -0
- data/tracks/java/exercises/beer-song/build.gradle +1 -0
- data/tracks/java/exercises/binary-search/build.gradle +1 -0
- data/tracks/java/exercises/binary/build.gradle +1 -0
- data/tracks/java/exercises/bob/build.gradle +1 -0
- data/tracks/java/exercises/book-store/build.gradle +1 -0
- data/tracks/java/exercises/bracket-push/build.gradle +1 -0
- data/tracks/java/exercises/change/build.gradle +1 -0
- data/tracks/java/exercises/clock/build.gradle +2 -1
- data/tracks/java/exercises/collatz-conjecture/build.gradle +18 -0
- data/tracks/java/exercises/collatz-conjecture/src/example/java/CollatzCalculator.java +19 -0
- data/tracks/java/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java +7 -0
- data/tracks/java/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java +59 -0
- data/tracks/java/exercises/crypto-square/build.gradle +1 -0
- data/tracks/java/exercises/diamond/build.gradle +1 -0
- data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +4 -4
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +6 -2
- data/tracks/java/exercises/difference-of-squares/build.gradle +1 -0
- data/tracks/java/exercises/difference-of-squares/src/main/java/.keep +0 -0
- data/tracks/java/exercises/etl/build.gradle +1 -0
- data/tracks/java/exercises/flatten-array/build.gradle +1 -0
- data/tracks/java/exercises/gigasecond/build.gradle +1 -0
- data/tracks/java/exercises/grade-school/build.gradle +1 -0
- data/tracks/java/exercises/hamming/build.gradle +1 -0
- data/tracks/java/exercises/hexadecimal/build.gradle +1 -0
- data/tracks/java/exercises/isogram/build.gradle +1 -0
- data/tracks/java/exercises/kindergarten-garden/build.gradle +1 -0
- data/tracks/java/exercises/largest-series-product/build.gradle +1 -0
- data/tracks/java/exercises/linked-list/build.gradle +1 -0
- data/tracks/java/exercises/luhn/build.gradle +1 -0
- data/tracks/java/exercises/matrix/build.gradle +2 -1
- data/tracks/java/exercises/meetup/build.gradle +1 -0
- data/tracks/java/exercises/minesweeper/build.gradle +1 -0
- data/tracks/java/exercises/nth-prime/build.gradle +1 -0
- data/tracks/java/exercises/ocr-numbers/build.gradle +1 -0
- data/tracks/java/exercises/octal/build.gradle +1 -0
- data/tracks/java/exercises/pangram/build.gradle +1 -0
- data/tracks/java/exercises/pascals-triangle/build.gradle +1 -0
- data/tracks/java/exercises/perfect-numbers/build.gradle +1 -0
- data/tracks/java/exercises/phone-number/build.gradle +1 -0
- data/tracks/java/exercises/pig-latin/build.gradle +1 -0
- data/tracks/java/exercises/queen-attack/build.gradle +1 -0
- data/tracks/java/exercises/raindrops/build.gradle +1 -0
- data/tracks/java/exercises/rectangles/build.gradle +1 -0
- data/tracks/java/exercises/rna-transcription/build.gradle +1 -0
- data/tracks/java/exercises/robot-simulator/build.gradle +1 -0
- data/tracks/java/exercises/roman-numerals/build.gradle +1 -0
- data/tracks/java/exercises/run-length-encoding/build.gradle +1 -0
- data/tracks/java/exercises/saddle-points/build.gradle +1 -0
- data/tracks/java/exercises/scrabble-score/build.gradle +1 -0
- data/tracks/java/exercises/secret-handshake/build.gradle +1 -0
- data/tracks/java/exercises/series/build.gradle +1 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/sieve/build.gradle +1 -0
- data/tracks/java/exercises/simple-cipher/build.gradle +1 -0
- data/tracks/java/exercises/simple-linked-list/build.gradle +1 -0
- data/tracks/java/exercises/space-age/build.gradle +1 -0
- data/tracks/java/exercises/strain/build.gradle +1 -0
- data/tracks/java/exercises/sublist/build.gradle +1 -0
- data/tracks/java/exercises/sum-of-multiples/build.gradle +1 -0
- data/tracks/java/exercises/triangle/build.gradle +1 -0
- data/tracks/java/exercises/trinary/build.gradle +1 -0
- data/tracks/java/exercises/twelve-days/build.gradle +2 -1
- data/tracks/java/exercises/word-count/build.gradle +1 -0
- data/tracks/java/exercises/wordy/build.gradle +1 -0
- data/tracks/javascript/LICENSE +2 -2
- data/tracks/javascript/README.md +0 -5
- data/tracks/julia/LICENSE +2 -2
- data/tracks/kotlin/LICENSE +2 -2
- data/tracks/kotlin/README.md +0 -7
- data/tracks/kotlin/TRACK_HINTS.md +1 -0
- data/tracks/kotlin/exercises/phone-number/src/example/kotlin/PhoneNumber.kt +1 -1
- data/tracks/kotlin/exercises/phone-number/src/test/kotlin/PhoneNumberTest.kt +7 -8
- data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +6 -6
- data/tracks/lfe/LICENSE +2 -2
- data/tracks/lfe/README.md +0 -5
- data/tracks/lisp/LICENSE +2 -2
- data/tracks/lisp/README.md +0 -5
- data/tracks/lua/LICENSE +2 -2
- data/tracks/lua/README.md +0 -5
- data/tracks/mips/LICENSE +2 -2
- data/tracks/mips/README.md +0 -5
- data/tracks/objective-c/LICENSE +2 -2
- data/tracks/objective-c/README.md +0 -5
- data/tracks/ocaml/LICENSE +2 -2
- data/tracks/ocaml/README.md +0 -5
- data/tracks/ocaml/config.json +54 -25
- data/tracks/ocaml/exercises/forth/.merlin +5 -0
- data/tracks/ocaml/exercises/forth/Makefile +11 -0
- data/tracks/ocaml/exercises/forth/example.ml +89 -0
- data/tracks/ocaml/exercises/forth/forth.mli +1 -0
- data/tracks/ocaml/exercises/forth/test.ml +147 -0
- data/tracks/ocaml/exercises/react/.merlin +5 -0
- data/tracks/ocaml/exercises/react/HINT.md +3 -0
- data/tracks/ocaml/exercises/react/Makefile +11 -0
- data/tracks/ocaml/exercises/react/example.ml +106 -0
- data/tracks/ocaml/exercises/react/react.mli +26 -0
- data/tracks/ocaml/exercises/react/test.ml +157 -0
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +5 -2
- data/tracks/ocaml/tools/test-generator/templates/forth/template.ml +114 -0
- data/tracks/perl5/LICENSE +2 -2
- data/tracks/perl6/LICENSE +2 -2
- data/tracks/perl6/README.md +0 -5
- data/tracks/perl6/config.json +5 -0
- data/tracks/perl6/exercises/clock/Example.pm6 +2 -2
- data/tracks/perl6/exercises/flatten-array/Example.pm6 +13 -0
- data/tracks/perl6/exercises/flatten-array/FlattenArray.pm6 +4 -0
- data/tracks/perl6/exercises/flatten-array/example.yaml +6 -0
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +80 -0
- data/tracks/php/LICENSE +2 -2
- data/tracks/php/README.md +0 -5
- data/tracks/powershell/.travis.yml +1 -0
- data/tracks/python/LICENSE +2 -2
- data/tracks/python/README.md +0 -5
- data/tracks/python/config.json +8 -0
- data/tracks/python/exercises/protein-translation/example.py +25 -0
- data/tracks/python/exercises/protein-translation/protein_translation.py +6 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +59 -0
- data/tracks/r/LICENSE +2 -2
- data/tracks/r/README.md +0 -5
- data/tracks/racket/LICENSE +2 -2
- data/tracks/racket/README.md +0 -5
- data/tracks/racket/config.json +5 -0
- data/tracks/racket/exercises/acronym/acronym-test.rkt +40 -0
- data/tracks/racket/exercises/acronym/acronym.rkt +3 -0
- data/tracks/racket/exercises/acronym/example.rkt +25 -0
- data/tracks/racket/exercises/grep/example.rkt +60 -26
- data/tracks/racket/exercises/grep/grep-test.rkt +154 -17
- data/tracks/racket/exercises/grep/grep.rkt +1 -18
- data/tracks/racket/exercises/grep/iliad.txt +9 -0
- data/tracks/racket/exercises/grep/midsummer-night.txt +7 -0
- data/tracks/racket/exercises/grep/paradise-lost.txt +8 -0
- data/tracks/ruby/README.md +4 -1
- data/tracks/ruby/exercises/acronym/.meta/.version +1 -1
- data/tracks/ruby/exercises/acronym/.meta/solutions/acronym.rb +1 -1
- data/tracks/ruby/exercises/acronym/acronym_test.rb +2 -7
- data/tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb +1 -1
- data/tracks/ruby/exercises/beer-song/.meta/generator/beer_song_case.rb +1 -1
- data/tracks/ruby/exercises/clock/.meta/generator/clock_case.rb +1 -1
- data/tracks/ruby/exercises/connect/.meta/generator/connect_case.rb +0 -3
- data/tracks/ruby/exercises/connect/.meta/generator/test_template.erb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/.version +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/solutions/difference_of_squares.rb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/difference_of_squares_test.rb +12 -17
- data/tracks/ruby/exercises/triangle/.meta/generator/triangle_case.rb +10 -2
- data/tracks/ruby/exercises/triangle/triangle_test.rb +17 -17
- data/tracks/ruby/exercises/wordy/.meta/generator/wordy_case.rb +1 -1
- data/tracks/ruby/lib/generator/case_values.rb +1 -1
- data/tracks/ruby/lib/generator/exercise_case.rb +16 -2
- data/tracks/ruby/lib/generator/exercise_case/assertion.rb +4 -4
- data/tracks/ruby/test/fixtures/xruby/exercises/alpha/.meta/generator/alpha_case.rb +1 -1
- data/tracks/ruby/test/generator/case_values_test.rb +28 -7
- data/tracks/ruby/test/generator/exercise_case/assertion_test.rb +7 -7
- data/tracks/ruby/test/generator/exercise_case_test.rb +21 -25
- data/tracks/ruby/test/wordy_cases_test.rb +4 -4
- data/tracks/rust/LICENSE +2 -2
- data/tracks/rust/README.md +0 -5
- data/tracks/rust/config.json +1 -0
- data/tracks/rust/exercises/etl/Cargo.toml +1 -1
- data/tracks/rust/exercises/etl/example.rs +2 -2
- data/tracks/rust/exercises/etl/tests/etl.rs +26 -32
- data/tracks/rust/exercises/forth/tests/forth.rs +20 -22
- data/tracks/rust/exercises/minesweeper/Cargo.toml +1 -1
- data/tracks/rust/exercises/minesweeper/example.rs +3 -0
- data/tracks/rust/exercises/minesweeper/tests/minesweeper.rs +44 -46
- data/tracks/rust/exercises/raindrops/Cargo.toml +1 -1
- data/tracks/rust/exercises/raindrops/tests/raindrops.rs +12 -0
- data/tracks/rust/exercises/rna-transcription/Cargo.toml +1 -1
- data/tracks/rust/exercises/rna-transcription/example.rs +13 -9
- data/tracks/rust/exercises/rna-transcription/tests/rna-transcription.rs +23 -5
- data/tracks/scala/LICENSE +2 -2
- data/tracks/scala/README.md +0 -5
- data/tracks/scheme/LICENSE +2 -2
- data/tracks/scheme/README.org +0 -6
- data/tracks/swift/Dangerfile +1 -1
- data/tracks/swift/LICENSE +2 -2
- data/tracks/swift/README.md +0 -6
- data/tracks/vbnet/.travis.yml +1 -0
- data/tracks/vimscript/.travis.yml +4 -0
- data/tracks/vimscript/.vintrc.yaml +5 -0
- data/tracks/vimscript/TRACK_HINTS.md +19 -1
- data/tracks/vimscript/bin/pre-push +18 -0
- data/tracks/vimscript/config.json +8 -1
- data/tracks/vimscript/docs/ABOUT.md +7 -6
- data/tracks/vimscript/docs/TESTS.md +4 -4
- data/tracks/vimscript/exercises/allergies/allergies.vader +68 -0
- data/tracks/vimscript/exercises/allergies/allergies.vim +29 -0
- data/tracks/vimscript/exercises/allergies/example.vim +23 -0
- data/tracks/vimscript/lib/generate.vim +89 -0
- metadata +81 -6
- data/tracks/java/exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java +0 -15
- data/tracks/ocaml/.vscode/launch.json +0 -13
data/tracks/r/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/r/README.md
CHANGED
@@ -134,11 +134,6 @@ Note however that at the moment only the following linting rules are strictly en
|
|
134
134
|
|
135
135
|
To perform these specific checks locally, run `source("bin/run_lints.R")`.
|
136
136
|
|
137
|
-
## License
|
138
|
-
|
139
|
-
The MIT License (MIT)
|
140
|
-
|
141
|
-
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
142
137
|
|
143
138
|
## R icon
|
144
139
|
The R logo was created by [Hadley Wickham](https://github.com/hadley) and others at [RStudio](https://www.rstudio.com/). The original file is licensed under version [4.0 of the Creative Commons Attribution-Share Alike license](https://creativecommons.org/licenses/by-sa/4.0/). We have adapted it, changing the colour scheme, for use on Exercism.
|
data/tracks/racket/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/racket/README.md
CHANGED
@@ -73,11 +73,6 @@ Please do not add a README or README.md file to the problem directory. The READM
|
|
73
73
|
|
74
74
|
Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
|
75
75
|
|
76
|
-
## License
|
77
|
-
|
78
|
-
The MIT License (MIT)
|
79
|
-
|
80
|
-
Copyright (c) 2015 Katrina Owen, _@kytrinyx.com
|
81
76
|
|
82
77
|
## Racket icon
|
83
78
|
The Racket logo was created by [Matthew Butterick](https://en.wikipedia.org/wiki/Matthew_Butterick) and released under the Creative Commons Attribution-Share Alike 3.0 Unported license.
|
data/tracks/racket/config.json
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
#lang racket/base
|
2
|
+
|
3
|
+
(require "acronym.rkt")
|
4
|
+
|
5
|
+
(module+ test
|
6
|
+
(require rackunit rackunit/text-ui)
|
7
|
+
|
8
|
+
(define suite
|
9
|
+
(test-suite
|
10
|
+
"acronym tests"
|
11
|
+
|
12
|
+
(test-equal? "basic"
|
13
|
+
(acronym "Portable Network Graphics")
|
14
|
+
"PNG")
|
15
|
+
|
16
|
+
(test-equal? "lowercase words"
|
17
|
+
(acronym "Ruby on Rails")
|
18
|
+
"ROR")
|
19
|
+
|
20
|
+
(test-equal? "camelcase"
|
21
|
+
(acronym "HyperText Markup Language")
|
22
|
+
"HTML")
|
23
|
+
|
24
|
+
(test-equal? "punctuation"
|
25
|
+
(acronym "First In, First Out")
|
26
|
+
"FIFO")
|
27
|
+
|
28
|
+
(test-equal? "all caps words"
|
29
|
+
(acronym "PHP: Hypertext Preprocessor")
|
30
|
+
"PHP")
|
31
|
+
|
32
|
+
(test-equal? "non-acronym all caps word"
|
33
|
+
(acronym "GNU Image Manipulation Program")
|
34
|
+
"GIMP")
|
35
|
+
|
36
|
+
(test-equal? "hyphenated"
|
37
|
+
(acronym "Complementary metal-oxide semiconductor")
|
38
|
+
"CMOS")))
|
39
|
+
|
40
|
+
(run-tests suite))
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#lang racket
|
2
|
+
|
3
|
+
(provide acronym)
|
4
|
+
|
5
|
+
(define (all-upper-case? s)
|
6
|
+
(equal? s (string-upcase s)))
|
7
|
+
|
8
|
+
(define (all-lower-case? s)
|
9
|
+
(equal? s (string-downcase s)))
|
10
|
+
|
11
|
+
(define (process-word word)
|
12
|
+
(define (first-letter s)
|
13
|
+
(~a (char-upcase (string-ref s 0))))
|
14
|
+
(define (filter-caps s)
|
15
|
+
(list->string (filter char-upper-case? (string->list s))))
|
16
|
+
(cond
|
17
|
+
[(all-upper-case? word) (first-letter word)]
|
18
|
+
[(all-lower-case? word) (first-letter word)]
|
19
|
+
[else (filter-caps word)])) ;; camelcase/mixed case
|
20
|
+
|
21
|
+
(define (acronym str)
|
22
|
+
(let ([words (string-split str #px"(\\s+)|-")])
|
23
|
+
(apply string-append
|
24
|
+
(for/list ([w (in-list words)])
|
25
|
+
(process-word w)))))
|
@@ -1,28 +1,62 @@
|
|
1
1
|
#lang racket
|
2
2
|
|
3
|
-
(provide grep
|
4
|
-
|
5
|
-
(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
3
|
+
(provide grep)
|
4
|
+
|
5
|
+
(struct flags (lineno case-sensitive filename whole invert))
|
6
|
+
|
7
|
+
(define (member? v lst)
|
8
|
+
(if (member v lst) #t #f))
|
9
|
+
|
10
|
+
(define (process-flags fs)
|
11
|
+
(flags
|
12
|
+
(member? "-n" fs)
|
13
|
+
(not (member? "-i" fs))
|
14
|
+
(member? "-l" fs)
|
15
|
+
(member? "-x" fs)
|
16
|
+
(member? "-v" fs)))
|
17
|
+
|
18
|
+
(define (add-line-numbers lines)
|
19
|
+
(for/list ([n (in-naturals 1)]
|
20
|
+
[line (in-list lines)])
|
21
|
+
(cons line n)))
|
22
|
+
|
23
|
+
(define (process-pattern pat flags)
|
24
|
+
(define cpat (regexp-quote pat (flags-case-sensitive flags)))
|
25
|
+
(if (flags-whole flags)
|
26
|
+
(string-append "^" cpat "$")
|
27
|
+
cpat))
|
28
|
+
|
29
|
+
(define (grep-file f pat flags mod print-filename?)
|
30
|
+
(define lines (add-line-numbers (file->lines f)))
|
31
|
+
(define line-filter
|
32
|
+
(lambda (line) (mod (regexp-match? pat (car line)))))
|
33
|
+
(define res (filter line-filter lines))
|
34
|
+
(define (add-lines matches)
|
35
|
+
(if (flags-lineno flags)
|
36
|
+
(map (lambda (m) (format "~a:~a" (cdr m) (car m))) matches)
|
37
|
+
(map (lambda (m) (car m)) matches)))
|
38
|
+
(define (add-filenames result)
|
39
|
+
(if print-filename?
|
40
|
+
(map (lambda (s) (format "~a:~a" f s)) result)
|
41
|
+
result))
|
42
|
+
(add-filenames (add-lines res)))
|
43
|
+
|
44
|
+
(define (file-contains? f pat)
|
45
|
+
(regexp-match? pat (file->string f)))
|
46
|
+
|
47
|
+
(define (grep fls pat files)
|
48
|
+
(define flags (process-flags fls))
|
49
|
+
(define repat (process-pattern pat flags))
|
50
|
+
(define filter-mod
|
51
|
+
(if (flags-invert flags)
|
52
|
+
not
|
53
|
+
identity))
|
54
|
+
(define file-filter
|
55
|
+
(lambda (f) (filter-mod (file-contains? f repat))))
|
56
|
+
(define print-filename? (> (length files) 1))
|
57
|
+
(if (flags-filename flags)
|
58
|
+
(filter file-filter files)
|
59
|
+
(apply append
|
60
|
+
(map (lambda (f)
|
61
|
+
(grep-file f repat flags filter-mod print-filename?))
|
62
|
+
files))))
|
@@ -5,28 +5,165 @@
|
|
5
5
|
(module+ test
|
6
6
|
(require rackunit rackunit/text-ui)
|
7
7
|
|
8
|
-
(define-syntax-rule (grep-this-file pat-str)
|
9
|
-
(grep-file "./grep-test.rkt" (regexp pat-str)))
|
10
|
-
|
11
8
|
(define suite
|
12
|
-
(test-suite
|
9
|
+
(test-suite
|
10
|
+
"grep tests"
|
11
|
+
|
12
|
+
(test-equal? "Test grepping a single file"
|
13
|
+
(grep '() ; flags
|
14
|
+
"Agamemnon" ; pattern
|
15
|
+
'("iliad.txt")) ; files
|
16
|
+
'("Of Atreus, Agamemnon, King of men."))
|
17
|
+
|
18
|
+
(test-equal? "One file, one match, print line numbers flag"
|
19
|
+
(grep '("-n")
|
20
|
+
"Forbidden"
|
21
|
+
'("paradise-lost.txt"))
|
22
|
+
'("2:Of that Forbidden Tree, whose mortal tast"))
|
23
|
+
|
24
|
+
(test-equal? "One file, one match, case-insensitive flag"
|
25
|
+
(grep '("-i")
|
26
|
+
"FORBIDDEN"
|
27
|
+
'("paradise-lost.txt"))
|
28
|
+
'("Of that Forbidden Tree, whose mortal tast"))
|
29
|
+
|
30
|
+
(test-equal? "One file, one match, print file names flag"
|
31
|
+
(grep '("-l")
|
32
|
+
"Forbidden"
|
33
|
+
'("paradise-lost.txt"))
|
34
|
+
'("paradise-lost.txt"))
|
35
|
+
|
36
|
+
(test-equal? "One file, one match, match entire lines flag"
|
37
|
+
(grep '("-x")
|
38
|
+
"With loss of Eden, till one greater Man"
|
39
|
+
'("paradise-lost.txt"))
|
40
|
+
'("With loss of Eden, till one greater Man"))
|
41
|
+
|
42
|
+
(test-equal? "One file, match entire lines flag, no match"
|
43
|
+
(grep '("-x")
|
44
|
+
"Eden"
|
45
|
+
'("paradise-lost.txt"))
|
46
|
+
'())
|
47
|
+
|
48
|
+
(test-equal? "One file, one match, multiple flags"
|
49
|
+
(grep '("-n" "-i" "-x")
|
50
|
+
"OF ATREUS, Agamemnon, KIng of MEN."
|
51
|
+
'("iliad.txt"))
|
52
|
+
'("9:Of Atreus, Agamemnon, King of men."))
|
53
|
+
|
54
|
+
(test-equal? "One file, several matches, no flags"
|
55
|
+
(grep '()
|
56
|
+
"may"
|
57
|
+
'("midsummer-night.txt"))
|
58
|
+
'("Nor how it may concern my modesty,"
|
59
|
+
"But I beseech your grace that I may know"
|
60
|
+
"The worst that may befall me in this case,"))
|
13
61
|
|
14
|
-
(test-equal? "
|
15
|
-
(grep
|
62
|
+
(test-equal? "One file, several matches, print line numbers flag"
|
63
|
+
(grep '("-n")
|
64
|
+
"may"
|
65
|
+
'("midsummer-night.txt"))
|
66
|
+
'("3:Nor how it may concern my modesty,"
|
67
|
+
"5:But I beseech your grace that I may know"
|
68
|
+
"6:The worst that may befall me in this case,"))
|
69
|
+
|
70
|
+
(test-equal? "One file, several matches, match entire lines flag"
|
71
|
+
(grep '("-x")
|
72
|
+
"may"
|
73
|
+
'("midsummer-night.txt"))
|
74
|
+
'())
|
75
|
+
|
76
|
+
(test-equal? "One file, several matches, case-insensitive flag"
|
77
|
+
(grep '("-i")
|
78
|
+
"ACHILLES"
|
79
|
+
'("iliad.txt"))
|
80
|
+
'("Achilles sing, O Goddess! Peleus' son;"
|
81
|
+
"The noble Chief Achilles from the son"))
|
82
|
+
|
83
|
+
(test-equal? "One file, several matches, inverted flag"
|
84
|
+
(grep '("-v")
|
85
|
+
"Of"
|
86
|
+
'("paradise-lost.txt"))
|
87
|
+
'("Brought Death into the World, and all our woe,"
|
88
|
+
"With loss of Eden, till one greater Man"
|
89
|
+
"Restore us, and regain the blissful Seat,"
|
90
|
+
"Sing Heav'nly Muse, that on the secret top"
|
91
|
+
"That Shepherd, who first taught the chosen Seed"))
|
92
|
+
|
93
|
+
(test-equal? "One file, no matches, various flags"
|
94
|
+
(grep '("-n" "-l" "-x" "-i")
|
95
|
+
"Gandalf"
|
96
|
+
'("iliad.txt"))
|
16
97
|
'())
|
17
98
|
|
18
|
-
(test-equal? "
|
19
|
-
(grep
|
20
|
-
|
99
|
+
(test-equal? "Test grepping multiples files at once"
|
100
|
+
(grep '()
|
101
|
+
"Agamemnon"
|
102
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
103
|
+
'("iliad.txt:Of Atreus, Agamemnon, King of men."))
|
104
|
+
|
105
|
+
(test-equal? "Multiple files, several matches, no flags"
|
106
|
+
(grep '()
|
107
|
+
"may"
|
108
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
109
|
+
'("midsummer-night.txt:Nor how it may concern my modesty,"
|
110
|
+
"midsummer-night.txt:But I beseech your grace that I may know"
|
111
|
+
"midsummer-night.txt:The worst that may befall me in this case,"))
|
112
|
+
|
113
|
+
(test-equal? "Multiple files, several matches, print line numbers flag"
|
114
|
+
(grep '("-n")
|
115
|
+
"that"
|
116
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
117
|
+
'("midsummer-night.txt:5:But I beseech your grace that I may know"
|
118
|
+
"midsummer-night.txt:6:The worst that may befall me in this case,"
|
119
|
+
"paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast"
|
120
|
+
"paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top"))
|
121
|
+
|
122
|
+
(test-equal? "Multiple files, one match, print file names flag"
|
123
|
+
(grep '("-l")
|
124
|
+
"who"
|
125
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
126
|
+
'("iliad.txt"
|
127
|
+
"paradise-lost.txt"))
|
128
|
+
|
129
|
+
(test-equal? "Multiple files, several matches, case-insensitive flag"
|
130
|
+
(grep '("-i")
|
131
|
+
"TO"
|
132
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
133
|
+
'("iliad.txt:Caused to Achaia's host, sent many a soul"
|
134
|
+
"iliad.txt:Illustrious into Ades premature,"
|
135
|
+
"iliad.txt:And Heroes gave (so stood the will of Jove)"
|
136
|
+
"iliad.txt:To dogs and to all ravening fowls a prey,"
|
137
|
+
"midsummer-night.txt:I do entreat your grace to pardon me."
|
138
|
+
"midsummer-night.txt:In such a presence here to plead my thoughts;"
|
139
|
+
"midsummer-night.txt:If I refuse to wed Demetrius."
|
140
|
+
"paradise-lost.txt:Brought Death into the World, and all our woe,"
|
141
|
+
"paradise-lost.txt:Restore us, and regain the blissful Seat,"
|
142
|
+
"paradise-lost.txt:Sing Heav'nly Muse, that on the secret top"))
|
143
|
+
|
144
|
+
(test-equal? "Multiple files, several matches, inverted flag"
|
145
|
+
(grep '("-v")
|
146
|
+
"a"
|
147
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
148
|
+
'("iliad.txt:Achilles sing, O Goddess! Peleus' son;"
|
149
|
+
"iliad.txt:The noble Chief Achilles from the son"
|
150
|
+
"midsummer-night.txt:If I refuse to wed Demetrius."))
|
21
151
|
|
22
|
-
(test-equal? "
|
23
|
-
(
|
24
|
-
|
152
|
+
(test-equal? "Multiple files, one match, match entire lines flag"
|
153
|
+
(grep '("-x")
|
154
|
+
"But I beseech your grace that I may know"
|
155
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
156
|
+
'("midsummer-night.txt:But I beseech your grace that I may know"))
|
25
157
|
|
26
|
-
(test-equal? "
|
27
|
-
(
|
28
|
-
|
29
|
-
|
30
|
-
(
|
158
|
+
(test-equal? "Multiple files, one match, multiple flags"
|
159
|
+
(grep '("-n" "-i" "-x")
|
160
|
+
"WITH LOSS OF EDEN, TILL ONE GREATER MAN"
|
161
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
162
|
+
'("paradise-lost.txt:4:With loss of Eden, till one greater Man"))
|
31
163
|
|
164
|
+
(test-equal? "Multiple files, no matches, various flags"
|
165
|
+
(grep '("-n" "-l" "-x" "-i")
|
166
|
+
"Frodo"
|
167
|
+
'("iliad.txt" "midsummer-night.txt" "paradise-lost.txt"))
|
168
|
+
'())))
|
32
169
|
(run-tests suite))
|
@@ -1,20 +1,3 @@
|
|
1
1
|
#lang racket
|
2
2
|
|
3
|
-
(provide
|
4
|
-
grep-file
|
5
|
-
;; (-> Path-String Regexp (Listof (Pairof Natural String)))
|
6
|
-
;; Find lines in a file matching a regular expression pattern.
|
7
|
-
;; Output is a list of pairs containing the number and contents of
|
8
|
-
;; each matching line.
|
9
|
-
)
|
10
|
-
|
11
|
-
|
12
|
-
;; =============================================================================
|
13
|
-
|
14
|
-
(module+ main
|
15
|
-
;; Extra challenge: fill in this submodule so that running
|
16
|
-
;; `racket grep.rkt PATTERN FILE ...`
|
17
|
-
;; runs grep on each FILE searching for PATTERN, and prints the results
|
18
|
-
;; to stdout.
|
19
|
-
(printf "Not implemented!\n")
|
20
|
-
)
|
3
|
+
(provide grep)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Achilles sing, O Goddess! Peleus' son;
|
2
|
+
His wrath pernicious, who ten thousand woes
|
3
|
+
Caused to Achaia's host, sent many a soul
|
4
|
+
Illustrious into Ades premature,
|
5
|
+
And Heroes gave (so stood the will of Jove)
|
6
|
+
To dogs and to all ravening fowls a prey,
|
7
|
+
When fierce dispute had separated once
|
8
|
+
The noble Chief Achilles from the son
|
9
|
+
Of Atreus, Agamemnon, King of men.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
I do entreat your grace to pardon me.
|
2
|
+
I know not by what power I am made bold,
|
3
|
+
Nor how it may concern my modesty,
|
4
|
+
In such a presence here to plead my thoughts;
|
5
|
+
But I beseech your grace that I may know
|
6
|
+
The worst that may befall me in this case,
|
7
|
+
If I refuse to wed Demetrius.
|