From f83f59c135db4d5f24f49a512c93e781364bcaa2 Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Sat, 25 Jul 2015 20:55:06 +0300 Subject: [PATCH] First commit --- .gitignore | 6 ++++++ .travis.yml | 10 ++++++++++ LICENSE | 21 +++++++++++++++++++++ Projectfile | 2 ++ README.md | 37 +++++++++++++++++++++++++++++++++++++ spec/cryload_spec.cr | 9 +++++++++ spec/spec_helper.cr | 2 ++ src/cryload.cr | 29 +++++++++++++++++++++++++++++ src/cryload/version.cr | 3 +++ 9 files changed, 119 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 Projectfile create mode 100644 README.md create mode 100644 spec/cryload_spec.cr create mode 100644 spec/spec_helper.cr create mode 100644 src/cryload.cr create mode 100644 src/cryload/version.cr diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e6bbeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.deps/ +/libs/ +/.crystal/ +/doc/ + + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c59f98e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: c +before_install: | + curl http://dist.crystal-lang.org/apt/setup.sh | sudo bash + sudo apt-get -q update + +install: | + sudo apt-get install crystal + +script: + - crystal spec diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..47cce33 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Sdogruyol + +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. diff --git a/Projectfile b/Projectfile new file mode 100644 index 0000000..db1b48f --- /dev/null +++ b/Projectfile @@ -0,0 +1,2 @@ +deps do +end diff --git a/README.md b/README.md new file mode 100644 index 0000000..394335b --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# cryload + +TODO: Write a description here for library + +## Installation + +Add it to `Projectfile` + +```crystal +deps do + github "[your-github-name]/cryload" +end +``` + +## Usage + +```crystal +require "cryload" +``` + +TODO: Write usage here for library + +## Development + +TODO: Write instructions for development + +## Contributing + +1. Fork it ( https://github.com/[your-github-name]/cryload/fork ) +2. Create your feature branch (git checkout -b my-new-feature) +3. Commit your changes (git commit -am 'Add some feature') +4. Push to the branch (git push origin my-new-feature) +5. Create a new Pull Request + +## Contributors + +- [your-github-name](https://github.com/[your-github-name]) Sdogruyol - creator, maintainer diff --git a/spec/cryload_spec.cr b/spec/cryload_spec.cr new file mode 100644 index 0000000..8c760ae --- /dev/null +++ b/spec/cryload_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe Cryload do + # TODO: Write tests + + it "works" do + false.should eq(true) + end +end diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..af0570e --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/cryload" diff --git a/src/cryload.cr b/src/cryload.cr new file mode 100644 index 0000000..7ff31c3 --- /dev/null +++ b/src/cryload.cr @@ -0,0 +1,29 @@ +require "./cryload/*" +require "http" + +module Cryload + class LoadGenerator + def initialize(@host) + @request_count = 0 + ch = generate_request_channel + loop do + ch.receive + p "Total request made: #{@request_count}" + end + end + + def generate_request_channel() + channel = Channel(Int32).new + spawn do + loop do + HTTP::Client.get @host + @request_count+= 1 + channel.send @request_count + end + end + channel + end + end +end + +Cryload::LoadGenerator.new ARGV[0] diff --git a/src/cryload/version.cr b/src/cryload/version.cr new file mode 100644 index 0000000..bdb2026 --- /dev/null +++ b/src/cryload/version.cr @@ -0,0 +1,3 @@ +module Cryload + VERSION = "0.0.1" +end