openagent 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,8 +103,8 @@ module OpenAgent
103
103
  end while message && message.status_code == ZIS_SUCCESS
104
104
  end
105
105
 
106
- def run(wait_period=30)
107
- loop do
106
+ def run_loop(wait_period=30)
107
+ Proc.new do
108
108
  begin
109
109
  run_once
110
110
  sleep wait_period
@@ -117,6 +117,14 @@ module OpenAgent
117
117
  end
118
118
  end
119
119
 
120
+ def run(wait_period=30, cycles=nil)
121
+ if cycles
122
+ cycles.times(&run_loop(wait_period))
123
+ else
124
+ loop(&run_loop(wait_period))
125
+ end
126
+ end
127
+
120
128
  protected
121
129
 
122
130
  def check_for_errors(msg)
@@ -1,3 +1,3 @@
1
1
  module OpenAgent
2
- VERSION = '0.9.3' unless defined?(OpenAgent::VERSION)
2
+ VERSION = '0.9.4' unless defined?(OpenAgent::VERSION)
3
3
  end
@@ -14,15 +14,8 @@ module SIF
14
14
  attribute :schedule_info_overrides, Array[Common::ScheduleInfoOverride]
15
15
  attribute :credits_attempted, Common::CreditsAttempted
16
16
 
17
- def status
18
- status = 'active'
19
- if entry_date && entry_date.past?
20
- status = 'active'
21
- end
22
- if exit_date && exit_date.past?
23
- status = 'concluded'
24
- end
25
- return status
17
+ def status(as_of = Date.today)
18
+ return (exit_date && as_of > exit_date) ? 'deleted' : 'active'
26
19
  end
27
20
  end
28
21
  end
data/spec/client_spec.rb CHANGED
@@ -63,6 +63,14 @@ describe OpenAgent::Client do
63
63
  stub_rr(File.read(fixture("messages/get_message.xml")), "")
64
64
  lambda { client.run_once }.should raise_error(OpenAgent::ResponseError)
65
65
  end
66
+
67
+ it "exits after N loops" do
68
+ stub_rr(File.read(fixture("messages/get_message.xml")),
69
+ File.read(fixture("messages/response.xml")))
70
+ stub_rr(File.read(fixture("messages/get_message.xml")),
71
+ File.read(fixture("messages/response_done.xml")))
72
+ client.run(0.001, 1)
73
+ end
66
74
  end
67
75
 
68
76
  context "given a response message" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-13 00:00:00.000000000 Z
14
+ date: 2014-02-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake