spitball 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +33 -17
- data/bin/spitball +6 -6
- data/bin/spitball-server +36 -28
- data/lib/spitball.rb +4 -1
- data/lib/spitball/remote.rb +8 -3
- data/lib/spitball/version.rb +3 -0
- data/spitball.gemspec +20 -62
- metadata +31 -14
- data/VERSION +0 -1
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
ROOT_DIR = File.expand_path(File.dirname(__FILE__))
|
2
|
+
VERSION_FILE = File.expand_path("lib/spitball/version.rb", ROOT_DIR)
|
2
3
|
|
3
4
|
require 'rubygems' rescue nil
|
4
5
|
require 'rake'
|
@@ -12,22 +13,37 @@ Spec::Rake::SpecTask.new(:spec) do |t|
|
|
12
13
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
require 'bundler'
|
17
|
+
Bundler::GemHelper.install_tasks
|
18
|
+
|
19
|
+
namespace :version do
|
20
|
+
def update_version
|
21
|
+
source = File.read(VERSION_FILE)
|
22
|
+
new_v = nil
|
23
|
+
File.open(VERSION_FILE, 'w') do |f|
|
24
|
+
f.write source.gsub(/\d+\.\d+\.\d+/) {|v|
|
25
|
+
new_v = yield(*v.split(".").map {|i| i.to_i}).join(".")
|
26
|
+
}
|
27
|
+
end
|
28
|
+
new_v
|
29
|
+
end
|
30
|
+
|
31
|
+
def commit_version(v)
|
32
|
+
system "git add #{VERSION_FILE} && git c -m 'release version #{v}' && git tag #{v}"
|
33
|
+
end
|
34
|
+
|
35
|
+
task :incr_major do
|
36
|
+
new_v = update_version {|m,_,_| [m+1, 0, 0] }
|
37
|
+
commit_version(new_v)
|
38
|
+
end
|
39
|
+
|
40
|
+
task :incr_minor do
|
41
|
+
new_v = update_version {|ma,mi,_| [ma, mi+1, 0] }
|
42
|
+
commit_version(new_v)
|
43
|
+
end
|
44
|
+
|
45
|
+
task :incr_patch do
|
46
|
+
new_v = update_version {|ma,mi,p| [ma, mi, p+1] }
|
47
|
+
commit_version(new_v)
|
30
48
|
end
|
31
|
-
rescue LoadError
|
32
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
33
49
|
end
|
data/bin/spitball
CHANGED
@@ -20,13 +20,13 @@ opts = OptionParser.new do |opts|
|
|
20
20
|
args[:port] = port
|
21
21
|
end
|
22
22
|
|
23
|
-
opts.on('
|
24
|
-
|
23
|
+
opts.on('-v', '--version', 'Display the version and quit') do
|
24
|
+
puts Spitball::VERSION
|
25
|
+
exit!(0)
|
25
26
|
end
|
26
27
|
|
27
|
-
opts.on('--
|
28
|
-
|
29
|
-
exit 0
|
28
|
+
opts.on('--without a,b,c', Array, 'Excluded groups in the tarball. Does not apply to remote spitballs') do |without|
|
29
|
+
args[:without] = without
|
30
30
|
end
|
31
31
|
|
32
32
|
opts.separator ""
|
@@ -49,7 +49,7 @@ gemfile = File.read(args[:gemfile])
|
|
49
49
|
gemfile_lock = File.read("#{args[:gemfile]}.lock")
|
50
50
|
|
51
51
|
ball = args[:host] ?
|
52
|
-
Spitball::Remote.new(gemfile, gemfile_lock, :host => args[:host], :port => (args[:port] || 8080).to_i) :
|
52
|
+
Spitball::Remote.new(gemfile, gemfile_lock, :host => args[:host], :port => (args[:port] || 8080).to_i, :without => args[:without]) :
|
53
53
|
Spitball.new(gemfile, gemfile_lock, :without => args[:without])
|
54
54
|
|
55
55
|
ball.copy_to args[:destination]
|
data/bin/spitball-server
CHANGED
@@ -46,40 +46,48 @@ end
|
|
46
46
|
# 202 Accepted if it does not. The body of the response is the URI for
|
47
47
|
# the tarball.
|
48
48
|
post '/create' do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if ball.cached?
|
54
|
-
status 201
|
55
|
-
"Bundle tarball pre-cached.\n"
|
49
|
+
request_version = request.env["HTTP_#{Spitball::PROTOCOL_HEADER.gsub(/-/, '_').upcase}"]
|
50
|
+
if request_version != Spitball::PROTOCOL_VERSION
|
51
|
+
status 403
|
52
|
+
"Received version #{request_version} but need version #{Spitball::PROTOCOL_VERSION}"
|
56
53
|
else
|
57
|
-
|
54
|
+
without = request_version = request.env["HTTP_#{Spitball::WITHOUT_HEADER.gsub(/-/, '_').upcase}"]
|
55
|
+
without &&= without.split(',')
|
56
|
+
ball = Spitball.new(params['gemfile'], params['gemfile_lock'], :without => without)
|
57
|
+
url = "#{request.url.split("/create").first}/#{ball.digest}.tgz"
|
58
|
+
response['Location'] = url
|
58
59
|
|
59
|
-
|
60
|
+
if ball.cached?
|
61
|
+
status 201
|
62
|
+
"Bundle tarball pre-cached.\n"
|
63
|
+
else
|
64
|
+
status 202
|
60
65
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
i,o = IO.pipe
|
67
|
+
|
68
|
+
# fork twice. once so we can have a pid to detach from in order to clean up,
|
69
|
+
# twice in order to properly redirect stdout for underlying shell commands.
|
70
|
+
pid = fork do
|
71
|
+
baller = open("|-")
|
72
|
+
if baller == nil # child
|
73
|
+
begin
|
74
|
+
ball.cache!
|
75
|
+
rescue Object => e
|
76
|
+
puts "#{e.class}: #{e}", e.backtrace.map{|l| "\t#{l}" }
|
77
|
+
end
|
78
|
+
else
|
79
|
+
while buf = baller.read(200)
|
80
|
+
$stdout.print buf
|
81
|
+
o.print buf
|
82
|
+
end
|
75
83
|
end
|
84
|
+
exit!
|
76
85
|
end
|
77
|
-
exit!
|
78
|
-
end
|
79
86
|
|
80
|
-
|
81
|
-
|
87
|
+
o.close
|
88
|
+
Process.detach(pid)
|
82
89
|
|
83
|
-
|
90
|
+
Streamer.new(i)
|
91
|
+
end
|
84
92
|
end
|
85
93
|
end
|
data/lib/spitball.rb
CHANGED
@@ -9,12 +9,15 @@ class Spitball
|
|
9
9
|
require 'spitball/repo'
|
10
10
|
require 'spitball/file_lock'
|
11
11
|
require 'spitball/remote'
|
12
|
+
require 'spitball/version'
|
12
13
|
|
13
14
|
class ServerFailure < StandardError; end
|
14
15
|
class ClientError < StandardError; end
|
15
16
|
class BundleCreationFailure < StandardError; end
|
16
17
|
|
17
|
-
|
18
|
+
PROTOCOL_VERSION = '1'
|
19
|
+
PROTOCOL_HEADER = "X-Spitball-Protocol"
|
20
|
+
WITHOUT_HEADER = "X-Spitball-Without"
|
18
21
|
|
19
22
|
include Spitball::Digest
|
20
23
|
include Spitball::ClientCommon
|
data/lib/spitball/remote.rb
CHANGED
@@ -10,6 +10,7 @@ class Spitball::Remote
|
|
10
10
|
@gemfile_lock = gemfile_lock
|
11
11
|
@host = opts[:host]
|
12
12
|
@port = opts[:port]
|
13
|
+
@without = (opts[:without] || []).map{|w| w.to_sym}
|
13
14
|
end
|
14
15
|
|
15
16
|
def cached?
|
@@ -22,14 +23,17 @@ class Spitball::Remote
|
|
22
23
|
url = URI.parse("http://#{@host}:#{@port}/create")
|
23
24
|
req = Net::HTTP::Post.new(url.path)
|
24
25
|
req.form_data = {'gemfile' => @gemfile, 'gemfile_lock' => @gemfile_lock}
|
25
|
-
|
26
|
+
req.add_field Spitball::PROTOCOL_HEADER, Spitball::PROTOCOL_VERSION
|
27
|
+
req.add_field Spitball::WITHOUT_HEADER, @without.join(',')
|
26
28
|
res = Net::HTTP.new(url.host, url.port).start do |http|
|
29
|
+
http.read_timeout = 3000
|
27
30
|
http.request(req) {|r| puts r.read_body }
|
28
31
|
end
|
29
32
|
|
30
33
|
case res.code
|
31
34
|
when '201', '202' # Created, Accepted
|
32
35
|
@tarball_url = res['Location']
|
36
|
+
when '403'
|
33
37
|
else
|
34
38
|
raise Spitball::ServerFailure, "Expected 2xx response code. Got #{res.code}."
|
35
39
|
end
|
@@ -49,6 +53,7 @@ class Spitball::Remote
|
|
49
53
|
end
|
50
54
|
|
51
55
|
def get_tarball_data(location)
|
56
|
+
puts "location --> #{location.inspect}"
|
52
57
|
uri = URI.parse(location)
|
53
58
|
|
54
59
|
if (res = Net::HTTP.get_response(uri)).code == '200'
|
@@ -56,7 +61,7 @@ class Spitball::Remote
|
|
56
61
|
else
|
57
62
|
raise Spitball::ServerFailure, "Spitball download failed."
|
58
63
|
end
|
59
|
-
rescue URI::InvalidURIError => e
|
60
|
-
|
64
|
+
#rescue URI::InvalidURIError => e
|
65
|
+
# raise Spitball::ClientError, e.message
|
61
66
|
end
|
62
67
|
end
|
data/spitball.gemspec
CHANGED
@@ -1,69 +1,27 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "spitball/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = "spitball"
|
7
|
+
s.version = Spitball::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Matt Freels", "Brandon Mitchell", "Joshua Hull"]
|
10
|
+
s.email = "freels@twitter.com"
|
11
|
+
s.homepage = "http://rubygems.org/gems/spitball"
|
12
|
+
s.summary = %q{Use bundler to generate gem tarball packages.}
|
13
13
|
s.description = %q{Use bundler to generate gem tarball packages.}
|
14
|
-
s.email = %q{freels@twitter.com}
|
15
|
-
s.executables = ["spitball", "spitball-cache-cleanup", "spitball-server"]
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"README.md",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"bin/spitball",
|
25
|
-
"bin/spitball-cache-cleanup",
|
26
|
-
"bin/spitball-server",
|
27
|
-
"lib/ext/bundler_fake_dsl.rb",
|
28
|
-
"lib/ext/bundler_lockfile_parser.rb",
|
29
|
-
"lib/spitball.rb",
|
30
|
-
"lib/spitball/client_common.rb",
|
31
|
-
"lib/spitball/digest.rb",
|
32
|
-
"lib/spitball/file_lock.rb",
|
33
|
-
"lib/spitball/remote.rb",
|
34
|
-
"lib/spitball/repo.rb",
|
35
|
-
"spec/spec.opts",
|
36
|
-
"spec/spec_helper.rb",
|
37
|
-
"spec/spitball_spec.rb",
|
38
|
-
"spitball.gemspec"
|
39
|
-
]
|
40
|
-
s.homepage = %q{http://github.com/freels/spitball}
|
41
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.3.7}
|
44
|
-
s.summary = %q{get a bundle}
|
45
|
-
s.test_files = [
|
46
|
-
"spec/spec_helper.rb",
|
47
|
-
"spec/spitball_spec.rb"
|
48
|
-
]
|
49
14
|
|
50
|
-
|
51
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
-
s.specification_version = 3
|
15
|
+
s.rubyforge_project = "spitball"
|
53
16
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
s.add_dependency(%q<sinatra>, [">= 1.0"])
|
60
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
61
|
-
s.add_dependency(%q<rr>, [">= 0"])
|
62
|
-
end
|
63
|
-
else
|
64
|
-
s.add_dependency(%q<sinatra>, [">= 1.0"])
|
65
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
66
|
-
s.add_dependency(%q<rr>, [">= 0"])
|
67
|
-
end
|
68
|
-
end
|
17
|
+
s.add_dependency 'sinatra', '>= 1.0'
|
18
|
+
s.add_development_dependency 'rspec', "~> 1.3.0"
|
19
|
+
s.add_development_dependency 'rr'
|
20
|
+
s.add_development_dependency 'rake'
|
69
21
|
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.extra_rdoc_files = [ "README.md" ]
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spitball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Freels
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-11-13 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -41,12 +41,14 @@ dependencies:
|
|
41
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
46
|
+
hash: 27
|
47
47
|
segments:
|
48
|
+
- 1
|
49
|
+
- 3
|
48
50
|
- 0
|
49
|
-
version:
|
51
|
+
version: 1.3.0
|
50
52
|
type: :development
|
51
53
|
version_requirements: *id002
|
52
54
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +65,20 @@ dependencies:
|
|
63
65
|
version: "0"
|
64
66
|
type: :development
|
65
67
|
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rake
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id004
|
66
82
|
description: Use bundler to generate gem tarball packages.
|
67
83
|
email: freels@twitter.com
|
68
84
|
executables:
|
@@ -77,7 +93,6 @@ files:
|
|
77
93
|
- .gitignore
|
78
94
|
- README.md
|
79
95
|
- Rakefile
|
80
|
-
- VERSION
|
81
96
|
- bin/spitball
|
82
97
|
- bin/spitball-cache-cleanup
|
83
98
|
- bin/spitball-server
|
@@ -89,17 +104,18 @@ files:
|
|
89
104
|
- lib/spitball/file_lock.rb
|
90
105
|
- lib/spitball/remote.rb
|
91
106
|
- lib/spitball/repo.rb
|
107
|
+
- lib/spitball/version.rb
|
92
108
|
- spec/spec.opts
|
93
109
|
- spec/spec_helper.rb
|
94
110
|
- spec/spitball_spec.rb
|
95
111
|
- spitball.gemspec
|
96
112
|
has_rdoc: true
|
97
|
-
homepage: http://
|
113
|
+
homepage: http://rubygems.org/gems/spitball
|
98
114
|
licenses: []
|
99
115
|
|
100
116
|
post_install_message:
|
101
|
-
rdoc_options:
|
102
|
-
|
117
|
+
rdoc_options: []
|
118
|
+
|
103
119
|
require_paths:
|
104
120
|
- lib
|
105
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -122,11 +138,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
138
|
version: "0"
|
123
139
|
requirements: []
|
124
140
|
|
125
|
-
rubyforge_project:
|
141
|
+
rubyforge_project: spitball
|
126
142
|
rubygems_version: 1.3.7
|
127
143
|
signing_key:
|
128
144
|
specification_version: 3
|
129
|
-
summary:
|
145
|
+
summary: Use bundler to generate gem tarball packages.
|
130
146
|
test_files:
|
147
|
+
- spec/spec.opts
|
131
148
|
- spec/spec_helper.rb
|
132
149
|
- spec/spitball_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.2
|