Module: StaleFish

Defined in:
lib/stale_fish.rb,
lib/stale_fish/fixture.rb

Defined Under Namespace

Classes: Fixture

Class Method Summary collapse

Class Method Details

.configurationObject



21
22
23
24
25
26
27
# File 'lib/stale_fish.rb', line 21

def configuration
  @configuration || #if defined?(Rails)
                    #  File.join(Rails.root, 'spec', 'stale_fish.yml')
                    #else
                      'stale_fish.yml'
                    #end
end

.configuration=(config) ⇒ Object



17
18
19
# File 'lib/stale_fish.rb', line 17

def configuration=(config)
  @configuration = config
end

.fixtures(params = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/stale_fish.rb', line 54

def fixtures(params=nil)
  @fixtures ||= []
  if params.is_a?(Hash)
    if params[:only]
      @fixtures.select { |f| params[:only].include?(f.name.to_sym) }
    elsif params[:except]
      @fixtures.select { |f| !params[:except].include?(f.name.to_sym) }
    end
  else
    @fixtures
  end
end

.setup(config_location = nil) ⇒ Object



11
12
13
14
15
# File 'lib/stale_fish.rb', line 11

def setup(config_location=nil)
  self.configuration = config_location
  load
  block_requests
end

.update_stale(options = :all) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/stale_fish.rb', line 29

def update_stale(options = :all)
  reset_fixtures = false

  allow_requests
  fixtures(options).each do |fixture|
    if fixture.is_stale?
      fixture.update!
      reset_fixtures = true
    end
  end
  drop_locks if reset_fixtures
  block_requests
  write
end

.update_stale!(options = :all) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/stale_fish.rb', line 44

def update_stale!(options = :all)
  allow_requests
  fixtures(options).each do |fixture|
    fixture.update!
  end
  drop_locks
  block_requests
  write
end