bundler-github 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +31 -6
- data/lib/bundler/github.rb +4 -2
- data/lib/bundler/github/dsl_patch.rb +3 -4
- data/test/bundler_github_test.rb +6 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -19,28 +19,53 @@ Usage
|
|
19
19
|
In your `Gemfile` you can now replace:
|
20
20
|
|
21
21
|
``` ruby
|
22
|
-
gem '
|
22
|
+
gem 'recaptcha', git: 'https://github.com/ambethia/recaptcha.git'
|
23
23
|
```
|
24
24
|
|
25
25
|
with:
|
26
26
|
|
27
27
|
``` ruby
|
28
|
-
gem '
|
28
|
+
gem 'recaptcha', github: 'ambethia/recaptcha'
|
29
29
|
```
|
30
30
|
|
31
31
|
**But wait!** That sugar only gets sweeter! If the repository's name is the same as the gem's name (and it usally is), you can leave out the repo name and just include the repository owner.
|
32
32
|
|
33
33
|
``` ruby
|
34
|
-
gem '
|
34
|
+
gem 'recaptcha', github: 'ambethia'
|
35
35
|
```
|
36
36
|
|
37
37
|
*How you like them apples!?*
|
38
38
|
|
39
|
+
One inconvenience I haven't figured a work around for is that you'll need to explicitly `bundler/github` before you require `bundler/setup`. In a Rails app
|
40
|
+
you might change your `boot.rb` (*oh, the humanity!*) from:
|
41
|
+
|
42
|
+
``` ruby
|
43
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
44
|
+
```
|
45
|
+
|
46
|
+
to look like:
|
47
|
+
|
48
|
+
``` ruby
|
49
|
+
if File.exists?(ENV['BUNDLE_GEMFILE'])
|
50
|
+
require 'bundler/github'
|
51
|
+
require 'bundler/setup'
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
However, you don't *need* to require `bundler-github` from your `Gemfile`, it's already loaded by the time your application's `Gemfile` is read anyways.
|
56
|
+
|
57
|
+
### Private Repositories ###
|
58
|
+
|
59
|
+
By default HTTP transport is used, but you can switch to an authenticated url scheme (ssh) by prepending a `:` to the account name, like:
|
60
|
+
|
61
|
+
``` ruby
|
62
|
+
gem 'has_secrets', github: ':ambethia'
|
63
|
+
```
|
64
|
+
|
39
65
|
### Other notes on usage ###
|
40
66
|
|
41
|
-
* `bundler-github` just expands and swaps the `:github` option out for `:git`, other options, like `:branch`, `:ref`, etc.
|
67
|
+
* `bundler-github` just expands and swaps the `:github` option out for `:git`, other options, like `:branch`, `:ref`, etc. will be left untouched.
|
42
68
|
* I may favor the Ruby 1.9 syntaxes in my examples, but the gem does not. It was developed for and tested against 1.8.7 and 1.9.x.
|
43
|
-
* You should not include `bundler-github` in your `Gemfile`. Bundler is already loaded by the time your application's `Gemfile` is read.
|
44
69
|
|
45
70
|
Caveat emptor!
|
46
71
|
--------------
|
@@ -51,7 +76,7 @@ I have no idea if this is going to work for you, in your environment. It's beta-
|
|
51
76
|
|
52
77
|
The only way I could find to hook in and add the `:github` option was to make my own `bundle` command which replaces the executable generated by Rubygems in your `$PATH`. The new command includes our patch then loads Bunder's original `bundle` command. For a hack, I think it's pretty elegant.
|
53
78
|
|
54
|
-
If you can suggest a better way to hook
|
79
|
+
The unique way bundler is used makes it challenging to extend without any kind of plugin API. If you can suggest a better way to hook it without needing to modify the original gem, I'd love to hear it.
|
55
80
|
|
56
81
|
Copyright
|
57
82
|
---------
|
data/lib/bundler/github.rb
CHANGED
@@ -5,11 +5,13 @@ module Bundler
|
|
5
5
|
|
6
6
|
module Github
|
7
7
|
|
8
|
-
|
8
|
+
HTTP = lambda { |user, repo| "https://github.com/#{user}/#{repo}.git" }
|
9
|
+
SSH = lambda { |user, repo| "git@github.com:#{user}/#{repo}.git" }
|
9
10
|
|
10
11
|
def self.expand_options(name, version, opts)
|
11
12
|
user, repo = opts.delete('github').split('/')
|
12
|
-
|
13
|
+
transport = user =~ /^:/ ? (user.slice!(0); SSH) : HTTP
|
14
|
+
opts['git'] = transport.call(user, repo || name)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Bundler::Github
|
2
2
|
module DslPatch
|
3
3
|
|
4
|
-
# The list of valid options is buried in
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# for :git, with the expanded URI
|
4
|
+
# The list of valid options is buried in this original method, so to add
|
5
|
+
# an option without reimplementing (and duplicating) code, we rescue the
|
6
|
+
# exception, and swap our :github option for :git, with the expanded URI
|
8
7
|
def _normalize_options_with_github(*args)
|
9
8
|
begin
|
10
9
|
_normalize_options_without_github(*args)
|
data/test/bundler_github_test.rb
CHANGED
@@ -7,7 +7,7 @@ class BundlerGithubTest < MiniTest::Unit::TestCase
|
|
7
7
|
# Let's get meta.
|
8
8
|
def setup
|
9
9
|
@gem = @repo = 'bundler-github'
|
10
|
-
@uri = lambda { "
|
10
|
+
@uri = lambda { "https://github.com/ambethia/#{@repo}.git" }
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_expands_uri
|
@@ -28,6 +28,11 @@ class BundlerGithubTest < MiniTest::Unit::TestCase
|
|
28
28
|
assert_equal @uri.call, expand('ambethia')
|
29
29
|
end
|
30
30
|
|
31
|
+
def test_expands_authenticated_uri_with_shh
|
32
|
+
@uri = 'git@github.com:ambethia/bundler-github.git'
|
33
|
+
assert_equal @uri, expand(':ambethia')
|
34
|
+
end
|
35
|
+
|
31
36
|
def expand(repository)
|
32
37
|
{ 'github' => repository }.tap { |opts|
|
33
38
|
Bundler::Github.expand_options(@gem, nil, opts)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bundler-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jason L Perry
|
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
hash:
|
66
|
+
hash: -3869597957558738981
|
67
67
|
segments:
|
68
68
|
- 0
|
69
69
|
version: "0"
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
75
|
+
hash: -3869597957558738981
|
76
76
|
segments:
|
77
77
|
- 0
|
78
78
|
version: "0"
|