spitball 0.7.4 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2345cee5f5ecd06c78fe5be3a6e3a36cabeb9137
4
+ data.tar.gz: 2541b8df75e52d080e74148dc9427f8f3d52feac
5
+ SHA512:
6
+ metadata.gz: 17f5b06496261b19dc266f3361a47b9352b4ec41d6876e0cdeb8247472c29fc986ebe5a3aad470085d6cae88d1a4dc1f7164840e5832d2166373ac6fd97d576f
7
+ data.tar.gz: c90f8aca684bf93f39b9c094c92dd1c94d3afbecabac99cb1ae64aaa5cfd66caf8bada7aacadd4981b6d5ccfd684665daa7c3896ae9dfd6e8ee7eb794051f9a8
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ree
4
3
  - 1.8.7
5
4
  - 1.9.3
6
5
  - 2.0.0
6
+ - 2.1.6
7
7
  before_install:
8
8
  - gem update --system 2.1.11
9
9
  - gem --version
@@ -30,6 +30,10 @@ opts = OptionParser.new do |opts|
30
30
  args[:without] = without
31
31
  end
32
32
 
33
+ opts.on('--bundle-config CONFIG_FILE', 'Pass a bundle-config styled configuration file with build instructions') do |bundle_config|
34
+ args[:bundle_config] = bundle_config
35
+ end
36
+
33
37
  opts.on('-g', '--generate-only', "Only generate, don't download") do
34
38
  args[:generate] = true
35
39
  end
@@ -52,9 +56,11 @@ end
52
56
 
53
57
  gemfile = File.read(args[:gemfile])
54
58
  gemfile_lock = File.read("#{args[:gemfile]}.lock")
59
+ bundle_config = File.read(args[:bundle_config]) if args[:bundle_config]
55
60
 
56
61
  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])
62
+ Spitball::Remote.new(gemfile, gemfile_lock, :host => args[:host], :port => (args[:port] || 8080).to_i,
63
+ :without => args[:without], :bundle_config => bundle_config) :
64
+ Spitball.new(gemfile, gemfile_lock, :without => args[:without], :bundle_config => bundle_config)
59
65
 
60
66
  args[:generate] ? ball.cache! : ball.copy_to(args[:destination])
@@ -5,6 +5,9 @@ require 'optparse'
5
5
  require 'sinatra'
6
6
  require 'json'
7
7
 
8
+
9
+ configure { set :server, :puma }
10
+
8
11
  # cargo culting sinatra's option parser, since it has trouble
9
12
  # with rubygem stub files
10
13
 
@@ -58,7 +61,7 @@ post '/create' do
58
61
  else
59
62
  without = request_version = request.env["HTTP_#{Spitball::WITHOUT_HEADER.gsub(/-/, '_').upcase}"]
60
63
  without &&= without.split(',')
61
- ball = Spitball.new(params['gemfile'], params['gemfile_lock'], :without => without)
64
+ ball = Spitball.new(params['gemfile'], params['gemfile_lock'], :without => without, :bundle_config => params['bundle_config'])
62
65
  url = "#{request.url.split("/create").first}/#{ball.digest}.tgz"
63
66
  response['Location'] = url
64
67
 
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'tempfile'
2
3
  require 'digest/md5'
3
4
  require 'ext/bundler_lockfile_parser'
4
5
  require 'ext/bundler_fake_dsl'
@@ -25,6 +26,7 @@ class Spitball
25
26
  PROTOCOL_VERSION = '1'
26
27
  PROTOCOL_HEADER = "X-Spitball-Protocol"
27
28
  WITHOUT_HEADER = "X-Spitball-Without"
29
+ BUNDLE_CONFIG_ENV = 'BUNDLE_CONFIG'
28
30
 
29
31
  include Spitball::Digest
30
32
  include Spitball::ClientCommon
@@ -38,10 +40,23 @@ class Spitball
38
40
  @options = options
39
41
  @without = options[:without].is_a?(Enumerable) ? options[:without].map(&:to_sym) : (options[:without] ? [options[:without].to_sym] : [])
40
42
  @parsed_lockfile, @dsl = Bundler::FakeLockfileParser.new(gemfile_lock), Bundler::FakeDsl.new(gemfile)
43
+
44
+ use_bundle_config(options[:bundle_config]) if options[:bundle_config]
45
+
41
46
  raise "You need to run bundle install before you can use spitball" unless (@parsed_lockfile.dependencies.map{|d| d.name}.uniq.sort == @dsl.__gem_names.uniq.sort)
42
47
  @groups_to_install = @dsl.__groups.keys - @without
43
48
  end
44
49
 
50
+ def use_bundle_config(bundle_config)
51
+ tempfile = Tempfile.new('bundle_config')
52
+ File.open(tempfile.path, 'w') { |f| f.write options[:bundle_config] }
53
+ original_config_path = ENV[BUNDLE_CONFIG_ENV]
54
+ ENV[BUNDLE_CONFIG_ENV] = tempfile.path
55
+ @bundle_config = Bundler::Settings.new
56
+ tempfile.close
57
+ ENV[BUNDLE_CONFIG_ENV] = original_config_path
58
+ end
59
+
45
60
  def cached?
46
61
  File.exist? tarball_path
47
62
  end
@@ -49,14 +64,17 @@ class Spitball
49
64
  def cache!(sync = true)
50
65
  return if cached?
51
66
  lock = Spitball::FileLock.new(bundle_path('lock'))
52
- if lock.acquire_lock
67
+
68
+ # We check cached again to avoid falling into a race condition
69
+ if lock.acquire_lock && !cached?
53
70
  begin
54
- create_bundle
71
+ create_bundle
55
72
  ensure
56
73
  lock.release_lock
57
74
  end
58
75
  elsif sync
59
- sleep 0.1 until cached?
76
+ sleep 0.5
77
+ cache!
60
78
  end
61
79
  end
62
80
 
@@ -119,12 +137,13 @@ class Spitball
119
137
  end
120
138
 
121
139
  def install_and_copy_spec(name, version)
122
- cache_dir = File.join(Repo.gemcache_path, "#{name}-#{::Digest::MD5.hexdigest([name, version, sources_opt(@parsed_lockfile.sources)].join('/'))}")
140
+ build_args = @bundle_config["build.#{name}"] if @bundle_config
141
+ cache_dir = File.join(Repo.gemcache_path, "#{name}-#{::Digest::MD5.hexdigest([name, version, sources_opt(@parsed_lockfile.sources), build_args].join('/'))}")
123
142
  unless File.exist?(cache_dir)
124
143
  FileUtils.mkdir_p(cache_dir)
125
144
  out = ""
126
145
  Dir.chdir($pwd) do
127
- out = `#{Spitball.gem_cmd} install #{name} -v'#{version}' --no-rdoc --no-ri --ignore-dependencies -i#{cache_dir} #{sources_opt(@parsed_lockfile.sources)} 2>&1`
146
+ out = `#{Spitball.gem_cmd} install #{name} -v'#{version}' --no-rdoc --no-ri --ignore-dependencies -i#{cache_dir} #{sources_opt(@parsed_lockfile.sources)} #{generate_build_args(build_args)} 2>&1`
128
147
  end
129
148
  if $? == 0
130
149
  puts out
@@ -138,6 +157,10 @@ class Spitball
138
157
  `cp -R #{cache_dir}/* #{bundle_path}`
139
158
  end
140
159
 
160
+ def generate_build_args(build_args)
161
+ build_args ? "-- #{build_args}" : ''
162
+ end
163
+
141
164
  def sources_opt(sources)
142
165
  Array(ENV['SOURCE_OVERRIDE'] ||
143
166
  sources.
@@ -12,6 +12,7 @@ class Spitball::Remote
12
12
  @port = opts[:port]
13
13
  @without = (opts[:without] || []).map{|w| w.to_sym}
14
14
  @cache_dir = ENV['SPITBALL_CACHE'] || "/tmp/spitball-#{ENV['USER']}/client"
15
+ @bundle_config = opts[:bundle_config]
15
16
  FileUtils.mkdir_p(@cache_dir)
16
17
  use_cache_file
17
18
  end
@@ -23,7 +24,7 @@ class Spitball::Remote
23
24
  end
24
25
 
25
26
  def cache_file
26
- hash = ::Digest::MD5.hexdigest(([@host, @port, @gemfile, @gemfile_lock, Spitball::PROTOCOL_VERSION] + @without).join('/'))
27
+ hash = ::Digest::MD5.hexdigest(([@host, @port, @gemfile, @gemfile_lock, Spitball::PROTOCOL_VERSION, @bundle_config] + @without).join('/'))
27
28
  File.join(@cache_dir, hash)
28
29
  end
29
30
 
@@ -36,7 +37,9 @@ class Spitball::Remote
36
37
 
37
38
  url = URI.parse("http://#{@host}:#{@port}/create")
38
39
  req = Net::HTTP::Post.new(url.path)
39
- req.form_data = {'gemfile' => @gemfile, 'gemfile_lock' => @gemfile_lock}
40
+ data = {'gemfile' => @gemfile, 'gemfile_lock' => @gemfile_lock}
41
+ data['bundle_config'] = @bundle_config if @bundle_config
42
+ req.form_data = data
40
43
  req.add_field Spitball::PROTOCOL_HEADER, Spitball::PROTOCOL_VERSION
41
44
  req.add_field Spitball::WITHOUT_HEADER, @without.join(',')
42
45
 
@@ -1,3 +1,3 @@
1
1
  class Spitball
2
- VERSION = '0.7.4' unless const_defined?(:VERSION)
2
+ VERSION = '0.8.1' unless const_defined?(:VERSION)
3
3
  end
@@ -71,7 +71,7 @@ describe Spitball do
71
71
  done_caching = true
72
72
  end
73
73
 
74
- sleep 0.5
74
+ sleep 0.1
75
75
  done_caching.should_not == true
76
76
 
77
77
  cached = true
@@ -80,6 +80,16 @@ describe Spitball do
80
80
  end
81
81
  end
82
82
 
83
+ describe "generate_build_args" do
84
+ it "returns an empty string for nil" do
85
+ @spitball.send(:generate_build_args, nil).should == ''
86
+ end
87
+
88
+ it "returns arguments prepended with double dashes for a string" do
89
+ @spitball.send(:generate_build_args, '--build-args=joesmith').should == '-- --build-args=joesmith'
90
+ end
91
+ end
92
+
83
93
  describe "create_bundle" do
84
94
  it "generates a bundle at the bundle_path" do
85
95
  mock(@spitball).install_gem(anything).times(any_times)
@@ -143,7 +153,7 @@ describe Spitball do
143
153
  @spitball.send(:sources_opt, parsed_lockfile.sources).should == "--source http://rubygems.org/"
144
154
  end
145
155
 
146
- it "does not add --clear sources for rubygems >= 1.4.0" do
156
+ it "adds --clear sources for rubygems >= 1.4.0" do
147
157
  @spitball = Spitball.new(@gemfile, @lockfile)
148
158
  parsed_lockfile = @spitball.instance_variable_get("@parsed_lockfile")
149
159
  Gem::VERSION = "1.4.0"
@@ -356,4 +366,4 @@ describe Bundler::FakeDsl do
356
366
  dsl.__groups[:development].should == ["rails"]
357
367
  dsl.__groups[:test].should == ["json_pure"]
358
368
  end
359
- end
369
+ end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency 'json'
22
+ s.add_dependency 'puma'
22
23
  s.add_dependency 'sem_ver'
23
24
  s.add_dependency 'sinatra', '~> 1.2.0'
24
25
  s.add_development_dependency 'rspec', "~> 1.3.0"
metadata CHANGED
@@ -1,123 +1,111 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spitball
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 4
10
- version: 0.7.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Matt Freels
14
8
  - Brandon Mitchell
15
9
  - Joshua Hull
16
10
  autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2014-05-31 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
13
+ date: 2015-08-05 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
32
16
  name: sem_ver
33
- prerelease: false
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- hash: 27
43
- segments:
44
- - 1
45
- - 3
46
- - 0
47
- version: 1.3.0
48
- name: rspec
49
23
  prerelease: false
50
- type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
56
26
  - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- name: diff-lcs
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 1.3.0
36
+ type: :development
63
37
  prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 1.3.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: diff-lcs
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
64
50
  type: :development
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
70
54
  - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
76
58
  name: rr
77
- prerelease: false
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
78
64
  type: :development
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - "="
85
- - !ruby/object:Gem::Version
86
- hash: 49
87
- segments:
88
- - 0
89
- - 8
90
- - 7
91
- version: 0.8.7
92
- name: rake
93
65
  prerelease: false
94
- type: :development
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
100
68
  - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
106
- name: phocus
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.8.7
78
+ type: :development
107
79
  prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '='
83
+ - !ruby/object:Gem::Version
84
+ version: 0.8.7
85
+ - !ruby/object:Gem::Dependency
86
+ name: phocus
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
108
92
  type: :development
109
- version_requirements: *id006
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
110
99
  description: Use bundler to generate gem tarball packages.
111
100
  email: freels@twitter.com
112
- executables:
101
+ executables:
113
102
  - spitball
114
103
  extensions: []
115
-
116
- extra_rdoc_files:
104
+ extra_rdoc_files:
117
105
  - README.md
118
- files:
119
- - .gitignore
120
- - .travis.yml
106
+ files:
107
+ - ".gitignore"
108
+ - ".travis.yml"
121
109
  - CONTRIBUTING.md
122
110
  - Gemfile
123
111
  - LICENSE
@@ -142,38 +130,29 @@ files:
142
130
  - spitball.gemspec
143
131
  homepage: http://github.com/twitter/spitball
144
132
  licenses: []
145
-
133
+ metadata: {}
146
134
  post_install_message:
147
135
  rdoc_options: []
148
-
149
- require_paths:
136
+ require_paths:
150
137
  - lib
151
- required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
- requirements:
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
154
140
  - - ">="
155
- - !ruby/object:Gem::Version
156
- hash: 3
157
- segments:
158
- - 0
159
- version: "0"
160
- required_rubygems_version: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
163
145
  - - ">="
164
- - !ruby/object:Gem::Version
165
- hash: 3
166
- segments:
167
- - 0
168
- version: "0"
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
169
148
  requirements: []
170
-
171
149
  rubyforge_project: spitball
172
- rubygems_version: 1.8.3
150
+ rubygems_version: 2.4.5
173
151
  signing_key:
174
- specification_version: 3
152
+ specification_version: 4
175
153
  summary: Use bundler to generate gem tarball packages
176
- test_files:
154
+ test_files:
177
155
  - spec/spec.opts
178
156
  - spec/spec_helper.rb
179
157
  - spec/spitball_spec.rb
158
+ has_rdoc: