Skip to content
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.bundle
*.lock
tryruby/log/*
tmp/*
tmp/*
8 changes: 8 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'

Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks
41 changes: 41 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
source 'http://rubygems.org'

gem 'rails', '3.0.9'

gem 'mysql2', '< 0.3'
gem 'fakefs', '0.2.1', :git => "http://github.com/defunkt/fakefs.git", :ref => "aa0cb96b8ebc81287a2e", :require => 'fakefs/safe'
# Use unicorn as the web server
# gem 'unicorn'
gem 'i18n'
# Deploy with Capistrano
# gem 'capistrano'

gem 'devise'

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
gem 'jquery-rails'
gem 'ruby_parser'
gem 'racc'

#gem 'ruby2ruby'
#gem 'newrelic_rpm'
#gem 'madmimi'
#gem 'delayed_job'
#gem 'dalli'
# Bundle the extra gems:
# gem 'bj'

gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
gem 'capybara'
gem 'rspec-rails'
gem 'cucumber-rails'
#gem 'factory-girl'
299 changes: 229 additions & 70 deletions README

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions tryruby/Rakefile → Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
Tryruby::Application.load_tasks
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
#require File.dirname(__FILE__) + '/../../lib/tryruby'

class ApplicationController < ActionController::Base




layout 'tryruby'

# attr_accessor :past_commands, :current_statement, :start_time


# attr_accessor :past_commands, :current_statement, :start_time





=begin
#attr_accessor :session
TryRuby.session = session

TryRuby.session['start_time'] ||= Time.now
TryRuby.session['current_statement'] ||= ''
TryRuby.session['past_commands'] ||= ''

helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Scrub sensitive parameters from your log
# filter_parameter_logging :password
#class << self
attr_accessor :session
TryRuby.session = TryRuby::Session.new
=end
# not needed
#end
end
2 changes: 2 additions & 0 deletions app/controllers/classic_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ClassicController < ApplicationController
end
8 changes: 8 additions & 0 deletions app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class IndexController < ApplicationController
def terminal
end

def index

end
end
85 changes: 85 additions & 0 deletions app/controllers/irb_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
class IrbController < ApplicationController
# GET /irb
# GET /irb.xml
def index

@irb = []

respond_to do |format|
format.html # index.html.erb
format.to_json
format.xml { render :xml => @irb }
end
end

# GET /irb/1
# GET /irb/1.xml
def show
@irb = Irb.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @irb }
end
end

# GET /irb/new
# GET /irb/new.xml
def new
@irb = Irb.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @irb }
end
end

# GET /irb/1/edit
def edit
@irb = Irb.find(params[:id])
end

# POST /irb
# POST /irb.xml
def create
@irb = Irb.new(params[:irb])

respond_to do |format|
if @irb.save
format.html { redirect_to(@irb, :notice => 'Irb was successfully created.') }
format.xml { render :xml => @irb, :status => :created, :location => @irb }
else
format.html { render :action => "new" }
format.xml { render :xml => @irb.errors, :status => :unprocessable_entity }
end
end
end

# PUT /irb/1
# PUT /irb/1.xml
def update
@irb = Irb.find(params[:id])

respond_to do |format|
if @irb.update_attributes(params[:irb])
format.html { redirect_to(@irb, :notice => 'Irb was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @irb.errors, :status => :unprocessable_entity }
end
end
end

# DELETE /irb/1
# DELETE /irb/1.xml
def destroy
@irb = Irb.find(params[:id])
@irb.destroy

respond_to do |format|
format.html { redirect_to(irb_url) }
format.xml { head :ok }
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/public_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PublicController < ApplicationController
end
42 changes: 42 additions & 0 deletions app/controllers/tryruby_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

class TryrubyController < ApplicationController

layout 'tryruby'
def index
end

def run
eval(params[:cmd])

#@cmd=params[:cmd]
# @a= run_script(@cmd)
# @b = "handleJSON({\"type\": #{@a.type.to_json}, \"output\":#{@a.output.to_json},\"result\":#{@a.result.inspect.to_json}, \"error\": #{@a.error.inspect.to_json}})"

begin
render :json => @b
rescue
end
end


def run_script(command)
#output = begin
eval(command)
# rescue StandardError => e
# e.message + ". On the "
begin
# Tryrubyengine.session ||= TRSession.new
#TryRuby.run_line(TryRuby.session.cgi['cmd']).format
#Tryrubyengine.new
# @c= Tryrubyengine.session
# @c.inspect
# Tryrubyengine.run_line(command)
rescue

end
# end

# return "=> #{output}" + ", says yoda"
end

end
18 changes: 18 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module ApplicationHelper

def google_analytics_js
ua_code = "UA-2365371-3"
'<script type="text/javascript">
var _gaq = _gaq || []; _gaq.push(["_setAccount","'+ua_code+'"}]);
_gaq.push(["_trackPageview"]);

(function() { var ga = document.createElement("script");
ga.type = "text/javascript";
ga.async = true;
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s); })();
</script>'

end

end
2 changes: 2 additions & 0 deletions app/helpers/classic_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ClassicHelper
end
2 changes: 2 additions & 0 deletions app/helpers/index_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module IndexHelper
end
2 changes: 2 additions & 0 deletions app/helpers/irb_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module IrbHelper
end
2 changes: 2 additions & 0 deletions app/helpers/public_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PublicHelper
end
2 changes: 2 additions & 0 deletions app/helpers/tutorials_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TutorialsHelper
end
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions app/views/irb/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%= form_for(@irb) do |f| %>
<% if @irb.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@irb.errors.count, "error") %> prohibited this irb from being saved:</h2>

<ul>
<% @irb.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/irb/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing irb</h1>

<%= render 'form' %>

<%= link_to 'Show', @irb %> |
<%= link_to 'Back', irb_path %>
21 changes: 21 additions & 0 deletions app/views/irb/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1>Listing irb</h1>

<table>
<tr>
<th></th>
<th></th>
<th></th>
</tr>

<% @irb.each do |irb| %>
<tr>
<td><%= link_to 'Show', irb %></td>
<td><%= link_to 'Edit', edit_irb_path(irb) %></td>
<td><%= link_to 'Destroy', irb, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Irb', new_irb_path %>
5 changes: 5 additions & 0 deletions app/views/irb/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New irb</h1>

<%= render 'form' %>

<%= link_to 'Back', irb_path %>
5 changes: 5 additions & 0 deletions app/views/irb/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p id="notice"><%= notice %></p>


<%= link_to 'Edit', edit_irb_path(@irb) %> |
<%= link_to 'Back', irb_path %>
Loading