From 1eea4328efd4502cfa9746b81618080ef129d077 Mon Sep 17 00:00:00 2001 From: Eduardo Lanchares Date: Wed, 29 Feb 2012 15:56:34 +0100 Subject: [PATCH] Init --- .gitignore | 1 + .rvmrc | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Procfile | 1 + app.js | 15 ++++++++++ index.html | 16 +++++++++++ package.json | 8 ++++++ 6 files changed, 122 insertions(+) create mode 100644 .gitignore create mode 100644 .rvmrc create mode 100644 Procfile create mode 100644 app.js create mode 100644 index.html create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.rvmrc b/.rvmrc new file mode 100644 index 0000000..9b5e6eb --- /dev/null +++ b/.rvmrc @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# This is an RVM Project .rvmrc file, used to automatically load the ruby +# development environment upon cd'ing into the directory + +# First we specify our desired [@], the @gemset name is optional. +environment_id="ruby-1.9.2-p290@charrobot" + +# +# Uncomment the following lines if you want to verify rvm version per project +# +# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start +# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || { +# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading." +# return 1 +# } +# + +# +# Uncomment following line if you want options to be set only for given project. +# +# PROJECT_JRUBY_OPTS=( --1.9 ) +# +# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell: +# +# chmod +x ${rvm_path}/hooks/after_use_jruby_opts +# + +# +# First we attempt to load the desired environment directly from the environment +# file. This is very fast and efficient compared to running through the entire +# CLI and selector. If you want feedback on which environment was used then +# insert the word 'use' after --create as this triggers verbose mode. +# +if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ + && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] +then + \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" + + if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] + then + . "${rvm_path:-$HOME/.rvm}/hooks/after_use" + fi +else + # If the environment file has not yet been created, use the RVM CLI to select. + if ! rvm --create use "$environment_id" + then + echo "Failed to create RVM environment '${environment_id}'." + return 1 + fi +fi + +# +# If you use an RVM gemset file to install a list of gems (*.gems), you can have +# it be automatically loaded. Uncomment the following and adjust the filename if +# necessary. +# +# filename=".gems" +# if [[ -s "$filename" ]] +# then +# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d' +# fi + +# If you use bundler, this might be useful to you: +# if [[ -s Gemfile ]] && ! command -v bundle >/dev/null +# then +# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n" +# gem install bundler +# fi +# if [[ -s Gemfile ]] && command -v bundle +# then +# bundle install +# fi + +if [[ $- == *i* ]] # check for interactive shells +then + echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green +else + echo "Using: $GEM_HOME" # don't use colors in interactive shells +fi + diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..e1d4131 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..3bcc5c7 --- /dev/null +++ b/app.js @@ -0,0 +1,15 @@ +var app = require('express').createServer(); +var io = require('socket.io').listen(app); + +app.listen(5000); + +app.get('/', function (req, res) { + res.sendfile(__dirname + '/index.html'); +}); + +io.sockets.on('connection', function (socket) { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', function (data) { + console.log(data); + }); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..0612551 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + Socket.io example + + + + +

Charrobot test

+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..7a403c8 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "charrobot-test", + "version": "0.0.1", + "dependencies": { + "express": "2.5.8", + "socket.io": "0.9.0" + } +}