geminabox 0.2.5 → 0.2.6
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/lib/geminabox.rb +19 -20
- data/lib/geminabox/gem_version_collection.rb +25 -0
- data/views/atom.erb +16 -0
- data/views/layout.erb +1 -0
- metadata +15 -4
data/lib/geminabox.rb
CHANGED
@@ -5,6 +5,7 @@ require "rubygems/indexer"
|
|
5
5
|
|
6
6
|
require 'hostess'
|
7
7
|
|
8
|
+
|
8
9
|
class Geminabox < Sinatra::Base
|
9
10
|
enable :static, :methodoverride
|
10
11
|
|
@@ -13,30 +14,17 @@ class Geminabox < Sinatra::Base
|
|
13
14
|
set :views, File.join(File.dirname(__FILE__), *%w[.. views])
|
14
15
|
use Hostess
|
15
16
|
|
17
|
+
autoload :GemVersionCollection, "geminabox/gem_version_collection"
|
16
18
|
|
17
19
|
get '/' do
|
18
|
-
|
19
|
-
@gems = %w(latest_specs prerelease_specs).inject([]){|gems, spec|
|
20
|
-
gems + Marshal.load(Gem.gunzip(Gem.read_binary( File.join(options.data, "#{spec}.#{Gem.marshal_version}.gz")) ))
|
21
|
-
}
|
22
|
-
rescue
|
23
|
-
@gems = []
|
24
|
-
end
|
25
|
-
|
26
|
-
indices = {}
|
27
|
-
@gems = @gems.inject([]) do |grouped_gems, (name, version, lang)|
|
28
|
-
if i = indices[name]
|
29
|
-
grouped_gems[i][1] << version
|
30
|
-
grouped_gems[i][1].sort!
|
31
|
-
else
|
32
|
-
indices[name] = grouped_gems.size
|
33
|
-
grouped_gems << [name, [version], lang]
|
34
|
-
end
|
35
|
-
grouped_gems
|
36
|
-
end
|
37
|
-
|
20
|
+
@gems = load_gems
|
38
21
|
erb :index
|
39
22
|
end
|
23
|
+
|
24
|
+
get '/atom.xml' do
|
25
|
+
@gems = load_gems
|
26
|
+
erb :atom, :layout => false
|
27
|
+
end
|
40
28
|
|
41
29
|
get '/upload' do
|
42
30
|
erb :upload
|
@@ -76,6 +64,17 @@ private
|
|
76
64
|
File.expand_path(File.join(options.data, *request.path_info))
|
77
65
|
end
|
78
66
|
|
67
|
+
def load_gems
|
68
|
+
%w(specs prerelease_specs).inject(GemVersionCollection.new){|gems, specs_file_type|
|
69
|
+
specs_file_path = File.join(options.data, "#{specs_file_type}.#{Gem.marshal_version}.gz")
|
70
|
+
if File.exists?(specs_file_path)
|
71
|
+
gems + Marshal.load(Gem.gunzip(Gem.read_binary(specs_file_path)))
|
72
|
+
else
|
73
|
+
gems
|
74
|
+
end
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
79
78
|
helpers do
|
80
79
|
def url_for(path)
|
81
80
|
url = request.scheme + "://"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Geminabox::GemVersionCollection
|
2
|
+
include Enumerable
|
3
|
+
|
4
|
+
def initialize(initial_gems = [])
|
5
|
+
@gems = Hash.new{|h,k| h[k] = [] }
|
6
|
+
initial_gems.each{|g| self << g }
|
7
|
+
end
|
8
|
+
|
9
|
+
def <<(gemdef)
|
10
|
+
name,version,_ = gemdef
|
11
|
+
@gems[name] += [version].flatten
|
12
|
+
@gems[name].sort!
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def + other
|
17
|
+
other.inject(self.class.new(self)){|new_set, gemdef|
|
18
|
+
new_set << gemdef
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def each(&block)
|
23
|
+
@gems.sort_by{|name, versions| name }.each(&block)
|
24
|
+
end
|
25
|
+
end
|
data/views/atom.erb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
4
|
+
<title>Gem in a Box</title>
|
5
|
+
<link href="<%= url_for '/atom.xml' %>" rel="self" />
|
6
|
+
<link href="<%= url_for '/' %>" />
|
7
|
+
|
8
|
+
<% @gems.each do |name, versions| %>
|
9
|
+
<entry>
|
10
|
+
<title><%= name %> (<%= versions.size == 1 ? versions.first : "#{versions.first} - #{versions.last}" %>)</title>
|
11
|
+
<% versions.each do |version| %>
|
12
|
+
<link href="<%= url_for "/gems/#{name}-#{version}.gem" %>" />
|
13
|
+
<% end %>
|
14
|
+
</entry>
|
15
|
+
<% end %>
|
16
|
+
</feed>
|
data/views/layout.erb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
<head>
|
3
3
|
<title>Gem in a Box</title>
|
4
4
|
<link rel="stylesheet" href="/master.css" type="text/css" media="screen" charset="utf-8">
|
5
|
+
<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom Feed">
|
5
6
|
<script type="text/javascript" src="/jquery.js"></script>
|
6
7
|
<script type="text/javascript" src="/master.js"></script>
|
7
8
|
</head>
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geminabox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Tom Lea
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-05-
|
18
|
+
date: 2010-05-19 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: sinatra
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: builder
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -51,6 +56,7 @@ extra_rdoc_files:
|
|
51
56
|
- README.markdown
|
52
57
|
files:
|
53
58
|
- README.markdown
|
59
|
+
- lib/geminabox/gem_version_collection.rb
|
54
60
|
- lib/geminabox.rb
|
55
61
|
- lib/hostess.rb
|
56
62
|
- lib/rubygems/commands/inabox_command.rb
|
@@ -59,6 +65,7 @@ files:
|
|
59
65
|
- public/jquery.js
|
60
66
|
- public/master.css
|
61
67
|
- public/master.js
|
68
|
+
- views/atom.erb
|
62
69
|
- views/index.erb
|
63
70
|
- views/layout.erb
|
64
71
|
- views/upload.erb
|
@@ -73,23 +80,27 @@ rdoc_options:
|
|
73
80
|
require_paths:
|
74
81
|
- lib
|
75
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
76
84
|
requirements:
|
77
85
|
- - ">="
|
78
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
79
88
|
segments:
|
80
89
|
- 0
|
81
90
|
version: "0"
|
82
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
83
93
|
requirements:
|
84
94
|
- - ">="
|
85
95
|
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
86
97
|
segments:
|
87
98
|
- 0
|
88
99
|
version: "0"
|
89
100
|
requirements: []
|
90
101
|
|
91
102
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.7
|
93
104
|
signing_key:
|
94
105
|
specification_version: 3
|
95
106
|
summary: Really simple rubygem hosting
|