gemirro 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gemirro might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/gemirro/server.rb +18 -15
- data/lib/gemirro/version.rb +1 -1
- data/spec/gemirro/server_spec.rb +39 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 174665ea51d2dab7ee0f62ed7fea8ab858696e3c
|
4
|
+
data.tar.gz: c595859875f3131b7b8c1700c6523f3cc6ddabaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b92c93ca0bf860e7fb16b72582ea1f1bc241b8b1410c10575b21b5127831be8f15787d8956ac4f5a02735d1d92de2e79d38a3de19cc6fe46d4b583eac6e5c73
|
7
|
+
data.tar.gz: 3dcdfbeed2cc2e2cca94eff1eef3de5c4e1b1271806b6d73a08497958998cb93bfb567fdc89ac56eff9b1844abf3b746ed47ddd49267e72eced9715349e75f6f
|
data/lib/gemirro/server.rb
CHANGED
@@ -89,9 +89,7 @@ module Gemirro
|
|
89
89
|
#
|
90
90
|
get '/api/v1/dependencies' do
|
91
91
|
content_type 'application/octet-stream'
|
92
|
-
|
93
|
-
return Marshal.dump(query_gems_list) if query_gems_list.any?
|
94
|
-
404
|
92
|
+
query_gems.any? ? Marshal.dump(query_gems_list) : 200
|
95
93
|
end
|
96
94
|
|
97
95
|
##
|
@@ -101,9 +99,7 @@ module Gemirro
|
|
101
99
|
#
|
102
100
|
get '/api/v1/dependencies.json' do
|
103
101
|
content_type 'application/json'
|
104
|
-
|
105
|
-
return JSON.dump(query_gems_list) if query_gems_list.any?
|
106
|
-
404
|
102
|
+
query_gems.any? ? JSON.dump(query_gems_list) : {}
|
107
103
|
end
|
108
104
|
|
109
105
|
##
|
@@ -116,7 +112,7 @@ module Gemirro
|
|
116
112
|
resource = "#{settings.public_folder}#{path}"
|
117
113
|
|
118
114
|
# Try to download gem
|
119
|
-
fetch_gem(resource)
|
115
|
+
fetch_gem(resource) unless File.exist?(resource)
|
120
116
|
# If not found again, return a 404
|
121
117
|
return not_found unless File.exist?(resource)
|
122
118
|
|
@@ -211,10 +207,11 @@ module Gemirro
|
|
211
207
|
##
|
212
208
|
# Generate Gems collection from Marshal dump
|
213
209
|
#
|
210
|
+
# @param [TrueClass|FalseClass] orig Fetch orig files
|
214
211
|
# @return [Gemirro::GemVersionCollection]
|
215
212
|
#
|
216
|
-
def gems_collection
|
217
|
-
gems = specs_files_paths.map do |specs_file_path|
|
213
|
+
def gems_collection(orig = true)
|
214
|
+
gems = specs_files_paths(orig).map do |specs_file_path|
|
218
215
|
if File.exist?(specs_file_path)
|
219
216
|
Marshal.load(Zlib::GzipReader.open(specs_file_path).read)
|
220
217
|
else
|
@@ -247,7 +244,7 @@ module Gemirro
|
|
247
244
|
# @return [Array]
|
248
245
|
#
|
249
246
|
def gem_dependencies(gem_name)
|
250
|
-
gems = gems_collection
|
247
|
+
gems = gems_collection(false)
|
251
248
|
gem_collection = gems.find_by_name(gem_name)
|
252
249
|
return '' if gem_collection.nil?
|
253
250
|
|
@@ -280,13 +277,17 @@ module Gemirro
|
|
280
277
|
##
|
281
278
|
# Return specs fils paths
|
282
279
|
#
|
280
|
+
# @param [TrueClass|FalseClass] orig Fetch orig files
|
283
281
|
# @return [Array]
|
284
282
|
#
|
285
|
-
def specs_files_paths
|
283
|
+
def specs_files_paths(orig = true)
|
286
284
|
marshal_version = Gemirro::Configuration.marshal_version
|
287
285
|
specs_file_types.map do |specs_file_type|
|
288
286
|
File.join(settings.public_folder,
|
289
|
-
[specs_file_type,
|
287
|
+
[specs_file_type,
|
288
|
+
marshal_version,
|
289
|
+
'gz' + (orig ? '.orig' : '')
|
290
|
+
].join('.'))
|
290
291
|
end
|
291
292
|
end
|
292
293
|
|
@@ -310,11 +311,13 @@ module Gemirro
|
|
310
311
|
def spec_for(gemname, version, platform = 'ruby')
|
311
312
|
filename = [gemname, version]
|
312
313
|
filename.push(platform) if platform != 'ruby'
|
314
|
+
gemspec_path = File.join('quick',
|
315
|
+
Gemirro::Configuration.marshal_identifier,
|
316
|
+
"#{filename.join('-')}.gemspec.rz")
|
313
317
|
spec_file = File.join(settings.public_folder,
|
314
|
-
|
315
|
-
Gemirro::Configuration.marshal_identifier,
|
316
|
-
"#{filename.join('-')}.gemspec.rz")
|
318
|
+
gemspec_path)
|
317
319
|
|
320
|
+
fetch_gem(gemspec_path) unless File.exist?(spec_file)
|
318
321
|
File.open(spec_file, 'r') do |uz_file|
|
319
322
|
uz_file.binmode
|
320
323
|
Marshal.load(::Gem.inflate(uz_file.read))
|
data/lib/gemirro/version.rb
CHANGED
data/spec/gemirro/server_spec.rb
CHANGED
@@ -57,20 +57,53 @@ module Gemirro
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should display gem specifications' do
|
60
|
-
marshal_dump = Marshal.dump([['
|
60
|
+
marshal_dump = Marshal.dump([['volay',
|
61
61
|
::Gem::Version.create('0.1.0'),
|
62
62
|
'ruby']])
|
63
63
|
|
64
64
|
MirrorFile.new('/var/www/gemirro/specs.4.8.gz.orig').write(marshal_dump)
|
65
65
|
Struct.new('SuccessGzipReader', :read)
|
66
66
|
gzip_reader = Struct::SuccessGzipReader.new(marshal_dump)
|
67
|
+
MirrorDirectory.new('/var/www/gemirro')
|
68
|
+
.add_directory('quick/Marshal.4.8')
|
69
|
+
MirrorFile.new('/var/www/gemirro/quick/Marshal.4.8/' \
|
70
|
+
'volay-0.1.0.gemspec.rz')
|
71
|
+
.write("x\x9C\x8D\x94]\x8F\xD2@\x14\x86\x89Y\xBB\xB4|\xEC\x12\xD7h" \
|
72
|
+
"\xD4h\xD3K\x13J\x01\x97\xC84n\x9A\xA8\xBBi\xE2\xC5\x06\xBB" \
|
73
|
+
"{\xC3\x85)\xE5\x00\x13f:u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|
+
"\xC02G\xF9\b\xEC\x16:\x9D\xC3\x06\b\x8B\xD2\xA9\x95\x84" \
|
90
|
+
"\xD9\x97\xED\xC3p\x89+\x81\xA9}\xAB`\xD9\x9D\xFF\x03\xF6" \
|
91
|
+
"\xD2\xC2\xBF\xCD\xFD`\xDD\x15\x10\x97\xED\xA4.[\xAB\xC6(" \
|
92
|
+
"\x94\x05B\xE3\xB1\xBC\xA5e\xF6\xC3\xAA\x11\n\xE5>A\x8CiD " \
|
93
|
+
"`\x9B\xF2\x04\xE3\xCA\t\xC6\x87\by-f,`Q\xD9\x1E,sp^q\x0F" \
|
94
|
+
"\x85\xD4r\x8Dg\x11\x06\xCE\xC1\xE4>\x9D\xF9\xC9\xFC\xE5" \
|
95
|
+
"\xC8YR\x1F\x133`4\xBB\xF9R~\xEF:\x93\xE8\x93\\\x92\xBF\r" \
|
96
|
+
"\xA3\t\xF8\x84l\xF5<\xBF\xBE\xF9\xE3Q\xD2?q,\x04\x84:\x0E" \
|
97
|
+
"\xF5\xF4\x1D1\xF3\xBA\xE7+!\"\xD4\xEB-\xB1X%\xB3\x14\xD3" \
|
98
|
+
"\xCB\xEDw\xEE\xBD\xFDk\xE99OSz\xF3\xEA\xFA]w7\xF5\xAF\xB5" \
|
99
|
+
"\x9F+\xFEG\x96")
|
67
100
|
|
68
101
|
allow(Zlib::GzipReader).to receive(:open)
|
69
102
|
.once
|
70
103
|
.with('/var/www/gemirro/specs.4.8.gz.orig')
|
71
104
|
.and_return(gzip_reader)
|
72
105
|
|
73
|
-
get '/gem/
|
106
|
+
get '/gem/volay'
|
74
107
|
expect(last_response.status).to eq(200)
|
75
108
|
expect(last_response).to be_ok
|
76
109
|
end
|
@@ -177,11 +210,12 @@ module Gemirro
|
|
177
210
|
it 'should retrieve empty json when gem was not found' do
|
178
211
|
get '/api/v1/dependencies.json?gems=gemirro'
|
179
212
|
expect(last_response.headers['Content-Type'])
|
180
|
-
.to eq('
|
181
|
-
expect(last_response).
|
213
|
+
.to eq('application/json')
|
214
|
+
expect(last_response.body).to eq('[]')
|
215
|
+
expect(last_response).to be_ok
|
182
216
|
end
|
183
217
|
|
184
|
-
it 'should retrieve
|
218
|
+
it 'should retrieve json when gem was found' do
|
185
219
|
MirrorDirectory.new('/var/www/gemirro')
|
186
220
|
.add_directory('quick/Marshal.4.8')
|
187
221
|
MirrorFile.new('/var/www/gemirro/quick/Marshal.4.8/' \
|