officer 0.7.4 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -1,5 +1,5 @@
1
- README.rdoc
2
1
  lib/**/*.rb
3
2
  bin/*
3
+ -
4
4
  features/**/*.feature
5
- LICENSE
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ gem "eventmachine"
4
+ gem "json"
5
+ gem "daemons"
6
+ gem "choice"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "2.4.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.5.2"
14
+ gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ choice (0.1.4)
5
+ daemons (1.1.0)
6
+ diff-lcs (1.1.2)
7
+ eventmachine (0.12.10)
8
+ git (1.2.5)
9
+ jeweler (1.5.2)
10
+ bundler (~> 1.0.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ json (1.4.6)
14
+ rake (0.8.7)
15
+ rcov (0.9.9)
16
+ rspec (2.4.0)
17
+ rspec-core (~> 2.4.0)
18
+ rspec-expectations (~> 2.4.0)
19
+ rspec-mocks (~> 2.4.0)
20
+ rspec-core (2.4.0)
21
+ rspec-expectations (2.4.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.4.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ choice
31
+ daemons
32
+ eventmachine
33
+ jeweler (~> 1.5.2)
34
+ json
35
+ rcov
36
+ rspec (= 2.4.0)
data/Rakefile CHANGED
@@ -1,49 +1,47 @@
1
1
  require 'rubygems'
2
- require 'rake'
3
-
2
+ require 'bundler'
4
3
  begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "officer"
8
- gem.summary = %Q{Distributed lock server and client}
9
- gem.description = %Q{Distributed lock server and client written in Ruby and EventMachine}
10
- gem.email = "chad@remesch.com"
11
- gem.homepage = "http://github.com/chadrem/officer"
12
- gem.authors = ["Chad Remesch"]
13
- gem.add_dependency "eventmachine", ">= 0"
14
- gem.add_dependency "json", ">= 0"
15
- gem.add_dependency "daemons", ">= 0"
16
- gem.add_dependency "choice", ">= 0"
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
22
9
  end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "officer"
16
+ gem.homepage = "http://github.com/chadrem/officer"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Distributed lock server and client}
19
+ gem.description = %Q{Distributed lock server and client written in Ruby and EventMachine}
20
+ gem.email = "chad@remesch.com"
21
+ gem.authors = ["Chad Remesch"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ gem.add_development_dependency 'rspec', '2.4.0'
25
+ gem.add_dependency "eventmachine", ">= 0"
26
+ gem.add_dependency "json", ">= 0"
27
+ gem.add_dependency "daemons", ">= 0"
28
+ gem.add_dependency "choice", ">= 0"
23
29
 
24
- require 'rake/testtask'
25
- Rake::TestTask.new(:test) do |test|
26
- test.libs << 'lib' << 'test'
27
- test.pattern = 'test/**/test_*.rb'
28
- test.verbose = true
29
30
  end
31
+ Jeweler::RubygemsDotOrgTasks.new
30
32
 
31
- begin
32
- require 'rcov/rcovtask'
33
- Rcov::RcovTask.new do |test|
34
- test.libs << 'test'
35
- test.pattern = 'test/**/test_*.rb'
36
- test.verbose = true
37
- end
38
- rescue LoadError
39
- task :rcov do
40
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
- end
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
42
37
  end
43
38
 
44
- task :test => :check_dependencies
39
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
45
43
 
46
- task :default => :test
44
+ task :default => :spec
47
45
 
48
46
  require 'rake/rdoctask'
49
47
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.4
1
+ 0.8.1
@@ -113,4 +113,4 @@ module Officer
113
113
  end
114
114
  end
115
115
 
116
- end
116
+ end
@@ -77,7 +77,9 @@ module Officer
77
77
  end
78
78
 
79
79
  def release name, connection, options={}
80
- options[:callback] ||= true
80
+ if options[:callback].nil?
81
+ options[:callback] = true
82
+ end
81
83
 
82
84
  lock = @locks[name]
83
85
  names = @connections[connection]
@@ -160,4 +162,4 @@ module Officer
160
162
  end
161
163
  end
162
164
 
163
- end
165
+ end
data/lib/officer.rb CHANGED
@@ -10,6 +10,7 @@ require 'eventmachine'
10
10
  require 'json'
11
11
  require 'daemons'
12
12
  require 'choice'
13
+ # require 'ruby-debug'
13
14
 
14
15
  # Application.
15
16
  require 'officer/log'
data/officer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{officer}
8
- s.version = "0.7.4"
8
+ s.version = "0.8.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Remesch"]
12
- s.date = %q{2011-01-20}
12
+ s.date = %q{2011-01-22}
13
13
  s.default_executable = %q{officer}
14
14
  s.description = %q{Distributed lock server and client written in Ruby and EventMachine}
15
15
  s.email = %q{chad@remesch.com}
@@ -20,6 +20,9 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
23
26
  "LICENSE",
24
27
  "README.markdown",
25
28
  "Rakefile",
@@ -33,16 +36,17 @@ Gem::Specification.new do |s|
33
36
  "lib/officer/log.rb",
34
37
  "lib/officer/server.rb",
35
38
  "officer.gemspec",
36
- "test/helper.rb",
37
- "test/test_officer.rb"
39
+ "spec/integration/officer_spec.rb",
40
+ "spec/spec_helper.rb"
38
41
  ]
39
42
  s.homepage = %q{http://github.com/chadrem/officer}
43
+ s.licenses = ["MIT"]
40
44
  s.require_paths = ["lib"]
41
45
  s.rubygems_version = %q{1.3.7}
42
46
  s.summary = %q{Distributed lock server and client}
43
47
  s.test_files = [
44
- "test/helper.rb",
45
- "test/test_officer.rb"
48
+ "spec/integration/officer_spec.rb",
49
+ "spec/spec_helper.rb"
46
50
  ]
47
51
 
48
52
  if s.respond_to? :specification_version then
@@ -54,17 +58,44 @@ Gem::Specification.new do |s|
54
58
  s.add_runtime_dependency(%q<json>, [">= 0"])
55
59
  s.add_runtime_dependency(%q<daemons>, [">= 0"])
56
60
  s.add_runtime_dependency(%q<choice>, [">= 0"])
61
+ s.add_development_dependency(%q<rspec>, ["= 2.4.0"])
62
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
64
+ s.add_development_dependency(%q<rcov>, [">= 0"])
65
+ s.add_development_dependency(%q<rspec>, ["= 2.4.0"])
66
+ s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
67
+ s.add_runtime_dependency(%q<json>, [">= 0"])
68
+ s.add_runtime_dependency(%q<daemons>, [">= 0"])
69
+ s.add_runtime_dependency(%q<choice>, [">= 0"])
57
70
  else
58
71
  s.add_dependency(%q<eventmachine>, [">= 0"])
59
72
  s.add_dependency(%q<json>, [">= 0"])
60
73
  s.add_dependency(%q<daemons>, [">= 0"])
61
74
  s.add_dependency(%q<choice>, [">= 0"])
75
+ s.add_dependency(%q<rspec>, ["= 2.4.0"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
78
+ s.add_dependency(%q<rcov>, [">= 0"])
79
+ s.add_dependency(%q<rspec>, ["= 2.4.0"])
80
+ s.add_dependency(%q<eventmachine>, [">= 0"])
81
+ s.add_dependency(%q<json>, [">= 0"])
82
+ s.add_dependency(%q<daemons>, [">= 0"])
83
+ s.add_dependency(%q<choice>, [">= 0"])
62
84
  end
63
85
  else
64
86
  s.add_dependency(%q<eventmachine>, [">= 0"])
65
87
  s.add_dependency(%q<json>, [">= 0"])
66
88
  s.add_dependency(%q<daemons>, [">= 0"])
67
89
  s.add_dependency(%q<choice>, [">= 0"])
90
+ s.add_dependency(%q<rspec>, ["= 2.4.0"])
91
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
92
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
93
+ s.add_dependency(%q<rcov>, [">= 0"])
94
+ s.add_dependency(%q<rspec>, ["= 2.4.0"])
95
+ s.add_dependency(%q<eventmachine>, [">= 0"])
96
+ s.add_dependency(%q<json>, [">= 0"])
97
+ s.add_dependency(%q<daemons>, [">= 0"])
98
+ s.add_dependency(%q<choice>, [">= 0"])
68
99
  end
69
100
  end
70
101
 
@@ -0,0 +1,71 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Officer do
4
+ before do
5
+ @server_thread = Thread.new do
6
+ Officer::Server.new.run
7
+ end
8
+ end
9
+
10
+ after do
11
+ @server_thread.terminate
12
+ end
13
+
14
+ context "single client tests" do
15
+ before do
16
+ @client = Officer::Client.new
17
+ end
18
+
19
+ after do
20
+ @client.send("disconnect")
21
+ @client = nil
22
+ end
23
+
24
+ it "should allow a client to request its locks" do
25
+ @client.my_locks.should eq({"value"=>[], "result"=>"locks"})
26
+ end
27
+
28
+ it "should allow a client to request and release a lock using non-block syntax" do
29
+ @client.lock("testlock")
30
+ @client.my_locks.should eq({"value"=>["testlock"], "result"=>"locks"})
31
+ @client.unlock("testlock")
32
+ @client.my_locks.should eq({"value"=>[], "result"=>"locks"})
33
+ end
34
+
35
+ it "should allow a client to request and release a lock using block syntax" do
36
+ @client.with_lock("testlock") do
37
+ @client.my_locks.should eq({"value"=>["testlock"], "result"=>"locks"})
38
+ end
39
+ end
40
+
41
+ it "should allow a client to reset all of its locks (release them all)" do
42
+ @client.lock("testlock1")
43
+ @client.lock("testlock2")
44
+ @client.my_locks.should eq({"value"=>["testlock1", "testlock2"], "result"=>"locks"})
45
+ @client.reset
46
+ @client.my_locks.should eq({"value"=>[], "result"=>"locks"})
47
+ end
48
+ end
49
+
50
+ context "multi-client tests" do
51
+ before do
52
+ @client1 = Officer::Client.new
53
+ @client2 = Officer::Client.new
54
+ end
55
+
56
+ after do
57
+ @client1.send("disconnect")
58
+ @client1 = nil
59
+ @client2.send("disconnect")
60
+ @client2 = nil
61
+ end
62
+
63
+ it "should allow a client to see all the locks on a server (including those owned by other clients)" do
64
+ @client1.lock("client1_testlock1")
65
+ @client1.lock("client1_testlock2")
66
+ @client2.lock("client2_testlock1")
67
+ @client2.lock("client2_testlock2")
68
+ # @client2.locks.should eq(false)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'officer'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: officer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 4
10
- version: 0.7.4
8
+ - 8
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chad Remesch
@@ -15,13 +15,14 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-20 00:00:00 -05:00
18
+ date: 2011-01-22 00:00:00 -05:00
19
19
  default_executable: officer
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: eventmachine
23
22
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ name: eventmachine
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
@@ -30,12 +31,26 @@ dependencies:
30
31
  segments:
31
32
  - 0
32
33
  version: "0"
33
- type: :runtime
34
- version_requirements: *id001
34
+ requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ type: :runtime
36
38
  name: json
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
37
50
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
51
+ type: :runtime
52
+ name: daemons
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
54
  none: false
40
55
  requirements:
41
56
  - - ">="
@@ -44,12 +59,74 @@ dependencies:
44
59
  segments:
45
60
  - 0
46
61
  version: "0"
62
+ requirement: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ prerelease: false
47
65
  type: :runtime
48
- version_requirements: *id002
66
+ name: choice
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirement: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ prerelease: false
79
+ type: :development
80
+ name: rspec
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - "="
85
+ - !ruby/object:Gem::Version
86
+ hash: 31
87
+ segments:
88
+ - 2
89
+ - 4
90
+ - 0
91
+ version: 2.4.0
92
+ requirement: *id005
49
93
  - !ruby/object:Gem::Dependency
50
- name: daemons
51
94
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
95
+ type: :development
96
+ name: bundler
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ hash: 23
103
+ segments:
104
+ - 1
105
+ - 0
106
+ - 0
107
+ version: 1.0.0
108
+ requirement: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ prerelease: false
111
+ type: :development
112
+ name: jeweler
113
+ version_requirements: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ hash: 7
119
+ segments:
120
+ - 1
121
+ - 5
122
+ - 2
123
+ version: 1.5.2
124
+ requirement: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ prerelease: false
127
+ type: :development
128
+ name: rcov
129
+ version_requirements: &id008 !ruby/object:Gem::Requirement
53
130
  none: false
54
131
  requirements:
55
132
  - - ">="
@@ -58,12 +135,42 @@ dependencies:
58
135
  segments:
59
136
  - 0
60
137
  version: "0"
138
+ requirement: *id008
139
+ - !ruby/object:Gem::Dependency
140
+ prerelease: false
141
+ type: :development
142
+ name: rspec
143
+ version_requirements: &id009 !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - "="
147
+ - !ruby/object:Gem::Version
148
+ hash: 31
149
+ segments:
150
+ - 2
151
+ - 4
152
+ - 0
153
+ version: 2.4.0
154
+ requirement: *id009
155
+ - !ruby/object:Gem::Dependency
156
+ prerelease: false
61
157
  type: :runtime
62
- version_requirements: *id003
158
+ name: eventmachine
159
+ version_requirements: &id010 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ hash: 3
165
+ segments:
166
+ - 0
167
+ version: "0"
168
+ requirement: *id010
63
169
  - !ruby/object:Gem::Dependency
64
- name: choice
65
170
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
171
+ type: :runtime
172
+ name: json
173
+ version_requirements: &id011 !ruby/object:Gem::Requirement
67
174
  none: false
68
175
  requirements:
69
176
  - - ">="
@@ -72,8 +179,35 @@ dependencies:
72
179
  segments:
73
180
  - 0
74
181
  version: "0"
182
+ requirement: *id011
183
+ - !ruby/object:Gem::Dependency
184
+ prerelease: false
75
185
  type: :runtime
76
- version_requirements: *id004
186
+ name: daemons
187
+ version_requirements: &id012 !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ hash: 3
193
+ segments:
194
+ - 0
195
+ version: "0"
196
+ requirement: *id012
197
+ - !ruby/object:Gem::Dependency
198
+ prerelease: false
199
+ type: :runtime
200
+ name: choice
201
+ version_requirements: &id013 !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
208
+ - 0
209
+ version: "0"
210
+ requirement: *id013
77
211
  description: Distributed lock server and client written in Ruby and EventMachine
78
212
  email: chad@remesch.com
79
213
  executables:
@@ -85,6 +219,9 @@ extra_rdoc_files:
85
219
  - README.markdown
86
220
  files:
87
221
  - .document
222
+ - .rspec
223
+ - Gemfile
224
+ - Gemfile.lock
88
225
  - LICENSE
89
226
  - README.markdown
90
227
  - Rakefile
@@ -98,12 +235,12 @@ files:
98
235
  - lib/officer/log.rb
99
236
  - lib/officer/server.rb
100
237
  - officer.gemspec
101
- - test/helper.rb
102
- - test/test_officer.rb
238
+ - spec/integration/officer_spec.rb
239
+ - spec/spec_helper.rb
103
240
  has_rdoc: true
104
241
  homepage: http://github.com/chadrem/officer
105
- licenses: []
106
-
242
+ licenses:
243
+ - MIT
107
244
  post_install_message:
108
245
  rdoc_options: []
109
246
 
@@ -135,5 +272,5 @@ signing_key:
135
272
  specification_version: 3
136
273
  summary: Distributed lock server and client
137
274
  test_files:
138
- - test/helper.rb
139
- - test/test_officer.rb
275
+ - spec/integration/officer_spec.rb
276
+ - spec/spec_helper.rb
data/test/helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'officer'
8
-
9
- class Test::Unit::TestCase
10
- end
data/test/test_officer.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestOfficer < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end