spitball 0.5.0 → 0.5.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/lib/spitball/version.rb +1 -1
- metadata +6 -11
- data/bin/spitball +0 -61
- data/bin/spitball-cache-cleanup +0 -22
- data/bin/spitball-server +0 -100
data/lib/spitball/version.rb
CHANGED
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: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
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: 2011-04-
|
20
|
+
date: 2011-04-28 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -94,10 +94,8 @@ dependencies:
|
|
94
94
|
version_requirements: *id005
|
95
95
|
description: Use bundler to generate gem tarball packages.
|
96
96
|
email: freels@twitter.com
|
97
|
-
executables:
|
98
|
-
|
99
|
-
- spitball-cache-cleanup
|
100
|
-
- spitball-server
|
97
|
+
executables: []
|
98
|
+
|
101
99
|
extensions: []
|
102
100
|
|
103
101
|
extra_rdoc_files:
|
@@ -107,9 +105,6 @@ files:
|
|
107
105
|
- Gemfile
|
108
106
|
- README.md
|
109
107
|
- Rakefile
|
110
|
-
- bin/spitball
|
111
|
-
- bin/spitball-cache-cleanup
|
112
|
-
- bin/spitball-server
|
113
108
|
- lib/ext/bundler_fake_dsl.rb
|
114
109
|
- lib/ext/bundler_lockfile_parser.rb
|
115
110
|
- lib/spitball.rb
|
data/bin/spitball
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'spitball'
|
4
|
-
require 'optparse'
|
5
|
-
require 'net/http'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
STDOUT.sync = true
|
9
|
-
|
10
|
-
args = {}
|
11
|
-
opts = OptionParser.new do |opts|
|
12
|
-
opts.banner = "Usage: spitball [options] GEMFILE ARCHIVE"
|
13
|
-
opts.separator ""
|
14
|
-
opts.separator "options:"
|
15
|
-
|
16
|
-
opts.on('-h', '--host HOST', 'Get the tarball from a remote spitball server') do |host|
|
17
|
-
args[:host] = host
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on('-p', '--port PORT', 'Specify the remote server port. Default 8080') do |port|
|
21
|
-
args[:port] = port
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on('-v', '--version', 'Display the version and quit') do
|
25
|
-
puts Spitball::VERSION
|
26
|
-
exit!(0)
|
27
|
-
end
|
28
|
-
|
29
|
-
opts.on('--without a,b,c', Array, 'Excluded groups in the tarball. Does not apply to remote spitballs') do |without|
|
30
|
-
args[:without] = without
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on('-g', '--generate-only', "Only generate, don't download") do
|
34
|
-
args[:generate] = true
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.separator ""
|
38
|
-
opts.separator "environment variables:"
|
39
|
-
opts.separator "\tSPITBALL_CACHE\t\t Specifies the cache dir. Defaults to /tmp/spitball"
|
40
|
-
opts.separator ""
|
41
|
-
end
|
42
|
-
|
43
|
-
opts.permute!(ARGV)
|
44
|
-
|
45
|
-
args[:gemfile] = ARGV[0]
|
46
|
-
args[:destination] = ARGV[1]
|
47
|
-
|
48
|
-
unless args[:gemfile] and args[:destination]
|
49
|
-
puts opts.help
|
50
|
-
exit 1
|
51
|
-
end
|
52
|
-
|
53
|
-
gemfile = File.read(args[:gemfile])
|
54
|
-
gemfile_lock = File.read("#{args[:gemfile]}.lock")
|
55
|
-
|
56
|
-
ball = args[:host] ?
|
57
|
-
Spitball::Remote.new(gemfile, gemfile_lock, :host => args[:host], :port => (args[:port] || 8080).to_i, :without => args[:without]) :
|
58
|
-
Spitball.new(gemfile, gemfile_lock, :without => args[:without])
|
59
|
-
|
60
|
-
args[:generate] ? ball.cache! : ball.copy_to(args[:destination])
|
61
|
-
|
data/bin/spitball-cache-cleanup
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'spitball'
|
4
|
-
require 'optparse'
|
5
|
-
|
6
|
-
args = {}
|
7
|
-
|
8
|
-
opts = OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage: spitball-cache-cleanup [options]"
|
10
|
-
opts.separator ""
|
11
|
-
opts.separator "options:"
|
12
|
-
|
13
|
-
opts.on('-w', '--access-window SECONDS', 'Access window within which tarballs are kept. Default 30 days') do |access_window|
|
14
|
-
args[:access_window] = access_window
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
opts.permute!(ARGV)
|
19
|
-
|
20
|
-
args[:access_window] ||= 2592000
|
21
|
-
|
22
|
-
Spitball::Repo.clean_up_unused(args[:access_window].to_i)
|
data/bin/spitball-server
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'spitball'
|
4
|
-
require 'optparse'
|
5
|
-
require 'sinatra'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
# cargo culting sinatra's option parser, since it has trouble
|
9
|
-
# with rubygem stub files
|
10
|
-
|
11
|
-
OptionParser.new { |op|
|
12
|
-
op.on('-x') { set :lock, true }
|
13
|
-
op.on('-e env') { |val| set :environment, val.to_sym }
|
14
|
-
op.on('-s server') { |val| set :server, val }
|
15
|
-
op.on('-p port') { |val| set :port, val.to_i }
|
16
|
-
op.on('-o addr') { |val| set :bind, val }
|
17
|
-
}.parse!(ARGV.dup)
|
18
|
-
|
19
|
-
# always run
|
20
|
-
set :run, true
|
21
|
-
|
22
|
-
mime_type :gemfile, 'text/plain'
|
23
|
-
mime_type :lock, 'text/plain'
|
24
|
-
mime_type :tgz, 'application/x-compressed'
|
25
|
-
|
26
|
-
# return json array of cached SHAs
|
27
|
-
get '/list' do
|
28
|
-
content_type :json
|
29
|
-
JSON.dump Spitball::Repo.cached_digests
|
30
|
-
end
|
31
|
-
|
32
|
-
get '/env' do
|
33
|
-
content_type :text
|
34
|
-
`#{$:.inspect}\n#{Spitball.gem_cmd} env`
|
35
|
-
end
|
36
|
-
|
37
|
-
# return tgz or gemfile of cached SHA or 404
|
38
|
-
get '/:digest.:format' do |digest, format|
|
39
|
-
error 400 unless ['tgz', 'gemfile'].include? format
|
40
|
-
|
41
|
-
# this returns 404 on Errno::ENOENT
|
42
|
-
send_file Spitball::Repo.bundle_path(digest, format), :type => format
|
43
|
-
end
|
44
|
-
|
45
|
-
class Streamer
|
46
|
-
def initialize(io); @io = io end
|
47
|
-
def each; while buf = @io.read(200); yield buf end end
|
48
|
-
end
|
49
|
-
|
50
|
-
# POST a gemfile. Returns 201 Created if the bundle already exists, or
|
51
|
-
# 202 Accepted if it does not. The body of the response is the URI for
|
52
|
-
# the tarball.
|
53
|
-
post '/create' do
|
54
|
-
request_version = request.env["HTTP_#{Spitball::PROTOCOL_HEADER.gsub(/-/, '_').upcase}"]
|
55
|
-
if request_version != Spitball::PROTOCOL_VERSION
|
56
|
-
status 403
|
57
|
-
"Received version #{request_version} but need version #{Spitball::PROTOCOL_VERSION}"
|
58
|
-
else
|
59
|
-
without = request_version = request.env["HTTP_#{Spitball::WITHOUT_HEADER.gsub(/-/, '_').upcase}"]
|
60
|
-
without &&= without.split(',')
|
61
|
-
ball = Spitball.new(params['gemfile'], params['gemfile_lock'], :without => without)
|
62
|
-
url = "#{request.url.split("/create").first}/#{ball.digest}.tgz"
|
63
|
-
response['Location'] = url
|
64
|
-
|
65
|
-
if ball.cached?
|
66
|
-
status 201
|
67
|
-
"Bundle tarball pre-cached.\n"
|
68
|
-
else
|
69
|
-
status 202
|
70
|
-
|
71
|
-
i,o = IO.pipe
|
72
|
-
o.sync = true
|
73
|
-
|
74
|
-
# fork twice. once so we can have a pid to detach from in order to clean up,
|
75
|
-
# twice in order to properly redirect stdout for underlying shell commands.
|
76
|
-
pid = fork do
|
77
|
-
baller = open("|-")
|
78
|
-
if baller == nil # child
|
79
|
-
$stdout.sync = true
|
80
|
-
begin
|
81
|
-
ball.cache!
|
82
|
-
rescue Object => e
|
83
|
-
puts "#{e.class}: #{e}", e.backtrace.map{|l| "\t#{l}" }
|
84
|
-
end
|
85
|
-
else
|
86
|
-
while buf = baller.read(200)
|
87
|
-
$stdout.print buf
|
88
|
-
o.print buf
|
89
|
-
end
|
90
|
-
end
|
91
|
-
exit!
|
92
|
-
end
|
93
|
-
|
94
|
-
o.close
|
95
|
-
Process.detach(pid)
|
96
|
-
|
97
|
-
Streamer.new(i)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|