Sha256: 27b8bc6b511ea9d0a896a0b479fa6669afe3cf081dbced98e761b39952d5f5fe

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# GemWatch regroups multiple checks and consolidates them in a pretty formated result.
class GemWatch
  # Update object to perform check on
  attr_reader :update_on
  
  # Initialize a new GemWatch object using <tt>params</tt>.
  # == params
  # <tt>:update</tt>: accepts a String of coma separated gem names or directly an Array of gem string names.
  def initialize(params = {})
    @update_on  = case params[:update].class
    when Array
      params[:update]
    when String
      params[:update].split(',').collect {|s| s.strip}
    else
      [params[:update]]
    end
    
    @update_on = @update_on.collect {|name| GemWatch::Check::Update.new name}    
  end
  
  # Run all checks
  def run_checks
    @update_on.each {|check| check.run}
  end
  
  # Returns true if all checks passed.
  def passed?
    @update_on.all? {|check| check.passed?}
  end
  
  # Formated results.
  def results
    if @update_on.any? {|check| !check.passed?}
      <<-EOS

Those gems can be updated to their latest version:

Name                Local     Remote
=========================================
#{@update_on.collect {|check| check.results}.join "\n"}

      EOS
    end
  end
end

require "gem_watch/checks/update"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gem_watch-0.1.2 lib/gem_watch.rb
gem_watch-0.1.0 lib/gem_watch.rb
gem_watch-0.1.1 lib/gem_watch.rb