Class: Spaarti::Site
- Inherits:
-
Object
- Object
- Spaarti::Site
- Defined in:
- lib/spaarti/site.rb
Overview
Site object, represents a group of repos
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Site
constructor
A new instance of Site.
- #purge! ⇒ Object
- #sync! ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Site
Returns a new instance of Site.
26 27 28 29 30 31 |
# File 'lib/spaarti/site.rb', line 26 def initialize(params = {}) @options = DEFAULT_OPTIONS.dup.merge params load_config(params.include?(:config_file)) return unless @options[:auth_file].is_a? String @options[:auth_file] = File.(@options[:auth_file]) end |
Instance Method Details
#purge! ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/spaarti/site.rb', line 40 def purge! Dir.glob('**/.git').each do |git_dir| repo = Pathname.new(git_dir).dirname next if repos.any? { |x| x.parent_of(repo) } FileUtils.rmtree repo end end |
#sync! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/spaarti/site.rb', line 33 def sync! Dir.chdir(File.(@options[:base_path])) do repos.each(&:sync!) purge! if @options[:purge] end end |