gemstash 1.0.4 → 1.1.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.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +33 -0
  3. data/lib/gemstash.rb +2 -0
  4. data/lib/gemstash/api_key_authorization.rb +29 -0
  5. data/lib/gemstash/authorization.rb +5 -1
  6. data/lib/gemstash/cli/authorize.rb +1 -1
  7. data/lib/gemstash/cli/setup.rb +50 -37
  8. data/lib/gemstash/cli/start.rb +1 -1
  9. data/lib/gemstash/config.ru +1 -0
  10. data/lib/gemstash/configuration.rb +35 -3
  11. data/lib/gemstash/db/version.rb +11 -0
  12. data/lib/gemstash/env.rb +16 -10
  13. data/lib/gemstash/gem_fetcher.rb +1 -1
  14. data/lib/gemstash/gem_pusher.rb +15 -17
  15. data/lib/gemstash/gem_source/private_source.rb +29 -44
  16. data/lib/gemstash/gem_source/upstream_source.rb +4 -4
  17. data/lib/gemstash/gem_unyanker.rb +10 -4
  18. data/lib/gemstash/gem_yanker.rb +10 -4
  19. data/lib/gemstash/health.rb +53 -0
  20. data/lib/gemstash/http_client.rb +5 -3
  21. data/lib/gemstash/logging.rb +1 -1
  22. data/lib/gemstash/man/gemstash-authorize.1 +6 -5
  23. data/lib/gemstash/man/gemstash-authorize.1.txt +14 -13
  24. data/lib/gemstash/man/gemstash-configuration.5 +90 -8
  25. data/lib/gemstash/man/gemstash-configuration.5.txt +82 -6
  26. data/lib/gemstash/man/gemstash-customize.7 +68 -12
  27. data/lib/gemstash/man/gemstash-customize.7.txt +64 -26
  28. data/lib/gemstash/man/gemstash-debugging.7 +1 -1
  29. data/lib/gemstash/man/gemstash-deploy.7 +33 -1
  30. data/lib/gemstash/man/gemstash-deploy.7.txt +25 -0
  31. data/lib/gemstash/man/gemstash-mirror.7 +1 -1
  32. data/lib/gemstash/man/gemstash-multiple-sources.7 +1 -1
  33. data/lib/gemstash/man/gemstash-private-gems.7 +52 -3
  34. data/lib/gemstash/man/gemstash-private-gems.7.txt +39 -4
  35. data/lib/gemstash/man/gemstash-readme.7 +34 -4
  36. data/lib/gemstash/man/gemstash-readme.7.txt +34 -12
  37. data/lib/gemstash/man/gemstash-setup.1 +3 -1
  38. data/lib/gemstash/man/gemstash-setup.1.txt +3 -1
  39. data/lib/gemstash/man/gemstash-start.1 +4 -3
  40. data/lib/gemstash/man/gemstash-start.1.txt +5 -4
  41. data/lib/gemstash/man/gemstash-status.1 +4 -3
  42. data/lib/gemstash/man/gemstash-status.1.txt +3 -2
  43. data/lib/gemstash/man/gemstash-stop.1 +4 -3
  44. data/lib/gemstash/man/gemstash-stop.1.txt +3 -2
  45. data/lib/gemstash/man/gemstash-version.1 +1 -1
  46. data/lib/gemstash/puma.rb +2 -2
  47. data/lib/gemstash/specs_builder.rb +14 -16
  48. data/lib/gemstash/version.rb +1 -1
  49. metadata +29 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4c86611f04efabc000653d70884cd2cad313b98a
4
- data.tar.gz: 9d720ecfb8eafa60ec05829d8beb2c92b50b88c6
2
+ SHA256:
3
+ metadata.gz: 653074694a6da8d9a0d09699993e21229de4676097e5cc930ffbd6110898a6cf
4
+ data.tar.gz: 62e548f1804f1da0d2709fb725186ad8a811f608c8e9d6a5f2567307295136f6
5
5
  SHA512:
6
- metadata.gz: 99decbbafb9c1062cbdd600f7e45cec081121f6925dd4171ed2304899e102cb134805e1dd23182c2f6987406346663a19c9db49cbc3d95c6cbb781027a21bc6a
7
- data.tar.gz: 05de14fa477ee16db9c0c1f249cf6c1efad0e5f1785a5154ae9e1ad23fcc3b5cde465cc9b24218132ca39fcda7cf28ebe1f243abf3d53cc2a67aae07204ff431
6
+ metadata.gz: d378ab9b7674da573af0fd96fd0c22d8070cdc0f0e7e02c9efd4f22cff6723e28892b28067c64ed740ad18f2add456542ff16274a5f6c318840afb3d35eb2737
7
+ data.tar.gz: 61d2a82b279c024f9e89d3aa037c967af91a47ae99b4f28da26e93a759cf9e7459d09738385f9715b29191fd92046c56f05cbc01428a0a63977ff01bbc89084b
@@ -1,3 +1,36 @@
1
+ ## 1.1.0 (2017-07-31)
2
+
3
+ ### Bugfixes
4
+
5
+ - Gracefully handle empty configuration files ([#97](https://github.com/bundler/gemstash/pull/97), [@rjocoleman](https://github.com/rjocoleman))
6
+ - Remove bundler-audit since we don't commit our Gemfile.lock ([#98](https://github.com/bundler/gemstash/pull/98), [@smellsblue](https://github.com/smellsblue))
7
+ - Clarify what is being cached for 30 minutes ([#108](https://github.com/bundler/gemstash/pull/108), [@Nowaker](https://github.com/Nowaker))
8
+ - Update documentation ([#112](https://github.com/bundler/gemstash/pull/112), [@smellsblue](https://github.com/smellsblue))
9
+ - Integration tests for searching for gems ([#113](https://github.com/bundler/gemstash/pull/113), [@smellsblue](https://github.com/smellsblue))
10
+ - Add `ruby-head` Gemfile for Travis ([#121](https://github.com/bundler/gemstash/pull/121), [@olleolleolle](https://github.com/olleolleolle))
11
+ - Make all Pandoc filters executable ([#122](https://github.com/bundler/gemstash/pull/122), [@olleolleolle](https://github.com/olleolleolle))
12
+ - Fix `rake doc` to work with newer versions of Pandoc ([#124](https://github.com/bundler/gemstash/pull/124), [@smellsblue](https://github.com/smellsblue))
13
+ - Use `curl` since `unyank` is removed in newer RubyGems versions ([#125](https://github.com/bundler/gemstash/pull/125), [@smellsblue](https://github.com/smellsblue))
14
+ - Touch up docs and update CHANGELOG ([#128](https://github.com/bundler/gemstash/pull/128), [@smellsblue](https://github.com/smellsblue))
15
+ - Update Travis to use ruby `2.3.3` ([#127](https://github.com/bundler/gemstash/pull/127), [@olleolleolle](https://github.com/olleolleolle))
16
+ - Add Ruby `2.4.0` to Travis ([#132](https://github.com/bundler/gemstash/pull/132), [@thedrow](https://github.com/thedrow))
17
+
18
+ ### Features
19
+
20
+ - Add support for mysql2 adapter ([#71](https://github.com/bundler/gemstash/pull/71), [@chriseckhardt](https://github.com/chriseckhardt))
21
+ - Allow logging to a different file ([#74](https://github.com/bundler/gemstash/pull/74), [@mrchucho](https://github.com/mrchucho))
22
+ - Document temporary protected fetch solution ([#80](https://github.com/bundler/gemstash/pull/80), [@taoza](https://github.com/taoza))
23
+ - Make gem fetch timeout configurable ([#81](https://github.com/bundler/gemstash/pull/81), [@midwire](https://github.com/midwire))
24
+ - Document fallback timeout for when Gemstash is down ([#88](https://github.com/bundler/gemstash/pull/88), [@parndt](https://github.com/parndt))
25
+ - Allow ERB parsed config file via `.erb` extension ([#90](https://github.com/bundler/gemstash/pull/90), [@jiexinhuang](https://github.com/jiexinhuang), [@rjocoleman](https://github.com/rjocoleman))
26
+ - Improve code climate ([#92](https://github.com/bundler/gemstash/pull/92), [@smellsblue](https://github.com/smellsblue))
27
+ - Refactor authorization ([#93](https://github.com/bundler/gemstash/pull/93), [@smellsblue](https://github.com/smellsblue), [@rjocoleman](https://github.com/rjocoleman))
28
+ - Add protected fetch for private gems ([#94](https://github.com/bundler/gemstash/pull/94), [@rjocoleman](https://github.com/rjocoleman))
29
+ - Add Ruby Together call to action ([#116](https://github.com/bundler/gemstash/pull/116), [@mrb](https://github.com/mrb))
30
+ - Configurable options to `Sequel.connect` ([#123](https://github.com/bundler/gemstash/pull/123), [@olleolleolle](https://github.com/olleolleolle))
31
+ - Support the `latest_specs.4.8.gz` endpoint for private gems ([#131](https://github.com/bundler/gemstash/pull/131), [@randycoulman](https://github.com/randycoulman))
32
+ - Merge in the latest 1.0 stable ([#136](https://github.com/bundler/gemstash/pull/136), [@smellsblue](https://github.com/smellsblue), [@randycoulman](https://github.com/randycoulman))
33
+
1
34
  ## 1.0.4 (2017-01-27)
2
35
 
3
36
  ### Features
@@ -1,5 +1,6 @@
1
1
  #:nodoc:
2
2
  module Gemstash
3
+ autoload :ApiKeyAuthorization, "gemstash/api_key_authorization"
3
4
  autoload :Authorization, "gemstash/authorization"
4
5
  autoload :DB, "gemstash/db"
5
6
  autoload :Cache, "gemstash/cache"
@@ -12,6 +13,7 @@ module Gemstash
12
13
  autoload :GemSource, "gemstash/gem_source"
13
14
  autoload :GemUnyanker, "gemstash/gem_unyanker"
14
15
  autoload :GemYanker, "gemstash/gem_yanker"
16
+ autoload :Health, "gemstash/health"
15
17
  autoload :HTTPClient, "gemstash/http_client"
16
18
  autoload :Logging, "gemstash/logging"
17
19
  autoload :LruReduxClient, "gemstash/cache"
@@ -0,0 +1,29 @@
1
+ require "gemstash"
2
+
3
+ module Gemstash
4
+ # Authorize actions via an API key and Gemstash::Authorization.
5
+ class ApiKeyAuthorization
6
+ def initialize(key)
7
+ @key = key
8
+ end
9
+
10
+ def self.protect(app, &block)
11
+ key = parse_authorization(app.request.env)
12
+ app.auth = new(key)
13
+ yield
14
+ rescue Gemstash::NotAuthorizedError => e
15
+ app.headers["WWW-Authenticate"] = "Basic realm=\"Gemstash Private Gems\""
16
+ app.halt 401, e.message
17
+ end
18
+
19
+ def self.parse_authorization(request_env)
20
+ http_auth = Rack::Auth::Basic::Request.new(request_env)
21
+ return http_auth.credentials.first if http_auth.provided? && http_auth.basic?
22
+ request_env["HTTP_AUTHORIZATION"]
23
+ end
24
+
25
+ def check(permission)
26
+ Gemstash::Authorization.check(@key, permission)
27
+ end
28
+ end
29
+ end
@@ -9,7 +9,7 @@ module Gemstash
9
9
  class Authorization
10
10
  extend Gemstash::Env::Helper
11
11
  extend Gemstash::Logging
12
- VALID_PERMISSIONS = %w(push yank unyank).freeze
12
+ VALID_PERMISSIONS = %w(push yank unyank fetch).freeze
13
13
 
14
14
  def self.authorize(auth_key, permissions)
15
15
  raise "Authorization key is required!" if auth_key.to_s.strip.empty?
@@ -83,5 +83,9 @@ module Gemstash
83
83
  def unyank?
84
84
  can?("unyank")
85
85
  end
86
+
87
+ def fetch?
88
+ can?("fetch")
89
+ end
86
90
  end
87
91
  end
@@ -20,7 +20,7 @@ module Gemstash
20
20
  private
21
21
 
22
22
  def setup_logging
23
- Gemstash::Logging.setup_logger(gemstash_env.base_file("server.log"))
23
+ Gemstash::Logging.setup_logger(gemstash_env.log_file)
24
24
  end
25
25
 
26
26
  def remove_authorization
@@ -22,6 +22,8 @@ module Gemstash
22
22
  ask_storage
23
23
  ask_cache
24
24
  ask_database
25
+ ask_protected_fetch
26
+ ask_timeout
25
27
  check_cache
26
28
  check_storage
27
29
  check_database
@@ -45,6 +47,22 @@ module Gemstash
45
47
  @cli.say "#{label}: #{gemstash_env.config[option]}"
46
48
  end
47
49
 
50
+ def ask_with_default(prompt, options, default)
51
+ raise "The options must all be lower case" if options.any? {|x| x.downcase != x }
52
+ result = nil
53
+ displayed_options = options.map {|x| x == default ? x.upcase : x }
54
+ prompt = "#{prompt} [#{displayed_options.join(", ")}]"
55
+
56
+ until result
57
+ result = @cli.ask prompt
58
+ result = result.downcase
59
+ result = default if result.empty?
60
+ result = nil unless options.include?(result)
61
+ end
62
+
63
+ result
64
+ end
65
+
48
66
  def ask_storage
49
67
  say_current_config(:base_path, "Current base path")
50
68
  path = @cli.ask "Where should files go? [~/.gemstash]", path: true
@@ -54,18 +72,8 @@ module Gemstash
54
72
 
55
73
  def ask_cache
56
74
  say_current_config(:cache_type, "Current cache")
57
- options = %w(memory memcached)
58
- cache = nil
59
-
60
- until cache
61
- cache = @cli.ask "Cache with what? [MEMORY, memcached]"
62
- cache = cache.downcase
63
- cache = "memory" if cache.empty?
64
- cache = nil unless options.include?(cache)
65
- end
66
-
67
- @config[:cache_type] = cache
68
- ask_memcached_details if cache == "memcached"
75
+ @config[:cache_type] = ask_with_default("Cache with what?", %w(memory memcached), "memory")
76
+ ask_memcached_details if @config[:cache_type] == "memcached"
69
77
  end
70
78
 
71
79
  def ask_memcached_details
@@ -77,27 +85,17 @@ module Gemstash
77
85
 
78
86
  def ask_database
79
87
  say_current_config(:db_adapter, "Current database adapter")
80
- options = %w(sqlite3 postgres mysql)
81
- database = nil
82
-
83
- until database
84
- database = @cli.ask "What database adapter? [SQLITE3, postgres, mysql]"
85
- database = database.downcase
86
- database = "sqlite3" if database.empty?
87
- database = nil unless options.include?(database)
88
- end
89
-
90
- @config[:db_adapter] = database
91
- ask_database_details(database) unless database == "sqlite3"
88
+ @config[:db_adapter] = ask_with_default("What database adapter?", %w(sqlite3 postgres mysql mysql2), "sqlite3")
89
+ ask_database_details(@config[:db_adapter]) unless @config[:db_adapter] == "sqlite3"
92
90
  end
93
91
 
94
92
  def ask_database_details(database)
95
93
  say_current_config(:db_url, "Current database url")
96
94
 
97
- if RUBY_PLATFORM == "java"
98
- default_value = "jdbc:#{database}:///gemstash"
95
+ default_value = if RUBY_PLATFORM == "java"
96
+ "jdbc:#{database}:///gemstash"
99
97
  else
100
- default_value = "#{database}:///gemstash"
98
+ "#{database}:///gemstash"
101
99
  end
102
100
 
103
101
  url = @cli.ask "Where is the database? [#{default_value}]"
@@ -105,20 +103,27 @@ module Gemstash
105
103
  @config[:db_url] = url
106
104
  end
107
105
 
106
+ def ask_protected_fetch
107
+ say_current_config(:protected_fetch, "Protected Fetch enabled")
108
+
109
+ value = @cli.yes? "Use Protected Fetch for Private Gems? [y/N]"
110
+ value = Gemstash::Configuration::DEFAULTS[:protected_fetch] if value.is_a?(String) && value.empty?
111
+ @config[:protected_fetch] = value
112
+ end
113
+
114
+ def ask_timeout
115
+ say_current_config(:fetch_timeout, "Fetch timeout")
116
+ timeout = @cli.ask "How many seconds to wait when fetching a gem? [20]"
117
+ timeout = Gemstash::Configuration::DEFAULTS[:fetch_timeout] if timeout.to_i < 1
118
+ @config[:fetch_timeout] = timeout.to_i
119
+ end
120
+
108
121
  def check_cache
109
- @cli.say "Checking that the cache is available"
110
- with_new_config { gemstash_env.cache_client.alive! }
111
- rescue => e
112
- say_error "Cache error", e
113
- raise Gemstash::CLI::Error.new(@cli, "The cache is not available")
122
+ try("cache") { gemstash_env.cache_client.alive! }
114
123
  end
115
124
 
116
125
  def check_database
117
- @cli.say "Checking that the database is available"
118
- with_new_config { gemstash_env.db.test_connection }
119
- rescue => e
120
- say_error "Database error", e
121
- raise Gemstash::CLI::Error.new(@cli, "The database is not available")
126
+ try("database") { gemstash_env.db.test_connection }
122
127
  end
123
128
 
124
129
  def check_storage
@@ -168,6 +173,14 @@ module Gemstash
168
173
  ensure
169
174
  gemstash_env.reset
170
175
  end
176
+
177
+ def try(thing)
178
+ @cli.say "Checking that the #{thing} is available"
179
+ with_new_config { yield }
180
+ rescue => e
181
+ say_error "Error checking #{thing}", e
182
+ raise Gemstash::CLI::Error.new(@cli, "The #{thing} is not available")
183
+ end
171
184
  end
172
185
  end
173
186
  end
@@ -18,7 +18,7 @@ module Gemstash
18
18
 
19
19
  def setup_logging
20
20
  return unless daemonize?
21
- Gemstash::Logging.setup_logger(gemstash_env.base_file("server.log"))
21
+ Gemstash::Logging.setup_logger(gemstash_env.log_file)
22
22
  end
23
23
 
24
24
  def store_daemonized
@@ -10,4 +10,5 @@ end
10
10
 
11
11
  use Gemstash::Env::RackMiddleware, Gemstash::Env.current
12
12
  use Gemstash::GemSource::RackMiddleware
13
+ use Gemstash::Health::RackMiddleware
13
14
  run Gemstash::Web.new(gemstash_env: Gemstash::Env.current)
@@ -1,4 +1,5 @@
1
1
  require "yaml"
2
+ require "erb"
2
3
 
3
4
  module Gemstash
4
5
  #:nodoc:
@@ -8,7 +9,12 @@ module Gemstash
8
9
  base_path: File.expand_path("~/.gemstash"),
9
10
  db_adapter: "sqlite3",
10
11
  bind: "tcp://0.0.0.0:9292",
11
- rubygems_url: "https://rubygems.org"
12
+ rubygems_url: "https://rubygems.org",
13
+ protected_fetch: false,
14
+ fetch_timeout: 20,
15
+ # Actual default for db_connection_options is dynamic based on the adapter
16
+ db_connection_options: {},
17
+ puma_threads: 16
12
18
  }.freeze
13
19
 
14
20
  DEFAULT_FILE = File.expand_path("~/.gemstash/config.yml").freeze
@@ -28,10 +34,10 @@ module Gemstash
28
34
  end
29
35
 
30
36
  raise MissingFileError, file if file && !File.exist?(file)
31
- file ||= DEFAULT_FILE
37
+ file ||= default_file
32
38
 
33
39
  if File.exist?(file)
34
- @config = YAML.load_file(file)
40
+ @config = parse_config(file)
35
41
  @config = DEFAULTS.merge(@config)
36
42
  @config.freeze
37
43
  else
@@ -46,5 +52,31 @@ module Gemstash
46
52
  def [](key)
47
53
  @config[key]
48
54
  end
55
+
56
+ # @return [Hash] Sequel connection configuration hash
57
+ def database_connection_config
58
+ case self[:db_adapter]
59
+ when "sqlite3"
60
+ { max_connections: 1 }.merge(self[:db_connection_options])
61
+ when "postgres", "mysql", "mysql2"
62
+ { max_connections: self[:puma_threads] + 1 }.merge(self[:db_connection_options])
63
+ else
64
+ raise "Unsupported DB adapter: '#{self[:db_adapter]}'"
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def default_file
71
+ File.exist?("#{DEFAULT_FILE}.erb") ? "#{DEFAULT_FILE}.erb" : DEFAULT_FILE
72
+ end
73
+
74
+ def parse_config(file)
75
+ if file.end_with?(".erb")
76
+ YAML.load(ERB.new(File.read(file)).result) || {}
77
+ else
78
+ YAML.load_file(file) || {}
79
+ end
80
+ end
49
81
  end
50
82
  end
@@ -19,6 +19,17 @@ module Gemstash
19
19
  [rubygem.name, Gem::Version.new(number), platform]
20
20
  end
21
21
 
22
+ def self.slug(params)
23
+ version = params[:version]
24
+ platform = params[:platform]
25
+
26
+ if platform.to_s.empty?
27
+ version
28
+ else
29
+ "#{version}-#{platform}"
30
+ end
31
+ end
32
+
22
33
  def self.for_spec_collection(prerelease: false, latest: false)
23
34
  versions = where(indexed: true, prerelease: prerelease).association_join(:rubygem)
24
35
  latest ? select_latest(versions) : versions
@@ -31,6 +31,7 @@ module Gemstash
31
31
 
32
32
  def call(env)
33
33
  env["gemstash.env"] = @gemstash_env
34
+ Gemstash::Env.current = @gemstash_env
34
35
  @app.call(env)
35
36
  end
36
37
  end
@@ -55,11 +56,8 @@ module Gemstash
55
56
  end
56
57
 
57
58
  def self.daemonized?
58
- if @daemonized.nil?
59
- raise "Daemonized hasn't been set yet!"
60
- else
61
- @daemonized
62
- end
59
+ raise "Daemonized hasn't been set yet!" if @daemonized.nil?
60
+ @daemonized
63
61
  end
64
62
 
65
63
  def self.daemonized=(value)
@@ -99,6 +97,14 @@ module Gemstash
99
97
  File.join(base_path, path)
100
98
  end
101
99
 
100
+ def log_file
101
+ if config[:log_file] == :stdout
102
+ $stdout
103
+ else
104
+ base_file(config[:log_file] || "server.log")
105
+ end
106
+ end
107
+
102
108
  def atomic_write(file, &block)
103
109
  File.atomic_write(file, File.dirname(file), &block)
104
110
  end
@@ -113,13 +119,13 @@ module Gemstash
113
119
  when "sqlite3"
114
120
  db_path = base_file("gemstash.db")
115
121
 
116
- if RUBY_PLATFORM == "java"
117
- db = Sequel.connect("jdbc:sqlite:#{db_path}", max_connections: 1)
122
+ db = if RUBY_PLATFORM == "java"
123
+ Sequel.connect("jdbc:sqlite:#{db_path}", config.database_connection_config)
118
124
  else
119
- db = Sequel.connect("sqlite://#{URI.escape(db_path)}", max_connections: 1)
125
+ Sequel.connect("sqlite://#{URI.escape(db_path)}", config.database_connection_config)
120
126
  end
121
- when "postgres", "mysql"
122
- db = Sequel.connect(config[:db_url])
127
+ when "postgres", "mysql", "mysql2"
128
+ db = Sequel.connect(config[:db_url], config.database_connection_config)
123
129
  else
124
130
  raise "Unsupported DB adapter: '#{config[:db_adapter]}'"
125
131
  end
@@ -31,7 +31,7 @@ module Gemstash
31
31
  end
32
32
 
33
33
  def filter_headers(headers)
34
- headers.inject({}) do|properties, (key, value)|
34
+ headers.inject({}) do |properties, (key, value)|
35
35
  properties[key.downcase] = value if @valid_headers.include?(key.downcase)
36
36
  properties
37
37
  end
@@ -16,12 +16,17 @@ module Gemstash
16
16
  class YankedVersionError < ExistingVersionError
17
17
  end
18
18
 
19
- def initialize(auth_key, content)
20
- @auth_key = auth_key
19
+ def self.serve(app)
20
+ gem = app.request.body.read
21
+ new(app.auth, gem).serve
22
+ end
23
+
24
+ def initialize(auth, content)
25
+ @auth = auth
21
26
  @content = content
22
27
  end
23
28
 
24
- def push
29
+ def serve
25
30
  check_auth
26
31
  store_gem
27
32
  store_gemspec
@@ -44,7 +49,7 @@ module Gemstash
44
49
  end
45
50
 
46
51
  def check_auth
47
- Gemstash::Authorization.check(@auth_key, "push")
52
+ @auth.check("push")
48
53
  end
49
54
 
50
55
  def store_gem
@@ -64,15 +69,8 @@ module Gemstash
64
69
  gemstash_env.db.transaction do
65
70
  gem_id = Gemstash::DB::Rubygem.find_or_insert(spec)
66
71
  existing = Gemstash::DB::Version.find_by_spec(gem_id, spec)
67
-
68
- if existing
69
- if existing.indexed
70
- raise ExistingVersionError, "Cannot push to an existing version!"
71
- else
72
- raise YankedVersionError, "Cannot push to a yanked version!"
73
- end
74
- end
75
-
72
+ raise ExistingVersionError, "Cannot push to an existing version!" if existing && existing.indexed
73
+ raise YankedVersionError, "Cannot push to a yanked version!" if existing && !existing.indexed
76
74
  version_id = Gemstash::DB::Version.insert_by_spec(gem_id, spec)
77
75
  Gemstash::DB::Dependency.insert_by_spec(version_id, spec)
78
76
  end
@@ -90,14 +88,14 @@ module Gemstash
90
88
  module LegacyRubyGemsSupport
91
89
  def self.included(base)
92
90
  base.class_eval do
93
- alias_method :push_without_cleanup, :push
94
- remove_method :push
91
+ alias_method :serve_without_cleanup, :serve
92
+ remove_method :serve
95
93
  remove_method :gem
96
94
  end
97
95
  end
98
96
 
99
- def push
100
- push_without_cleanup
97
+ def serve
98
+ serve_without_cleanup
101
99
  ensure
102
100
  cleanup
103
101
  end