spitball 0.2.2 → 0.2.3
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/VERSION +1 -1
- data/bin/spitball-server +18 -6
- data/lib/spitball/remote.rb +31 -16
- data/lib/spitball.rb +1 -1
- data/spitball.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/bin/spitball-server
CHANGED
@@ -36,20 +36,32 @@ get '/:digest.:format' do |digest, format|
|
|
36
36
|
send_file Spitball::Repo.path(digest, format), :type => format
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
class Streamer
|
40
|
+
def initialize(io); @io = io end
|
41
|
+
def each; while buf = @io.read(200); yield buf end end
|
42
|
+
end
|
43
|
+
|
44
|
+
# POST a gemfile. Returns 201 Created if the bundle already exists, or
|
45
|
+
# 202 Accepted if it does not. The body of the response is the URI for
|
46
|
+
# the tarball.
|
40
47
|
post '/create' do
|
41
|
-
p request.body.read
|
42
|
-
request.body.rewind
|
43
48
|
ball = Spitball.new(request.body.read)
|
44
49
|
url = "#{request.url.split("/create").first}/#{ball.digest}.tgz"
|
45
50
|
response['Location'] = url
|
46
51
|
|
47
52
|
if ball.cached?
|
48
53
|
status 201
|
54
|
+
"Bundle tarball pre-cached.\n"
|
49
55
|
else
|
50
56
|
status 202
|
51
|
-
fork { ball.cache! }
|
52
|
-
end
|
53
57
|
|
54
|
-
|
58
|
+
pid = open("|-")
|
59
|
+
|
60
|
+
if pid == nil # child
|
61
|
+
ball.cache!
|
62
|
+
exit!
|
63
|
+
end
|
64
|
+
|
65
|
+
Streamer.new(pid)
|
66
|
+
end
|
55
67
|
end
|
data/lib/spitball/remote.rb
CHANGED
@@ -12,33 +12,48 @@ class Spitball::Remote
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def copy_to(path)
|
15
|
-
data =
|
15
|
+
data = generate_remote_tarball
|
16
16
|
File.open(path, 'w') { |f| f.write data }
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
private
|
20
|
+
|
21
|
+
def generate_remote_tarball
|
20
22
|
url = URI.parse("http://#{@host}:#{@port}/create")
|
21
23
|
res = Net::HTTP.start(url.host, url.port) do |http|
|
22
|
-
http.post(url.path, @gemfile)
|
24
|
+
http.post(url.path, @gemfile) do |body|
|
25
|
+
print body
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return try.body
|
29
|
+
print "\nDownloading tarball..."; $stdout.flush
|
30
|
+
|
31
|
+
data =
|
32
|
+
case res.code
|
33
|
+
when '201', '202' # Created, Accepted
|
34
|
+
get_tarball_data res['Location']
|
35
|
+
else
|
36
|
+
raise Spitball::ServerFailure, "Expected 2xx response code. Got #{res.code}."
|
34
37
|
end
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
39
|
+
puts "done."
|
40
|
+
|
41
|
+
data
|
40
42
|
rescue URI::InvalidURIError => e
|
41
43
|
raise Spitball::ClientError, e.message
|
42
44
|
end
|
43
45
|
|
46
|
+
def get_tarball_data(location)
|
47
|
+
uri = URI.parse(location)
|
48
|
+
|
49
|
+
(WAIT_SECONDS / 2).times do
|
50
|
+
if (res = Net::HTTP.get_response(uri)).code == '200'
|
51
|
+
return res.body
|
52
|
+
else
|
53
|
+
sleep 2
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
raise Spitball::ServerFailure, "Spitball download timed out."
|
58
|
+
end
|
44
59
|
end
|
data/lib/spitball.rb
CHANGED
data/spitball.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{spitball}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Freels", "Brandon Mitchell"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-02}
|
13
13
|
s.description = %q{Use bundler to generate gem tarball packages.}
|
14
14
|
s.email = %q{freels@twitter.com}
|
15
15
|
s.executables = ["spitball", "spitball-cache-cleanup", "spitball-server"]
|
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: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Freels
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-09-02 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|