beginner.codes 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +7 -2
- data/lib/challenges.rb +17 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff8827c1454a8d44b7ebd23a4c6c2b0c6f73e6502643630b0de30434d54ca424
|
4
|
+
data.tar.gz: f845377f0f7e3e4ce5a5446fcea9196c9d3ebe411b778c7708c508f200de5c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca8ca526d9026fcb0fe9745c96f801c9e210a8c761cbb973014d644d3c3ccdb5dd9426e52d5e2b03488bacf38afc290b79ded83db2f7c9bfe8f41e89b2157af5
|
7
|
+
data.tar.gz: 9fff417792131a316f81e47ecd08e29798f8d0d3ff548aeda9de2457c2e18f2257c1c431614dfdcaeff9434015359f4564e65333aeb51fedec5731c070923d07
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# 0.1.5 (9 November 2023)
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
## Enhancements
|
6
|
+
|
7
|
+
- Added two arguments passed to test `description: true` and `examples: true` to print out additional challenge data during testing
|
8
|
+
|
9
|
+
## Bug Fixes
|
10
|
+
|
11
|
+
## Performance
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
- Updated README to include the new arguments
|
16
|
+
- Thanksgiving approaches along with the cruel realization that I never lost the weight from last new years.
|
17
|
+
|
18
|
+
---
|
19
|
+
|
1
20
|
# 0.1.4 (7 November 2023)
|
2
21
|
|
3
22
|
---
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This is the un-official Ruby Gem for the Beginner.Codes Discord server.
|
|
6
6
|
|
7
7
|
- Install the package: `gem install beginner.codes`
|
8
8
|
- Import the test runner: `require 'challenges'`
|
9
|
-
- Run the tests, passing in the challenge number and your solution function: `test(458, n_differences)`
|
9
|
+
- Run the tests, passing in the challenge number and your solution function: `test(458, :n_differences)` for a function or `test(458, n_differences)` for a lambda function
|
10
10
|
```ruby
|
11
11
|
require 'challenges'
|
12
12
|
|
@@ -22,4 +22,9 @@ n_differences = -> (x) {x*2}
|
|
22
22
|
|
23
23
|
test(458, n_differences)
|
24
24
|
```
|
25
|
-
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.
|
25
|
+
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.
|
26
|
+
|
27
|
+
Additionally, you can view the description and examples when running the tests by adding some options to the test function
|
28
|
+
```ruby
|
29
|
+
test(458, :n_differences, description: true, examples: true)
|
30
|
+
```
|
data/lib/challenges.rb
CHANGED
@@ -4,7 +4,10 @@ require 'json'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'net/http'
|
6
6
|
require 'colorize'
|
7
|
+
require 'tty-markdown'
|
7
8
|
|
9
|
+
TEST_CASE_URL = 'https://raw.githubusercontent.com/beginner-codes/challenges/main/weekday/test_cases_'
|
10
|
+
DESCRIPTION_URL = 'https://raw.githubusercontent.com/beginner-codes/challenges/main/weekday/challenge_'
|
8
11
|
|
9
12
|
module Status
|
10
13
|
SUCCESS = 1
|
@@ -25,9 +28,20 @@ class Result
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
31
|
+
# fetches the description from source
|
32
|
+
def puts_info(challenge, description, examples)
|
33
|
+
url = URI(DESCRIPTION_URL + "#{challenge}.md")
|
34
|
+
response = Net::HTTP.get(url).force_encoding('UTF-8')
|
35
|
+
result = "\n"
|
36
|
+
result += response.split('## ').first.gsub("\n\n", "\n")+"\n" if description
|
37
|
+
result += response.split('#')[3].gsub("\n\n", "\n").insert(0,'#') if examples
|
38
|
+
result = TTY::Markdown.parse(result)
|
39
|
+
puts result
|
40
|
+
end
|
41
|
+
|
28
42
|
# fetches the result from the source
|
29
43
|
def get_tests(challenge)
|
30
|
-
uri = URI("
|
44
|
+
uri = URI(TEST_CASE_URL + "#{challenge}.json")
|
31
45
|
response = Net::HTTP.get_response(uri)
|
32
46
|
raise "Challenge #{challenge} was not found" unless response.is_a?(Net::HTTPSuccess)
|
33
47
|
|
@@ -77,8 +91,9 @@ def show_results(challenge, results, total_tests)
|
|
77
91
|
end
|
78
92
|
|
79
93
|
# the main entry point function
|
80
|
-
def test(challenge, solution_func)
|
94
|
+
def test(challenge, solution_func, description: false, examples: false)
|
81
95
|
tests = get_tests(challenge)
|
96
|
+
puts_info(challenge, description, examples) if description || examples
|
82
97
|
results = run_tests(tests, solution_func)
|
83
98
|
show_results(challenge, results, tests.size)
|
84
99
|
end
|
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mr. Robinhood 5
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-11-
|
12
|
+
date: 2023-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.1.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: tty-markdown
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.2
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.7.2
|
28
42
|
description: This is the un-official RubyGem for the Beginner.Codes Discord server.
|
29
43
|
Test your daily challenge solutions with provided tests automatically to ensure
|
30
44
|
you have a good solution.
|