thread_so_safe 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,36 @@
1
+ = thread_so_safe
2
+
3
+ thread_so_safe is a very simple gem to help keep multi-threaded environments synced.
4
+
5
+ == Examples
6
+
7
+ ThreadSoSafe.safeguard('My.App Users')
8
+ users = User.find(:all)
9
+
10
+ # ...
11
+
12
+ unless ThreadSoSafe.safe?
13
+ users = User.find(:all)
14
+ ThreadSoSafe.update!
15
+ end
16
+
17
+ ###
18
+
19
+ # if you're working with multiple data sets that need to be in sync
20
+ # you can pass the name (in the first example's case, My.App Users)
21
+ # into the safe? and update!
22
+
23
+ ThreadSoSafe.safeguard('Users')
24
+ users = User.find(:all)
25
+
26
+ ThreadSoSafe.safeguard('Roles')
27
+ roles = Role.find(:all)
28
+
29
+ # ...
30
+
31
+ unless ThreadSoSafe.safe?('Roles')
32
+ users = User.find(:all)
33
+ ThreadSoSafe.update!('Roles)
34
+ end
35
+
36
+ Copyright (c) 2010 Dane Harrigan. See LICENSE for details.
data/Rakefile CHANGED
@@ -6,8 +6,9 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |gem|
8
8
  gem.name = "thread_so_safe"
9
- gem.version = "0.1"
9
+ gem.version = "0.1.1"
10
10
  gem.summary = %Q{thread_so_safe is a very simple gem to help keep multi-threaded environments synced.}
11
+ gem.description = gem.summary
11
12
  gem.email = "dane.harrigan@gmail.com"
12
13
  gem.homepage = "http://github.com/daneharrigan/thread_so_safe"
13
14
  gem.authors = ["Dane Harrigan"]
@@ -9,11 +9,10 @@ class ThreadSoSafe
9
9
  def safeguard(name)
10
10
  @@current_thread = name
11
11
  name = file_name(name)
12
+ path = full_path(name)
12
13
 
13
- file = File.new(full_path(name),'w+')
14
- @@threads[name] = file.mtime
15
-
16
- file.close
14
+ FileUtils.touch(path) unless File.exists? path
15
+ @@threads[name] = File.mtime(path)
17
16
  return
18
17
  end
19
18
 
@@ -5,21 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{thread_so_safe}
8
- s.version = "0.1"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dane Harrigan"]
12
12
  s.date = %q{2010-06-27}
13
+ s.description = %q{thread_so_safe is a very simple gem to help keep multi-threaded environments synced.}
13
14
  s.email = %q{dane.harrigan@gmail.com}
14
15
  s.extra_rdoc_files = [
15
16
  "LICENSE",
16
- "README.textile"
17
+ "README.rdoc"
17
18
  ]
18
19
  s.files = [
19
20
  ".document",
20
21
  ".gitignore",
21
22
  "LICENSE",
22
- "README.textile",
23
+ "README.rdoc",
23
24
  "Rakefile",
24
25
  "lib/thread_so_safe.rb",
25
26
  "spec/spec_helper.rb",
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- version: "0.1"
8
+ - 1
9
+ version: 0.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Dane Harrigan
@@ -30,7 +31,7 @@ dependencies:
30
31
  version: 1.2.9
31
32
  type: :development
32
33
  version_requirements: *id001
33
- description:
34
+ description: thread_so_safe is a very simple gem to help keep multi-threaded environments synced.
34
35
  email: dane.harrigan@gmail.com
35
36
  executables: []
36
37
 
@@ -38,12 +39,12 @@ extensions: []
38
39
 
39
40
  extra_rdoc_files:
40
41
  - LICENSE
41
- - README.textile
42
+ - README.rdoc
42
43
  files:
43
44
  - .document
44
45
  - .gitignore
45
46
  - LICENSE
46
- - README.textile
47
+ - README.rdoc
47
48
  - Rakefile
48
49
  - lib/thread_so_safe.rb
49
50
  - spec/spec_helper.rb
data/README.textile DELETED
@@ -1,30 +0,0 @@
1
- h1. thread_so_safe
2
-
3
- thread_so_safe is a very simple gem to help keep multi-threaded environments synced.
4
-
5
- h2. Examples
6
-
7
- <code><pre>
8
- # Starting thread-safety is easy!
9
- ThreadSoSafe.safeguard('My.Application')
10
- ThreadSoSafe.safeguard('My.Second.Application')
11
-
12
- # Time to check if our data is till up to date
13
- unless ThreadSoSafe.safe?('My.Application')
14
- puts "Updating data..."
15
- ThreadSoSafe.update!('My.Application')
16
- end
17
-
18
- unless ThreadSoSafe.safe?('My.Second.Application')
19
- # update second set of data
20
- ThreadSoSafe.update!('My.Second.Application')
21
- end
22
-
23
- # If you're working with only one application you can use the slightly shorter-hand
24
- unless ThreadSoSafe.safe?
25
- # bring your code up to date
26
- ThreadSoSafe.update!
27
- end
28
- </pre></code>
29
-
30
- Copyright (c) 2010 Dane Harrigan. See LICENSE for details.