Skip to content

Commit

Permalink
feat: load wiki page (#2)
Browse files Browse the repository at this point in the history
* fetch wiki page and show results in console
* add a todo to extract languages from page content
  • Loading branch information
baudoliver7 committed Dec 9, 2021
1 parent 7e9b670 commit fd36aa2
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ buildNumber.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
.idea/
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mvn clean pre-integration-test -Pstart-app

### From JAR file
``` cmd
java -Dfile.encoding=utf-8 -cp ool-survey-X.X.X.jar com.ool.survey.Main
java -Dfile.encoding=utf-8 -cp ool-survey-X.X.X-jar-with-dependencies.jar com.ool.survey.Main
```

## How to contribute
Expand Down
83 changes: 81 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,71 @@ SOFTWARE.
<developerConnection>scm:git:git://github.com:baudoliver7/ool-survey.git</developerConnection>
<url>http://github.com/baudoliver7/ool-survey/tree/master</url>
</scm>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-http</artifactId>
<version>1.17.7</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<output>file</output>
<outputDirectory>${project.build.directory}/site/jacoco</outputDirectory>
</configuration>
<executions>
<execution>
<id>jacoco-check</id>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>qulice</id>
Expand All @@ -76,10 +141,10 @@ SOFTWARE.
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.19.4</version>
<configuration>
<license>file:${basedir}/LICENSE.txt</license>
<excludes>
<exclude>checkstyle:/src/main/resources/.*</exclude>
<exclude>xml:.*</exclude>
<exclude>duplicatefinder:.*</exclude>
<exclude>dependencies:.*</exclude>
</excludes>
Expand Down Expand Up @@ -113,5 +178,19 @@ SOFTWARE.
</plugins>
</build>
</profile>
<profile>
<id>sonatype</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<configuration>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
64 changes: 64 additions & 0 deletions src/main/java/com/ool/survey/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* MIT License
*
* Copyright (c) 2021 Olivier B. OURA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ool.survey;

import com.jcabi.http.Request;
import com.jcabi.http.request.JdkRequest;
import java.io.IOException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;

/**
* Class Entrance.
*
* @since 0.1
* @todo #1:30min Extract languages from loaded wiki page.
* We have loaded the entire page of wiki. Now, we want to extract
* all languages present in its content.
* @checkstyle HideUtilityClassConstructorCheck (100 lines)
*/
@SuppressWarnings({"PMD.SystemPrintln", "PMD.UseUtilityClass"})
public final class Main {

/**
* Wikipedia page link.
*/
private static final String WIKI_PAGE =
"https://en.wikipedia.org/wiki/List_of_programming_languages";

/**
* Entrance.
* @param args Arguments
* @throws IOException If fails to fetch
*/
public static void main(final String... args) throws IOException {
final String html = new JdkRequest(Main.WIKI_PAGE)
.uri().back()
.method(Request.GET)
.header(HttpHeaders.ACCEPT, MediaType.TEXT_HTML)
.fetch()
.body();
System.out.println(html);
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/ool/survey/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* MIT License
*
* Copyright (c) 2021 Olivier B. OURA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/**
* Main package.
*
* @since 0.1
*/
package com.ool.survey;

1 comment on commit fd36aa2

@0pdd
Copy link

@0pdd 0pdd commented on fd36aa2 Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-fb1261a8 discovered in src/main/java/com/ool/survey/Main.java and submitted as #3. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.