Browse Source

Starting with Groovy

master
Julio Biason 12 months ago
parent
commit
31b6d31970
  1. 6
      .editorconfig
  2. 6
      .gitignore
  3. 25
      groovy/hello-world/.exercism/config.json
  4. 1
      groovy/hello-world/.exercism/metadata.json
  5. 48
      groovy/hello-world/HELP.md
  6. 38
      groovy/hello-world/README.md
  7. 18
      groovy/hello-world/build.gradle
  8. 7
      groovy/hello-world/src/main/groovy/HelloWorld.groovy
  9. 13
      groovy/hello-world/src/test/groovy/HelloWorldSpec.groovy
  10. 23
      groovy/two-fer/.exercism/config.json
  11. 1
      groovy/two-fer/.exercism/metadata.json
  12. 48
      groovy/two-fer/HELP.md
  13. 48
      groovy/two-fer/README.md
  14. 18
      groovy/two-fer/build.gradle
  15. 9
      groovy/two-fer/src/main/groovy/TwoFer.groovy
  16. 36
      groovy/two-fer/src/test/groovy/TwoFerSpec.groovy

6
.editorconfig

@ -0,0 +1,6 @@
root = true
[*.groovy]
indent_style = space
indent_size = 4

6
.gitignore vendored

@ -22,3 +22,9 @@ _build
# TypeScript/JavaScript
**/node_modules/**
# Groovy
**/build/**
**/gradle*
**/.gradle/**
**/gradle/**

25
groovy/hello-world/.exercism/config.json

@ -0,0 +1,25 @@
{
"authors": [
"duffn"
],
"contributors": [
"alexanderific",
"amscotti",
"Dispader",
"kytrinyx"
],
"files": {
"solution": [
"src/main/groovy/HelloWorld.groovy"
],
"test": [
"src/test/groovy/HelloWorldSpec.groovy"
],
"example": [
".meta/src/reference/groovy/HelloWorld.groovy"
]
},
"blurb": "The classical introductory exercise. Just say \"Hello, World!\".",
"source": "This is an exercise to introduce users to using Exercism",
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
}

1
groovy/hello-world/.exercism/metadata.json

@ -0,0 +1 @@
{"track":"groovy","exercise":"hello-world","id":"019a349fbd6141aa90ccecb1ae98683e","url":"https://exercism.org/tracks/groovy/exercises/hello-world","handle":"JBiason","is_requester":true,"auto_approve":false}

48
groovy/hello-world/HELP.md

@ -0,0 +1,48 @@
# Help
## Running the tests
On MacOS/Linux, please run:
```sh
$ chmod +x gradlew
```
Execute the tests with:
```sh
$ ./gradlew test
```
> Use `gradlew.bat` if you're on Windows
## Skipped tests
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
## Submitting your solution
You can submit your solution using the `exercism submit src/main/groovy/HelloWorld.groovy` 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 [Groovy track's documentation](https://exercism.org/docs/tracks/groovy)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- 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:
- The [Groovy Language Documentation](http://docs.groovy-lang.org/docs/latest/html/documentation/)
- The [Groovy Community](http://www.groovy-lang.org/community.html) entry of the Groovy Language Documentation
- [/r/groovy](https://www.reddit.com/r/groovy) is the Groovy subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/groovy) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

38
groovy/hello-world/README.md

@ -0,0 +1,38 @@
# Hello World
Welcome to Hello World on Exercism's Groovy Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
The classical introductory exercise.
Just say "Hello, World!".
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.
The objectives are simple:
- Modify the provided code so that it produces the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
## Source
### Created by
- @duffn
### Contributed to by
- @alexanderific
- @amscotti
- @Dispader
- @kytrinyx
### Based on
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program

18
groovy/hello-world/build.gradle

@ -0,0 +1,18 @@
apply plugin: "groovy"
repositories {
mavenCentral()
}
dependencies {
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
implementation "org.codehaus.groovy:groovy-all:3.0.2"
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
events = ["passed", "failed", "skipped"]
}
}

7
groovy/hello-world/src/main/groovy/HelloWorld.groovy

@ -0,0 +1,7 @@
class HelloWorld {
def hello() {
'Hello, World!'
}
}

13
groovy/hello-world/src/test/groovy/HelloWorldSpec.groovy

@ -0,0 +1,13 @@
import spock.lang.*
class HelloWorldSpec extends Specification {
def "Say Hi!"() {
expect:
new HelloWorld().hello() == expected
where:
expected = 'Hello, World!'
}
}

23
groovy/two-fer/.exercism/config.json

@ -0,0 +1,23 @@
{
"authors": [
"ikhadykin"
],
"contributors": [
"amscotti",
"mattmoss",
"sjwarner-bp"
],
"files": {
"solution": [
"src/main/groovy/TwoFer.groovy"
],
"test": [
"src/test/groovy/TwoFerSpec.groovy"
],
"example": [
".meta/src/reference/groovy/TwoFer.groovy"
]
},
"blurb": "Create a sentence of the form \"One for X, one for me.\".",
"source_url": "https://github.com/exercism/problem-specifications/issues/757"
}

1
groovy/two-fer/.exercism/metadata.json

@ -0,0 +1 @@
{"track":"groovy","exercise":"two-fer","id":"1146ca2f98784150b4277877b3e13927","url":"https://exercism.org/tracks/groovy/exercises/two-fer","handle":"JBiason","is_requester":true,"auto_approve":false}

48
groovy/two-fer/HELP.md

@ -0,0 +1,48 @@
# Help
## Running the tests
On MacOS/Linux, please run:
```sh
$ chmod +x gradlew
```
Execute the tests with:
```sh
$ ./gradlew test
```
> Use `gradlew.bat` if you're on Windows
## Skipped tests
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
## Submitting your solution
You can submit your solution using the `exercism submit src/main/groovy/TwoFer.groovy` 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 [Groovy track's documentation](https://exercism.org/docs/tracks/groovy)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- 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:
- The [Groovy Language Documentation](http://docs.groovy-lang.org/docs/latest/html/documentation/)
- The [Groovy Community](http://www.groovy-lang.org/community.html) entry of the Groovy Language Documentation
- [/r/groovy](https://www.reddit.com/r/groovy) is the Groovy subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/groovy) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

48
groovy/two-fer/README.md

@ -0,0 +1,48 @@
# Two Fer
Welcome to Two Fer on Exercism's Groovy Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
`Two-fer` or `2-fer` is short for two for one.
One for you and one for me.
Given a name, return a string with the message:
```text
One for name, one for me.
```
Where "name" is the given name.
However, if the name is missing, return the string:
```text
One for you, one for me.
```
Here are some examples:
|Name |String to return
|:-------|:------------------
|Alice |One for Alice, one for me.
|Bob |One for Bob, one for me.
| |One for you, one for me.
|Zaphod |One for Zaphod, one for me.
## Source
### Created by
- @ikhadykin
### Contributed to by
- @amscotti
- @mattmoss
- @sjwarner-bp
### Based on
https://github.com/exercism/problem-specifications/issues/757

18
groovy/two-fer/build.gradle

@ -0,0 +1,18 @@
apply plugin: "groovy"
repositories {
mavenCentral()
}
dependencies {
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
implementation "org.codehaus.groovy:groovy-all:3.0.2"
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
events = ["passed", "failed", "skipped"]
}
}

9
groovy/two-fer/src/main/groovy/TwoFer.groovy

@ -0,0 +1,9 @@
class TwoFer {
static String twoFer(String name) {
if (!name) {
name = 'you'
}
"One for ${name}, one for me."
}
}

36
groovy/two-fer/src/test/groovy/TwoFerSpec.groovy

@ -0,0 +1,36 @@
import spock.lang.*
class TwoFerSpec extends Specification {
def "No name given"() {
expect:
TwoFer.twoFer() == 'One for you, one for me.'
}
def "Empty name given"() {
expect:
TwoFer.twoFer(name) == expected
where:
name || expected
'' || 'One for you, one for me.'
}
def "A name given"() {
expect:
TwoFer.twoFer(name) == expected
where:
name || expected
'Alice' || 'One for Alice, one for me.'
}
def "Another name given"() {
expect:
TwoFer.twoFer(name) == expected
where:
name || expected
'Bob' || 'One for Bob, one for me.'
}
}
Loading…
Cancel
Save