specistent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +22 -0
- data/README.textile +1 -0
- data/Rakefile +54 -0
- data/bin/specistent +82 -0
- data/lib/specistent.rb +2 -0
- data/lib/specistent/specistent_client.rb +25 -0
- data/lib/specistent/specistent_server.rb +53 -0
- metadata +68 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 James Pozdena
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
h1. Specistent
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
GEM = 'specistent'
|
8
|
+
GEM_NAME = 'specistent'
|
9
|
+
GEM_VERSION = '0.0.1'
|
10
|
+
AUTHORS = ['James Pozdena']
|
11
|
+
EMAIL = "jpoz@jpoz.net"
|
12
|
+
HOMEPAGE = "http://github.com/jpoz/specistent"
|
13
|
+
SUMMARY = ""
|
14
|
+
|
15
|
+
spec = Gem::Specification.new do |s|
|
16
|
+
s.name = GEM
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["MIT-LICENSE"]
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.authors = AUTHORS
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
s.require_path = 'lib'
|
27
|
+
s.autorequire = GEM
|
28
|
+
s.executables = ['specistent']
|
29
|
+
s.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob("{lib}/**/*") + Dir.glob("{bin}/**/*")
|
30
|
+
end
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
desc "Run specs"
|
35
|
+
Spec::Rake::SpecTask.new do |t|
|
36
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
37
|
+
t.spec_opts = %w(-fs --color)
|
38
|
+
end
|
39
|
+
|
40
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
41
|
+
pkg.gem_spec = spec
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "install the gem locally"
|
45
|
+
task :install => [:package] do
|
46
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "create a gemspec file"
|
50
|
+
task :make_spec do
|
51
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
52
|
+
file.puts spec.to_ruby
|
53
|
+
end
|
54
|
+
end
|
data/bin/specistent
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'specistent'
|
4
|
+
require 'optparse'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:klass => SpecistentClient,
|
9
|
+
:host => '127.0.0.1',
|
10
|
+
:port => 8081,
|
11
|
+
:env => 'test',
|
12
|
+
:remote => 'origin',
|
13
|
+
:yml => 'specistent.yml'
|
14
|
+
}
|
15
|
+
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
opts.banner = "Usage: specistent [options]"
|
18
|
+
|
19
|
+
opts.on("-h","--host HOST", "Host to run server on") do |h|
|
20
|
+
options[:host] = h
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-s","--server", "Run as Server") do |v|
|
24
|
+
options[:klass] = SpecistentServer
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-p","--port PORT", "Port") do |p|
|
28
|
+
options[:port] = p.to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-e","--env ENV", "Environment") do |e|
|
32
|
+
options[:env] = e
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("-b","--branch BRANCH", "git branch to pull from (defaults to current branch)") do |b|
|
36
|
+
options[:branch] = b
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-r","--remote REMOTE", "git remote to pull from (default origin)") do |r|
|
40
|
+
options[:remote] = r
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-y","--yml YML", "yaml file of servers (default specistent.yml)") do |y|
|
44
|
+
options[:yml] = y
|
45
|
+
end
|
46
|
+
|
47
|
+
end.parse!
|
48
|
+
|
49
|
+
if (SpecistentServer == options[:klass])
|
50
|
+
g = Git.open(Dir.pwd)
|
51
|
+
RENV = options[:env]
|
52
|
+
EventMachine::run {
|
53
|
+
puts "Started server on port #{options[:port]}"
|
54
|
+
EventMachine::start_server options[:host], options[:port], SpecistentServer
|
55
|
+
}
|
56
|
+
else
|
57
|
+
servers = YAML::load(File.read(options[:yml])).map { |s| s.split(":") << [] }
|
58
|
+
options[:branch] ||= Git.open(Dir.pwd).branch.name
|
59
|
+
EM.run {
|
60
|
+
queue = EM::Queue.new
|
61
|
+
processor = proc{ |connection_array|
|
62
|
+
EventMachine::connect( connection_array[0], connection_array[1], SpecistentClient ) { |c|
|
63
|
+
c.files = connection_array[2]
|
64
|
+
c.branch = options[:branch]
|
65
|
+
c.remote = options[:remote]
|
66
|
+
c.start_spec
|
67
|
+
}
|
68
|
+
queue.pop(&processor)
|
69
|
+
}
|
70
|
+
queue.pop(&processor)
|
71
|
+
|
72
|
+
files = Dir.glob("spec/**/*_spec.rb")
|
73
|
+
files.each_with_index do |f, i|
|
74
|
+
server_index = (i % servers.size)
|
75
|
+
servers[server_index][2] << f
|
76
|
+
end
|
77
|
+
|
78
|
+
servers.each do |s|
|
79
|
+
queue.push(s)
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
data/lib/specistent.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'logger'
|
4
|
+
require 'git'
|
5
|
+
|
6
|
+
module SpecistentClient # < EventMachine::Connection
|
7
|
+
|
8
|
+
attr_accessor :files, :branch, :remote
|
9
|
+
|
10
|
+
def start_spec
|
11
|
+
return puts "NO files" if files.empty?
|
12
|
+
send_data "run #{remote}/#{branch} #{files.join(' ')};"
|
13
|
+
end
|
14
|
+
|
15
|
+
def receive_data(data)
|
16
|
+
print data
|
17
|
+
STDOUT.flush
|
18
|
+
end
|
19
|
+
|
20
|
+
def unbind
|
21
|
+
puts "A connection has terminated"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'logger'
|
4
|
+
require 'git'
|
5
|
+
|
6
|
+
module SpecProcess
|
7
|
+
|
8
|
+
def initialize(socket)
|
9
|
+
@socket = socket
|
10
|
+
end
|
11
|
+
|
12
|
+
def receive_data(data)
|
13
|
+
puts "sent #{data}"
|
14
|
+
@socket.send_data(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class SpecistentServer < EM::Protocols::LineAndTextProtocol
|
20
|
+
include EM::Protocols::LineText2
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@databuf = []
|
24
|
+
@g = nil
|
25
|
+
@directory = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def command(cmd)
|
29
|
+
case cmd
|
30
|
+
when /run\s(\w*)\/(\w*)\s(.*)/
|
31
|
+
@g = Git.open(Dir.pwd)
|
32
|
+
puts @g.pull($1, "#{$1}/#{$2}", "#{$1} pull")
|
33
|
+
EM.popen("/bin/sh -c 'RAILS_ENV=#{RENV} spec #{$3}'", SpecProcess, self)
|
34
|
+
else
|
35
|
+
send_data("unknown command #{cmd.inspect}\r\n")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def receive_data(data)
|
40
|
+
@databuf << data
|
41
|
+
puts data
|
42
|
+
if (/(.*)\;/ =~ @databuf.to_s)
|
43
|
+
command($1)
|
44
|
+
reset_databuf()
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def reset_databuf
|
50
|
+
@databuf = []
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: specistent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- James Pozdena
|
13
|
+
autorequire: specistent
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-01 00:00:00 -07:00
|
18
|
+
default_executable: specistent
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: ""
|
22
|
+
email: jpoz@jpoz.net
|
23
|
+
executables:
|
24
|
+
- specistent
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- MIT-LICENSE
|
29
|
+
files:
|
30
|
+
- MIT-LICENSE
|
31
|
+
- README.textile
|
32
|
+
- Rakefile
|
33
|
+
- lib/specistent/specistent_client.rb
|
34
|
+
- lib/specistent/specistent_server.rb
|
35
|
+
- lib/specistent.rb
|
36
|
+
- bin/specistent
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/jpoz/specistent
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.6
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: ""
|
67
|
+
test_files: []
|
68
|
+
|