Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move loops out of bin, drop depedency on grit

  • Loading branch information...
commit 7982a1021f57b1c9be133901eee008eca67c1ae3 1 parent 5dca648
@technomancy authored
View
11 README.rdoc
@@ -11,8 +11,19 @@ supported.
== Installation
+* sudo gem install net-mdns
* sudo gem install technomancy-conspire --source=http://gems.github.com
Once a proper release has happened:
* sudo gem install conspire
+
+== Editor Support
+
+Editors must support:
+
+* Saving on an interval
+* Committing files to the repo
+* Refreshing internal copies
+
+Edits should not be allowed in between these steps.
View
1  Rakefile
@@ -9,7 +9,6 @@ Hoe.new('conspire', Conspire::VERSION) do |p|
# Get these from github:
p.extra_deps << 'nogoth-gitjour'
- p.extra_deps << 'mojombo-grit'
end
# vim: syntax=Ruby
View
19 bin/conspire
@@ -3,17 +3,12 @@
require File.dirname(__FILE__) + '/../lib/conspire'
# TODO: real option parsing
+# Should be able to set:
+# * port
+# * path
+# * sync interval
+# *
Conspire.start :port => ARGV.first || Conspire::DEFAULT_OPTIONS[:port]
-Thread.new do
- loop do
- Conspire.discover
- p Conspire.conspirators if ENV['DEBUG']
- sleep 10
- end
-end
-
-loop do
- Conspire.sync_all
- sleep 1
-end
+Thread.new { Conspire.discover_loop }
+Conspire.sync_loop
View
20 lib/conspire.rb
@@ -4,7 +4,6 @@
require 'rubygems'
require 'gitjour'
-require 'mojombo-grit'
require 'conspire/gitjour_exts'
require 'conspire/conspirator'
@@ -13,7 +12,8 @@ module Conspire
VERSION = '0.0.1'
DEFAULT_OPTIONS = { :port => 7456, :path => Dir.pwd }
SERVICE_NAME = 'conspire'
- DISCOVER_TIME = 2
+ DISCOVER_INTERVAL = 10
+ SYNC_INTERVAL = 1
@conspirators = Set.new
@@ -25,7 +25,6 @@ def start(options = {})
FileUtils.mkdir_p(@options[:path]) unless File.exist? @options[:path]
`cd #{@options[:path]}; git init` if ! File.exist? @options[:path] + '/.git'
- @repo = Grit::Repo.new(@options[:path])
@thread = Thread.new do
Gitjour::Application.serve(@options[:path], SERVICE_NAME, @options[:port])
@@ -34,7 +33,7 @@ def start(options = {})
end
# This should be called periodically
- def discover(wait = DISCOVER_TIME)
+ def discover(wait = DISCOVER_INTERVAL)
Gitjour::Application.discover('_git._tcp', wait) do |service|
next if service.name !~ Regexp.new(SERVICE_NAME)
next if service.port.to_i == @options[:port].to_i # TODO: and local
@@ -45,7 +44,18 @@ def discover(wait = DISCOVER_TIME)
def sync_all
# TODO: drop conspirators if they shut down their repo
- @conspirators.map{ |s| s.sync(File.dirname(@repo.path)) }
+ @conspirators.map{ |s| s.sync(File.dirname(@options[:path])) }
+ end
+
+ def sync_loop
+ loop { sync_all and sleep SYNC_INTERVAL }
+ end
+
+ def discover_loop
+ loop do
+ Conspire.discover
+ p Conspire.conspirators if ENV['DEBUG']
+ end
end
def conspirators; @conspirators end
View
6 lib/conspire/support/conspire.el
@@ -31,6 +31,12 @@
;; Let's use git for real-time collaborative editing!
+;;; TODO:
+
+;; In its current state, it's very dangerous to start a conspire
+;; session and then switch buffers, since the timer is not yet buffer
+;; local. Watch out!
+
;;; Code:
(defvar conspire-interval 0.33
Please sign in to comment.
Something went wrong with that request. Please try again.