geminabox 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geminabox might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2QyZTI0YzVmMDBkZmRjNzAxOTcyNGU5Mzc1ZWE5MzQxZGYyMDUwMw==
5
+ data.tar.gz: !binary |-
6
+ YmFkNzRmNDAyMGI5NzMyMWI2OThjYTQyMGIyZGI0NDM4ZDY0YzQxNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Yjc5MTkzOWYxZDA2NWZlNWM2MDQxODQ0MWM3ODIyMWU3ZjY1ZTE1Y2VmMDNk
10
+ OTAyNGU2ZTc0NTQwN2FiNWI4OGVkYjliYjM2MjNmMTNjOTI0MDE4OTcxYjY0
11
+ NDc4MmM3NGI1MDU0MDBmYWZkNmQ2MTYxNGZmMzA3ODhlZTljOTE=
12
+ data.tar.gz: !binary |-
13
+ NDQ5YTkzZjIzMWFlZWQ2YjQ4MTE4MWRlODFiNThiNDcwOTM2YTUzYzkyY2Rh
14
+ OWUxNzgxOTFiNjI1MGRhMmI1NzY5OWUyMDkyYjA0NzJmNTFjMWQ3ZWM1ZDY5
15
+ NjZjYzA5OGU5ZTU5OWZhMTMxYWNkOGIwMTY0Yjk4Y2U4N2FlNmY=
data/README.markdown CHANGED
@@ -1,19 +1,20 @@
1
1
  # Gem in a Box – Really simple rubygem hosting
2
- ##
2
+ [![Build Status](https://secure.travis-ci.org/cwninja/geminabox.png)](http://travis-ci.org/cwninja/geminabox)
3
+ [![Gem Version](https://badge.fury.io/rb/geminabox.png)](http://badge.fury.io/rb/geminabox)
3
4
 
4
5
  Geminabox lets you host your own gems, and push new gems to it just like with rubygems.org.
5
6
  The bundler dependencies API is supported out of the box.
6
7
  Authentication is left up to either the web server, or the Rack stack.
7
8
  For basic auth, try [Rack::Auth](http://rack.rubyforge.org/doc/Rack/Auth/Basic.html).
8
9
 
9
-
10
- [![Build Status](https://secure.travis-ci.org/cwninja/geminabox.png)](http://travis-ci.org/cwninja/geminabox)
11
-
12
-
13
10
  ![screen shot](http://pics.tomlea.co.uk/bbbba6/geminabox.png)
14
11
 
12
+ ## System Requirements
15
13
 
14
+ Tested on Mac OS X 10.8.2
15
+ Ruby 1.9.3-392
16
16
 
17
+ Tests fail on Ruby 2.0.0-p0
17
18
 
18
19
  ## Server Setup
19
20
 
@@ -27,7 +28,7 @@ Create a config.ru as follows:
27
28
  Geminabox.data = "/var/geminabox-data" # ... or wherever
28
29
  run Geminabox
29
30
 
30
- And finally, hook up the config.ru as you normally would ([passenger][passenger], [thin][thin], [unicorn][unicorn], whatever floats your boat).
31
+ Start your gem server with 'rackup' to run WEBrick or hook up the config.ru as you normally would ([passenger][passenger], [thin][thin], [unicorn][unicorn], whatever floats your boat).
31
32
 
32
33
  ## Legacy RubyGems index
33
34
 
@@ -43,14 +44,42 @@ RubyGems supports generating indexes for the so called legacy versions (< 1.2),
43
44
 
44
45
  Configure Gem in a box (interactive prompt to specify where to upload to):
45
46
 
46
- geminabox -c
47
+ gem inabox -c
47
48
 
48
49
  Change the host to upload to:
49
50
 
50
- geminabox -g HOST
51
+ gem inabox -g HOST
51
52
 
52
53
  Simples!
53
54
 
55
+ ## Command Line Help
56
+
57
+ Usage: gem inabox GEM [options]
58
+
59
+ Options:
60
+ -c, --configure Configure GemInABox
61
+ -g, --host HOST Host to upload to.
62
+ -o, --overwrite Overwrite Gem.
63
+
64
+
65
+ Common Options:
66
+ -h, --help Get help on this command
67
+ -V, --[no-]verbose Set the verbose level of output
68
+ -q, --quiet Silence commands
69
+ --config-file FILE Use this config file instead of default
70
+ --backtrace Show stack backtrace on errors
71
+ --debug Turn on Ruby debugging
72
+
73
+
74
+ Arguments:
75
+ GEM built gem to push up
76
+
77
+ Summary:
78
+ Push a gem up to your GemInABox
79
+
80
+ Description:
81
+ Push a gem up to your GemInABox
82
+
54
83
  ## Licence
55
84
 
56
85
  Fork it, mod it, choose it, use it, make it better. All under the [do what the fuck you want to + beer/pizza public license][WTFBPPL].
data/lib/geminabox.rb CHANGED
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'digest/md5'
3
3
  require 'builder'
4
4
  require 'sinatra/base'
5
- require 'rubygems/builder'
6
5
  require 'rubygems/indexer'
7
6
  require 'rubygems/package'
8
7
  require 'hostess'
@@ -20,6 +19,7 @@ class Geminabox < Sinatra::Base
20
19
  set :views, File.join(File.dirname(__FILE__), *%w[.. views])
21
20
  set :allow_replace, false
22
21
  set :gem_permissions, 0644
22
+ set :allow_delete, true
23
23
  use Hostess
24
24
 
25
25
  class << self
@@ -27,6 +27,10 @@ class Geminabox < Sinatra::Base
27
27
  ! allow_replace
28
28
  end
29
29
 
30
+ def allow_delete?
31
+ allow_delete
32
+ end
33
+
30
34
  def fixup_bundler_rubygems!
31
35
  return if @post_reset_hook_applied
32
36
  Gem.post_reset{ Gem::Specification.all = nil } if defined? Bundler and Gem.respond_to? :post_reset
@@ -54,23 +58,8 @@ class Geminabox < Sinatra::Base
54
58
  erb :atom, :layout => false
55
59
  end
56
60
 
57
- # Return a list of versions of gem 'gem_name' with the dependencies of each version.
58
- def gem_dependencies(gem_name)
59
- dependency_cache.marshal_cache(gem_name) do
60
- load_gems.select {|gem| gem_name == gem.name }.map do |gem|
61
- spec = spec_for(gem.name, gem.number)
62
- {
63
- :name => gem.name,
64
- :number => gem.number.version,
65
- :platform => gem.platform,
66
- :dependencies => spec.dependencies.select {|dep| dep.type == :runtime}.map {|dep| [dep.name, dep.requirement.to_s] }
67
- }
68
- end
69
- end
70
- end
71
-
72
61
  get '/api/v1/dependencies' do
73
- query_gems = params[:gems].split(',')
62
+ query_gems = params[:gems].to_s.split(',')
74
63
  deps = query_gems.inject([]){|memo, query_gem| memo + gem_dependencies(query_gem) }
75
64
  Marshal.dump(deps)
76
65
  end
@@ -92,6 +81,9 @@ class Geminabox < Sinatra::Base
92
81
  end
93
82
 
94
83
  delete '/gems/*.gem' do
84
+ unless Geminabox.allow_delete?
85
+ error_response(403, 'Gem deletion is disabled - see https://github.com/cwninja/geminabox/issues/115')
86
+ end
95
87
  File.delete file_path if File.exists? file_path
96
88
  reindex(:force_rebuild)
97
89
  redirect url("/")
@@ -120,7 +112,7 @@ private
120
112
  def handle_incoming_gem(gem)
121
113
  prepare_data_folders
122
114
  error_response(400, "Cannot process gem") unless gem.valid?
123
- handle_replacement(gem)
115
+ handle_replacement(gem) unless params[:overwrite] == "true"
124
116
  write_and_index(gem)
125
117
 
126
118
  if api_request?
@@ -170,7 +162,7 @@ HTML
170
162
  if existing_file_digest != gem.hexdigest
171
163
  error_response(409, "Updating an existing gem is not permitted.\nYou should either delete the existing version, or change your version number.")
172
164
  else
173
- error_response(200, "Ignoring upload, you uploaded the same thing previously.")
165
+ error_response(200, "Ignoring upload, you uploaded the same thing previously.\nPlease use -o to ovewrite.")
174
166
  end
175
167
  end
176
168
  end
@@ -253,5 +245,30 @@ HTML
253
245
  spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
254
246
  Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
255
247
  end
248
+
249
+ # Return a list of versions of gem 'gem_name' with the dependencies of each version.
250
+ def gem_dependencies(gem_name)
251
+ dependency_cache.marshal_cache(gem_name) do
252
+ load_gems.
253
+ select { |gem| gem_name == gem.name }.
254
+ map { |gem| [gem, spec_for(gem.name, gem.number)] }.
255
+ reject { |(_, spec)| spec.nil? }.
256
+ map do |(gem, spec)|
257
+ {
258
+ :name => gem.name,
259
+ :number => gem.number.version,
260
+ :platform => gem.platform,
261
+ :dependencies => runtime_dependencies(spec)
262
+ }
263
+ end
264
+ end
265
+ end
266
+
267
+ def runtime_dependencies(spec)
268
+ spec.
269
+ dependencies.
270
+ select { |dep| dep.type == :runtime }.
271
+ map { |dep| [dep.name, dep.requirement.to_s] }
272
+ end
256
273
  end
257
274
  end
@@ -33,16 +33,26 @@ class Geminabox::IncomingGem
33
33
  end
34
34
 
35
35
  def spec
36
- unless @spec
36
+ @spec ||= extract_spec
37
+ end
38
+
39
+ def extract_spec
40
+ if Gem::Package.respond_to? :open
37
41
  Gem::Package.open(gem_data, "r", nil) do |pkg|
38
- @spec = pkg.metadata
42
+ return pkg.metadata
39
43
  end
44
+ else
45
+ Gem::Package.new(@tempfile.path).spec
40
46
  end
41
- @spec
42
47
  end
43
48
 
44
49
  def name
45
- "#{spec.name}-#{spec.version}.gem"
50
+ unless @name
51
+ filename = %W[#{spec.name} #{spec.version}]
52
+ filename.push(spec.platform) if spec.platform && spec.platform != "ruby"
53
+ @name = filename.join("-") + ".gem"
54
+ end
55
+ @name
46
56
  end
47
57
 
48
58
  def dest_filename
@@ -1 +1 @@
1
- GeminaboxVersion = '0.10.1' unless defined? GeminaboxVersion
1
+ GeminaboxVersion = '0.11.0' unless defined? GeminaboxVersion
@@ -26,8 +26,8 @@ class GeminaboxClient
26
26
  url + path.to_s
27
27
  end
28
28
 
29
- def push(gemfile)
30
- response = http_client.post(url_for(:upload), {'file' => File.open(gemfile, "rb")}, {'Accept' => 'text/plain'})
29
+ def push(gemfile, options = {})
30
+ response = http_client.post(url_for(:upload), { 'file' => File.open(gemfile, "rb"), 'overwrite' => !!options[:overwrite] }, { 'Accept' => 'text/plain' })
31
31
 
32
32
  if response.status < 300
33
33
  response.body
@@ -23,6 +23,10 @@ class Gem::Commands::InaboxCommand < Gem::Command
23
23
  add_option('-g', '--host HOST', "Host to upload to.") do |value, options|
24
24
  options[:host] = value
25
25
  end
26
+
27
+ add_option('-o', '--overwrite', "Overwrite Gem.") do |value, options|
28
+ options[:overwrite] = true
29
+ end
26
30
  end
27
31
 
28
32
  def last_minute_requires!
@@ -51,7 +55,7 @@ class Gem::Commands::InaboxCommand < Gem::Command
51
55
  gemfiles.each do |gemfile|
52
56
  say "Pushing #{File.basename(gemfile)} to #{client.url}..."
53
57
  begin
54
- say client.push(gemfile)
58
+ say client.push(gemfile, options)
55
59
  rescue GeminaboxClient::Error => e
56
60
  alert_error e.message
57
61
  terminate_interaction(1)
metadata CHANGED
@@ -1,159 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: geminabox
3
- version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease:
6
- segments:
7
- - 0
8
- - 10
9
- - 1
10
- version: 0.10.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Tom Lea
8
+ - Jack Foy
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-01-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: sinatra
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
31
21
  type: :runtime
32
- requirement: *id001
33
22
  prerelease: false
34
- - !ruby/object:Gem::Dependency
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
35
29
  name: builder
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
45
35
  type: :runtime
46
- requirement: *id002
47
36
  prerelease: false
48
- - !ruby/object:Gem::Dependency
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
49
43
  name: httpclient
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 9
56
- segments:
57
- - 2
58
- - 2
59
- - 7
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
60
48
  version: 2.2.7
61
49
  type: :runtime
62
- requirement: *id003
63
50
  prerelease: false
64
- - !ruby/object:Gem::Dependency
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 2.2.7
56
+ - !ruby/object:Gem::Dependency
65
57
  name: rake
66
- version_requirements: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
75
63
  type: :development
76
- requirement: *id004
77
64
  prerelease: false
78
- - !ruby/object:Gem::Dependency
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
79
71
  name: rack-test
80
- version_requirements: &id005 !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
89
77
  type: :development
90
- requirement: *id005
91
78
  prerelease: false
92
- - !ruby/object:Gem::Dependency
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
93
85
  name: minitest
94
- version_requirements: &id006 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
103
91
  type: :development
104
- requirement: *id006
105
92
  prerelease: false
106
- - !ruby/object:Gem::Dependency
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
107
99
  name: capybara
108
- version_requirements: &id007 !ruby/object:Gem::Requirement
109
- none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
117
105
  type: :development
118
- requirement: *id007
119
106
  prerelease: false
120
- - !ruby/object:Gem::Dependency
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
121
113
  name: capybara-mechanize
122
- version_requirements: &id008 !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
131
119
  type: :development
132
- requirement: *id008
133
120
  prerelease: false
134
- - !ruby/object:Gem::Dependency
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
135
127
  name: pry
136
- version_requirements: &id009 !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
- version: "0"
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
145
133
  type: :development
146
- requirement: *id009
147
134
  prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
148
140
  description: A sinatra based gem hosting app, with client side gem push style functionality.
149
- email: contrib@tomlea.co.uk
141
+ email:
142
+ - contrib@tomlea.co.uk
143
+ - jack@foys.net
150
144
  executables: []
151
-
152
145
  extensions: []
153
-
154
- extra_rdoc_files:
146
+ extra_rdoc_files:
155
147
  - README.markdown
156
- files:
148
+ files:
157
149
  - README.markdown
158
150
  - lib/geminabox/disk_cache.rb
159
151
  - lib/geminabox/gem_version.rb
@@ -177,37 +169,27 @@ files:
177
169
  - views/upload.erb
178
170
  homepage: http://tomlea.co.uk/p/gem-in-a-box
179
171
  licenses: []
180
-
172
+ metadata: {}
181
173
  post_install_message:
182
- rdoc_options:
174
+ rdoc_options:
183
175
  - --main
184
176
  - README.markdown
185
- require_paths:
177
+ require_paths:
186
178
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
188
- none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
194
- - 0
195
- version: "0"
196
- required_rubygems_version: !ruby/object:Gem::Requirement
197
- none: false
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- hash: 3
202
- segments:
203
- - 0
204
- version: "0"
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
205
189
  requirements: []
206
-
207
190
  rubyforge_project:
208
- rubygems_version: 1.8.24
191
+ rubygems_version: 2.0.3
209
192
  signing_key:
210
- specification_version: 3
193
+ specification_version: 4
211
194
  summary: Really simple rubygem hosting
212
195
  test_files: []
213
-