bundler-pgs 0.7.4 → 0.8.1

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
  SHA1:
3
- metadata.gz: 9c9c0932962d7f6f4104ede28812bc3ea1f5f67e
4
- data.tar.gz: dfd10843086f36d4462a706b2f851760a2058c1c
3
+ metadata.gz: 05f09a50f4d2b609c647a2812a56da73408c6e3f
4
+ data.tar.gz: c3c4c0c739164bd69365b080d814cd3662727c8a
5
5
  SHA512:
6
- metadata.gz: 80f9bbf8819a7b86ebb37746baae9cf021dae4f9bf90a9adbe34001eda4f5dfec28eddf791bd29282b247b5a2c1803e5ce59e7aeeef5629dd17df3191bd1857d
7
- data.tar.gz: b98b694620ac9b14d25faef3c9a42fa36864e22f236daebadf6c127f35c051735ccd0817f4839f21929169dab72137894e99567201efed5a397acc51c1a30a26
6
+ metadata.gz: 35740fcab017a8ca3a287f0b4566c5869fe6715168d9e11f95b02bb1e7ce0442535702c866ca689ff200a229e7525a9e890a748c21c43beed2067d243837a4e4
7
+ data.tar.gz: cd074bbce0092e19a24f6a86c1d6a663976b0d6f1aa2d29982eb0483dae294509f74a5c74111d3fcd8b3c70640d397f7fd78c946a1a544c0a9dbb576e5cf9b10
data/README.md CHANGED
@@ -1,31 +1,30 @@
1
1
  # Bundler Private Gem Server
2
2
 
3
- Patch for bundler to support credentials for sources that are not stored in Gemfile.lock.
4
- Useful when running an additional private gem server besides rubygems.org.
3
+ Patch for bundler to support credentials for sources that are not stored in `Gemfile.lock`.
4
+ Useful when running an additional private gem server besides `rubygems.org`.
5
5
 
6
6
  Example:
7
7
 
8
8
  # Gemfile
9
9
  source "https://rubygems.org/"
10
- source "http://_:_@gems.mycompany.com"
10
+ source "http://_:_@gems.mycompany.com" do
11
+ ...
12
+ end
11
13
 
12
14
  # Gemfile.lock
13
15
  GEM
14
16
  remote: https://rubygems.org/
15
- remote: http://_:_@gems.mycompany.com/
17
+ remote: http://_:_@gems.mycompany.com/ (not http://user:password@gems.mycompany.com)
16
18
 
17
19
  ## Warning
18
20
 
19
21
  This comes with no warranty!
20
22
 
21
- To prevent bundler from storing a source url to your private gem server with credentials I had to **patch** bundler.
22
- See `lib/bundler-pgs/bundler_patch.rb` for details.
23
+ To prevent bundler from storing a source url to your private gem server with credentials
24
+ I **patched** bundler. See `lib/bundler-pgs/bundler_patch.rb` for details.
23
25
 
24
- As long as the internal implementation of fetching a gem from an url does not change everything is fine.
25
- In case a newer version of bundler change this code part the url might be stored in `Gemfile.lock`
26
- with the credentials again.
27
-
28
- bundler-pgs supports bundler 1.7.4 and older.
26
+ `bundle-pgs` will raise an exception in case the patched class and method does not exist
27
+ in `bundler`anymore.
29
28
 
30
29
  ## Usage
31
30
 
@@ -54,7 +53,9 @@ Add your private gem server url with `_` (underscore) as placeholder for the cre
54
53
 
55
54
  # Gemfile
56
55
  source "https://rubygems.org"
57
- source "http://_:_@gems.mycompany.com"
56
+ source "http://_:_@gems.mycompany.com" do
57
+ gem 'my_private_gem'
58
+ end
58
59
 
59
60
  Add your credentials to `~/.gem/gemserver_credential` on **every** server using bundler,
60
61
  e.g. ci, staging and production:
@@ -87,5 +88,5 @@ You will also need to change the bundle command for Capistrano:
87
88
 
88
89
  For comments and question feel free to contact me: business@thomasbaustert.de
89
90
 
90
- Copyright © 2013 [Thomas Baustert](http://thomasbaustert.de), released under the MIT license
91
+ Copyright by [Thomas Baustert](http://thomasbaustert.de), released under the MIT license
91
92
 
@@ -19,7 +19,6 @@ require 'bundler/cli'
19
19
  require 'bundler/friendly_errors'
20
20
 
21
21
  require 'bundler-pgs'
22
- puts "[bundler-pgs] v#{Bundler::Pgs::VERSION} is loaded"
23
- puts "[bundler-pgs] patching bundler"
22
+ puts "[bundler-pgs] v#{Bundler::Pgs::VERSION} is used and patches bundler."
24
23
 
25
24
  Bundler.with_friendly_errors { Bundler::CLI.start }
@@ -1,13 +1,4 @@
1
1
  require 'bundler/version'
2
-
3
- if Bundler::VERSION > "1.7.4"
4
- puts "\nWarning: You are using bundler #{Bundler::VERSION} and bundler-pgs patch might not work for this version."
5
- puts "Make sure your Gemfile.lock does not contain your credentials after running bundle-pgs!"
6
- puts ""
7
- end
8
-
9
2
  require "bundler-pgs/version"
10
- require "bundler-pgs/credential_file"
11
3
  require "bundler-pgs/bundler_patch"
12
- require "bundler-pgs/bundler_dsl_extension"
13
4
 
@@ -1,13 +1,24 @@
1
- require "yaml"
1
+ require 'yaml'
2
2
  require 'bundler'
3
3
 
4
+ module Bundler::Pgs
5
+ class MonkeyPatchFailed < RuntimeError
6
+ def message
7
+ "bundler-pgs #{Bundler::Pgs::VERSION} failed to patch bundler #{Bundler::VERSION}. Cause: #{message}"
8
+ end
9
+ end
10
+ end
11
+
4
12
  ##
5
13
  # Patches Bundler::RubygemsIntegration bundler to use url with the credentials.
6
14
  #
15
+ raise Bundler::Pgs::MonkeyPatchFailed, "Bundler::RubygemsIntegration not defined anymore" unless defined?(Bundler::RubygemsIntegration)
16
+ raise Bundler::Pgs::MonkeyPatchFailed, "Bundler::RubygemsIntegration.download_gem not defined anymore" unless Bundler::RubygemsIntegration.new.respond_to?(:download_gem)
17
+
7
18
  module Bundler
8
19
  class RubygemsIntegration
9
20
  def download_gem(spec, uri, path)
10
- new_uri = ::BundlerPatch::UriResolver.resolve(uri)
21
+ new_uri = ::Bundler::Pgs::UriResolver.resolve(uri)
11
22
  Gem::RemoteFetcher.fetcher.download(spec, new_uri, path)
12
23
  end
13
24
  end
@@ -16,12 +27,14 @@ end
16
27
  ##
17
28
  # Patches Bundler::Fetcher bundler to use url with the credentials.
18
29
  #
30
+ raise Bundler::Pgs::MonkeyPatchFailed, "Bundler::Fetcher not defined anymore" unless defined?(Bundler::Fetcher)
31
+
19
32
  module Bundler
20
33
  class Fetcher
21
34
  alias_method :orig_initialize, :initialize
22
35
 
23
36
  def initialize(remote_uri)
24
- new_uri = ::BundlerPatch::UriResolver.resolve(remote_uri)
37
+ new_uri = ::Bundler::Pgs::UriResolver.resolve(remote_uri)
25
38
  orig_initialize(new_uri)
26
39
  end
27
40
  end
@@ -30,9 +43,8 @@ end
30
43
  ##
31
44
  # Replaces credential placeholder (e.g. http://_:_@....) with the credentials from the credentials file.
32
45
  #
33
- module BundlerPatch
46
+ module Bundler::Pgs
34
47
  class UriResolver
35
- extend BundlerPatch::CredentialFile
36
48
 
37
49
  def self.resolve(uri)
38
50
  if uri_with_hidden_credentials?(uri)
@@ -75,6 +87,13 @@ module BundlerPatch
75
87
  new_uri || orig_uri
76
88
  end
77
89
 
90
+ def self.with_credential_file(&block)
91
+ credential_filename = File.join(ENV["HOME"], ".gem", "gemserver_credentials")
92
+ if File.exists?(credential_filename)
93
+ yield(credential_filename) if block_given?
94
+ end
95
+ end
96
+
78
97
  def self.uri_with_hidden_credentials?(uri)
79
98
  user_exists?(uri) && password_exists?(uri)
80
99
  end
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Pgs
3
- VERSION = "0.7.4"
3
+ VERSION = "0.8.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-pgs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Baustert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,9 +54,7 @@ files:
54
54
  - bin/bundle-pgs
55
55
  - bundler-pgs.gemspec
56
56
  - lib/bundler-pgs.rb
57
- - lib/bundler-pgs/bundler_dsl_extension.rb
58
57
  - lib/bundler-pgs/bundler_patch.rb
59
- - lib/bundler-pgs/credential_file.rb
60
58
  - lib/bundler-pgs/version.rb
61
59
  homepage: https://github.com/thomasbaustert/bundler-pgs
62
60
  licenses: []
@@ -77,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
75
  version: '0'
78
76
  requirements: []
79
77
  rubyforge_project:
80
- rubygems_version: 2.2.2
78
+ rubygems_version: 2.4.6
81
79
  signing_key:
82
80
  specification_version: 4
83
81
  summary: bundler patch to support private gem server (pgs)
@@ -1,22 +0,0 @@
1
- ##
2
- # Extend bundler DSL to allow using convenient method in Gemfile.
3
- # This is optional and not really necessary.
4
- #
5
- # Examples:
6
- # source "https://rubygems.org"
7
- # private_gem_server
8
- # private_gem_server("fooserver")
9
- #
10
- module Bundler
11
- class Dsl
12
- include BundlerPatch::CredentialFile
13
-
14
- def private_gem_server(name = "default")
15
- with_credential_file do |credential_filename|
16
- yaml = YAML.load_file(credential_filename)
17
- yaml[name]["source"].to_s.strip
18
- end
19
- end
20
- end
21
- end
22
-
@@ -1,12 +0,0 @@
1
- module BundlerPatch
2
- module CredentialFile
3
-
4
- def with_credential_file(&block)
5
- credential_filename = File.join(ENV["HOME"], ".gem", "gemserver_credentials")
6
- if File.exists?(credential_filename)
7
- yield(credential_filename) if block_given?
8
- end
9
- end
10
- end
11
-
12
- end