beginner.codes 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +1 -1
  4. data/lib/challenges.rb +10 -8
  5. metadata +20 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 883130a887d01073e42756b639c831358de832e4ae66cc64f313b55efe24a8d8
4
- data.tar.gz: dad00e03f0974229c83195acba6eda00c98963f490fce03e52335d00cf452d63
3
+ metadata.gz: b8de84d0cc7092d0bcb44af92ce102a8e94077a42e44dff82f2b115651109e71
4
+ data.tar.gz: 3f7e092d43c8df7e34aceb6546af41b423ba77bd773b248e4e461678a7235eda
5
5
  SHA512:
6
- metadata.gz: a9085b34a2d791b85fca92effeb3acaa203937ba0716b8267095bb22cd9917c69b4e352b9b5a67104ff1bc83e48fd6999caa9cc6c1bc59a057678a5c0e1140ed
7
- data.tar.gz: ab9bfc561117e74f6077d72f0df222637d4e5772f9791e61e98a7db85bf77f00eb1fc7d89e6602d858e7be296aee5a51d2a67365001eb8209e1caea2aab1cbb4
6
+ metadata.gz: 309b1e6659355f613667320920e2b677b183d61f8f6914817566fd2d8e3acae5ed83b44c9f332f61f6eaf6cd9fec689bf6a5e2bf182104d89a9cd126da9b5b2d
7
+ data.tar.gz: c6437f9788090fc7ccc199f8ae28bb70f94190eed11d42a26ea0aa36185c71db2b400ba49b294b0779a4b6152c454bc7ce3ae333d23f390ae0a8e889e8610587
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ # 0.1.3 (1 November 2023)
2
+
3
+ ---
4
+
5
+ ## Enhancements
6
+
7
+ - Added some colors via the 'colorize' gem to make it a little more clear what the expected and received answers were.
8
+
9
+ ## Bug Fixes
10
+
11
+ ## Performance
12
+
13
+ ## Documentation
14
+
15
+ - Added comments to make code 10.25% more helpful
16
+ - Sometimes I feel I've got to <> <> run away.. I've got to <> <> get away..
17
+
18
+ ---
19
+
20
+ # 0.1.2 (27 October 2023)
21
+
22
+ ---
23
+
24
+ ## Enhancements
25
+
26
+ ## Bug Fixes
27
+
28
+ - `.equal?` is not the same as `.eql?` ladies and gentlemen. Lessons learned. `equal?` compares for the same object in memory. `eql?` compares the *values* of both objects. Silly rabbit.
29
+ ## Performance
30
+
31
+ ## Documentation
32
+
33
+ - Updated the description to re-iterate its for a specific Discord server. Its public. Go check it out! Beginner.Codes
34
+
35
+ ---
36
+
1
37
  # 0.1.1 (27 October 2023)
2
38
 
3
39
  ---
data/README.md CHANGED
@@ -15,6 +15,6 @@ def n_differences(nums)
15
15
  end # Your code goes here!!!
16
16
 
17
17
 
18
- test(458, n_differences)
18
+ test(458, :n_differences)
19
19
  ```
20
20
  This will handle downloading the necessary challenge test cases and will run them against your code. It will show you which tests failed, what went wrong, and how many tests succeeded.
data/lib/challenges.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  require 'json'
4
4
  require 'uri'
5
5
  require 'net/http'
6
+ require 'colorize'
6
7
 
7
- # this gets imported to your file
8
8
 
9
9
  module Status
10
10
  SUCCESS = 1
@@ -25,10 +25,9 @@ class Result
25
25
  end
26
26
  end
27
27
 
28
-
28
+ # fetches the result from the source
29
29
  def get_tests(challenge)
30
30
  uri = URI("https://raw.githubusercontent.com/beginner-codes/challenges/main/weekday/test_cases_#{challenge}.json")
31
- # uri = URI("https://raw.githubusercontent.com/beginner-codes/challenges/bfb59fe9fbec461a33cc80b20d1d976e9095853c/weekday/test_cases_#{challenge}.json")
32
31
  response = Net::HTTP.get_response(uri)
33
32
  raise "Challenge #{challenge} was not found" unless response.is_a?(Net::HTTPSuccess)
34
33
 
@@ -36,6 +35,7 @@ def get_tests(challenge)
36
35
 
37
36
  end
38
37
 
38
+ # parses your functions and checks if it passes
39
39
  def run_tests(tests, solution_func)
40
40
  results = []
41
41
  tests.each_with_index do |test_case, index|
@@ -46,18 +46,19 @@ def run_tests(tests, solution_func)
46
46
  result.status = Status::EXCEPTION
47
47
  result.got = e
48
48
  else
49
- result.status = Status::FAILED unless result.got.equal?(test_case['return'])
49
+ result.status = Status::FAILED unless result.got.eql?(test_case['return'])
50
50
  end
51
51
  results << result
52
52
  end
53
53
  results
54
54
  end
55
55
 
56
+ # displays the results on the terminal
56
57
  def show_results(challenge, results, total_tests)
57
58
  failures = 0
58
59
  results.each do |result|
59
60
  if result.status.equal?(Status::FAILED)
60
- puts "Test #{result.index} failed: Expected #{result.expected}, got #{result.got}."
61
+ puts "Test #{result.index.to_s.blue} failed: Expected #{result.expected.to_s.green}, got #{result.got.to_s.red}"
61
62
  failures += 1
62
63
  elsif result.status.equal?(Status::EXCEPTION)
63
64
  puts "Test #{result.index} failed: #{result.got}"
@@ -65,11 +66,12 @@ def show_results(challenge, results, total_tests)
65
66
  end
66
67
  end
67
68
  puts ' ' if failures
68
- puts "---- Challenge #{challenge} Results ----"
69
- puts "#{total_tests - failures} passed, #{failures} failed"
70
- puts "\n**** Great job!!! ****" if failures.zero?
69
+ puts "---- Challenge #{challenge} Results ----".light_yellow.on_black
70
+ puts "#{(total_tests - failures).to_s.green} passed, #{failures.to_s.red} failed"
71
+ puts "\n**** Great job!!! ****".green if failures.zero?
71
72
  end
72
73
 
74
+ # the main entry point function
73
75
  def test(challenge, solution_func)
74
76
  tests = get_tests(challenge)
75
77
  results = run_tests(tests, solution_func)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beginner.codes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mr. Robinhood 5
@@ -9,10 +9,25 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-28 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Test your daily challenge solutions with provided tests automatically
15
- to ensure you have a good solution.
12
+ date: 2023-11-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 1.1.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.0
28
+ description: This is the un-official RubyGem for the Beginner.Codes Discord server.
29
+ Test your daily challenge solutions with provided tests automatically to ensure
30
+ you have a good solution.
16
31
  email: mrrobinhood5@gmail.com
17
32
  executables: []
18
33
  extensions: []