Sha256: 3e97bf785bf372cdbbabf1eefb195d851fa0802b924e0617c082be96b29f2530

Contents?: true

Size: 1.26 KB

Versions: 15

Compression:

Stored size: 1.26 KB

Contents

# When upgrading jets, automatically rm -rf /tmp/jets/project in case the structure has changed.
module Jets::Builders
  class Purger
    def initialize
      @project_name = Jets.project_name
      @version_file = "/tmp/jets/#{@project_name}/jets_version.txt"
    end

    def purge
      if version_changed?
        last_version = @last_version || "unknown"
        puts "The jets version has changed enough since the last build to merit refreshing the build cache."
        puts "Current jets version: #{Jets::VERSION} Last built jets version: #{last_version}"
        puts "Removing /tmp/jets/#{@project_name} to start fresh."
        FileUtils.rm_rf("/tmp/jets/#{@project_name}")
      end
      write_version
    end

    # When jets changes versions major or minor version consider it a big enough can to purge the cache
    def version_changed?
      return true unless File.exist?(@version_file)

      @last_version = IO.read(@version_file).strip
      last_major, last_minor, _ = @last_version.split('.')
      current_major, current_minor, _ = Jets::VERSION.split('.')
      last_major != current_major || last_minor != current_minor
    end

    def write_version
      FileUtils.mkdir_p(File.dirname(@version_file))
      IO.write(@version_file, Jets::VERSION)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/builders/purger.rb
jets-5.0.12 lib/jets/builders/purger.rb
jets-5.0.11 lib/jets/builders/purger.rb
jets-5.0.10 lib/jets/builders/purger.rb
jets-5.0.9 lib/jets/builders/purger.rb
jets-5.0.8 lib/jets/builders/purger.rb
jets-5.0.7 lib/jets/builders/purger.rb
jets-5.0.6 lib/jets/builders/purger.rb
jets-5.0.5 lib/jets/builders/purger.rb
jets-5.0.4 lib/jets/builders/purger.rb
jets-5.0.3 lib/jets/builders/purger.rb
jets-5.0.2 lib/jets/builders/purger.rb
jets-5.0.1 lib/jets/builders/purger.rb
jets-5.0.0 lib/jets/builders/purger.rb
jets-5.0.0.beta1 lib/jets/builders/purger.rb