Class: DotMe::Incubator
- Inherits:
-
Object
- Object
- DotMe::Incubator
- Defined in:
- lib/dotme/incubator.rb
Constant Summary collapse
- @@incubators =
[]
- @@cells =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Incubator
constructor
A new instance of Incubator.
Constructor Details
#initialize(path) ⇒ Incubator
Returns a new instance of Incubator.
9 10 11 12 13 14 15 16 |
# File 'lib/dotme/incubator.rb', line 9 def initialize(path) @path = path @relative = @path.gsub( Etc.getpwuid.dir, '~' ) @basename = ::File.basename @path unless @basename[0] != '.' @basename = @basename[1..-1] end end |
Class Method Details
.cells ⇒ Object
39 40 41 |
# File 'lib/dotme/incubator.rb', line 39 def self.cells @@cells end |
.incubate(path, to) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dotme/incubator.rb', line 23 def self.incubate(path,to) path = ::File.join( Etc.getpwuid.dir, path ) unless ::File.exists? path Dir.mkdir to, 0700 unless ::File.directory? to puts "Incubating #{::File.basename path} to #{to}" incubator = nil # get the last valid incubator @@incubators.each { |c| if c.incubates? path then incubator = c end } unless incubator raise NoIncubator end @@cells << incubator.new(path).incubate(to) end |
.register!(c) ⇒ Object
18 19 20 21 |
# File 'lib/dotme/incubator.rb', line 18 def self.register!(c) raise TypeError, 'Not an Incubator derived class.' unless c.respond_to? :incubates? @@incubators << c end |