bundler_local_development 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +89 -0
- data/Rakefile +2 -0
- data/bundler_local_development.gemspec +19 -0
- data/lib/bundler/local_development.rb +44 -0
- data/lib/bundler_local_development.rb +1 -0
- data/lib/bundler_local_development/version.rb +3 -0
- metadata +65 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Nathan Broadbent
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Bundler - Local Development
|
2
|
+
|
3
|
+
### Provides a simple way to switch between local and installed gems.
|
4
|
+
|
5
|
+
Since this gem overrides bundler itself, it is installed and required in an unusual way.
|
6
|
+
It is required *within* your Gemfile, and is not meant to be used in your application.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add these lines to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'bundler_local_development', :group => :development, :require => false
|
13
|
+
begin
|
14
|
+
require 'bundler_local_development'
|
15
|
+
Bundler.development_gems = [/foo/, 'bar', /baz/]
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
* Call `Bundler.development_gems = [...]` in your Gemfile, to configure
|
27
|
+
your default set of local gems.
|
28
|
+
You can provide regular expressions or strings to match gem names.
|
29
|
+
* Set the `$DEV_GEMS` environment variable to add extra gems to this list (comma separated list of gem names).
|
30
|
+
|
31
|
+
If the `$GEM_DEV` environment variable is unset, this gem will have no effect.
|
32
|
+
|
33
|
+
If the `$GEM_DEV` environment variable is set:
|
34
|
+
|
35
|
+
* Bundler will search for local gems in the
|
36
|
+
path specified by `$GEM_DEV_DIR`. (The default search path is `$HOME/code/gems`, if `$GEM_DEV_DIR` is unset.)
|
37
|
+
|
38
|
+
* If a local copy of the gem is found, it will add the `:path => <path>`
|
39
|
+
option to the `gem` command.
|
40
|
+
|
41
|
+
* `Gemfile.lock` will **NOT** be updated if this gem is activated.
|
42
|
+
|
43
|
+
|
44
|
+
## Shell shortcut
|
45
|
+
|
46
|
+
In order to make the most of this gem, you need a quick way to enable or disable it.
|
47
|
+
|
48
|
+
Add the following function to your `~/.bashrc` or `~/.zshrc`:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
# Gem development shortcuts
|
52
|
+
# Toggle between gem development and production mode
|
53
|
+
# (Set / unset $GEM_DEV variable)
|
54
|
+
gdv() {
|
55
|
+
local flag_var="GEM_DEV"
|
56
|
+
if env | grep -q "^$flag_var="; then
|
57
|
+
unset $flag_var
|
58
|
+
else
|
59
|
+
export $flag_var=true
|
60
|
+
fi
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
Now you will be able to enable or disable the gem by typing: `gdv`
|
65
|
+
|
66
|
+
|
67
|
+
## Indicator in Shell Prompt
|
68
|
+
|
69
|
+
Finally, you might want to know whether or not the gem is enabled.
|
70
|
+
|
71
|
+
Add the following function to your `~/.bashrc` or `~/.zshrc`:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
# When developing gems ($GEM_DEV is exported), display a hammer and pick
|
75
|
+
parse_gem_development() {
|
76
|
+
if env | grep -q "^GEM_DEV="; then echo "\[\e[0;33m\]⚒ "; fi
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
Then, use `$(parse_gem_development)` to display the indicator in your prompt.
|
81
|
+
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
1. Fork it
|
86
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
87
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
88
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
89
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/bundler_local_development/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nathan Broadbent"]
|
6
|
+
gem.email = ["nathan.f77@gmail.com"]
|
7
|
+
gem.description = %q{Provides a simple way to switch between local and installed gems.}
|
8
|
+
gem.summary = %q{Switch to a set of local gems with a single command}
|
9
|
+
gem.homepage = "https://github.com/ndbroadbent/bundler_local_development"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "bundler_local_development"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = BundlerLocalDevelopment::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'bundler'
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Provides a simple way to switch between local and installed gems.
|
3
|
+
#
|
4
|
+
# * Call `Bundler.development_gems=[]` in your Gemfile, to configure
|
5
|
+
# the default set of gems to override with local copies.
|
6
|
+
# * Set $DEVELOPMENT_GEMS to add extra gems to this list.
|
7
|
+
#
|
8
|
+
# If the $GEM_DEV environment variable is set, bundler will search for gems in the
|
9
|
+
# path specified by $GEM_DEV_DIR (or $HOME/code/gems if not set.)
|
10
|
+
|
11
|
+
module Bundler
|
12
|
+
class << self
|
13
|
+
def development_gems=(search_strings)
|
14
|
+
@@development_gems = search_strings
|
15
|
+
end
|
16
|
+
def development_gems
|
17
|
+
(@@development_gems ||= []) +
|
18
|
+
ENV['DEV_GEMS'].to_s.split(',').map(&:strip).select{|s| s != "" }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Dsl
|
23
|
+
alias :gem_without_development :gem
|
24
|
+
def gem_with_development(name, *args)
|
25
|
+
if ENV['GEM_DEV'] && Bundler.development_gems.any?{ |s| name[s] }
|
26
|
+
gem_dev_dir = ENV['GEM_DEV_DIR'] || "#{`echo $HOME`.strip}/code/gems"
|
27
|
+
path = File.join(gem_dev_dir, name)
|
28
|
+
if File.exist?(path)
|
29
|
+
return gem_without_development name, :path => path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
gem_without_development(name, *args)
|
33
|
+
end
|
34
|
+
alias :gem :gem_with_development
|
35
|
+
end
|
36
|
+
|
37
|
+
class Definition
|
38
|
+
# Don't update Gemfile.lock when developing with local gems
|
39
|
+
alias :lock_original :lock
|
40
|
+
def lock(*args)
|
41
|
+
lock_original(*args) unless ENV['GEM_DEV']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/local_development'
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler_local_development
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nathan Broadbent
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &82862610 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *82862610
|
25
|
+
description: Provides a simple way to switch between local and installed gems.
|
26
|
+
email:
|
27
|
+
- nathan.f77@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- bundler_local_development.gemspec
|
38
|
+
- lib/bundler/local_development.rb
|
39
|
+
- lib/bundler_local_development.rb
|
40
|
+
- lib/bundler_local_development/version.rb
|
41
|
+
homepage: https://github.com/ndbroadbent/bundler_local_development
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.17
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Switch to a set of local gems with a single command
|
65
|
+
test_files: []
|