This repository has been archived by the owner on Jan 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9b7ec9e
Showing
8 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
=== 0.0.1 / 2008-07-22 | ||
|
||
* 1 major enhancement | ||
|
||
* Birthday! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
COPYING | ||
History.txt | ||
Manifest.txt | ||
README.txt | ||
Rakefile | ||
bin/conspire | ||
lib/conspire.rb | ||
lib/conspire/conspirator.rb | ||
lib/conspire/gitjour_exts.rb | ||
lib/conspire/support/conspire.el | ||
test/test_conspire.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- ruby -*- | ||
|
||
require 'rubygems' | ||
require 'hoe' | ||
require './lib/conspire.rb' | ||
|
||
Hoe.new('conspire', Conspire::VERSION) do |p| | ||
p.developer('Phil Hagelberg', 'technomancy@gmail.com') | ||
|
||
# Get these from github: | ||
p.extra_deps << 'nogoth-gitjour' | ||
p.extra_deps << 'mojombo-grit' | ||
end | ||
|
||
# vim: syntax=Ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require File.dirname(__FILE__) + '/../lib/conspire' | ||
|
||
# For now... | ||
Conspire.send *ARGV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
$LOAD_PATH << File.dirname(__FILE__) | ||
require 'set' | ||
require 'rubygems' | ||
require 'gitjour' | ||
require 'mojombo-grit' | ||
|
||
require 'conspire/gitjour_exts' | ||
require 'conspire/conspirator' | ||
|
||
module Conspire | ||
VERSION = '0.0.1' | ||
DEFAULT_OPTIONS = { :port => 7456, :path => Dir.pwd } | ||
SERVICE_NAME = 'conspire' | ||
|
||
@conspirators = Set.new | ||
|
||
module_function | ||
|
||
def start(options = {}) | ||
options = DEFAULT_OPTIONS.merge(options) | ||
@repo = Grit::Repo.new(options[:path]) | ||
@thread = Thread.new do | ||
Gitjour::Application.serve(options[:path], SERVICE_NAME, options[:port]) | ||
end | ||
at_exit { @thread.join } | ||
end | ||
|
||
def discover | ||
Gitjour::Application.service_list('_git._tcp').each do |service| | ||
next unless service.name == SERVICE_NAME | ||
# No-op if we've got it already, since @conspirators is a Set | ||
@conspirators << Conspirator.new(service.host, service.port) | ||
end | ||
end | ||
|
||
def sync_all | ||
@conspirators.map{ |s| s.sync(@repo.path) } | ||
end | ||
|
||
def conspirators; @conspirators end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Conspire | ||
class Conspirator | ||
attr_accessor :last_synced | ||
|
||
def initialize(host, port) | ||
@host, @port = remote.split(':') | ||
@port ||= DEFAULT_OPTIONS[:port] | ||
end | ||
|
||
def to_s | ||
"#{@host}:#{@port}" | ||
end | ||
|
||
def sync(path) | ||
`cd #{path} && git pull #{url}` | ||
@last_synced = Time.now | ||
end | ||
|
||
def url; "git://#{@host}:#{@port}/conspire" end | ||
|
||
def eql?(other) | ||
self.to_s == other.to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Gitjour | ||
class Application | ||
class << self | ||
public :serve, :service_list | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'rubygems' | ||
begin | ||
gem 'miniunit' | ||
rescue LoadError; end | ||
|
||
require 'test/unit' | ||
require 'fileutils' | ||
require File.dirname(__FILE__) + '/../lib/conspire' | ||
|
||
REMOTE_SPACE = File.dirname(__FILE__) + '/remote-space' | ||
LOCAL_SPACE = File.dirname(__FILE__) + '/local-space' | ||
|
||
module Conspire | ||
def self.reset! | ||
@conspirators = [] | ||
@thread && @thread.kill | ||
end | ||
end | ||
|
||
class TestConspire < Test::Unit::TestCase | ||
def setup | ||
FileUtils.mkdir_p(REMOTE_SPACE) | ||
File.open(REMOTE_SPACE + '/file', 'w') { |f| f.puts "hello world." } | ||
`cd #{REMOTE_SPACE}; git init; git add file; git commit -m "init"` | ||
|
||
FileUtils.mkdir_p(LOCAL_SPACE) | ||
`cd #{LOCAL_SPACE}; git init` | ||
|
||
@remote_thread = Thread.new do | ||
Gitjour::Application.serve(REMOTE_SPACE, Conspire::SERVICE_NAME, 7458) | ||
end | ||
|
||
Conspire.start(:port => 7457, | ||
:path => "#{File.dirname(__FILE__)}/local-space") | ||
Conspire.discover | ||
end | ||
|
||
def teardown | ||
FileUtils.rm_rf(REMOTE_SPACE) | ||
FileUtils.rm_rf(LOCAL_SPACE) | ||
@remote_thread.kill | ||
Conspire.reset! | ||
end | ||
|
||
def test_start | ||
assert_equal ['localhost:7458'], Conspire.conspirators.map{ |s| s.to_s } | ||
end | ||
|
||
def test_subscribe | ||
assert_equal ['file'], Conspire.files.map{ |f| f.name } | ||
end | ||
|
||
def test_commit | ||
end | ||
|
||
def test_rebase | ||
end | ||
end |