Skip to content

Commit

Permalink
introducing shelly cloud hosting.
Browse files Browse the repository at this point in the history
  • Loading branch information
5v3n committed Oct 26, 2013
1 parent 81e862a commit 0ff1b17
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 42 deletions.
16 changes: 16 additions & 0 deletions Cloudfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ratpack:
ruby_version: 2.0.0 # 2.0.0, jruby, 1.9.3, 1.9.2 or ree-1.8.7
environment: production # RAILS_ENV
monitoring_email: [email protected]
domains:
- ratpack.shellyapp.com
- ratpack.makingthingshappen.de
websockets: on
servers:
app1:
size: small
thin: 1
databases:
# - postgresql
# - mongodb
# - redis
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ source 'https://rubygems.org'

ruby '2.0.0'

gem "shelly-dependencies", :group => :production

gem 'rake'
gem 'sinatra'
gem 'haml'

gem 'faye'
gem 'faye', '>=1.0.0'

gem 'thin'

Expand Down
62 changes: 34 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,44 @@ GEM
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
cookiejar (0.3.0)
curb (0.8.3)
curb (0.8.5)
daemons (1.1.9)
diff-lcs (1.2.4)
dotenv (0.8.0)
em-http-request (1.0.3)
addressable (>= 2.2.3)
dotenv (0.9.0)
em-http-request (1.1.1)
addressable (>= 2.3.4)
cookiejar
em-socksify
eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3)
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0.beta.2)
em-socksify (0.3.0)
eventmachine (>= 1.0.0.beta.4)
eventmachine (1.0.3)
faye (0.8.9)
faye (1.0.0)
cookiejar (>= 0.3.0)
em-http-request (>= 0.3.0)
eventmachine (>= 0.12.0)
faye-websocket (>= 0.4.0)
faye-websocket (>= 0.7.0)
multi_json (>= 1.0.0)
rack (>= 1.0.0)
yajl-ruby (>= 1.0.0)
faye-websocket (0.4.7)
websocket-driver (>= 0.3.0)
faye-websocket (0.7.0)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.3.0)
ffi (1.9.0)
foreman (0.63.0)
dotenv (>= 0.7)
thor (>= 0.13.6)
haml (4.0.3)
tilt
http_parser.rb (0.5.3)
mime-types (1.23)
mini_portile (0.5.1)
multi_json (1.7.8)
http_parser.rb (0.6.0.beta.2)
mime-types (1.25)
mini_portile (0.5.2)
multi_json (1.8.2)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
rack (1.5.2)
rack-protection (1.5.0)
rack-protection (1.5.1)
rack
rack-test (0.6.2)
rack (>= 1.0)
Expand All @@ -55,48 +57,52 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.4)
rspec-expectations (2.14.0)
rspec-core (2.14.6)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.2)
rubyzip (0.9.9)
selenium-webdriver (2.33.0)
rspec-mocks (2.14.4)
rubyzip (1.0.0)
selenium-webdriver (2.37.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
rubyzip (~> 1.0.0)
websocket (~> 1.0.4)
shelly-dependencies (0.2.3)
rake
thin
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
sinatra (1.4.3)
sinatra (1.4.4)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
thin (1.5.1)
thin (1.6.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
eventmachine (>= 1.0.0)
rack (>= 1.5.0)
thor (0.18.1)
tilt (1.4.1)
websocket (1.0.7)
websocket-driver (0.3.0)
xpath (2.0.0)
nokogiri (~> 1.3)
yajl-ruby (1.1.0)

PLATFORMS
ruby

DEPENDENCIES
capybara
curb
faye
faye (>= 1.0.0)
foreman
haml
rack-test
rake
rspec
selenium-webdriver
shelly-dependencies
simplecov
sinatra
thin
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec thin start -R ./sinatra/config.ru -p $PORT
web: bundle exec thin start -R ./config.ru -p $PORT
15 changes: 11 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
require 'rspec/core/rake_task'
if ['development','test'].include? ENV['RACK_ENV']
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern="./sinatra/spec{,/*/**}/*_spec.rb"
end

RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern="./sinatra/spec{,/*/**}/*_spec.rb"
task :default => :spec
end

task :default => :spec
desc 'fake tasks needed by shelly'
namespace :db do
task :migrate
task :setup
end
4 changes: 2 additions & 2 deletions sinatra/config.ru → config.ru
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'faye'
require File.expand_path('../rat_pack_server', __FILE__)
require File.expand_path('../sinatra/rat_pack_server', __FILE__)

Faye::WebSocket.load_adapter('thin')

use Rack::ShowExceptions if ENV['RACK_ENV']=='development'
use Faye::RackAdapter, :mount => '/faye',
:timeout => 25

run RatPackServer
run RatPackServer
6 changes: 3 additions & 3 deletions sinatra/public/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var RatPack = RatPack || {};
$(document).ready(function() {
RatPack.fayeClient = new Faye.Client('/faye');
RatPack.fayeClient = new Faye.Client(window.location.protocol + '//' + window.location.host + '/faye');
var subscription = RatPack.fayeClient.subscribe('/status/realtime', function(message) {
message.activated === 0 ? RatPack.turnOffButton() : RatPack.turnOnButton()
});
Expand All @@ -14,7 +14,7 @@ $(document).ready(function() {
RatPack.turnOnButton = function(){
var button = $('.btn.off');
button.removeClass('off');
button.addClass('on');
button.addClass('on');
button.html('on');
};
});
});
2 changes: 1 addition & 1 deletion sinatra/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
APP_PORT=4180

def app
builder = Rack::Builder.parse_file(File.dirname(__FILE__) + '/../config.ru')
builder = Rack::Builder.parse_file(File.dirname(__FILE__) + '/../../config.ru')
builder.first
end

Expand Down
4 changes: 2 additions & 2 deletions sinatra/views/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
%title Rat Pack
%link(rel="stylesheet" type="text/css" href="stylesheets/style.css")
%script(src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js")
%script(src="javascripts/main.js")
%script{src: "/faye/client.js"}
%script(src="faye/client.js")
%script{src: "javascripts/main.js"}
%body
.container
.content
Expand Down

0 comments on commit 0ff1b17

Please sign in to comment.