Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some files

  • Loading branch information...
commit 4e3cab0074577294bf85ad9292690daa673acc56 1 parent 3f857ac
Jamie Rumbelow authored
2  Gemfile
View
@@ -7,7 +7,7 @@ gem 'mysql'
gem 'etherpad-lite'
gem 'devise'
gem 'thinking-sphinx'
-gem 'octopi'
+gem 'grit'
group :development do
gem 'activerecord-import'
3  app/assets/javascripts/notes.js.coffee
View
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3  app/assets/stylesheets/notes.css.scss
View
@@ -0,0 +1,3 @@
+// Place all the styles related to the notes controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
18 app/controllers/notes_controller.rb
View
@@ -0,0 +1,18 @@
+class NotesController < ApplicationController
+ def show
+ git = Gittastic.new("#{Rails.root}/../notes")
+ git.add('.').and.commit({ '-m' => '"Some files"' }).and.push('origin master')
+
+ output = "<pre>Command to run: #{git.cmd}\n"
+ output << git.![0]
+
+ render :text => output
+ end
+
+ def create
+ end
+
+ def update
+ end
+
+end
2  app/helpers/notes_helper.rb
View
@@ -0,0 +1,2 @@
+module NotesHelper
+end
68 app/models/gittastic.rb
View
@@ -0,0 +1,68 @@
+# Gittastic
+#
+# A really little and lightweight Ruby wrapper
+# to the Git interface.
+#
+# by Jamie Rumbelow
+# http://jamierumbelow.net
+
+class Gittastic
+
+ # Accessible attributes
+ attr_accessor :path, :cmd
+
+ # Create a new Gittastic instance.
+ #
+ # path - The String path to the root directory
+ # of the repository
+ def initialize(path)
+ @path = File.expand_path(path)
+ @cmd = 'git'
+
+ unless File.exist?(File.join(@path, '.git'))
+ raise Exception.new("Invalid Git repository: #{@path}")
+ end
+ end
+
+ # The clever bit: method_missing provides a proxy
+ # onto the same Gittastic instance (by returning
+ # self) and thus lets us build up.
+ def method_missing(method, *arguments, &block)
+ @cmd << " #{method.to_s}"
+ cmdify(arguments) if arguments
+
+ self
+ end
+
+ # Execute the command and return the result
+ def !
+ `#{@cmd}`
+ end
+
+ # A short helper method to link methods together
+ def and
+ @cmd << " && git"
+ self
+ end
+
+ # Clear the command
+ def clear!
+ @cmd = 'git'
+ end
+
+ protected
+
+ # Convert a hash of arguments into command-line flags
+ def cmdify(args)
+ args = args[0]
+
+ if args.class == Hash
+ args.each do |name, arg|
+ @cmd << " #{name} #{arg}"
+ end
+ elsif args.class == String
+ @cmd << " #{args}"
+ end
+ end
+
+end
2  app/views/notes/create.html.erb
View
@@ -0,0 +1,2 @@
+<h1>Notes#create</h1>
+<p>Find me in app/views/notes/create.html.erb</p>
2  app/views/notes/show.html.erb
View
@@ -0,0 +1,2 @@
+<h1>Notes#show</h1>
+<p>Find me in app/views/notes/show.html.erb</p>
2  app/views/notes/update.html.erb
View
@@ -0,0 +1,2 @@
+<h1>Notes#update</h1>
+<p>Find me in app/views/notes/update.html.erb</p>
2  config/git.yml
View
@@ -0,0 +1,2 @@
+git:
+ notes: "#{Rails.root}/../notes"
1  config/routes.rb
View
@@ -1,4 +1,5 @@
Revisionhub::Application.routes.draw do
+ resources :notes, :only => [ :show, :create, :update ]
resources :searches, :only => [ :create ] # POST /searches
devise_for :users
19 test/functional/notes_controller_test.rb
View
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class NotesControllerTest < ActionController::TestCase
+ test "should get show" do
+ get :show
+ assert_response :success
+ end
+
+ test "should get create" do
+ get :create
+ assert_response :success
+ end
+
+ test "should get update" do
+ get :update
+ assert_response :success
+ end
+
+end
4 test/unit/helpers/notes_helper_test.rb
View
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class NotesHelperTest < ActionView::TestCase
+end
Please sign in to comment.
Something went wrong with that request. Please try again.