gemirro 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -7
- data/Gemfile +2 -0
- data/MANIFEST +1 -3
- data/README.md +1 -1
- data/bin/gemirro +1 -0
- data/gemirro.gemspec +15 -13
- data/lib/gemirro/cache.rb +3 -0
- data/lib/gemirro/cli/index.rb +2 -0
- data/lib/gemirro/cli/init.rb +4 -0
- data/lib/gemirro/cli/list.rb +2 -0
- data/lib/gemirro/cli/server.rb +10 -9
- data/lib/gemirro/cli/update.rb +2 -0
- data/lib/gemirro/cli.rb +3 -3
- data/lib/gemirro/configuration.rb +3 -1
- data/lib/gemirro/gem.rb +4 -3
- data/lib/gemirro/gem_version.rb +2 -0
- data/lib/gemirro/gem_version_collection.rb +3 -2
- data/lib/gemirro/gems_fetcher.rb +2 -0
- data/lib/gemirro/http.rb +31 -4
- data/lib/gemirro/indexer.rb +18 -12
- data/lib/gemirro/mirror_directory.rb +2 -0
- data/lib/gemirro/mirror_file.rb +2 -0
- data/lib/gemirro/server.rb +13 -11
- data/lib/gemirro/source.rb +4 -2
- data/lib/gemirro/utils.rb +6 -1
- data/lib/gemirro/version.rb +3 -1
- data/lib/gemirro/versions_fetcher.rb +2 -0
- data/lib/gemirro/versions_file.rb +2 -0
- data/lib/gemirro.rb +3 -3
- data/spec/gemirro/configuration_spec.rb +1 -0
- data/spec/gemirro/gems_fetcher_spec.rb +1 -0
- data/spec/gemirro/server_spec.rb +2 -2
- data/template/config.rb +19 -1
- data/template/public/dist/css/bootstrap.min.css +5 -3
- data/template/public/dist/js/bootstrap.min.js +6 -6
- data/views/layout.erb +12 -4
- metadata +49 -32
- data/.travis.yml +0 -7
- data/template/public/dist/js/jquery.min.js +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56fa41eef2a76a964a6d885f5c78ea8e6193c2442ae9dc7b3db6cae10c934ea9
|
4
|
+
data.tar.gz: '08152e167296fd41283619abf268f08279b950ff3d683f500f3cdce5fe49ae5e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab54b560eb64207ce1074ac87c02a71569ecf626069a59ae4aa3bfb8dbc5e504c57712e57e216a9c0d27347fca1c54db3037846fefe90ad1ad70de35423b257
|
7
|
+
data.tar.gz: da5e332d738e42ca80ed7946a2bb598b213ce50d54df704f672d3717d010b07bfa5dc3e07d7b3290cc95557f657635a7de46ab9372c6a981b3b19f233c3f2acf
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 2.5
|
3
4
|
Include:
|
4
5
|
- '**/Gemfile'
|
5
6
|
- lib/**/*.rb
|
@@ -14,13 +15,9 @@ AllCops:
|
|
14
15
|
Naming/FileName:
|
15
16
|
Exclude:
|
16
17
|
- Rakefile
|
17
|
-
|
18
|
+
Layout/MethodLength:
|
18
19
|
Enabled: false
|
19
|
-
|
20
|
-
Enabled: false
|
21
|
-
ClassLength:
|
22
|
-
Enabled: false
|
23
|
-
ParameterLists:
|
20
|
+
Layout/ClassLength:
|
24
21
|
Enabled: false
|
25
22
|
Metrics/CyclomaticComplexity:
|
26
23
|
Enabled: false
|
@@ -34,3 +31,7 @@ Security/MarshalLoad:
|
|
34
31
|
Enabled: false
|
35
32
|
Style/ExpandPathArguments:
|
36
33
|
Enabled: false
|
34
|
+
Style/OptionalBooleanParameter:
|
35
|
+
Enabled: false
|
36
|
+
Lint/MissingSuper:
|
37
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/MANIFEST
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
.gitignore
|
2
2
|
.rubocop.yml
|
3
|
-
.travis.yml
|
4
3
|
Gemfile
|
5
4
|
LICENSE
|
6
5
|
MANIFEST
|
@@ -62,9 +61,8 @@ template/public/dist/fonts/glyphicons-halflings-regular.ttf
|
|
62
61
|
template/public/dist/fonts/glyphicons-halflings-regular.woff
|
63
62
|
template/public/dist/fonts/glyphicons-halflings-regular.woff2
|
64
63
|
template/public/dist/js/bootstrap.min.js
|
65
|
-
template/public/dist/js/jquery.min.js
|
66
64
|
template/public/gems/.gitkeep
|
67
65
|
views/gem.erb
|
68
66
|
views/index.erb
|
69
67
|
views/layout.erb
|
70
|
-
views/not_found.erb
|
68
|
+
views/not_found.erb
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ This is done by running the `gemirro init` command.
|
|
29
29
|
$ gemirro init /srv/http/mirror.com/
|
30
30
|
```
|
31
31
|
|
32
|
-
Once created you can edit the main configuration file called
|
32
|
+
Once created you can edit the main configuration file called [config.rb](https://github.com/PierreRambaud/gemirro/blob/master/template/config.rb).
|
33
33
|
This configuration file specifies what source to mirror, destination directory, server host and port, etc.
|
34
34
|
|
35
35
|
Once configured and if you add gem in the `define_source`, you can pull them by running the following command:
|
data/bin/gemirro
CHANGED
data/gemirro.gemspec
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
require File.expand_path('../lib/gemirro/version', __FILE__)
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
7
|
s.name = 'gemirro'
|
6
8
|
s.version = Gemirro::VERSION
|
7
|
-
s.date = Date.today.to_s
|
8
9
|
s.authors = ['Pierre Rambaud']
|
9
10
|
s.email = 'pierre.rambaud86@gmail.com'
|
10
11
|
s.license = 'GPL-3.0'
|
@@ -15,22 +16,23 @@ Gem::Specification.new do |s|
|
|
15
16
|
|
16
17
|
s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n")
|
17
18
|
|
18
|
-
s.required_ruby_version = '>= 2.
|
19
|
+
s.required_ruby_version = '>= 2.5'
|
19
20
|
|
20
|
-
s.add_dependency 'addressable', '~>2.
|
21
|
+
s.add_dependency 'addressable', '~>2.8'
|
21
22
|
s.add_dependency 'builder', '~>3.2'
|
22
|
-
s.add_dependency 'confstruct', '~>1.
|
23
|
+
s.add_dependency 'confstruct', '~>1.1'
|
23
24
|
s.add_dependency 'erubis', '~>2.7'
|
24
25
|
s.add_dependency 'httpclient', '~>2.8'
|
25
|
-
s.add_dependency 'parallel', '~>1.
|
26
|
-
s.add_dependency 'sinatra', '
|
26
|
+
s.add_dependency 'parallel', '~>1.21'
|
27
|
+
s.add_dependency 'sinatra', '>=2.1', '<4.0'
|
28
|
+
s.add_dependency 'sinatra-static-assets', '~>1.0'
|
27
29
|
s.add_dependency 'slop', '~>3.6'
|
28
|
-
s.add_dependency 'thin', '~>1.
|
30
|
+
s.add_dependency 'thin', '~>1.8'
|
29
31
|
|
30
|
-
s.add_development_dependency 'fakefs', '~>
|
31
|
-
s.add_development_dependency 'rack-test', '~>
|
32
|
-
s.add_development_dependency 'rake', '~>
|
33
|
-
s.add_development_dependency 'rspec', '~>3.
|
34
|
-
s.add_development_dependency 'rubocop', '~>
|
35
|
-
s.add_development_dependency 'simplecov', '~>0.
|
32
|
+
s.add_development_dependency 'fakefs', '~>1'
|
33
|
+
s.add_development_dependency 'rack-test', '~>1.1'
|
34
|
+
s.add_development_dependency 'rake', '~>13'
|
35
|
+
s.add_development_dependency 'rspec', '~>3.10'
|
36
|
+
s.add_development_dependency 'rubocop', '~>1'
|
37
|
+
s.add_development_dependency 'simplecov', '~>0.21'
|
36
38
|
end
|
data/lib/gemirro/cache.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Cache class contains all method to store marshal informations
|
@@ -102,6 +104,7 @@ module Gemirro
|
|
102
104
|
#
|
103
105
|
def write(key_hash, value)
|
104
106
|
return value if value.nil? || value.empty?
|
107
|
+
|
105
108
|
File.open(key_path(key_hash), 'wb') do |f|
|
106
109
|
Marshal.dump(value, f)
|
107
110
|
end
|
data/lib/gemirro/cli/index.rb
CHANGED
data/lib/gemirro/cli/init.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gemirro::CLI.options.command 'init' do
|
2
4
|
banner 'Usage: gemirro init [DIRECTORY] [OPTIONS]'
|
3
5
|
description 'Sets up a new mirror'
|
@@ -16,8 +18,10 @@ Gemirro::CLI.options.command 'init' do
|
|
16
18
|
else
|
17
19
|
Dir.glob("#{template}/**/*", File::FNM_DOTMATCH).each do |file|
|
18
20
|
next if ['.', '..'].include?(File.basename(file))
|
21
|
+
|
19
22
|
dest = File.join(directory, file.gsub(/^#{template}/, ''))
|
20
23
|
next if File.exist?(dest)
|
24
|
+
|
21
25
|
FileUtils.cp_r(file, dest)
|
22
26
|
end
|
23
27
|
end
|
data/lib/gemirro/cli/list.rb
CHANGED
data/lib/gemirro/cli/server.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gemirro::CLI.options.command 'server' do
|
2
4
|
banner 'Usage: gemirro server [OPTIONS]'
|
3
5
|
description 'Manage web server'
|
@@ -36,7 +38,7 @@ Gemirro::CLI.options.command 'server' do
|
|
36
38
|
end
|
37
39
|
|
38
40
|
# Copy stdout because we'll need to reopen it later on
|
39
|
-
@orig_stdout =
|
41
|
+
@orig_stdout = $stdout.clone
|
40
42
|
$PROGRAM_NAME = 'gemirro'
|
41
43
|
|
42
44
|
def create_pid
|
@@ -44,7 +46,7 @@ Gemirro::CLI.options.command 'server' do
|
|
44
46
|
f.write(Process.pid.to_s)
|
45
47
|
end
|
46
48
|
rescue Errno::EACCES
|
47
|
-
|
49
|
+
$stdout.reopen @orig_stdout
|
48
50
|
puts "Error: Can't write to #{@pid_file} - Permission denied"
|
49
51
|
exit!
|
50
52
|
end
|
@@ -63,20 +65,18 @@ Gemirro::CLI.options.command 'server' do
|
|
63
65
|
|
64
66
|
def start
|
65
67
|
puts 'Starting...'
|
66
|
-
if File.exist?(@pid_file)
|
67
|
-
|
68
|
-
|
69
|
-
abort
|
70
|
-
end
|
68
|
+
if File.exist?(@pid_file) && running?(pid)
|
69
|
+
puts "Error: #{$PROGRAM_NAME} already running"
|
70
|
+
abort
|
71
71
|
end
|
72
72
|
|
73
73
|
Process.daemon if Gemirro::Utils.configuration.server.daemonize
|
74
74
|
create_pid
|
75
|
-
|
75
|
+
$stdout.reopen @orig_stdout
|
76
76
|
puts "done! (PID is #{pid})\n"
|
77
77
|
Gemirro::Server.run!
|
78
78
|
destroy_pid
|
79
|
-
|
79
|
+
$stdout.reopen '/dev/null', 'a'
|
80
80
|
end
|
81
81
|
|
82
82
|
def stop
|
@@ -113,6 +113,7 @@ Gemirro::CLI.options.command 'server' do
|
|
113
113
|
|
114
114
|
def running?(process_id)
|
115
115
|
return false if process_id.nil?
|
116
|
+
|
116
117
|
Process.getpgid(process_id.to_i) != -1
|
117
118
|
rescue Errno::ESRCH
|
118
119
|
false
|
data/lib/gemirro/cli/update.rb
CHANGED
data/lib/gemirro/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
# CLI mode
|
3
5
|
module CLI
|
@@ -32,9 +34,7 @@ module Gemirro
|
|
32
34
|
config_file += '/config.rb' unless config_file.end_with?('.rb') ||
|
33
35
|
!File.directory?(config_file)
|
34
36
|
|
35
|
-
unless File.file?(config_file)
|
36
|
-
abort "The configuration file #{config_file} does not exist"
|
37
|
-
end
|
37
|
+
abort "The configuration file #{config_file} does not exist" unless File.file?(config_file)
|
38
38
|
|
39
39
|
require(config_file)
|
40
40
|
end
|
data/lib/gemirro/gem.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Gem class contains data about a Gem such as the name, requirement as
|
@@ -14,6 +16,7 @@ module Gemirro
|
|
14
16
|
class Gem
|
15
17
|
attr_reader :name, :requirement
|
16
18
|
attr_accessor :gemspec, :platform
|
19
|
+
|
17
20
|
ONLY_LATEST = %i[latest newest].freeze
|
18
21
|
|
19
22
|
##
|
@@ -33,9 +36,7 @@ module Gemirro
|
|
33
36
|
def initialize(name, requirement = nil, platform = 'ruby')
|
34
37
|
requirement ||= ::Gem::Requirement.default
|
35
38
|
|
36
|
-
if requirement.is_a?(String)
|
37
|
-
requirement = ::Gem::Requirement.new(requirement)
|
38
|
-
end
|
39
|
+
requirement = ::Gem::Requirement.new(requirement) if requirement.is_a?(String)
|
39
40
|
|
40
41
|
@name = name
|
41
42
|
@requirement = requirement
|
data/lib/gemirro/gem_version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The VersionCollection class contains a collection of ::Gem::Version
|
@@ -10,8 +12,7 @@ module Gemirro
|
|
10
12
|
class GemVersionCollection
|
11
13
|
include Enumerable
|
12
14
|
|
13
|
-
attr_reader :gems
|
14
|
-
attr_reader :grouped
|
15
|
+
attr_reader :gems, :grouped
|
15
16
|
|
16
17
|
##
|
17
18
|
# @param [Array] gems
|
data/lib/gemirro/gems_fetcher.rb
CHANGED
data/lib/gemirro/http.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Http class is responsible for executing GET request
|
@@ -18,9 +20,7 @@ module Gemirro
|
|
18
20
|
def self.get(url)
|
19
21
|
response = client.get(url, follow_redirect: true)
|
20
22
|
|
21
|
-
unless HTTP::Status.successful?(response.status)
|
22
|
-
raise HTTPClient::BadResponseError, response.reason
|
23
|
-
end
|
23
|
+
raise HTTPClient::BadResponseError, response.reason unless HTTP::Status.successful?(response.status)
|
24
24
|
|
25
25
|
response
|
26
26
|
end
|
@@ -29,7 +29,34 @@ module Gemirro
|
|
29
29
|
# @return [HTTPClient]
|
30
30
|
#
|
31
31
|
def self.client
|
32
|
-
|
32
|
+
client ||= HTTPClient.new
|
33
|
+
config = Utils.configuration
|
34
|
+
if defined?(config.upstream_user)
|
35
|
+
user = config.upstream_user
|
36
|
+
password = config.upstream_password
|
37
|
+
domain = config.upstream_domain
|
38
|
+
client.set_auth(domain, user, password)
|
39
|
+
end
|
40
|
+
|
41
|
+
if defined?(config.proxy)
|
42
|
+
proxy = config.proxy
|
43
|
+
client.proxy=(proxy)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Use my own ca file for self signed cert
|
47
|
+
if defined?(config.rootca)
|
48
|
+
abort "The configuration file #{config.rootca} does not exist" unless File.file?(config.rootca)
|
49
|
+
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
50
|
+
client.ssl_config.set_trust_ca(config.rootca)
|
51
|
+
elsif defined?(config.verify_mode)
|
52
|
+
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE unless config.verify_mode
|
53
|
+
end
|
54
|
+
|
55
|
+
# Enforce base auth
|
56
|
+
if defined?(config.basic_auth)
|
57
|
+
client.force_basic_auth=(true) if config.basic_auth
|
58
|
+
end
|
59
|
+
@client = client
|
33
60
|
end
|
34
61
|
end
|
35
62
|
end
|
data/lib/gemirro/indexer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Indexer class is responsible for downloading useful file directly
|
@@ -38,8 +40,8 @@ module Gemirro
|
|
38
40
|
|
39
41
|
unless defined?(Builder::XChar)
|
40
42
|
raise 'Gem::Indexer requires that the XML Builder ' \
|
41
|
-
|
42
|
-
|
43
|
+
'library be installed:' \
|
44
|
+
"\n\tgem install builder"
|
43
45
|
end
|
44
46
|
|
45
47
|
options = { build_modern: true }.merge options
|
@@ -118,6 +120,7 @@ module Gemirro
|
|
118
120
|
else
|
119
121
|
source_content = download_from_source(file)
|
120
122
|
next if source_content.nil?
|
123
|
+
|
121
124
|
MirrorFile.new(dst_name).write(source_content)
|
122
125
|
end
|
123
126
|
|
@@ -136,6 +139,7 @@ module Gemirro
|
|
136
139
|
Utils.logger.info("Download from source: #{file}")
|
137
140
|
resp = Http.get("#{source_host}/#{File.basename(file)}")
|
138
141
|
return unless resp.code == 200
|
142
|
+
|
139
143
|
resp.body
|
140
144
|
end
|
141
145
|
|
@@ -155,7 +159,7 @@ module Gemirro
|
|
155
159
|
#
|
156
160
|
def build_indicies
|
157
161
|
specs = *map_gems_to_specs(gem_file_list)
|
158
|
-
specs.select! { |s| s.
|
162
|
+
specs.select! { |s| s.instance_of?(::Gem::Specification) }
|
159
163
|
::Gem::Specification.dirs = []
|
160
164
|
::Gem::Specification.all = specs
|
161
165
|
|
@@ -178,22 +182,23 @@ module Gemirro
|
|
178
182
|
#
|
179
183
|
def map_gems_to_specs(gems)
|
180
184
|
gems.map.with_index do |gemfile, index|
|
181
|
-
# rubocop:disable Metrics/LineLength
|
182
185
|
Utils.logger.info("[#{index + 1}/#{gems.size}]: Processing #{gemfile.split('/')[-1]}")
|
183
|
-
# rubocop:enable Metrics/LineLength
|
184
|
-
|
185
186
|
if File.size(gemfile).zero?
|
186
187
|
Utils.logger.warn("Skipping zero-length gem: #{gemfile}")
|
187
188
|
next
|
188
189
|
end
|
189
190
|
|
190
191
|
begin
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
192
|
+
begin
|
193
|
+
spec = if ::Gem::Package.respond_to? :open
|
194
|
+
::Gem::Package
|
195
|
+
.open(File.open(gemfile, 'rb'), 'r', &:metadata)
|
196
|
+
else
|
197
|
+
::Gem::Package.new(gemfile).spec
|
198
|
+
end
|
199
|
+
rescue NotImplementedError
|
200
|
+
next
|
201
|
+
end
|
197
202
|
|
198
203
|
spec.loaded_from = gemfile
|
199
204
|
|
@@ -325,6 +330,7 @@ module Gemirro
|
|
325
330
|
end
|
326
331
|
|
327
332
|
return false if source_content.nil?
|
333
|
+
|
328
334
|
new_content = source_content.concat(content).uniq
|
329
335
|
create_zlib_file(dst_name, new_content)
|
330
336
|
end
|
data/lib/gemirro/mirror_file.rb
CHANGED
data/lib/gemirro/server.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sinatra/base'
|
4
|
+
require 'sinatra/static_assets'
|
2
5
|
require 'thin'
|
3
6
|
require 'uri'
|
4
7
|
require 'addressable/uri'
|
@@ -8,16 +11,18 @@ module Gemirro
|
|
8
11
|
# Launch Sinatra server to easily download gems.
|
9
12
|
#
|
10
13
|
class Server < Sinatra::Base
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
register Sinatra::StaticAssets
|
15
|
+
|
16
|
+
# rubocop:disable Layout/LineLength
|
17
|
+
URI_REGEXP = /^(.*)-(\d+(?:\.\d+){1,4}.*?)(?:-(x86-(?:(?:mswin|mingw)(?:32|64)).*?|java))?\.(gem(?:spec\.rz)?)$/.freeze
|
18
|
+
# rubocop:enable Layout/LineLength
|
19
|
+
GEMSPEC_TYPE = 'gemspec.rz'
|
20
|
+
GEM_TYPE = 'gem'
|
15
21
|
|
16
22
|
access_logger = Logger.new(Utils.configuration.server.access_log).tap do |logger|
|
17
|
-
::Logger.class_eval { alias_method :write,
|
23
|
+
::Logger.class_eval { alias_method :write, :<< }
|
18
24
|
logger.level = ::Logger::INFO
|
19
25
|
end
|
20
|
-
# rubocop:enable Metrics/LineLength
|
21
26
|
|
22
27
|
error_logger = File.new(Utils.configuration.server.error_log, 'a+')
|
23
28
|
error_logger.sync = true
|
@@ -128,6 +133,7 @@ module Gemirro
|
|
128
133
|
#
|
129
134
|
def fetch_gem(resource)
|
130
135
|
return unless Utils.configuration.fetch_gem
|
136
|
+
|
131
137
|
name = File.basename(resource)
|
132
138
|
result = name.match(URI_REGEXP)
|
133
139
|
return unless result
|
@@ -139,10 +145,8 @@ module Gemirro
|
|
139
145
|
gem = Utils.stored_gem(gem_name, gem_version, gem_platform)
|
140
146
|
gem.gemspec = true if gem_type == GEMSPEC_TYPE
|
141
147
|
|
142
|
-
# rubocop:disable Metrics/LineLength
|
143
148
|
return if Utils.gems_fetcher.gem_exists?(gem.filename(gem_version)) && gem_type == GEM_TYPE
|
144
149
|
return if Utils.gems_fetcher.gemspec_exists?(gem.gemspec_filename(gem_version)) && gem_type == GEMSPEC_TYPE
|
145
|
-
# rubocop:enable Metrics/LineLength
|
146
150
|
|
147
151
|
Utils.logger
|
148
152
|
.info("Try to download #{gem_name} with version #{gem_version}")
|
@@ -216,9 +220,7 @@ module Gemirro
|
|
216
220
|
gem_collection = Parallel.map(gem_collection, in_threads: 4) do |gem|
|
217
221
|
[gem, spec_for(gem.name, gem.number, gem.platform)]
|
218
222
|
end
|
219
|
-
gem_collection.
|
220
|
-
spec.nil?
|
221
|
-
end
|
223
|
+
gem_collection.compact!
|
222
224
|
|
223
225
|
Parallel.map(gem_collection, in_threads: 4) do |gem, spec|
|
224
226
|
dependencies = spec.dependencies.select do |d|
|
data/lib/gemirro/source.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Source class is used for storing information about an external source
|
@@ -34,7 +36,7 @@ module Gemirro
|
|
34
36
|
"Fetching #{Configuration.versions_file} on #{@name} (#{@host})"
|
35
37
|
)
|
36
38
|
|
37
|
-
Http.get(host
|
39
|
+
Http.get("#{host}/#{Configuration.versions_file}").body
|
38
40
|
end
|
39
41
|
|
40
42
|
##
|
@@ -47,7 +49,7 @@ module Gemirro
|
|
47
49
|
"Fetching #{Configuration.prerelease_versions_file}" \
|
48
50
|
" on #{@name} (#{@host})"
|
49
51
|
)
|
50
|
-
Http.get(host
|
52
|
+
Http.get("#{host}/#{Configuration.prerelease_versions_file}").body
|
51
53
|
end
|
52
54
|
|
53
55
|
##
|
data/lib/gemirro/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemirro
|
2
4
|
##
|
3
5
|
# The Utils class is responsible for executing specific traitments
|
@@ -16,6 +18,7 @@ module Gemirro
|
|
16
18
|
:gems_fetcher,
|
17
19
|
:gems_collection,
|
18
20
|
:stored_gems)
|
21
|
+
|
19
22
|
##
|
20
23
|
# Cache class to store marshal and data into files
|
21
24
|
#
|
@@ -44,6 +47,7 @@ module Gemirro
|
|
44
47
|
Parallel.map(file_paths, in_threads: 4) do |file_path|
|
45
48
|
next if data[:files].key?(file_path) &&
|
46
49
|
data[:files][file_path] == File.mtime(file_path)
|
50
|
+
|
47
51
|
has_file_changed = true
|
48
52
|
end
|
49
53
|
|
@@ -53,6 +57,7 @@ module Gemirro
|
|
53
57
|
gems = []
|
54
58
|
Parallel.map(file_paths, in_threads: 4) do |file_path|
|
55
59
|
next unless File.exist?(file_path)
|
60
|
+
|
56
61
|
gems.concat(Marshal.load(Zlib::GzipReader.open(file_path).read))
|
57
62
|
data[:files][file_path] = File.mtime(file_path)
|
58
63
|
end
|
@@ -75,7 +80,7 @@ module Gemirro
|
|
75
80
|
File.join(configuration.destination,
|
76
81
|
[specs_file_type,
|
77
82
|
marshal_version,
|
78
|
-
|
83
|
+
"gz#{orig ? '.orig' : ''}"].join('.'))
|
79
84
|
end
|
80
85
|
end
|
81
86
|
|
data/lib/gemirro/version.rb
CHANGED
data/lib/gemirro.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'confstruct'
|
2
4
|
require 'digest/sha2'
|
3
5
|
require 'fileutils'
|
@@ -13,9 +15,7 @@ require 'stringio'
|
|
13
15
|
require 'tempfile'
|
14
16
|
require 'zlib'
|
15
17
|
|
16
|
-
unless $LOAD_PATH.include?(File.expand_path('../', __FILE__))
|
17
|
-
$LOAD_PATH.unshift(File.expand_path('../', __FILE__))
|
18
|
-
end
|
18
|
+
$LOAD_PATH.unshift(File.expand_path('../', __FILE__)) unless $LOAD_PATH.include?(File.expand_path('../', __FILE__))
|
19
19
|
|
20
20
|
require 'gemirro/version'
|
21
21
|
require 'gemirro/configuration'
|
@@ -72,6 +72,7 @@ module Gemirro
|
|
72
72
|
expect(@config.ignore_gem('rake', '1.0.0', 'ruby')).to eq(['1.0.0'])
|
73
73
|
expect(@config.ignored_gems).to eq('ruby' => {'rake' => ['1.0.0']})
|
74
74
|
expect(@config.ignore_gem?('rake', '1.0.0', 'ruby')).to be_truthy
|
75
|
+
expect(@config.ignore_gem?('rake', '1.0.0', 'java')).to be_falsy
|
75
76
|
end
|
76
77
|
|
77
78
|
it 'should add and return source' do
|
@@ -37,6 +37,7 @@ module Gemirro
|
|
37
37
|
expect(@fetcher.ignore_gem?('gemirro', '0.0.1', 'ruby')).to be_falsy
|
38
38
|
Utils.configuration.ignore_gem('gemirro', '0.0.1', 'ruby')
|
39
39
|
expect(@fetcher.ignore_gem?('gemirro', '0.0.1', 'ruby')).to be_truthy
|
40
|
+
expect(@fetcher.ignore_gem?('gemirro', '0.0.1', 'java')).to be_falsy
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should log error when fetch gem failed' do
|