spitball-server 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: ee0228cc2a93a5bcef1dbc0a9bc76994f47509d6
4
+ data.tar.gz: d090fe93be49ef2fc0ff4e19f9df7088806ce07c
5
+ SHA512:
6
+ metadata.gz: 037d68624218216d888e82698297e57e799c0fa7309838a710168741bb87f6105c99b7c8f2ed9a937b9ebd7ac1f1c97e0ca2e26cf2f803103cc441e10cfdfd28
7
+ data.tar.gz: fdbcafbef06ceced4e34fda3615cfe665c2072f7b768a431522466f0a68047c99a1a571c4c7aaae584bda112c77a86e980fc6a26663c896e8e3629326569975b
@@ -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,154 +1,153 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spitball-server
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: json
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
33
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: puma
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
34
36
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
40
  - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
46
44
  name: sem_ver
47
- prerelease: false
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
48
50
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- hash: 31
57
- segments:
58
- - 1
59
- - 2
60
- - 0
61
- version: 1.2.0
62
- name: sinatra
63
51
  prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: sinatra
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 1.2.0
64
64
  type: :runtime
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ~>
71
- - !ruby/object:Gem::Version
72
- hash: 27
73
- segments:
74
- - 1
75
- - 3
76
- - 0
77
- version: 1.3.0
78
- name: rspec
79
65
  prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: 1.2.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: 1.3.0
80
78
  type: :development
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- requirement: &id005 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
92
- name: diff-lcs
93
79
  prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.0
85
+ - !ruby/object:Gem::Dependency
86
+ name: diff-lcs
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
94
92
  type: :development
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
100
96
  - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ - !ruby/object:Gem::Dependency
106
100
  name: rr
107
- prerelease: false
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
108
106
  type: :development
109
- version_requirements: *id006
110
- - !ruby/object:Gem::Dependency
111
- requirement: &id007 !ruby/object:Gem::Requirement
112
- none: false
113
- requirements:
114
- - - "="
115
- - !ruby/object:Gem::Version
116
- hash: 49
117
- segments:
118
- - 0
119
- - 8
120
- - 7
121
- version: 0.8.7
122
- name: rake
123
107
  prerelease: false
124
- type: :development
125
- version_requirements: *id007
126
- - !ruby/object:Gem::Dependency
127
- requirement: &id008 !ruby/object:Gem::Requirement
128
- none: false
129
- requirements:
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
130
110
  - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 3
133
- segments:
134
- - 0
135
- version: "0"
136
- name: phocus
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rake
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '='
118
+ - !ruby/object:Gem::Version
119
+ version: 0.8.7
120
+ type: :development
137
121
  prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '='
125
+ - !ruby/object:Gem::Version
126
+ version: 0.8.7
127
+ - !ruby/object:Gem::Dependency
128
+ name: phocus
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
138
134
  type: :development
139
- version_requirements: *id008
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
140
141
  description: Use bundler to generate gem tarball packages - server!
141
142
  email: freels@twitter.com
142
- executables:
143
+ executables:
143
144
  - spitball-server
144
145
  - spitball-cache-cleanup
145
146
  extensions: []
146
-
147
147
  extra_rdoc_files: []
148
-
149
- files:
150
- - .gitignore
151
- - .travis.yml
148
+ files:
149
+ - ".gitignore"
150
+ - ".travis.yml"
152
151
  - CONTRIBUTING.md
153
152
  - Gemfile
154
153
  - LICENSE
@@ -171,40 +170,31 @@ files:
171
170
  - spec/spitball_spec.rb
172
171
  - spitball-server.gemspec
173
172
  - spitball.gemspec
174
- homepage: ""
173
+ homepage: ''
175
174
  licenses: []
176
-
175
+ metadata: {}
177
176
  post_install_message:
178
177
  rdoc_options: []
179
-
180
- require_paths:
178
+ require_paths:
181
179
  - lib
182
- required_ruby_version: !ruby/object:Gem::Requirement
183
- none: false
184
- requirements:
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
185
182
  - - ">="
186
- - !ruby/object:Gem::Version
187
- hash: 3
188
- segments:
189
- - 0
190
- version: "0"
191
- required_rubygems_version: !ruby/object:Gem::Requirement
192
- none: false
193
- requirements:
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
194
187
  - - ">="
195
- - !ruby/object:Gem::Version
196
- hash: 3
197
- segments:
198
- - 0
199
- version: "0"
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
200
190
  requirements: []
201
-
202
191
  rubyforge_project: spitball-server
203
- rubygems_version: 1.8.3
192
+ rubygems_version: 2.4.5
204
193
  signing_key:
205
- specification_version: 3
194
+ specification_version: 4
206
195
  summary: Use bundler to generate gem tarball packages -- server!
207
- test_files:
196
+ test_files:
208
197
  - spec/spec.opts
209
198
  - spec/spec_helper.rb
210
199
  - spec/spitball_spec.rb
200
+ has_rdoc: