Restructuring
This commit is contained in:
58
CT.rb
58
CT.rb
@ -1,58 +0,0 @@
|
|||||||
require "yaml"
|
|
||||||
require 'erb'
|
|
||||||
require 'open3'
|
|
||||||
require 'pp'
|
|
||||||
require 'benchmark'
|
|
||||||
include Benchmark
|
|
||||||
cli = { 'php' => 'php', 'ruby' => 'ruby', 'lua'=> 'lua', 'javascript'=>'node', 'js'=>'node', 'c' => 'tcc -run'}
|
|
||||||
settings = YAML::load_file("settings.yml")
|
|
||||||
|
|
||||||
problem = YAML::load_file(ARGV[0] + "/desc.yml")
|
|
||||||
|
|
||||||
case ARGV[1]
|
|
||||||
when 'test'
|
|
||||||
if(problem['solutions'])
|
|
||||||
problem['solutions'].each do |sol|
|
|
||||||
if(cli[sol[1]['language']])
|
|
||||||
puts "--------------\n|"+sol[0]+"\n--------------"
|
|
||||||
puts sol[1]['desc']
|
|
||||||
parameter = (sol[1]['parameters']) ? " " + sol[1]['parameters'] : ""
|
|
||||||
stdin, stdout, stderr = Open3.popen3(cli[sol[1]['language']] + " "+ARGV[0]+"/"+sol[0] + parameter)
|
|
||||||
puts "Result: " + stdout.readlines[0]
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
puts "No solutions for said problem"
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'table'
|
|
||||||
|
|
||||||
require 'terminal-table'
|
|
||||||
files = Dir[ARGV[0]+"/**/*/desc.yml"]
|
|
||||||
files.sort!
|
|
||||||
entry = []
|
|
||||||
files.each do |file|
|
|
||||||
yaml = YAML::load_file(file)
|
|
||||||
nested = file.split('/')
|
|
||||||
count = 0
|
|
||||||
if( yaml['solution'] and yaml['solutions'])
|
|
||||||
yaml['solutions'].each do |sol|
|
|
||||||
count += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
entry << {'title'=>yaml['title'],'code'=>nested[-2].to_s,'solved'=>count}
|
|
||||||
end
|
|
||||||
|
|
||||||
rows = []
|
|
||||||
entry.each do |e|
|
|
||||||
solvedstring = (e['solved'] == 0) ? "No" : "Yes("+e['solved'].to_s+")"
|
|
||||||
row = [e['code'],e['title'],solvedstring]
|
|
||||||
rows << row
|
|
||||||
end
|
|
||||||
table = Terminal::Table.new(:headings => ['Code','Title','Solved'],:rows => rows)
|
|
||||||
puts table
|
|
||||||
else
|
|
||||||
output = ERB.new(IO.read('template.rt'))
|
|
||||||
puts output.result()
|
|
||||||
end
|
|
13
composer.json
Normal file
13
composer.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "furyfire/codingtests",
|
||||||
|
"description": "Solutions for online coding challenges. (Support library for PHP)",
|
||||||
|
"homepage": "https://jcktrue.dk",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.1"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"CodingTests\\": "src/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
composer.lock
generated
Normal file
20
composer.lock
generated
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "1fec30c71407f68099d62f794946e565",
|
||||||
|
"packages": [],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": {
|
||||||
|
"php": "^8.1"
|
||||||
|
},
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
copy.src.files=false
|
|
||||||
copy.src.target=
|
|
||||||
index.file=
|
|
||||||
run.as=SCRIPT
|
|
||||||
url=http://localhost/codingtests/
|
|
@ -1,7 +0,0 @@
|
|||||||
include.path=${php.global.include.path}
|
|
||||||
php.version=PHP_54
|
|
||||||
source.encoding=UTF-8
|
|
||||||
src.dir=.
|
|
||||||
tags.asp=false
|
|
||||||
tags.short=true
|
|
||||||
web.root=.
|
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
|
||||||
<type>org.netbeans.modules.php.project</type>
|
|
||||||
<configuration>
|
|
||||||
<data xmlns="http://www.netbeans.org/ns/php-project/1">
|
|
||||||
<name>codingtests</name>
|
|
||||||
</data>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
24
phpunit.xml
Normal file
24
phpunit.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false" displayDetailsOnTestsThatTriggerWarnings="true">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Test Suite">
|
||||||
|
<directory>./tests/</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">src/</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
<logging>
|
||||||
|
<junit outputFile="output/test/junit.xml"/>
|
||||||
|
<testdoxHtml outputFile="output/test/index.html"/>
|
||||||
|
</logging>
|
||||||
|
|
||||||
|
<coverage>
|
||||||
|
<report>
|
||||||
|
<html outputDirectory="output/coverage" />
|
||||||
|
<clover outputFile ="output/coverage/clover.xml" />
|
||||||
|
</report>
|
||||||
|
</coverage>
|
||||||
|
</phpunit>
|
16
settings.yml
16
settings.yml
@ -1,16 +0,0 @@
|
|||||||
languages:
|
|
||||||
javascript:
|
|
||||||
command: node
|
|
||||||
ext: [js,javascript]
|
|
||||||
php:
|
|
||||||
command: php
|
|
||||||
ext: [php]
|
|
||||||
ruby:
|
|
||||||
command: ruby
|
|
||||||
ext: [ruby,rb]
|
|
||||||
tcc:
|
|
||||||
command: tcc -run
|
|
||||||
ext: [c]
|
|
||||||
lua:
|
|
||||||
command: lua
|
|
||||||
ext: [lua]
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user