Sha256: cba286df072580b81da18dc1e822e4186dea87cb90453afc26f857f154fd97ef

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'singleton'
require 'ftools'
require 'yaml'
require 'rubygems'
require 'activesupport' # only used for time helpers
require 'resourceful'

require 'stale_fish/utility'
require 'stale_fish/fixture_definition'

begin
  require 'fakeweb'
  require 'stale_fish/fakeweb'
rescue LoadError; end

module StaleFish
  # no one likes stale fish.

  class FixtureUpdateFailure < StandardError; end
  class MalformedSourceURL < StandardError;  end

  class << self
    attr_accessor :configuration
    attr_accessor :http
    attr_accessor :fixtures
    attr_accessor :force_flag
  end

  self.fixtures = []
  Utility.config_path = 'stale_fish.yml'
  self.http = Resourceful::HttpAccessor.new

  def self.update_stale(*args)
    # TODO move this to its own spot
    Utility.loader if self.fixtures.empty?
    self.force_flag = args.pop[:force] if args.last.is_a?(Hash)

    stale = if args.empty?
              fixtures.select { |f| f.is_stale? }
            else
              fixtures.select { |f| f.is_stale? && args.include?(f.tag) }
            end

    stale.each do |fixture|
      fixture.update!
    end

    fixtures.each { |fixture| fixture.register_uri if StaleFish.use_fakeweb }

    Utility.writer
    return stale.size
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stale_fish-1.2.4 lib/stale_fish.rb
stale_fish-1.2.3 lib/stale_fish.rb