Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .c9/runners/Hyperloop.run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bash",
"--login",
"-c",
"rvm 2.3.1 do bundle exec invoker start Procfile"
"rvm 2.3.4 do bundle exec invoker start Procfile"
],
"working_dir": "$project_path",
"info": "Hyperloop Application running at \\033[01;34m$url\\033[00m.\n\\033[01;31m",
Expand Down
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rails-clone-and-go
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.3.4
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bundle exec rails s -p 8080 -b 0.0.0.0
hot-loader: bundle exec opal-hot-reloader -d app/hyperloop -p 8081
web: bundle exec rails s -p 3000 -b 0.0.0.0
hot-loader: bundle exec opal-hot-reloader -d app/hyperloop

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ before proceeding.

Some steps in the setup can take 2-3 minutes... be patient...

**Once setup completes you will need to run `rvm use 2.3.1` to switch the Ruby 2.3.1.**
**Once setup completes you will need to run `rvm use 2.3.4` to switch the Ruby 2.3.4.**

Once you are installed you can fire up the server and the opal-hot-reloader by running `./bin/hyperloop` in a console window (in Cloud9 you can also use the run command at the top navbar.)

Expand Down Expand Up @@ -76,7 +76,7 @@ Hyperloop Operations keep Stores and Components separated, provides a central pl

Setup does the following. If you are not using rvm or mysql you will have to manually walk through these steps:

1. Make sure a recent version (we use 2.3.1, but 2.4.0 also works fine) of ruby is installed
1. Make sure a recent version (we use 2.3.4, but 2.4.0 also works fine) of ruby is installed
2. Make sure bundler is installed
3. Update the `config/database.yml` file
4. Change the applcation name in `config/application.rb`
Expand Down
5 changes: 3 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// about supported directives.
//
//= require rails-ujs
//= require 'jquery'
//= require jquery
//= require_tree .
//= require hyperloop-loader
Opal.OpalHotReloader.$listen() // optional (port, false, poll_seconds) i.e. (8081, false, 1)

Opal.OpalHotReloader.$listen() // optional (port) i.e. (8081), default is 25222
10 changes: 5 additions & 5 deletions app/hyperloop/components/app.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# app/hyperloop/components/app.rb
class App < Hyperloop::Router
class App < Hyperloop::Router
# usually the top level component is Router which is a kind of Hyperloop component

history :browser

after_mount do
every(1) { force_update! }
end

route do

DIV(class: :hyperloophelloworld) do
IMG(src: "assets/hyperloop-logo-medium-white.png")
IMG(src: 'assets/hyperloop-logo-medium-white.png')

DIV { "Hyperloop at your service! - The time is #{Time.now}" }

Expand Down
2 changes: 1 addition & 1 deletion bin/hyperloop
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ include FileUtils
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

chdir APP_ROOT do
system 'rvm 2.3.1 do bundle exec invoker start Procfile'
system 'rvm 2.3.4 do bundle exec invoker start Procfile'
end
32 changes: 16 additions & 16 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_NAME = ENV['C9_PROJECT'] || File.basename(APP_ROOT)
APP_CLASS = APP_NAME.gsub('-', '_').split('_').collect!{ |w| w.capitalize }.join
APP_NAME = ENV['C9_PROJECT'] || File.basename(APP_ROOT) # rails-clone-and-go
APP_CLASS = APP_NAME.gsub('-', '_').split('_').collect!{ |w| w.capitalize }.join # RailsCloneAndGo

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -15,15 +15,15 @@ end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing Ruby 2.3.1 =='
system `rvm install ruby-2.3.1`
system `rvm 2.3.1`

puts '== Installing dependencies =='
system! 'rvm 2.3.1 do gem install bundler --conservative'
system('rvm 2.3.1 do bundle check') || system!('rvm 2.3.1 do bundle install')

# puts '== Installing Ruby 2.3.4 =='
# system `rvm install ruby-2.3.4`
# system `rvm 2.3.4`

# puts '== Installing dependencies =='
# system! 'rvm 2.3.4 do gem install bundler --conservative'
# system('rvm 2.3.4 do bundle check') || system!('rvm 2.3.4 do bundle install')

puts '== Updating database yml file =='
db_yml_path = File.join(APP_ROOT, 'config', 'database.yml')
IO.write(db_yml_path, File.open(db_yml_path) {|f| f.read.gsub(/hyperloop_/, "#{APP_NAME}_")})
Expand All @@ -32,7 +32,7 @@ chdir APP_ROOT do
puts "== Updating app name to #{APP_CLASS} =="
application_path = File.join(APP_ROOT, 'config', 'application.rb')
IO.write(application_path, File.open(application_path) {|f| f.read.gsub(/HyperloopCloneAndGo/, "#{APP_CLASS}")})

if ENV['C9_PROJECT']
puts "== Updating Hot Reloader Settings =="
application_path = File.join(APP_ROOT, 'app', 'assets', 'javascripts', 'application.js')
Expand All @@ -42,23 +42,23 @@ chdir APP_ROOT do
application_path = File.join(APP_ROOT, 'Procfile')
IO.write(application_path, File.open(application_path) {|f| f.read.gsub(/ -p 808\d/, '')})
end

puts '== Initializing the DB =='
if ENV['C9_PROJECT'] && `mysql-ctl status 2>&1` =~ /stopped/
puts "********* starting mysql **********"
`mysql-ctl start`
end
system('rvm 2.3.1 do bundle exec rails db:create')
if system('rvm 2.3.1 do bundle exec rake environment')
system('rvm 2.3.4 do bundle exec rails db:create')
if system('rvm 2.3.4 do bundle exec rake environment')
puts "\n\n\e[33m"
puts "*********************************************************************************\n\n"
puts "To finish installation switch to ruby 2.3.1 by doing an 'rvm use 2.3.1'\n"
puts "To finish installation switch to ruby 2.3.4 by doing an 'rvm use 2.3.4'\n"
puts "*********************************************************************************\n\n"
else
puts "\n\n\e[33m"
puts "*********************************************************************************\n\n"
puts "Failed to create your DB. Make sure MySql is installed and running.\n"
puts "To finish installation switch to ruby 2.3.1 by doing an 'rvm use 2.3.1'\n"
puts "To finish installation switch to ruby 2.3.4 by doing an 'rvm use 2.3.4'\n"
puts "Then do a 'bundle exec rails db:create'"
puts "*********************************************************************************\n\n"
end
Expand Down
54 changes: 54 additions & 0 deletions config/database.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# MySQL. Versions 5.1.10 and up are supported.
#
# Install the MySQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.7/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /var/run/mysql/mysql.sock

development:
<<: *default
database: hyperloop_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: hyperloop_test

# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: hyperloop_production
username: hyperloop-developer
password: <%= ENV['HYPERLOOP_PRODUCTION_DB_PASSWORD'] %>