bundler-github 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +19 -0
- data/README.md +59 -0
- data/bin/bundle +4 -0
- data/lib/bundler/github.rb +17 -0
- data/lib/bundler/github/dsl_patch.rb +26 -0
- data/test/bundler_github_test.rb +36 -0
- metadata +87 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright 2011 Jason L Perry
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
bundler-github
|
2
|
+
==============
|
3
|
+
|
4
|
+
Use shorthand instead of full Github repository URIs in your `Gemfile`.
|
5
|
+
|
6
|
+
Oh, yes... **syntactic sugars!**
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
``` bash
|
12
|
+
gem install bundler-github
|
13
|
+
```
|
14
|
+
**Note:** Currently, this gem must always be installed *after* Bundler. If you update or re-install Bundler, you'll need to re-install this gem. See the caveat below for details.
|
15
|
+
|
16
|
+
Usage
|
17
|
+
-----
|
18
|
+
|
19
|
+
In your `Gemfile` you can now replace:
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
gem 'devise', git: 'https://github.com/plataformatec/devise.git'
|
23
|
+
```
|
24
|
+
|
25
|
+
with:
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
gem 'devise', github: 'plataformatec/devise'
|
29
|
+
```
|
30
|
+
|
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
|
+
|
33
|
+
``` ruby
|
34
|
+
gem 'devise', github: 'plataformatec'
|
35
|
+
```
|
36
|
+
|
37
|
+
*How you like them apples!?*
|
38
|
+
|
39
|
+
### Other notes on usage ###
|
40
|
+
|
41
|
+
* `bundler-github` just expands and swaps the `:github` option out for `:git`, other options, like `:branch`, `:ref`, etc. should be left untouched.
|
42
|
+
* 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
|
+
|
45
|
+
Caveat emptor!
|
46
|
+
--------------
|
47
|
+
|
48
|
+
> *You coveteth my ice cream bar...*
|
49
|
+
|
50
|
+
I have no idea if this is going to work for you, in your environment. It's beta-quality software, and as such should not be considered production ready.
|
51
|
+
|
52
|
+
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
|
+
|
54
|
+
If you can suggest a better way to hook another gem without needing to modify the original gem or require it somewhere explicitly, I'd love to hear it. The unique way bundler is used makes it challenging to extend without any kind of plugin API.
|
55
|
+
|
56
|
+
Copyright
|
57
|
+
---------
|
58
|
+
|
59
|
+
Copyright © 2011 Jason L Perry. See MIT-LICENSE for the rights reserved.
|
data/bin/bundle
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'bundler/github/dsl_patch'
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
|
6
|
+
module Github
|
7
|
+
|
8
|
+
URI = lambda { |user, repo| "git://github.com/#{user}/#{repo}.git" }
|
9
|
+
|
10
|
+
def self.expand_options(name, version, opts)
|
11
|
+
user, repo = opts.delete('github').split('/')
|
12
|
+
opts['git'] = URI.call(user, repo || name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Bundler::Dsl.send(:include, Bundler::Github::DslPatch)
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Bundler::Github
|
2
|
+
module DslPatch
|
3
|
+
|
4
|
+
# The list of valid options is buried in unfortunately buried in this
|
5
|
+
# original method, so to add an option without reimplementing (and
|
6
|
+
# duplicating) code, we rescue the exception, and swap our :github option
|
7
|
+
# for :git, with the expanded URI
|
8
|
+
def _normalize_options_with_github(*args)
|
9
|
+
begin
|
10
|
+
_normalize_options_without_github(*args)
|
11
|
+
rescue Bundler::InvalidOption => exception
|
12
|
+
if exception.message =~ /:github/
|
13
|
+
Bundler::Github.expand_options(*args)
|
14
|
+
retry
|
15
|
+
else
|
16
|
+
raise exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.included(mod)
|
22
|
+
mod.send :alias_method, :_normalize_options_without_github, :_normalize_options
|
23
|
+
mod.send :alias_method, :_normalize_options, :_normalize_options_with_github
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'bundler/github'
|
4
|
+
|
5
|
+
class BundlerGithubTest < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
# Let's get meta.
|
8
|
+
def setup
|
9
|
+
@gem = @repo = 'bundler-github'
|
10
|
+
@uri = lambda { "git://github.com/ambethia/#{@repo}.git" }
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_expands_uri
|
14
|
+
assert_equal @uri.call, expand('ambethia/bundler-github')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_expands_uri_with_distinct_gem_name
|
18
|
+
@gem = 'bundler_github'
|
19
|
+
assert_equal @uri.call, expand('ambethia/bundler-github')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_expands_uri_with_distinct_repo_name
|
23
|
+
@repo = 'bundler_github'
|
24
|
+
assert_equal @uri.call, expand('ambethia/bundler_github')
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_expands_uri_with_implicit_gem_name
|
28
|
+
assert_equal @uri.call, expand('ambethia')
|
29
|
+
end
|
30
|
+
|
31
|
+
def expand(repository)
|
32
|
+
{ 'github' => repository }.tap { |opts|
|
33
|
+
Bundler::Github.expand_options(@gem, nil, opts)
|
34
|
+
}['git']
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason L Perry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-02 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
description: " A hack for using shorthand like `:github => 'ambethia/recaptcha'` instead\n of a full git repository URI in your Gemfiles\n"
|
38
|
+
email:
|
39
|
+
- jasper@ambethia.com
|
40
|
+
executables:
|
41
|
+
- bundle
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- bin/bundle
|
48
|
+
- lib/bundler/github.rb
|
49
|
+
- lib/bundler/github/dsl_patch.rb
|
50
|
+
- MIT-LICENSE
|
51
|
+
- README.md
|
52
|
+
- test/bundler_github_test.rb
|
53
|
+
homepage: https://github.com/ambethia/bundler-github
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 616532358228670493
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 616532358228670493
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project: bundler-github
|
82
|
+
rubygems_version: 1.8.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Gemfile shorthand for Github repos
|
86
|
+
test_files:
|
87
|
+
- test/bundler_github_test.rb
|