bundler_local_development 0.2.0 → 0.3.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.
data/README.md CHANGED
@@ -26,7 +26,7 @@ And then execute:
26
26
  * Call `Bundler.development_gems = [...]` in your Gemfile, to configure
27
27
  your default set of local gems.
28
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).
29
+ * Set the `$DEV_GEMS` environment variable to add extra gems to this list (semicolon separated list of gem names).
30
30
 
31
31
  If the `$GEM_DEV` environment variable is unset, this gem will have no effect.
32
32
 
@@ -34,9 +34,12 @@ If the `$GEM_DEV` environment variable is set:
34
34
 
35
35
  * Bundler will search for local gems in the
36
36
  path specified by `$GEM_DEV_DIR`. (The default search path is `$HOME/code/gems`, if `$GEM_DEV_DIR` is unset.)
37
+ You can specify multiple directories by separating paths with a semicolon, e.g.
38
+ `$HOME/code/gems;$HOME/code/more_gems`
37
39
 
38
40
  * If a local copy of the gem is found, it will add the `:path => <path>`
39
41
  option to the `gem` command.
42
+ It will also scan the local gem's gemspec and process any runtime dependencies.
40
43
 
41
44
  * `Gemfile.lock` will **NOT** be updated if this gem is activated.
42
45
 
@@ -11,25 +11,34 @@
11
11
  module Bundler
12
12
  class << self
13
13
  def development_gems=(search_strings)
14
- @@development_gems = search_strings
14
+ @@development_gems = [search_strings].flatten
15
15
  end
16
16
  def development_gems
17
- (@@development_gems ||= []) +
18
- ENV['DEV_GEMS'].to_s.split(',').map(&:strip).select{|s| s != "" }
17
+ # If $DEV_GEMS is provided, append to @@development_gems
18
+ if ENV['DEV_GEMS']
19
+ (@@development_gems ||= []) +
20
+ ENV['DEV_GEMS'].to_s.split(';').map(&:strip).select{|s| s != "" }
21
+ # Otherwise, default is to make all gems local
22
+ else
23
+ @@development_gems ||= [:all]
24
+ end
19
25
  end
20
26
  end
21
27
 
22
28
  class Dsl
23
29
  alias :gem_without_development :gem
24
30
  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
- # Check each local gem's gemspec to see if any dependencies need to be made local
30
- gemspec_path = File.join(gem_dev_dir, name, "#{name}.gemspec")
31
- process_gemspec_dependencies(gemspec_path, gem_dev_dir) if File.exist?(gemspec_path)
32
- return gem_without_development name, :path => path
31
+ if ENV['GEM_DEV']
32
+ if Bundler.development_gems == [:all] || Bundler.development_gems.any?{ |s| name[s] }
33
+ gem_development_dirs.each do |dir|
34
+ path = File.join(dir, name)
35
+ if File.exist?(path)
36
+ # Check each local gem's gemspec to see if any dependencies need to be made local
37
+ gemspec_path = File.join(dir, name, "#{name}.gemspec")
38
+ process_gemspec_dependencies(gemspec_path) if File.exist?(gemspec_path)
39
+ return gem_without_development name, :path => path
40
+ end
41
+ end
33
42
  end
34
43
  end
35
44
  gem_without_development(name, *args)
@@ -37,11 +46,25 @@ module Bundler
37
46
  alias :gem :gem_with_development
38
47
 
39
48
  private
40
- def process_gemspec_dependencies(gemspec_path, gem_dev_dir)
49
+ # Returns local gem dirs from ENV or default
50
+ def gem_development_dirs
51
+ @gem_development_dirs ||= if ENV['GEM_DEV_DIR']
52
+ ENV['GEM_DEV_DIR'].split(';')
53
+ else
54
+ ["#{`echo $HOME`.strip}/code/gems"]
55
+ end
56
+ end
57
+
58
+ def process_gemspec_dependencies(gemspec_path)
41
59
  spec = Bundler.load_gemspec(gemspec_path)
42
60
  spec.runtime_dependencies.each do |dep|
43
- path = File.join(gem_dev_dir, dep.name)
44
- gem_without_development(dep.name, :path => path) if File.exist?(path)
61
+ gem_development_dirs.each do |dir|
62
+ path = File.join(dir, dep.name)
63
+ if File.exist?(path)
64
+ gem_without_development(dep.name, :path => path)
65
+ break # Process next dependency
66
+ end
67
+ end
45
68
  end
46
69
  end
47
70
  end
@@ -1,3 +1,3 @@
1
1
  module BundlerLocalDevelopment
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler_local_development
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -57,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  segments:
59
59
  - 0
60
- hash: -577521741
60
+ hash: 986860397
61
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  segments:
68
68
  - 0
69
- hash: -577521741
69
+ hash: 986860397
70
70
  requirements: []
71
71
  rubyforge_project:
72
72
  rubygems_version: 1.8.24