test-gem-push 2023.05.07.16.04.27 → 2023.05.07.22.42.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/app.rb +6 -5
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67da28c3df165b1d05d316cc2a6df364de8ace2377764a5e923efb6b149adcf6
4
- data.tar.gz: 07daf0e274135a4cbc7f703ee1fc0f8ebc68f116db58408ab77e35350d48a913
3
+ metadata.gz: bccefc8f1b3047dcdf8987dc8dcb9282c9be8f23db7babe19d5d1e9bf0668715
4
+ data.tar.gz: 447f6e4db2f4cababbea144807cb770444d568024874cb0eef9e648ea596d387
5
5
  SHA512:
6
- metadata.gz: 06e3612606a448cf6d5365b51784d4ed5c2e61c566f23b611eff9083d35db12c1f1052702108021d4bbfcd2a2ec48246f0f1cdb99be4239a2dbbcafe442fd472
7
- data.tar.gz: 44e25dd056092c6af93e16719741acf10d9f1356d23079b39bc71043bd70b22034ceb9ae77e5e3a8ce2fdb80753a98b22fbb76d7285253fafb847cd8d9b43d43
6
+ metadata.gz: dfbd2b3cae271ae5e7118a91c270c218feb51ed8fab004712620f77970b540576c4abadf89628e33d02bdc28cdf1ddb8fbe8b5e0d598d4597597a7675d651ca9
7
+ data.tar.gz: d1da1f37645c9015d0fcb019ef228a7f069155b080f00bef601976c5bcf196a4b5a8ed95468725cff9f564dacae2708684154d471ba0fe04d54f60f0a5a11b51
data/app.rb CHANGED
@@ -13,13 +13,13 @@ Gem.configuration.rubygems_api_key = ENV.fetch('RUBYGEMS_API_KEY')
13
13
  TOKEN = ENV.fetch('TOKEN')
14
14
 
15
15
  def get_json(host, path)
16
- resp = Net::HTTPS.get_response(host, path, 443)
16
+ resp = Net::HTTP.get_response(host, path, 443)
17
17
  JSON.load(resp.body)
18
18
  rescue => e
19
19
  raise "Failed to load JSON from #{host}#{path}:\n#{e.class}: #{e}\n#{resp.inspect}"
20
20
  end
21
21
 
22
- def push!(name, version, platform)
22
+ def push!(name, version, platform, push_host)
23
23
  spec = Gem::Specification.new do |s|
24
24
  s.name = name
25
25
  s.version = version
@@ -30,9 +30,10 @@ def push!(name, version, platform)
30
30
  s.required_ruby_version = '~> 2.0'
31
31
  s.required_rubygems_version = '~> 2.6'
32
32
  s.add_dependency 'foo', '~> 1.0'
33
+ s.metadata = { 'allowed_push_host' => push_host }
33
34
  end
34
35
  file = Gem::Package.build(spec)
35
- Gem::Commands::PushCommand.new.send_gem(file)
36
+ Gem::Commands::PushCommand.new.tap { |c| c.options[:host] = push_host }.send_gem(file)
36
37
  ensure
37
38
  File.delete(file)
38
39
  end
@@ -53,7 +54,7 @@ post '/' do
53
54
  halt 401, 'token does not match' unless TOKEN == params['token']
54
55
 
55
56
  version = params.fetch('version') { Time.now.strftime('%Y.%m.%d.%H.%M.%S') }
56
- gem_name = ENV.fetch('GEM_NAME')
57
+ gem_name = params.fetch('name') { ENV.fetch('GEM_NAME') }
57
58
  platform = params.fetch('platform') { 'ruby' }
58
59
  platform_string = platform == 'ruby' ? '' : "-#{platform}"
59
60
 
@@ -66,7 +67,7 @@ post '/' do
66
67
  # end
67
68
 
68
69
  begin
69
- push!(gem_name, version, platform)
70
+ push!(gem_name, version, platform, params.fetch('push_host') { 'https://staging.rubygems.org' })
70
71
  rescue Gem::SystemExitException
71
72
  halt 500, "Failed to push: #{$ERROR_INFO}"
72
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-gem-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 2023.05.07.16.04.27
4
+ version: 2023.05.07.22.42.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - example@example.com
@@ -33,7 +33,8 @@ files:
33
33
  - app.rb
34
34
  homepage:
35
35
  licenses: []
36
- metadata: {}
36
+ metadata:
37
+ allowed_push_host: https://rubygems.org
37
38
  post_install_message:
38
39
  rdoc_options: []
39
40
  require_paths: