Browse Source

Merge pull request #2127 from saturday06/remove-crystal-moonshine

Remove Crystal/moonshine
Nate 9 years ago
parent
commit
8b74cadf33

+ 0 - 1
.travis.yml

@@ -40,7 +40,6 @@ env:
     - "TESTDIR=Clojure/pedestal"
     - "TESTDIR=Clojure/aleph"
     - "TESTDIR=Crystal/crystal-raw"
-    - "TESTDIR=Crystal/moonshine"
     - "TESTDIR=Crystal/kemal"
     - "TESTDIR=D/vibed"
     - "TESTDIR=Dart/dart-raw"

+ 0 - 5
frameworks/Crystal/moonshine/.gitignore

@@ -1,5 +0,0 @@
-.deps
-.deps.lock
-libs/
-.crystal
-.shards

+ 0 - 5
frameworks/Crystal/moonshine/README.md

@@ -1,5 +0,0 @@
-# Crystal-Moonshine
-
-This is the [Moonshine](https://github.com/dhruvrajvanshi/Moonshine) test of the Framework Benchmarks. Crystal is a new language that closely resembles Ruby with a goal of removing typed variables and parameters (instead inferencing), whilst maintaining top speed through bindings into C.
-
-Moonshine is a minimal web framework for the Crystal language.

+ 0 - 28
frameworks/Crystal/moonshine/benchmark_config.json

@@ -1,28 +0,0 @@
-{
-  "framework": "moonshine",
-  "tests": [{
-    "default": {
-      "setup_file": "setup-postgres",
-      "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": "Fullstack",
-      "database": "Postgres",
-      "framework": "moonshine",
-      "language": "Crystal",
-      "orm": "micro",
-      "platform": "Crystal",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Moonshine",
-      "notes": "",
-      "versus": "ruby"
-    }
-  }]
-}

+ 0 - 157
frameworks/Crystal/moonshine/server-postgres.cr

@@ -1,157 +0,0 @@
-require "moonshine"
-require "pg"
-require "html/builder"
-
-include Moonshine
-include Moonshine::Utils::Shortcuts
-
-# Compose Objects (like Hash) to have a to_json method
-require "json/to_json"
-
-DB = PG.connect("postgres://benchmarkdbuser:benchmarkdbpass@#{ENV["DBHOST"]? || "127.0.0.1"}/hello_world")
-app = App.new
-
-class CONTENT
-  UTF8 = "; charset=UTF-8"
-  JSON = "application/json" + UTF8
-  PLAIN = "text/plain"
-  HTML = "text/html" + UTF8
-end
-
-ID_MAXIMUM = 10_000
-
-app.response_middleware do |req, res|
-    res.headers["Server"] = "Moonshine"
-    res.headers["Date"] = Time.now.to_s
-    res
-end
-
-private def randomWorld
-  id = rand(1..ID_MAXIMUM)
-  result = DB.exec({Int32, Int32}, "SELECT id, randomNumber FROM world WHERE id = $1", [id]).rows.first
-  {:id => result[0], :randomNumber => result[1]}
-end
-
-private def setWorld(world)
-  DB.exec("UPDATE world set randomNumber = $1 where id = $2", [world[:randomNumber], world[:id]])
-  world
-end
-
-private def fortunes
-  data = [] of  Hash(Symbol, (String | Int32))
-
-  DB.exec({Int32, String}, "select id, message from Fortune").rows.each do |row|
-    data.push({:id => row[0], :message => row[1]})
-  end
-  data
-end
-
-private def sanitizedQueryCount(request)
-  begin
-    queries = request.get["queries"].to_i
-  rescue
-    queries = 1
-  end
-  queries = 1 if queries < 1
-  queries = 500 if queries > 500
-  queries
-end
-
-#
-# Basic Tests
-#
-
-# Test 1: JSON Serialization
-app.get "/json", do |request|
-  res = ok({ :message => "Hello, World!" }.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Test 6: Plaintext
-app.get "/plaintext", do |request|
-  res = ok("Hello, World!")
-  res.headers["Content-type"] = CONTENT::PLAIN
-  res
-end
-
-#
-# Postgres DatabaseTests
-#
-
-# Postgres Test 2: Single database query
-app.get "/db", do |request|
-  res = ok(randomWorld.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Postgres Test 3: Multiple database query
-app.get "/queries", do |request|
-  results = (1..sanitizedQueryCount(request)).map do
-    randomWorld
-  end
-
-  res = ok(results.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Postgres Test 4: Fortunes
-app.get "/fortunes", do |request|
-  data = fortunes
-  
-  additional_fortune = {
-    :id => 0,
-    :message => "Additional fortune added at request time."
-  }
-  data.push(additional_fortune)
-
-  data.sort! do |a, b|
-    a[:message].to_s <=> b[:message].to_s
-  end
-
-  # New builder for each request!
-  html = HTML::Builder.new.build do
-    html {
-      head {
-        title { text "Fortunes" }
-      }
-      body {
-        table {
-          tr {
-            thead { text "id" }
-            thead { text "message" }
-          }
-          data.each { |e|
-            tr {
-              td { text e[:id].to_s }
-              td { text e[:message].to_s }
-            }
-          }
-        }
-      }
-    }
-  end
-
-  # Doctype not available in builder
-  # builder only supports `thead`, tests need to see `th`
-  res = ok("<!doctype html>" + html.gsub("thead", "th"))
-  res.headers["Content-type"] = CONTENT::HTML
-  res
-end
-
-# Postgres Test 5: Database Updates
-app.get "/updates", do |request|
-  updated = (1..sanitizedQueryCount(request)).map do
-    world = randomWorld
-    world[:randomNumber] = rand(1..ID_MAXIMUM)
-    setWorld(world)
-  end
-
-  res = ok(updated.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-app.run(8080)

+ 0 - 158
frameworks/Crystal/moonshine/server-redis.cr

@@ -1,158 +0,0 @@
-require "moonshine"
-require "redis"
-require "html/builder"
-
-include Moonshine
-include Moonshine::Utils::Shortcuts
-
-# Compose Objects (like Hash) to have a to_json method
-require "json/to_json"
-
-REDIS = Redis.new
-app = App.new
-
-class CONTENT
-  UTF8 = "; charset=UTF-8"
-  JSON = "application/json" #+ UTF8
-  PLAIN = "text/plain"
-  HTML = "text/html" #+ UTF8
-end
-
-ID_MAXIMUM = 10_000
-
-app.response_middleware do |req, res|
-    res.headers["Server"] = "Moonshine"
-    res.headers["Date"] = Time.now.to_s
-    res
-end
-
-private def randomWorld
-  id = rand(1..ID_MAXIMUM)
-  num = REDIS.get("world:" + id.to_s)
-  { :id => id, :randomNumber => num }
-end
-
-private def setWorld(world)
-  id = "world:" + world[:id].to_s
-  REDIS.set(id, world[:randomNumber])
-  world
-end
-
-private def fortunes
-  data = [] of  Hash(Symbol, (String | Int32))
-
-  REDIS.lrange("fortunes", 0, -1).each_with_index do |e, i|
-    data.push({:id => i + 1, :message => e.to_s})
-  end
-  data
-end
-
-private def sanitizedQueryCount(request)
-  begin
-    queries = request.get["queries"].to_i
-  rescue
-    queries = 1
-  end
-  queries = 1 if queries < 1
-  queries = 500 if queries > 500
-  queries
-end
-
-#
-# Basic Tests
-#
-
-# Test 1: JSON Serialization
-app.get "/json", do |request|
-  res = ok({ :message => "Hello, World!" }.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Test 6: Plaintext
-app.get "/plaintext", do |request|
-  res = ok("Hello, World!")
-  res.headers["Content-type"] = CONTENT::PLAIN
-  res
-end
-
-#
-# Redis DatabaseTests
-#
-
-# Redis Test 2: Single database query
-app.get "/db", do |request|
-  res = ok(randomWorld.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Redis Test 3: Multiple database query
-app.get "/queries", do |request|
-  results = (1..sanitizedQueryCount(request)).map do
-    randomWorld
-  end
-
-  res = ok(results.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-# Redis Test 4: Fortunes
-app.get "/fortunes", do |request|
-  data = fortunes
-  
-  additional_fortune = {
-    :id => 0,
-    :message => "Additional fortune added at request time."
-  }
-  data.push(additional_fortune)
-
-  data.sort! do |a, b|
-    a[:message].to_s <=> b[:message].to_s
-  end
-
-  # New builder for each request!
-  html = HTML::Builder.new.build do
-    html {
-      head {
-        title { text "Fortunes" }
-      }
-      body {
-        table {
-          tr {
-            thead { text "id" }
-            thead { text "message" }
-          }
-          data.each { |e|
-            tr {
-              td { text e[:id].to_s }
-              td { text e[:message].to_s }
-            }
-          }
-        }
-      }
-    }
-  end
-
-  # Doctype not available in builder
-  # builder only supports `thead`, tests need to see `th`
-  res = ok("<!doctype html>" + html.gsub("thead", "th"))
-  res.headers["Content-type"] = CONTENT::HTML
-  res
-end
-
-# Redis Test 5: Database Updates
-app.get "/updates", do |request|
-  updated = (1..sanitizedQueryCount(request)).map do
-    world = randomWorld
-    world[:randomNumber] = rand(1..ID_MAXIMUM)
-    setWorld(world)
-  end
-
-  res = ok(updated.to_json)
-  res.headers["Content-type"] = CONTENT::JSON
-  res
-end
-
-app.run(8080)

+ 0 - 7
frameworks/Crystal/moonshine/setup-postgres.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-fw_depends crystal
-
-crystal deps install
-
-crystal server-postgres.cr &

+ 0 - 7
frameworks/Crystal/moonshine/setup-redis.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-fw_depends crystal
-
-crystal deps install
-
-crystal server-redis.cr &

+ 0 - 15
frameworks/Crystal/moonshine/shard.yml

@@ -1,15 +0,0 @@
-name: "moonshine"
-version: "0.0.1"
-
-dependencies:
-  pg:
-    github: "will/crystal-pg"
-    version: ">= 0.4.3"
-  moonshine:
-    github: "dhruvrajvanshi/Moonshine"
-    branch: master
-  redis:
-    github: "stefanwille/crystal-redis"
-    version: "~> 1.2.1"
-
-license: MIT