geminabox 0.2.15 → 0.3.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 +5 -0
- data/lib/geminabox.rb +36 -1
- data/lib/geminabox/gem_version_collection.rb +1 -0
- data/views/index.erb +1 -1
- metadata +7 -7
data/README.markdown
CHANGED
@@ -31,6 +31,11 @@ And finally, hook up the config.ru as you normally would ([passenger][passenger]
|
|
31
31
|
|
32
32
|
Simples!
|
33
33
|
|
34
|
+
## Licence
|
35
|
+
|
36
|
+
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].
|
37
|
+
|
38
|
+
[WTFBPPL]: http://tomlea.co.uk/WTFBPPL.txt
|
34
39
|
[sinatra]: http://www.sinatrarb.com/
|
35
40
|
[passenger]: http://www.modrails.com/
|
36
41
|
[thin]: http://code.macournoyer.com/thin/
|
data/lib/geminabox.rb
CHANGED
@@ -13,8 +13,15 @@ class Geminabox < Sinatra::Base
|
|
13
13
|
set :public, File.join(File.dirname(__FILE__), *%w[.. public])
|
14
14
|
set :data, File.join(File.dirname(__FILE__), *%w[.. data])
|
15
15
|
set :views, File.join(File.dirname(__FILE__), *%w[.. views])
|
16
|
+
set :allow_replace, false
|
16
17
|
use Hostess
|
17
18
|
|
19
|
+
class << self
|
20
|
+
def disallow_replace?
|
21
|
+
! allow_replace
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
autoload :GemVersionCollection, "geminabox/gem_version_collection"
|
19
26
|
|
20
27
|
get '/' do
|
@@ -49,7 +56,21 @@ class Geminabox < Sinatra::Base
|
|
49
56
|
|
50
57
|
Dir.mkdir(File.join(options.data, "gems")) unless File.directory? File.join(options.data, "gems")
|
51
58
|
|
52
|
-
File.
|
59
|
+
dest_filename = File.join(options.data, "gems", File.basename(name))
|
60
|
+
|
61
|
+
|
62
|
+
if Geminabox.disallow_replace? and File.exist?(dest_filename)
|
63
|
+
existing_file_digest = Digest::SHA1.file(dest_filename).hexdigest
|
64
|
+
tmpfile_digest = Digest::SHA1.file(tmpfile.path).hexdigest
|
65
|
+
|
66
|
+
if existing_file_digest != tmpfile_digest
|
67
|
+
return error_response(409, "Gem already exists, you must delete the existing version first.")
|
68
|
+
else
|
69
|
+
return [200, "Ignoring upload, you uploaded the same thing previously."]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
File.open(dest_filename, "wb") do |f|
|
53
74
|
while blk = tmpfile.read(65536)
|
54
75
|
f << blk
|
55
76
|
end
|
@@ -59,6 +80,20 @@ class Geminabox < Sinatra::Base
|
|
59
80
|
end
|
60
81
|
|
61
82
|
private
|
83
|
+
|
84
|
+
def error_response(code, message)
|
85
|
+
html = <<HTML
|
86
|
+
<html>
|
87
|
+
<head><title>Error - #{code}</title></head>
|
88
|
+
<body>
|
89
|
+
<h1>Error - #{code}</h1>
|
90
|
+
<p>#{message}</p>
|
91
|
+
</body>
|
92
|
+
</html>
|
93
|
+
HTML
|
94
|
+
[code, html]
|
95
|
+
end
|
96
|
+
|
62
97
|
def reindex
|
63
98
|
Gem::Indexer.new(options.data).generate_index
|
64
99
|
end
|
data/views/index.erb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<h2><%= name %> (<%= versions.size == 1 ? versions.first : "#{versions.first} - #{versions.last}" %>)</h2>
|
11
11
|
<% versions.each do |version| %>
|
12
12
|
<form class="delete-form" method="post" action="/gems/<%= name %>-<%= version %>.gem">
|
13
|
-
<code>gem install <%= name %> -v "<%= version %>"</code>
|
13
|
+
<code>gem install <%= name %> <%= "--prerelease" if version.to_s.match(/[a-z]/i) %> -v "<%= version %>"</code>
|
14
14
|
<input type="hidden" name="_method" value="DELETE" />
|
15
15
|
<button type="submit">delete</button>
|
16
16
|
</form>
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Lea
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-23 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements: []
|
101
101
|
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.5.0
|
104
104
|
signing_key:
|
105
105
|
specification_version: 3
|
106
106
|
summary: Really simple rubygem hosting
|