Permalink
Browse files

changes the executable to accepts commands

moves template to lib where it belongs to =)
  • Loading branch information...
1 parent dd91573 commit cff6c39115a740b3450a08437a03f759fbe30dfd @ricardovaleriano ricardovaleriano committed Apr 20, 2012
Showing with 61 additions and 21 deletions.
  1. +2 −2 README.md
  2. +32 −0 bin/gnarus
  3. +0 −13 bin/gnarus_activity
  4. +3 −4 gnarus_exercise.gemspec
  5. +23 −1 template.rb → lib/activity_template.rb
  6. +1 −1 lib/gnarus_exercise/version.rb
View
@@ -7,11 +7,11 @@ Configuring a new project
=========================
```
-gnarus_activity my_exercise
+gnarus activity my_exercise
```
You will be prompted about adding <code>devise</code> into your application, then it is up
-to you accept or not (if you want to auth your exercises). The template will handle all configuration required for you.
+to you accept it (if you want authentication in your exercises) or not.
TODO
View
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+# encoding:utf-8
+template = File.expand_path("../../lib/activity_template.rb", __FILE__)
+
+puts ":::::::::::::::::::::::"
+puts "gnarus activity utility"
+puts ":::::::::::::::::::::::\n\n"
+
+if !ARGV[0]
+ puts "ooops, what do you want me to do?"
+ puts "did you want to create an activity?"
+ puts " if so: gnarus activity [project]\n\n"
+ exit(0)
+end
+
+command = ARGV[0]
+option = ARGV[1]
+
+if command == "activity"
+ if !option
+ puts "you need a project name: gnarus activity [project]\n\n"
+ exit(0)
+ end
+ execution = "rails new #{option} -m #{template}"
+ puts "executando: #{execution}"
+ system(execution)
+ exit(0)
+end
+
+puts "i don't know any [#{command}]"
+puts "Y U NO TELL ME WHAT TO DO?!?!?\n\n"
+exit(0)
View
@@ -1,13 +0,0 @@
-#!/usr/bin/env ruby
-lib = File.expand_path("../../lib", __FILE__)
-$:.unshift lib unless $:.include?(lib)
-
-template = File.expand_path("../../template.rb", __FILE__)
-
-if !ARGV[0]
- puts "qual o nome do projeto?"
-else
- command = "rails new #{ARGV[0]} -m #{template}"
- puts "executando: #{command}"
- system(command)
-end
@@ -13,13 +13,12 @@ Gem::Specification.new do |s|
s.summary = "A plugin structure for external exercises."
s.description = "Create external exercises by mounting this plugin."
- s.files = Dir["{app,config,db,lib,bin}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md", "template.rb"]
+ s.files = Dir["{app,config,db,lib,bin}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]
- s.add_dependency "rails", "~> 3.2.2"
- # s.add_dependency "jquery-rails"
+ s.add_dependency "rails", "~> 3.2.3"
s.add_development_dependency "sqlite3"
- s.executables = ["gnarus_activity"]
+ s.executables << "gnarus"
end
@@ -1,6 +1,7 @@
# clean up rails defaults
remove_file 'public/index.html'
remove_file 'public/images/rails.png'
+remove_file 'README.rdoc'
run 'cp config/database.yml config/database.example'
append_file ".gitignore", "config/database.yml"
@@ -17,7 +18,28 @@
rake "gnarus_exercise:install:migrations", :env => "development"
create_file("app/views/gnarus_exercise/attempts/index.html.erb") do
- "<strong>Your exercise here</strong>"
+ %Q(
+<span><%= @attempt.exercise.title %></span><br />
+<form id="exercise" method="POST" action="<%= exercise_attempt_executions_url(@attempt.exercise, @attempt)%>">
+ <input name="solution" id="solution" value="" />
+ <input type="button" id="try" value="Verificar">
+ <input type="button" id="skip" value="Ignorar e continuar">
+</form>
+<script>
+function showToUser(r) {
+ successMessage = "sucesso"
+ errorMessage = "no no"
+ $('#result').html(r.suceeded ? successMessage : errorMessage);
+}
+function extractSolution() {
+ return {solution : $('#solution').val()};
+}
+$(function() {
+ var form = gnarus.attemptForm(extractSolution, showToUser, '<%=@attempt.return_uri%>');
+ form.setup();
+ $('#skip').click(form.skip);
+});
+</script>)
end
if @devised
@@ -1,3 +1,3 @@
module GnarusExercise
- VERSION = "1.0.5"
+ VERSION = "1.0.6"
end

0 comments on commit cff6c39

Please sign in to comment.