Sha256: 8f0d509a8dd7ac40827738858ce35f8d61878f25623e369282091ad28e4226a2
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
require 'r10k' module R10K::Module # Register an inheriting class for later generation def self.included(klass) klass.extend self @klasses ||= [] @klasses << klass end # Look up the implementing class and instantiate an object # # This method takes the arguments for normal object generation and checks all # inheriting classes to see if they implement the behavior needed to create # the requested object. It selects the first class that can implement an object # with `name, args`, and generates an object of that class. # # @param [String] name The unique name of the module # @param [String] basedir The root to install the module in # @param [Object] args An arbitary value or set of values that specifies the implementation # # @return [Object < R10K::Module] A member of the implementing subclass def self.new(name, basedir, args) if implementation = @klasses.find { |klass| klass.implement?(name, args) } obj = implementation.new(name, basedir, args) obj else raise "Module #{name} with args #{args.inspect} doesn't have an implementation. (Are you using the right arguments?)" end end attr_accessor :name, :basedir # @return [String] The full filesystem path to the module. def full_path File.join(@basedir, @name) end end require 'r10k/module/git' require 'r10k/module/forge'
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
r10k-1.0.0 | lib/r10k/module.rb |
r10k-1.0.0rc4 | lib/r10k/module.rb |
r10k-1.0.0rc3 | lib/r10k/module.rb |
r10k-1.0.0rc2 | lib/r10k/module.rb |
r10k-1.0.0rc1 | lib/r10k/module.rb |