Skip to content

Commit

Permalink
Add Crystal
Browse files Browse the repository at this point in the history
  • Loading branch information
will committed May 25, 2015
1 parent 18acdbe commit cafe46d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ frameworks/Ur/urweb/*.exe

# nim
nimcache

# crystal
.crystal
*.out
29 changes: 29 additions & 0 deletions frameworks/Crystal/stdlib/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"framework": "crystal",
"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries?queries=",
"fortune_url": "/fortunes",
"update_url": "/updates?queries=",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "crystal",
"language": "Crystal",
"orm": "Raw",
"platform": "Crystal",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "Crystal",
"notes": "",
"versus": "crystal"
}
}]
}

3 changes: 3 additions & 0 deletions frameworks/Crystal/stdlib/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

fw_depends crystal
18 changes: 18 additions & 0 deletions frameworks/Crystal/stdlib/server.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "http/server"
require "json"

server = HTTP::Server.new(8080) do |request|
headers = HTTP::Headers{"Server": "Crystal", "Date": Time.utc_now.to_s}
case request.path
when "/json"
headers.add("Content-Type", "application/json")
HTTP::Response.new 200, {message: "Hello, World!"}.to_json, headers
when "/plaintext"
headers.add("Content-Type", "text/plain")
HTTP::Response.new 200, "Hello, world!", headers
else
HTTP::Response.not_found
end
end

server.listen
4 changes: 4 additions & 0 deletions frameworks/Crystal/stdlib/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

crystal build --release server.cr -o server.out
./server.out
14 changes: 14 additions & 0 deletions toolset/setup/linux/languages/crystal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex

RETCODE=$(fw_exists ${IROOT}/crystal.installed)
[ ! "$RETCODE" == 0 ] || { return 0; }

sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54
echo "deb http://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list

sudo apt-get update

sudo apt-get install -y crystal

touch ${IROOT}/crystal.installed

0 comments on commit cafe46d

Please sign in to comment.