Sha256: 86c977755abd6883b8b98cb782e0de51f094d19b422e73c65b887c7c35f67d94

Contents?: true

Size: 1.02 KB

Versions: 31

Compression:

Stored size: 1.02 KB

Contents

module Capricorn
  class System
    module Satellites
      
      def satellites_hash
        @satellites || load_satellites
      end
      
      def satellites
        satellites_hash.values
      end
      
      def find_satellite(domain)
        satellites_hash[domain]
      end
      
      def save_satellite!(satellite)
        satellites_hash[satellite.domain] = satellite
        satellite.dump_file(self.path('satellites', "#{satellite.domain}.yml"))
      end
      
      def destroy_satellite!(satellite)
        satellites_hash.delete(satellite.domain)
        FileUtils.rm_f(self.path('satellites', "#{satellite.domain}.yml"))
      end
      
      private
      
      def load_satellites
        @satellites = {}
        
        FileUtils.mkdir_p(self.path('satellites'))
        Dir.glob(self.path('satellites', '*.yml')).each do |yml|
          satellite = Capricorn::Satellite.load_file(yml)
          @satellites[satellite.domain] = satellite
        end
        
        @satellites
      end
      
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
simonmenke-capricorn-0.2.00 lib/capricorn/system/satellites.rb
simonmenke-capricorn-0.2.03 lib/capricorn/system/satellites.rb
simonmenke-capricorn-0.2.07 lib/capricorn/system/satellites.rb
simonmenke-capricorn-0.2.25 lib/capricorn/system/satellites.rb
simonmenke-capricorn-0.2.26 lib/capricorn/system/satellites.rb
capricorn-0.2.25 lib/capricorn/system/satellites.rb
capricorn-0.2.24 lib/capricorn/system/satellites.rb
capricorn-0.2.23 lib/capricorn/system/satellites.rb
capricorn-0.2.22 lib/capricorn/system/satellites.rb
capricorn-0.2.21 lib/capricorn/system/satellites.rb
capricorn-0.2.20 lib/capricorn/system/satellites.rb
capricorn-0.2.19 lib/capricorn/system/satellites.rb
capricorn-0.2.18 lib/capricorn/system/satellites.rb
capricorn-0.2.17 lib/capricorn/system/satellites.rb
capricorn-0.2.16 lib/capricorn/system/satellites.rb
capricorn-0.2.15 lib/capricorn/system/satellites.rb
capricorn-0.2.14 lib/capricorn/system/satellites.rb
capricorn-0.2.13 lib/capricorn/system/satellites.rb
capricorn-0.2.12 lib/capricorn/system/satellites.rb
capricorn-0.2.11 lib/capricorn/system/satellites.rb