gemirro 2.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e54b02e5575feb8b7a4fcbb40f5fd91764fb0f589368e4a9207f6a5074fe2f05
4
- data.tar.gz: 14449b2b15d5477216adaecea6e36aff26dae8b30104e3db627bdcdbdf7c6b7d
3
+ metadata.gz: f4433d72ad5aef6af085761295239943b68ca7afbf8decf4a6e4fd1724eae1d3
4
+ data.tar.gz: 73492105d34fa6b3dbd0da1f0158e9a9c6ac95915e2b714be1c107f375473264
5
5
  SHA512:
6
- metadata.gz: ba26ee7c502dd1bbfc02fd55e1263097dedad78670281d8f775bd9c5940be1c46032130cd76be02fbdee3b8a4c2f24504f39b38c7e5901497c7eff28d13a0307
7
- data.tar.gz: ce425c173bcfc46ea6298cc0911ddec8a838f321749f9ec782da8323afdaf3268f6071d629be5fa6b129fbe29d2198e930b6202225d23f17ac582fac71fc1533
6
+ metadata.gz: 1c5ab9469369f159fe071f0f9eb8215971018f5880cbbf4236333c30675a460f8b5936f136d2becc15203b07f8065d9f2c6309d3c58f5807e7be7555e7804314
7
+ data.tar.gz: bff9e9a7c93475fcfa4a8a341bc57823e3267b759c3602905449af813a4d239fc29f9bec3d12976b2e08e1bfb79daa27f5d2fe442c08e09c41547e2ba81d1415
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: ['3.0', '3.1', '3.2']
10
+ ruby: ['3.2', '3.3', '3.4']
11
11
  name: Rspec on Ruby ${{ matrix.ruby }}
12
12
  steps:
13
13
  - uses: actions/checkout@v4
data/.gitignore CHANGED
@@ -4,4 +4,5 @@
4
4
  /.ruby-version
5
5
  /*.gem
6
6
  /.bundle
7
+ /vendor
7
8
  .DS_Store
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  SuggestExtensions: false
3
3
  NewCops: enable
4
- TargetRubyVersion: 3.0
4
+ TargetRubyVersion: 3.2
5
5
  Include:
6
6
  - '**/Gemfile'
7
7
  - lib/**/*.rb
@@ -20,6 +20,8 @@ Metrics/MethodLength:
20
20
  Enabled: false
21
21
  Metrics/ClassLength:
22
22
  Enabled: false
23
+ Metrics/ModuleLength:
24
+ Enabled: false
23
25
  Metrics/CyclomaticComplexity:
24
26
  Enabled: false
25
27
  Metrics/PerceivedComplexity:
data/Gemfile CHANGED
@@ -6,9 +6,10 @@ gemspec
6
6
 
7
7
  group :development, :test do
8
8
  gem 'fakefs', '~> 2'
9
- gem 'rack-test', '~> 1.1'
9
+ gem 'rack-test', '~> 2.1'
10
10
  gem 'rake', '~> 13'
11
11
  gem 'rspec', '~> 3.10'
12
12
  gem 'rubocop', '~> 1'
13
13
  gem 'simplecov', '~> 0.21'
14
+ gem 'webmock', '~> 3.24'
14
15
  end
data/Gemfile.lock CHANGED
@@ -1,114 +1,125 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gemirro (2.0.0)
4
+ gemirro (3.0.0)
5
5
  addressable (~> 2.8)
6
6
  builder (~> 3.2)
7
7
  compact_index (~> 0.15)
8
8
  confstruct (~> 1.1)
9
- erubis (~> 2.7)
10
- httpclient (~> 2.8)
11
9
  logger (> 0)
12
10
  mutex_m (> 0)
13
11
  ostruct (> 0)
14
12
  parallel (~> 1.21)
13
+ puma (~> 6.4)
14
+ rackup (~> 2.2)
15
15
  rubygems-generate_index (> 0)
16
- sinatra (>= 3.1, < 4.0)
17
- slop (~> 3.6)
16
+ sinatra (~> 4.0)
18
17
  stringio (> 0)
19
- thin (~> 1.8)
20
18
 
21
19
  GEM
22
20
  remote: https://rubygems.org/
23
21
  specs:
24
- addressable (2.8.7)
25
- public_suffix (>= 2.0.2, < 7.0)
26
- ast (2.4.2)
27
- base64 (0.2.0)
22
+ addressable (2.9.0)
23
+ public_suffix (>= 2.0.2, < 8.0)
24
+ ast (2.4.3)
25
+ base64 (0.3.0)
26
+ bigdecimal (4.1.2)
28
27
  builder (3.3.0)
29
28
  compact_index (0.15.0)
30
29
  confstruct (1.1.0)
31
30
  hashie (>= 3.3, < 5)
32
- daemons (1.4.1)
33
- diff-lcs (1.5.1)
31
+ crack (1.0.1)
32
+ bigdecimal
33
+ rexml
34
+ diff-lcs (1.6.2)
34
35
  docile (1.4.1)
35
- erubis (2.7.0)
36
- eventmachine (1.2.7)
37
36
  fakefs (2.8.0)
37
+ hashdiff (1.2.1)
38
38
  hashie (4.1.0)
39
- httpclient (2.8.3)
40
- json (2.9.1)
41
- language_server-protocol (3.17.0.3)
42
- logger (1.6.5)
43
- mustermann (3.0.3)
44
- ruby2_keywords (~> 0.0.1)
39
+ json (2.21.2)
40
+ language_server-protocol (3.17.0.6)
41
+ lint_roller (1.1.0)
42
+ logger (1.7.0)
43
+ mustermann (3.1.1)
45
44
  mutex_m (0.3.0)
46
- ostruct (0.6.1)
47
- parallel (1.26.3)
48
- parser (3.3.7.0)
45
+ nio4r (2.7.5)
46
+ ostruct (0.6.3)
47
+ parallel (1.28.0)
48
+ parser (3.3.12.0)
49
49
  ast (~> 2.4.1)
50
50
  racc
51
- public_suffix (6.0.1)
51
+ prism (1.9.0)
52
+ public_suffix (7.0.5)
53
+ puma (6.6.1)
54
+ nio4r (~> 2.0)
52
55
  racc (1.8.1)
53
- rack (2.2.14)
54
- rack-protection (3.2.0)
56
+ rack (3.2.7)
57
+ rack-protection (4.2.1)
55
58
  base64 (>= 0.1.0)
56
- rack (~> 2.2, >= 2.2.4)
57
- rack-test (1.1.0)
58
- rack (>= 1.0, < 3)
59
+ logger (>= 1.6.0)
60
+ rack (>= 3.0.0, < 4)
61
+ rack-session (2.1.2)
62
+ base64 (>= 0.1.0)
63
+ rack (>= 3.0.0)
64
+ rack-test (2.2.0)
65
+ rack (>= 1.3)
66
+ rackup (2.3.1)
67
+ rack (>= 3)
59
68
  rainbow (3.1.1)
60
- rake (13.2.1)
61
- regexp_parser (2.10.0)
62
- rspec (3.13.0)
69
+ rake (13.4.2)
70
+ regexp_parser (2.12.0)
71
+ rexml (3.4.4)
72
+ rspec (3.13.2)
63
73
  rspec-core (~> 3.13.0)
64
74
  rspec-expectations (~> 3.13.0)
65
75
  rspec-mocks (~> 3.13.0)
66
- rspec-core (3.13.2)
76
+ rspec-core (3.13.6)
67
77
  rspec-support (~> 3.13.0)
68
- rspec-expectations (3.13.3)
78
+ rspec-expectations (3.13.5)
69
79
  diff-lcs (>= 1.2.0, < 2.0)
70
80
  rspec-support (~> 3.13.0)
71
- rspec-mocks (3.13.2)
81
+ rspec-mocks (3.13.8)
72
82
  diff-lcs (>= 1.2.0, < 2.0)
73
83
  rspec-support (~> 3.13.0)
74
- rspec-support (3.13.2)
75
- rubocop (1.70.0)
76
- json (~> 2.3)
77
- language_server-protocol (>= 3.17.0)
78
- parallel (~> 1.10)
84
+ rspec-support (3.13.7)
85
+ rubocop (1.90.0)
86
+ json (>= 2.3)
87
+ language_server-protocol (~> 3.17.0.2)
88
+ lint_roller (~> 1.1.0)
89
+ parallel (>= 1.10)
79
90
  parser (>= 3.3.0.2)
80
91
  rainbow (>= 2.2.2, < 4.0)
81
92
  regexp_parser (>= 2.9.3, < 3.0)
82
- rubocop-ast (>= 1.36.2, < 2.0)
93
+ rubocop-ast (>= 1.49.0, < 2.0)
83
94
  ruby-progressbar (~> 1.7)
84
95
  unicode-display_width (>= 2.4.0, < 4.0)
85
- rubocop-ast (1.37.0)
86
- parser (>= 3.3.1.0)
96
+ rubocop-ast (1.50.0)
97
+ parser (>= 3.3.7.2)
98
+ prism (~> 1.7)
87
99
  ruby-progressbar (1.13.0)
88
- ruby2_keywords (0.0.5)
89
- rubygems-generate_index (1.1.3)
90
- compact_index (~> 0.15.0)
100
+ rubygems-generate_index (1.2.0)
91
101
  simplecov (0.22.0)
92
102
  docile (~> 1.1)
93
103
  simplecov-html (~> 0.11)
94
104
  simplecov_json_formatter (~> 0.1)
95
- simplecov-html (0.13.1)
105
+ simplecov-html (0.13.2)
96
106
  simplecov_json_formatter (0.1.4)
97
- sinatra (3.2.0)
107
+ sinatra (4.2.1)
108
+ logger (>= 1.6.0)
98
109
  mustermann (~> 3.0)
99
- rack (~> 2.2, >= 2.2.4)
100
- rack-protection (= 3.2.0)
110
+ rack (>= 3.0.0, < 4)
111
+ rack-protection (= 4.2.1)
112
+ rack-session (>= 2.0.0, < 3)
101
113
  tilt (~> 2.0)
102
- slop (3.6.0)
103
- stringio (3.1.2)
104
- thin (1.8.2)
105
- daemons (~> 1.0, >= 1.0.9)
106
- eventmachine (~> 1.0, >= 1.0.4)
107
- rack (>= 1, < 3)
108
- tilt (2.6.0)
109
- unicode-display_width (3.1.4)
110
- unicode-emoji (~> 4.0, >= 4.0.4)
111
- unicode-emoji (4.0.4)
114
+ stringio (3.2.0)
115
+ tilt (2.9.0)
116
+ unicode-display_width (3.2.0)
117
+ unicode-emoji (~> 4.1)
118
+ unicode-emoji (4.2.0)
119
+ webmock (3.26.4)
120
+ addressable (>= 2.8.0)
121
+ crack (>= 0.3.2)
122
+ hashdiff (>= 0.4.0, < 2.0.0)
112
123
 
113
124
  PLATFORMS
114
125
  ruby
@@ -116,11 +127,12 @@ PLATFORMS
116
127
  DEPENDENCIES
117
128
  fakefs (~> 2)
118
129
  gemirro!
119
- rack-test (~> 1.1)
130
+ rack-test (~> 2.1)
120
131
  rake (~> 13)
121
132
  rspec (~> 3.10)
122
133
  rubocop (~> 1)
123
134
  simplecov (~> 0.21)
135
+ webmock (~> 3.24)
124
136
 
125
137
  BUNDLED WITH
126
138
  2.5.16
data/bin/gemirro CHANGED
@@ -3,11 +3,4 @@
3
3
 
4
4
  require File.expand_path('../../lib/gemirro', __FILE__)
5
5
 
6
- options = Gemirro::CLI.options
7
-
8
- begin
9
- puts options if options.parse.empty?
10
- rescue Slop::InvalidOptionError => e
11
- puts e.message
12
- puts options
13
- end
6
+ Gemirro::CLI.run(ARGV)
data/gemirro.gemspec CHANGED
@@ -16,23 +16,21 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n")
18
18
 
19
- s.required_ruby_version = '>= 3.0'
19
+ s.required_ruby_version = '>= 3.2'
20
20
 
21
21
  s.add_dependency 'addressable', '~>2.8'
22
22
  s.add_dependency 'builder', '~>3.2'
23
23
  s.add_dependency 'compact_index', '~> 0.15'
24
24
  s.add_dependency 'confstruct', '~>1.1'
25
- s.add_dependency 'erubis', '~>2.7'
26
- s.add_dependency 'httpclient', '~>2.8'
27
25
  s.add_dependency 'logger', '> 0' # stdlib
28
26
  s.add_dependency 'mutex_m', '> 0' # stdlib
29
27
  s.add_dependency 'ostruct', '> 0' # stdlib
30
28
  s.add_dependency 'parallel', '~>1.21'
29
+ s.add_dependency 'puma', '~> 6.4'
30
+ s.add_dependency 'rackup', '~> 2.2'
31
31
  s.add_dependency 'rubygems-generate_index', '> 0' # stdlib
32
- s.add_dependency 'sinatra', '>=3.1', '<4.0'
33
- s.add_dependency 'slop', '~>3.6'
32
+ s.add_dependency 'sinatra', '~> 4.0'
34
33
  s.add_dependency 'stringio', '> 0' # stdlib
35
- s.add_dependency 'thin', '~>1.8'
36
34
 
37
35
  s.metadata['rubygems_mfa_required'] = 'true'
38
36
  end
@@ -1,39 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Gemirro::CLI.options.command 'index' do
4
- banner 'Usage: gemirro index [OPTIONS]'
5
- description 'Retrieve specs list from source.'
6
- separator "\nOptions:\n"
3
+ module Gemirro
4
+ module CLI
5
+ # `gemirro index` command
6
+ module IndexCommand
7
+ ##
8
+ # @param [Array] argv
9
+ #
10
+ def self.run(argv)
11
+ options = {}
12
+ option_parser(options).parse!(argv)
7
13
 
8
- on :c=, :config=, 'Path to the configuration file'
9
- on :l=, :log_level=, 'Set logger level'
10
- on :u, :update, 'Update only'
14
+ Gemirro::CLI.load_configuration(options[:config])
15
+ config = Gemirro.configuration
16
+ config.logger_level = options[:log_level] if options[:log_level]
17
+ Gemirro::CLI.ensure_destination!(config)
11
18
 
12
- run do |opts, _args|
13
- Gemirro::CLI.load_configuration(opts[:c])
14
- config = Gemirro.configuration
15
- config.logger_level = opts[:l] if opts[:l]
19
+ indexer = Gemirro::Indexer.new
20
+ indexer.ui = ::Gem::SilentUI.new
16
21
 
17
- unless File.directory?(config.destination)
18
- config.logger.error("The directory #{config.destination} does not exist")
19
- abort
20
- end
22
+ if File.exist?(File.join(config.versions_file))
23
+ indexer.download_source_versions
24
+ if options[:update]
25
+ config.logger.info('Generating index updates')
26
+ indexer.update_index
27
+ else
28
+ config.logger.info('Generating indexes')
29
+ indexer.generate_index
30
+ end
31
+ else
32
+ config.logger.error("#{File.basename(config.versions_file)} file is missing.")
33
+ config.logger.error('Run "gemirro update" before running index.')
34
+ end
35
+ end
21
36
 
22
- indexer = Gemirro::Indexer.new
23
- indexer.ui = Gem::SilentUI.new
37
+ ##
38
+ # @param [Hash] options
39
+ # @return [OptionParser]
40
+ #
41
+ def self.option_parser(options)
42
+ OptionParser.new do |opts|
43
+ opts.banner = 'Usage: gemirro index [OPTIONS]'
44
+ opts.separator ''
45
+ opts.separator 'Options:'
46
+ opts.separator ''
24
47
 
25
- if File.exist?(File.join(config.versions_file))
26
- indexer.download_source_versions
27
- if opts[:u]
28
- config.logger.info('Generating index updates')
29
- indexer.update_index
30
- else
31
- config.logger.info('Generating indexes')
32
- indexer.generate_index
48
+ opts.on('-c', '--config CONFIG', 'Path to the configuration file') { |v| options[:config] = v }
49
+ opts.on('-l', '--log_level LEVEL', 'Set logger level') { |v| options[:log_level] = v }
50
+ opts.on('-u', '--update', 'Update only') { options[:update] = true }
51
+ opts.on('-h', '--help', 'Display this help message.') do
52
+ puts opts
53
+ exit
54
+ end
55
+ end
33
56
  end
34
- else
35
- config.logger.error("#{File.basename(config.versions_file)} file is missing.")
36
- config.logger.error('Run "gemirro update" before running index.')
37
57
  end
38
58
  end
39
59
  end
@@ -1,31 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Gemirro::CLI.options.command 'init' do
4
- banner 'Usage: gemirro init [DIRECTORY] [OPTIONS]'
5
- description 'Sets up a new mirror'
6
- separator "\nOptions:\n"
7
-
8
- on :force, 'Force overwrite'
9
-
10
- run do |opts, args|
11
- directory = File.expand_path(args[0] || Dir.pwd)
12
- template = Gemirro::Configuration.template_directory
13
-
14
- Dir.mkdir(directory) unless File.directory?(directory)
15
-
16
- if opts[:force]
17
- FileUtils.cp_r(File.join(template, '.'), directory)
18
- else
19
- Dir.glob("#{template}/**/*", File::FNM_DOTMATCH).each do |file|
20
- next if ['.', '..'].include?(File.basename(file))
21
-
22
- dest = File.join(directory, file.gsub(/^#{template}/, ''))
23
- next if File.exist?(dest) && dest !~ /gemirro.css/
3
+ module Gemirro
4
+ module CLI
5
+ # `gemirro init` command
6
+ module InitCommand
7
+ ##
8
+ # @param [Array] argv
9
+ #
10
+ def self.run(argv)
11
+ options = {}
12
+ option_parser(options).parse!(argv)
13
+
14
+ directory = File.expand_path(argv[0] || Dir.pwd)
15
+ template = Gemirro::Configuration.template_directory
16
+
17
+ Dir.mkdir(directory) unless File.directory?(directory)
18
+
19
+ if options[:force]
20
+ FileUtils.cp_r(File.join(template, '.'), directory)
21
+ else
22
+ Dir.glob("#{template}/**/*", File::FNM_DOTMATCH).each do |file|
23
+ next if ['.', '..'].include?(File.basename(file))
24
+
25
+ dest = File.join(directory, file.gsub(/^#{template}/, ''))
26
+ next if File.exist?(dest) && dest !~ /gemirro.css/
27
+
28
+ FileUtils.cp_r(file, dest)
29
+ end
30
+ end
31
+
32
+ puts "Initialized empty mirror in #{directory}"
33
+ end
24
34
 
25
- FileUtils.cp_r(file, dest)
35
+ ##
36
+ # @param [Hash] options
37
+ # @return [OptionParser]
38
+ #
39
+ def self.option_parser(options)
40
+ OptionParser.new do |opts|
41
+ opts.banner = 'Usage: gemirro init [DIRECTORY] [OPTIONS]'
42
+ opts.separator ''
43
+ opts.separator 'Options:'
44
+ opts.separator ''
45
+
46
+ opts.on('--force', 'Force overwrite') { options[:force] = true }
47
+ opts.on('-h', '--help', 'Display this help message.') do
48
+ puts opts
49
+ exit
50
+ end
51
+ end
26
52
  end
27
53
  end
28
-
29
- puts "Initialized empty mirror in #{directory}"
30
54
  end
31
55
  end
@@ -1,26 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Gemirro::CLI.options.command 'list' do
4
- banner 'Usage: gemirro list [OPTIONS]'
5
- description 'List available gems.'
6
- separator "\nOptions:\n"
3
+ module Gemirro
4
+ module CLI
5
+ # `gemirro list` command
6
+ module ListCommand
7
+ ##
8
+ # @param [Array] argv
9
+ #
10
+ def self.run(argv)
11
+ options = {}
12
+ option_parser(options).parse!(argv)
7
13
 
8
- on :c=, :config=, 'Path to the configuration file'
9
- on :l=, :log_level=, 'Set logger level'
14
+ Gemirro::CLI.load_configuration(options[:config])
15
+ config = Gemirro.configuration
16
+ config.logger_level = options[:log_level] if options[:log_level]
17
+ Gemirro::CLI.ensure_destination!(config)
10
18
 
11
- run do |opts, _args|
12
- Gemirro::CLI.load_configuration(opts[:c])
13
- config = Gemirro.configuration
14
- config.logger_level = opts[:l] if opts[:l]
19
+ gems = Gemirro::Utils.gems_collection.group_by(&:name).sort
20
+ gems.each do |name, versions|
21
+ puts "#{name}: (#{versions.map(&:number).join(', ')})"
22
+ end
23
+ end
15
24
 
16
- unless File.directory?(config.destination)
17
- config.logger.error("The directory #{config.destination} does not exist")
18
- abort
19
- end
25
+ ##
26
+ # @param [Hash] options
27
+ # @return [OptionParser]
28
+ #
29
+ def self.option_parser(options)
30
+ OptionParser.new do |opts|
31
+ opts.banner = 'Usage: gemirro list [OPTIONS]'
32
+ opts.separator ''
33
+ opts.separator 'Options:'
34
+ opts.separator ''
20
35
 
21
- gems = Gemirro::Utils.gems_collection.group_by(&:name).sort
22
- gems.each do |name, versions|
23
- puts "#{name}: (#{versions.map(&:number).join(', ')})"
36
+ opts.on('-c', '--config CONFIG', 'Path to the configuration file') { |v| options[:config] = v }
37
+ opts.on('-l', '--log_level LEVEL', 'Set logger level') { |v| options[:log_level] = v }
38
+ opts.on('-h', '--help', 'Display this help message.') do
39
+ puts opts
40
+ exit
41
+ end
42
+ end
43
+ end
24
44
  end
25
45
  end
26
46
  end