stale_fish 1.3.0.pre3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -29,6 +29,7 @@ A sample YAML file:
29
29
  update_interval: 30.days # update interval
30
30
  check_against: http://twitter.com/api/timeline # data to update fixture with when stale
31
31
  request_type: POST # request type to use when updating: GET, POST
32
+ update_method: StaleFishFixture.update_me # optional: this method is evaluated for a response instead of hitting the check_against param
32
33
  last_updated_at: # timestamp of last fixture update (can be left blank)
33
34
  gh_commits:
34
35
  file: 'commits.xml'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre3
1
+ 1.3.0
@@ -30,7 +30,7 @@ module StaleFish
30
30
  write_response_to_file(response)
31
31
  self.last_updated_at = DateTime.now
32
32
  end
33
-
33
+
34
34
  def update_by_method
35
35
  return eval(update_method)
36
36
  end
@@ -49,7 +49,7 @@ module StaleFish
49
49
 
50
50
  def register_lock!
51
51
  uri, type = build_uri, request_type.downcase.to_sym
52
- FakeWeb.register_uri(type, uri, :body => 'hey dude')
52
+ FakeWeb.register_uri(type, uri, :body => File.join(File.dirname(StaleFish.configuration), file))
53
53
 
54
54
  return FakeWeb.registered_uri?(type, uri)
55
55
  end
@@ -58,24 +58,24 @@ module StaleFish
58
58
  # update_interval.inspect trick is to prevent Fixnum being written
59
59
  yaml = ""
60
60
  yaml << <<-EOF
61
- #{name}:
62
- file: '#{file}'
63
- update_interval: #{update_interval.inspect.gsub(/ /, '.').gsub(/"/, '')}
64
- check_against: #{check_against}
65
- request_type: #{request_type}
61
+ - #{name}:
62
+ file: '#{file}'
63
+ update_interval: #{update_interval.inspect.gsub(/ /, '.').gsub(/"/, '')}
64
+ check_against: #{check_against}
65
+ request_type: #{request_type}
66
66
  EOF
67
67
  if update_method
68
68
  yaml << <<-EOF
69
- update_method: #{update_method}
69
+ update_method: #{update_method}
70
70
  EOF
71
71
  end
72
-
72
+
73
73
  yaml << <<-EOF
74
- last_updated_at: #{last_updated_at}
74
+ last_updated_at: #{last_updated_at}
75
75
  EOF
76
76
  return yaml
77
77
  end
78
-
78
+
79
79
  def last_updated_at
80
80
  if @last_updated_at.nil? || @last_updated_at.is_a?(DateTime)
81
81
  @last_updated_at
@@ -97,5 +97,6 @@ EOF
97
97
  def write_response_to_file(body)
98
98
  File.open(File.join(File.dirname(StaleFish.configuration), file), "w") { |file| file.write(body) }
99
99
  end
100
+
100
101
  end
101
102
  end
data/lib/stale_fish.rb CHANGED
@@ -29,7 +29,7 @@ module StaleFish
29
29
 
30
30
  def update_stale(options = :all)
31
31
  reset_fixtures = false
32
-
32
+
33
33
  allow_requests
34
34
  fixtures(options).each do |fixture|
35
35
  if fixture.is_stale?
@@ -69,15 +69,17 @@ module StaleFish
69
69
 
70
70
  def load
71
71
  @fixtures = []
72
- definitions = YAML::load(File.open(configuration))['stale'].symbolize_keys!
73
- definitions.each do |key, definition|
74
- self.fixtures << StaleFish::Fixture.new(definition.merge({:name => key.to_s}))
72
+ entries = YAML::load(File.open(configuration))['stale']#.symbolize_keys!
73
+ entries.each do |entry|
74
+ entry.each do |key, definition|
75
+ self.fixtures << StaleFish::Fixture.new(definition.merge({:name => key.to_s}))
76
+ end
75
77
  end
76
78
  return fixtures
77
79
  end
78
80
 
79
81
  def write
80
- updated_yaml = "stale:\n"
82
+ updated_yaml = "--- !omap\n- stale:\n"
81
83
  fixtures.each do |fixture|
82
84
  updated_yaml << fixture.to_yaml
83
85
  end
@@ -96,9 +98,10 @@ module StaleFish
96
98
  end
97
99
  FakeWeb.allow_net_connect = false
98
100
  end
99
-
101
+
100
102
  def drop_locks
101
103
  FakeWeb.clean_registry
102
104
  end
105
+
103
106
  end
104
107
  end
@@ -37,7 +37,7 @@ describe StaleFish::Fixture do
37
37
  it "should return false when fresh" do
38
38
  @fresh_fixture.is_stale?.should == false
39
39
  end
40
-
40
+
41
41
  it "should return true when last_updated_at is empty" do
42
42
  @stale_fixture.last_updated_at = nil
43
43
  @stale_fixture.is_stale?.should == true
@@ -58,12 +58,12 @@ describe StaleFish::Fixture do
58
58
  end
59
59
 
60
60
  it "should use Net::HTTP#get with a GET request_type"
61
-
61
+
62
62
  it "should call update_method when present" do
63
63
  @fixture.update_method = "CONSTANT"
64
64
  @fixture.should_receive(:update_by_method).once
65
65
  @fixture.update!
66
-
66
+
67
67
  end
68
68
  end
69
69
 
data/stale_fish.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stale_fish}
8
- s.version = "1.3.0.pre3"
8
+ s.version = "1.3.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Smestad"]
12
- s.date = %q{2010-02-23}
12
+ s.date = %q{2010-03-08}
13
13
  s.email = %q{justin.smestad@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.homepage = %q{http://github.com/jsmestad/stale_fish}
36
36
  s.rdoc_options = ["--charset=UTF-8"]
37
37
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.5}
38
+ s.rubygems_version = %q{1.3.6}
39
39
  s.summary = %q{keeps fixtures synchronized with sources to prevent outdated fixtures going undetected.}
40
40
  s.test_files = [
41
41
  "spec/spec_helper.rb",
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stale_fish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.pre3
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 3
8
+ - 0
9
+ version: 1.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Justin Smestad
@@ -9,29 +14,33 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-23 00:00:00 -07:00
17
+ date: 2010-03-08 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: fakeweb
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  description:
36
45
  email: justin.smestad@gmail.com
37
46
  executables: []
@@ -70,18 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
79
  requirements:
71
80
  - - ">="
72
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
73
84
  version: "0"
74
- version:
75
85
  required_rubygems_version: !ruby/object:Gem::Requirement
76
86
  requirements:
77
- - - ">"
87
+ - - ">="
78
88
  - !ruby/object:Gem::Version
79
- version: 1.3.1
80
- version:
89
+ segments:
90
+ - 0
91
+ version: "0"
81
92
  requirements: []
82
93
 
83
94
  rubyforge_project:
84
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.6
85
96
  signing_key:
86
97
  specification_version: 3
87
98
  summary: keeps fixtures synchronized with sources to prevent outdated fixtures going undetected.