Class: Repository
- Inherits:
-
Object
- Object
- Repository
- Defined in:
- lib/bundler/repository.rb
Overview
Bundler gemfile support for local/remote workspaces/repositories for work in development teams.
Usage:
# define paths to be searched for repositories:
workspace '~/.projects ~/Development/{projects,work}'
# define developer preferences for using local or remote repositories (uses ENV['user']):
developer :sven, :prefer => :local
# define repositories to be used for particular gems:
adva_cms = repository('adva-cms2', :git => '[email protected]:svenfuchs/adva-cms2.git', :ref => 'c2af0de')
adva_shop = repository('adva-shop', :source => :local)
# now use repositories to define gems:
adva_cms.gem 'adva-core'
adva_shop.gem 'adva-catalog'
# The gem definition will now be proxied to Bundler with arguments according
# to the setup defined earlier. E.g. as:
gem 'adva-core', :path => 'Development/projects/adva-cms2' # for developer 'sven'
gem 'adva-core', :git => '[email protected]:svenfuchs/adva-cms2.git', :ref => 'c2af0de' # for other developers
gem 'adva-catalog', :path => 'Development/projects/adva-shop' # for all developers
One can also set an environment variable FORCE_REMOTE which will force remote
repositories to be used *except* when a repository was defined with :source => :local
which always forces the local repository to be used.
Defined Under Namespace
Classes: Gem
Instance Attribute Summary collapse
-
#bundler ⇒ Object
readonly
Returns the value of attribute bundler.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
- .current_developer ⇒ Object
- .developer(name, preferences) ⇒ Object
- .developers(developers = nil) ⇒ Object
- .path(*paths) ⇒ Object
- .paths ⇒ Object
Instance Method Summary collapse
- #forced_source ⇒ Object
- #gem(name) ⇒ Object
-
#initialize(bundler, name, options) ⇒ Repository
constructor
A new instance of Repository.
- #local? ⇒ Boolean
- #path ⇒ Object
- #preferred_source ⇒ Object
Constructor Details
#initialize(bundler, name, options) ⇒ Repository
Returns a new instance of Repository.
71 72 73 74 75 76 |
# File 'lib/bundler/repository.rb', line 71 def initialize(bundler, name, ) @bundler = bundler @name = name @source = .delete(:source) @options = end |
Instance Attribute Details
#bundler ⇒ Object (readonly)
Returns the value of attribute bundler.
69 70 71 |
# File 'lib/bundler/repository.rb', line 69 def bundler @bundler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
69 70 71 |
# File 'lib/bundler/repository.rb', line 69 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
69 70 71 |
# File 'lib/bundler/repository.rb', line 69 def @options end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
69 70 71 |
# File 'lib/bundler/repository.rb', line 69 def source @source end |
Class Method Details
.current_developer ⇒ Object
50 51 52 |
# File 'lib/bundler/repository.rb', line 50 def current_developer developers[ENV['USER'].to_sym] || {} end |
.developer(name, preferences) ⇒ Object
45 46 47 48 |
# File 'lib/bundler/repository.rb', line 45 def developer(name, preferences) developers[name] = preferences workspaces(preferences[:workspace]) end |
.developers(developers = nil) ⇒ Object
54 55 56 |
# File 'lib/bundler/repository.rb', line 54 def developers(developers = nil) @developers ||= {} end |
.path(*paths) ⇒ Object
39 40 41 42 43 |
# File 'lib/bundler/repository.rb', line 39 def path(*paths) paths.join(' ').split(' ').each do |path| self.paths.concat(Pathname.glob(File.(path))) end end |
.paths ⇒ Object
35 36 37 |
# File 'lib/bundler/repository.rb', line 35 def paths @paths ||= [] end |
Instance Method Details
#forced_source ⇒ Object
90 91 92 |
# File 'lib/bundler/repository.rb', line 90 def forced_source :remote if ENV['FORCE_REMOTE'] end |
#gem(name) ⇒ Object
78 79 80 |
# File 'lib/bundler/repository.rb', line 78 def gem(name) bundler.gem(*Gem.new(name, self)) end |
#local? ⇒ Boolean
82 83 84 |
# File 'lib/bundler/repository.rb', line 82 def local? source == :local # && path end |
#path ⇒ Object
98 99 100 101 102 103 |
# File 'lib/bundler/repository.rb', line 98 def path @path ||= begin path = self.class.paths.detect { |path| path.join(name).exist? } path ? path.join(name) : Pathname.new('.') end end |
#preferred_source ⇒ Object
94 95 96 |
# File 'lib/bundler/repository.rb', line 94 def preferred_source self.class.current_developer[:prefer] || self.class.current_developer[name.to_sym] end |