geminabox 0.4.0 → 0.5.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.

data/README.markdown CHANGED
@@ -22,6 +22,11 @@ Create a config.ru as follows:
22
22
 
23
23
  And finally, hook up the config.ru as you normally would ([passenger][passenger], [thin][thin], [unicorn][unicorn], whatever floats your boat).
24
24
 
25
+ ## Legacy RubyGems index
26
+
27
+ RubyGems supports generating indexes for the so called legacy verions (< 1.2), and since it is very rare to use such versions nowadays, it can be disabled, thus improving indexing times for large repositories. If it's safe for your application, you can disable support for these legacy versions by adding the following configuration to yout config.ru file:
28
+
29
+ Geminabox.build_legacy = false
25
30
 
26
31
  ## Client Usage
27
32
 
data/lib/geminabox.rb CHANGED
@@ -12,8 +12,9 @@ require 'hostess'
12
12
  class Geminabox < Sinatra::Base
13
13
  enable :static, :methodoverride
14
14
 
15
- set :public, File.join(File.dirname(__FILE__), *%w[.. public])
15
+ set :public_folder, File.join(File.dirname(__FILE__), *%w[.. public])
16
16
  set :data, File.join(File.dirname(__FILE__), *%w[.. data])
17
+ set :build_legacy, false
17
18
  set :views, File.join(File.dirname(__FILE__), *%w[.. views])
18
19
  set :allow_replace, false
19
20
  use Hostess
@@ -48,13 +49,13 @@ class Geminabox < Sinatra::Base
48
49
  end
49
50
 
50
51
  get '/reindex' do
51
- reindex
52
+ reindex(:force_rebuild)
52
53
  redirect url("/")
53
54
  end
54
55
 
55
56
  delete '/gems/*.gem' do
56
57
  File.delete file_path if File.exists? file_path
57
- reindex
58
+ reindex(:force_rebuild)
58
59
  redirect url("/")
59
60
  end
60
61
 
@@ -67,9 +68,9 @@ class Geminabox < Sinatra::Base
67
68
 
68
69
  tmpfile.binmode
69
70
 
70
- Dir.mkdir(File.join(options.data, "gems")) unless File.directory? File.join(options.data, "gems")
71
+ Dir.mkdir(File.join(settings.data, "gems")) unless File.directory? File.join(settings.data, "gems")
71
72
 
72
- dest_filename = File.join(options.data, "gems", File.basename(name))
73
+ dest_filename = File.join(settings.data, "gems", File.basename(name))
73
74
 
74
75
 
75
76
  if Geminabox.disallow_replace? and File.exist?(dest_filename)
@@ -107,18 +108,27 @@ HTML
107
108
  [code, html]
108
109
  end
109
110
 
110
- def reindex
111
+ def reindex(force_rebuild = false)
111
112
  Geminabox.fixup_bundler_rubygems!
112
- Gem::Indexer.new(options.data).generate_index
113
+ force_rebuild = true if settings.build_legacy
114
+ if force_rebuild
115
+ indexer.generate_index
116
+ else
117
+ indexer.update_index
118
+ end
119
+ end
120
+
121
+ def indexer
122
+ Gem::Indexer.new(settings.data, :build_legacy => settings.build_legacy)
113
123
  end
114
124
 
115
125
  def file_path
116
- File.expand_path(File.join(options.data, *request.path_info))
126
+ File.expand_path(File.join(settings.data, *request.path_info))
117
127
  end
118
128
 
119
129
  def load_gems
120
130
  %w(specs prerelease_specs).inject(GemVersionCollection.new){|gems, specs_file_type|
121
- specs_file_path = File.join(options.data, "#{specs_file_type}.#{Gem.marshal_version}.gz")
131
+ specs_file_path = File.join(settings.data, "#{specs_file_type}.#{Gem.marshal_version}.gz")
122
132
  if File.exists?(specs_file_path)
123
133
  gems |= Geminabox::GemVersionCollection.new(Marshal.load(Gem.gunzip(Gem.read_binary(specs_file_path))))
124
134
  end
@@ -132,7 +142,7 @@ HTML
132
142
 
133
143
  helpers do
134
144
  def spec_for(gem_name, version)
135
- spec_file = File.join(options.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
145
+ spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
136
146
  Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
137
147
  end
138
148
  end
@@ -11,9 +11,13 @@ class Geminabox::GemVersion
11
11
  !!(platform =~ /ruby/i)
12
12
  end
13
13
 
14
+ def version
15
+ Gem::Version.create(number)
16
+ end
17
+
14
18
  def <=>(other)
15
19
  sort = other.name <=> name
16
- sort = other.number <=> number if sort.zero?
20
+ sort = version <=> other.version if sort.zero?
17
21
  sort = (other.ruby? && !ruby?) ? 1 : -1 if sort.zero? && ruby? != other.ruby?
18
22
  sort = other.platform <=> platform if sort.zero?
19
23
 
@@ -21,6 +21,14 @@ class Geminabox::GemVersionCollection
21
21
  @gems.sort!
22
22
  end
23
23
 
24
+ def oldest
25
+ @gems.first
26
+ end
27
+
28
+ def newest
29
+ @gems.last
30
+ end
31
+
24
32
  def |(other)
25
33
  self.class.new(self.gems | other.gems)
26
34
  end
data/public/master.css CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  body {
5
- background: #a00;
5
+ background: #ddd;
6
6
  color: #444;
7
7
  font-size: 1.2em;
8
8
  font-family: "helvetica neue", sans-serif;
@@ -35,6 +35,7 @@ code {
35
35
 
36
36
  #content {
37
37
  background: #fff;
38
+ border: 1px solid #ccc;
38
39
  width: 600px;
39
40
  margin: 0 auto;
40
41
  overflow: hidden;
data/views/atom.erb CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  <feed xmlns="http://www.w3.org/2005/Atom">
4
4
  <title>Gem in a Box</title>
5
- <link href="<%= url_for '/atom.xml' %>" rel="self" />
6
- <link href="<%= url_for '/' %>" />
5
+ <link href="<%= url '/atom.xml' %>" rel="self" />
6
+ <link href="<%= url '/' %>" />
7
7
 
8
8
  <% @gems.each do |name, versions| %>
9
9
  <entry>
10
10
  <title><%= name %> (<%= versions.size == 1 ? versions.first : "#{versions.first} - #{versions.last}" %>)</title>
11
11
  <% versions.each do |version| %>
12
- <link href="<%= url_for "/gems/#{name}-#{version}.gem" %>" />
12
+ <link href="<%= url "/gems/#{name}-#{version}.gem" %>" />
13
13
  <% end %>
14
14
  </entry>
15
15
  <% end %>
data/views/index.erb CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  <% @gems.by_name do |name, versions| %>
9
9
  <li <%= %{id="jump_#{name[0..0]}"} if @index_gems.delete(name[0..0]) %> class="gem-version">
10
- <h2><%= name %> (<%= versions.count == 1 ? versions.first.number : "#{versions.first.number} - #{versions.first.number}" %>)</h2>
10
+ <h2><%= name %> (<%= versions.count == 1 ? versions.first.number : "#{versions.oldest.number} - #{versions.newest.number}" %>)</h2>
11
11
  <% versions.each do |version| %>
12
12
  <p>
13
13
  <code>gem install <%= version.name %> <%= "--prerelease" if version.number.to_s.match(/[a-z]/i) %> -v "<%= version.number %>"</code>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geminabox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Lea
@@ -15,12 +15,14 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-14 00:00:00 Z
18
+ date: 2012-01-13 00:00:00 +00:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: sinatra
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ type: :runtime
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
26
  none: false
25
27
  requirements:
26
28
  - - ">="
@@ -29,12 +31,12 @@ dependencies:
29
31
  segments:
30
32
  - 0
31
33
  version: "0"
32
- type: :runtime
33
- version_requirements: *id001
34
+ requirement: *id001
34
35
  - !ruby/object:Gem::Dependency
35
36
  name: builder
36
37
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ type: :runtime
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
40
42
  - - ">="
@@ -43,8 +45,21 @@ dependencies:
43
45
  segments:
44
46
  - 0
45
47
  version: "0"
46
- type: :runtime
47
- version_requirements: *id002
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ prerelease: false
52
+ type: :development
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirement: *id003
48
63
  description: A sinatra based gem hosting app, with client side gem push style functionality.
49
64
  email: contrib@tomlea.co.uk
50
65
  executables: []
@@ -69,6 +84,7 @@ files:
69
84
  - views/index.erb
70
85
  - views/layout.erb
71
86
  - views/upload.erb
87
+ has_rdoc: true
72
88
  homepage: http://tomlea.co.uk/p/gem-in-a-box
73
89
  licenses: []
74
90
 
@@ -99,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
115
  requirements: []
100
116
 
101
117
  rubyforge_project:
102
- rubygems_version: 1.8.10
118
+ rubygems_version: 1.5.0
103
119
  signing_key:
104
120
  specification_version: 3
105
121
  summary: Really simple rubygem hosting