trackler 2.0.5.0 → 2.0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/crystal/exercises/largest-series-product/spec/largest_series_product_spec.cr +32 -16
  4. data/tracks/fsharp/exercises/grep/GrepTest.fs +2 -1
  5. data/tracks/fsharp/exercises/linked-list/Example.fs +24 -17
  6. data/tracks/fsharp/exercises/linked-list/HINTS.md +14 -0
  7. data/tracks/fsharp/exercises/linked-list/LinkedListTest.fs +73 -80
  8. data/tracks/lua/config.json +8 -0
  9. data/tracks/lua/exercises/meetup/example.lua +61 -0
  10. data/tracks/lua/exercises/meetup/meetup_spec.lua +858 -0
  11. data/tracks/purescript/.travis.yml +4 -0
  12. data/tracks/purescript/config.json +7 -0
  13. data/tracks/purescript/exercises/bob/bower.json +17 -0
  14. data/tracks/purescript/exercises/bob/examples/src/Bob.purs +49 -0
  15. data/tracks/purescript/exercises/bob/src/Bob.purs +3 -0
  16. data/tracks/purescript/exercises/bob/test/Main.purs +82 -0
  17. data/tracks/ruby/.gitignore +1 -0
  18. data/tracks/ruby/Gemfile +2 -0
  19. data/tracks/ruby/Rakefile +6 -0
  20. data/tracks/ruby/bin/executable-tests-check +1 -1
  21. data/tracks/ruby/config.json +2 -1
  22. data/tracks/ruby/lib/generator.rb +8 -3
  23. data/tracks/ruby/test/generator_test.rb +21 -0
  24. data/tracks/ruby/test/test_helper.rb +16 -0
  25. data/tracks/scala/config.json +17 -0
  26. data/tracks/scala/exercises/allergies/example.scala +1 -5
  27. data/tracks/scala/exercises/allergies/src/main/scala/Allergies.scala +11 -0
  28. data/tracks/scala/exercises/allergies/src/test/scala/AllergiesTest.scala +14 -14
  29. data/tracks/scala/exercises/atbash-cipher/example.scala +4 -4
  30. data/tracks/scala/exercises/atbash-cipher/src/main/scala/Atbash.scala +3 -0
  31. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +9 -9
  32. data/tracks/scala/exercises/crypto-square/example.scala +1 -1
  33. data/tracks/scala/exercises/crypto-square/src/main/scala/CryptoSquare.scala +11 -0
  34. data/tracks/scala/exercises/crypto-square/src/test/scala/CryptoSquareTest.scala +17 -17
  35. data/tracks/scala/exercises/queen-attack/example.scala +2 -1
  36. data/tracks/scala/exercises/queen-attack/src/main/scala/Queens.scala +8 -0
  37. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +9 -9
  38. data/tracks/scala/exercises/raindrops/example.scala +1 -5
  39. data/tracks/scala/exercises/raindrops/src/main/scala/Raindrops.scala +4 -0
  40. data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +16 -16
  41. data/tracks/swift/README.md +16 -16
  42. metadata +16 -1
@@ -11,3 +11,7 @@ script:
11
11
  - bin/fetch-configlet
12
12
  - bin/configlet .
13
13
  - bin/test.sh
14
+
15
+ cache:
16
+ directories:
17
+ - $HOME/.cache/bower/
@@ -18,6 +18,13 @@
18
18
  "modulo"
19
19
  ]
20
20
  },
21
+ {
22
+ "slug": "bob",
23
+ "difficulty": 1,
24
+ "topics": [
25
+ "strings"
26
+ ]
27
+ },
21
28
  {
22
29
  "slug": "raindrops",
23
30
  "difficulty": 1,
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "hello-world",
3
+ "ignore": [
4
+ "**/.*",
5
+ "node_modules",
6
+ "bower_components",
7
+ "output"
8
+ ],
9
+ "dependencies": {
10
+ "purescript-prelude": "^2.1.0",
11
+ "purescript-console": "^2.0.0"
12
+ },
13
+ "devDependencies": {
14
+ "purescript-psci-support": "^2.0.0",
15
+ "purescript-test-unit": "^10.0.1"
16
+ }
17
+ }
@@ -0,0 +1,49 @@
1
+ module Bob
2
+ ( hey
3
+ ) where
4
+
5
+ import Prelude
6
+ import Data.String as String
7
+ import Data.Either as Either
8
+ import Data.String.Regex as Regex
9
+ import Data.String.Regex.Flags (noFlags)
10
+ import Partial.Unsafe as Partial
11
+
12
+ hey :: String -> String
13
+ hey msg =
14
+ if hasLetters msg && allUppercase msg then
15
+ "Whoachill out!"
16
+ else if isQuestion msg then
17
+ "Sure."
18
+ else if isSilence msg then
19
+ "Fine. Be that way!"
20
+ else
21
+ "Whatever."
22
+
23
+
24
+ allUppercase :: String -> Boolean
25
+ allUppercase str =
26
+ String.toUpper str == str
27
+
28
+
29
+ isQuestion :: String -> Boolean
30
+ isQuestion =
31
+ testRegex "\\?$"
32
+
33
+
34
+ hasLetters :: String -> Boolean
35
+ hasLetters =
36
+ testRegex "[a-zA-Z]"
37
+
38
+
39
+ isSilence :: String -> Boolean
40
+ isSilence =
41
+ testRegex "^[\\s\\t\\n]*$"
42
+
43
+
44
+ testRegex :: String -> String -> Boolean
45
+ testRegex patternStr =
46
+ Regex.test
47
+ $ Partial.unsafePartial
48
+ $ Either.fromRight
49
+ $ Regex.regex patternStr noFlags
@@ -0,0 +1,3 @@
1
+ module Bob
2
+ ( hey
3
+ ) where
@@ -0,0 +1,82 @@
1
+ module Test.Main where
2
+
3
+ import Prelude
4
+ import Test.Unit (suite, test)
5
+ import Test.Unit.Main (runTest)
6
+ import Test.Unit.Assert as Assert
7
+ import Bob as Bob
8
+
9
+
10
+ main = runTest do
11
+ suite "Bob.hey" do
12
+ test "stating something" do
13
+ Assert.equal "Whatever." $
14
+ Bob.hey "Tom-ay-totom-aaaah-to."
15
+
16
+ test "shouting" do
17
+ Assert.equal "Whoachill out!" $
18
+ Bob.hey "WATCH OUT!"
19
+
20
+ test "asking a question" do
21
+ Assert.equal "Sure." $
22
+ Bob.hey "Does this cryogenic chamber make me look fat?"
23
+
24
+ test "asking a numeric question" do
25
+ Assert.equal "Sure." $
26
+ Bob.hey "You arewhat, like 15?"
27
+
28
+ test "talking forcefully" do
29
+ Assert.equal "Whatever." $
30
+ Bob.hey "Let's go make out behind the gym!"
31
+
32
+ test "using acronyms in regular speech" do
33
+ Assert.equal "Whatever." $
34
+ Bob.hey "It's OK if you don't want to go to the DMV."
35
+
36
+ test "forceful questions" do
37
+ Assert.equal "Whoachill out!" $
38
+ Bob.hey "WHAT THE HELL WERE YOU THINKING?"
39
+
40
+ test "shouting numbers" do
41
+ Assert.equal "Whoachill out!" $
42
+ Bob.hey "12, 3 GO!"
43
+
44
+ test "only numbers" do
45
+ Assert.equal "Whatever." $
46
+ Bob.hey "12, 3"
47
+
48
+ test "question with only numbers" do
49
+ Assert.equal "Sure." $
50
+ Bob.hey "4?"
51
+
52
+ test "shouting with special characters" do
53
+ Assert.equal "Whoachill out!" $
54
+ Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"
55
+
56
+ test "shouting with no exclamation mark" do
57
+ Assert.equal "Whoachill out!" $
58
+ Bob.hey "I HATE YOU"
59
+
60
+ test "statement containing a question mark" do
61
+ Assert.equal "Whatever." $
62
+ Bob.hey "Ending with ? means a question."
63
+
64
+ test "prattling on" do
65
+ Assert.equal "Sure." $
66
+ Bob.hey "Wait! Hang on. Are you going to be OK?"
67
+
68
+ test "silence" do
69
+ Assert.equal "Fine. Be that way!" $
70
+ Bob.hey ""
71
+
72
+ test "prolonged silence" do
73
+ Assert.equal "Fine. Be that way!" $
74
+ Bob.hey " "
75
+
76
+ test "alternate silences" do
77
+ Assert.equal "Fine. Be that way!" $
78
+ Bob.hey "\t \n \t "
79
+
80
+ test "on multiple line questions" do
81
+ Assert.equal "Whatever." $
82
+ Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno"
@@ -2,3 +2,4 @@
2
2
  bin/configlet
3
3
  bin/configlet.exe
4
4
  Gemfile.lock
5
+ coverage/
data/tracks/ruby/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'minitest'
4
4
  gem 'rubocop', '0.36.0'
5
+ gem 'simplecov'
6
+ gem 'rake'
@@ -0,0 +1,6 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |task|
5
+ task.pattern = 'test/*_test.rb'
6
+ end
@@ -3,7 +3,7 @@ require 'minitest/autorun'
3
3
 
4
4
  # Assume that this file lives in #{base}/bin
5
5
  base = File.join(__dir__,'..')
6
- files = Dir.glob("#{base}/**/*test.rb") + Dir.glob("#{base}/bin/*")
6
+ files = Dir.glob("#{base}/exercises/**/*test.rb") + Dir.glob("#{base}/bin/*")
7
7
 
8
8
  files.each do |file|
9
9
  describe file do
@@ -517,7 +517,8 @@
517
517
  "ignored": [
518
518
  "docs",
519
519
  "img",
520
- "lib"
520
+ "lib",
521
+ "test"
521
522
  ],
522
523
  "foregone": [
523
524
 
@@ -8,17 +8,22 @@ class Generator
8
8
  METADATA_REPOSITORY = 'x-common'.freeze
9
9
 
10
10
  attr_reader :name, :cases
11
- def initialize(name, cases)
11
+ def initialize(name, cases, metadata_repository_path=nil)
12
12
  @name = name
13
13
  @cases = cases
14
+ @metadata_repository_path = metadata_repository_path || default_metadata_path
15
+ end
16
+
17
+ def default_metadata_path
18
+ File.join( '..', METADATA_REPOSITORY)
14
19
  end
15
20
 
16
21
  def metadata_dir
17
- File.expand_path(File.join('..', '..', '..', METADATA_REPOSITORY, 'exercises', name), __FILE__)
22
+ File.join(@metadata_repository_path, 'exercises', name)
18
23
  end
19
24
 
20
25
  def exercise_dir
21
- File.expand_path(File.join('..', '..', 'exercises', name), __FILE__)
26
+ File.join('exercises', name)
22
27
  end
23
28
 
24
29
  def exercise_meta_dir
@@ -0,0 +1,21 @@
1
+ require_relative 'test_helper'
2
+
3
+ class GeneratorTest < Minitest::Test
4
+ def test_default_metadata_path
5
+ subject = Generator.new('aname', nil)
6
+ # This is relative to the xruby root
7
+ assert_equal '../x-common/exercises/aname', subject.metadata_dir
8
+ end
9
+
10
+ def test_initalize_with_fixture_path
11
+ fixture_path = 'xruby/test/fixtures'
12
+ subject = Generator.new('aname', nil, fixture_path)
13
+ assert_equal 'xruby/test/fixtures/exercises/aname', subject.metadata_dir
14
+ end
15
+
16
+ def test_exercise_dir
17
+ subject = Generator.new('aname', nil)
18
+ # This is relative to the xruby root
19
+ assert_equal 'exercises/aname', subject.exercise_dir
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+
3
+ require 'simplecov'
4
+ require 'minitest/autorun'
5
+ require 'minitest/pride'
6
+
7
+ SimpleCov.start do
8
+ add_filter '/tests/'
9
+ add_group 'Utilities' do |file|
10
+ !(file.filename =~ /_cases\.rb$/)
11
+ end
12
+ add_group 'Cases', '_cases.rb'
13
+ end
14
+
15
+ # So we can be sure we have coverage on the whole lib directory:
16
+ Dir.glob('lib/*.rb').each { |file| require file.gsub(%r{(^lib\/|\.rb$)}, '') }
@@ -167,18 +167,27 @@
167
167
  "slug": "raindrops",
168
168
  "difficulty": 1,
169
169
  "topics": [
170
+ "Strings",
171
+ "Logic",
172
+ "Transforming"
170
173
  ]
171
174
  },
172
175
  {
173
176
  "slug": "allergies",
174
177
  "difficulty": 1,
175
178
  "topics": [
179
+ "Lists",
180
+ "Enumerations",
181
+ "Filtering"
176
182
  ]
177
183
  },
178
184
  {
179
185
  "slug": "atbash-cipher",
180
186
  "difficulty": 1,
181
187
  "topics": [
188
+ "Strings",
189
+ "Transforming",
190
+ "Security"
182
191
  ]
183
192
  },
184
193
  {
@@ -197,6 +206,10 @@
197
206
  "slug": "crypto-square",
198
207
  "difficulty": 1,
199
208
  "topics": [
209
+ "Strings",
210
+ "Lists",
211
+ "Security",
212
+ "Transforming"
200
213
  ]
201
214
  },
202
215
  {
@@ -221,6 +234,10 @@
221
234
  "slug": "queen-attack",
222
235
  "difficulty": 1,
223
236
  "topics": [
237
+ "Strings",
238
+ "Optional values",
239
+ "Logic",
240
+ "Games"
224
241
  ]
225
242
  },
226
243
  {
@@ -1,6 +1,6 @@
1
1
  import Allergen.Allergen
2
2
 
3
- class Allergies {
3
+ object Allergies {
4
4
  private lazy val allergenList = Allergen.values
5
5
 
6
6
  def isAllergicTo(allergen: Allergen, score: Int): Boolean =
@@ -10,10 +10,6 @@ class Allergies {
10
10
  allergenList.filter(a => isAllergicTo(a, score)).toList
11
11
  }
12
12
 
13
- object Allergies {
14
- def apply() = new Allergies
15
- }
16
-
17
13
  object Allergen extends Enumeration {
18
14
  type Allergen = Value
19
15
 
@@ -0,0 +1,11 @@
1
+ import Allergen.Allergen
2
+
3
+ object Allergies {
4
+ def isAllergicTo(allergen: Allergen, score: Int): Boolean = ???
5
+
6
+ def allergies(score: Int): List[Allergen] = ???
7
+ }
8
+
9
+ object Allergen extends Enumeration {
10
+ type Allergen = ???
11
+ }
@@ -2,67 +2,67 @@ import org.scalatest.{Matchers, FlatSpec}
2
2
 
3
3
  class AllergiesTest extends FlatSpec with Matchers {
4
4
  it should "handle no allergies means not allergic" in {
5
- Allergies().isAllergicTo(Allergen.Peanuts, 0) should equal (false)
6
- Allergies().isAllergicTo(Allergen.Cats, 0) should equal (false)
7
- Allergies().isAllergicTo(Allergen.Strawberries, 0) should equal (false)
5
+ Allergies.isAllergicTo(Allergen.Peanuts, 0) should equal (false)
6
+ Allergies.isAllergicTo(Allergen.Cats, 0) should equal (false)
7
+ Allergies.isAllergicTo(Allergen.Strawberries, 0) should equal (false)
8
8
  }
9
9
 
10
10
  it should "handle is allergic to eggs" in {
11
11
  pending
12
- Allergies().isAllergicTo(Allergen.Eggs, 1) should equal (true)
12
+ Allergies.isAllergicTo(Allergen.Eggs, 1) should equal (true)
13
13
  }
14
14
 
15
15
  it should "handle is allergic to eggs in addition to other stuff" in {
16
16
  pending
17
- Allergies().isAllergicTo(Allergen.Eggs, 5) should equal (true)
17
+ Allergies.isAllergicTo(Allergen.Eggs, 5) should equal (true)
18
18
  }
19
19
 
20
20
  it should "handle no allergies" in {
21
21
  pending
22
- Allergies().allergies(0) should equal (List())
22
+ Allergies.allergies(0) should equal (List())
23
23
  }
24
24
 
25
25
  it should "handle allergic to just eggs" in {
26
26
  pending
27
- Allergies().allergies(1) should equal (List(Allergen.Eggs))
27
+ Allergies.allergies(1) should equal (List(Allergen.Eggs))
28
28
  }
29
29
 
30
30
  it should "handle allergic to just peanuts" in {
31
31
  pending
32
- Allergies().allergies(2) should equal (List(Allergen.Peanuts))
32
+ Allergies.allergies(2) should equal (List(Allergen.Peanuts))
33
33
  }
34
34
 
35
35
  it should "handle allergic to just strawberries" in {
36
36
  pending
37
- Allergies().allergies(8) should equal (List(Allergen.Strawberries))
37
+ Allergies.allergies(8) should equal (List(Allergen.Strawberries))
38
38
  }
39
39
 
40
40
  it should "handle allergic to eggs and peanuts" in {
41
41
  pending
42
- Allergies().allergies(3) should equal (List(Allergen.Eggs, Allergen.Peanuts))
42
+ Allergies.allergies(3) should equal (List(Allergen.Eggs, Allergen.Peanuts))
43
43
  }
44
44
 
45
45
  it should "handle allergic to more than eggs but not peanuts" in {
46
46
  pending
47
- Allergies().allergies(5) should equal (List(Allergen.Eggs, Allergen.Shellfish))
47
+ Allergies.allergies(5) should equal (List(Allergen.Eggs, Allergen.Shellfish))
48
48
  }
49
49
 
50
50
  it should "handle allergic to lots of stuff" in {
51
51
  pending
52
- Allergies().allergies(248) should equal (List(Allergen.Strawberries, Allergen.Tomatoes,
52
+ Allergies.allergies(248) should equal (List(Allergen.Strawberries, Allergen.Tomatoes,
53
53
  Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
54
54
  }
55
55
 
56
56
  it should "handle allergic to everything" in {
57
57
  pending
58
- Allergies().allergies(255) should equal (List(Allergen.Eggs, Allergen.Peanuts,
58
+ Allergies.allergies(255) should equal (List(Allergen.Eggs, Allergen.Peanuts,
59
59
  Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes,
60
60
  Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
61
61
  }
62
62
 
63
63
  it should "ignore non allergen score parts" in {
64
64
  pending
65
- Allergies().allergies(509) should equal (List(Allergen.Eggs,
65
+ Allergies.allergies(509) should equal (List(Allergen.Eggs,
66
66
  Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes,
67
67
  Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
68
68
  }