knjrbfw 0.0.67 → 0.0.68

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.67
1
+ 0.0.68
data/knjrbfw.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjrbfw}
8
- s.version = "0.0.67"
8
+ s.version = "0.0.68"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = %q{2012-07-24}
12
+ s.date = %q{2012-07-26}
13
13
  s.description = %q{Including stuff for HTTP, SSH and much more.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.extra_rdoc_files = [
@@ -243,7 +243,6 @@ Gem::Specification.new do |s|
243
243
  "lib/knj/thread2.rb",
244
244
  "lib/knj/threadhandler.rb",
245
245
  "lib/knj/threadpool.rb",
246
- "lib/knj/threadsafe.rb",
247
246
  "lib/knj/translations.rb",
248
247
  "lib/knj/unix_proc.rb",
249
248
  "lib/knj/web.rb",
@@ -388,14 +388,14 @@ class KnjDB_sqlite3::Tables::Table
388
388
  name = index_data["name"]
389
389
  name = "#{self.name}__#{name}" if @db.opts[:index_append_table_name]
390
390
 
391
- sql = "CREATE INDEX #{@db.escape_col}#{@db.esc_col(name)}#{@db.escape_col} ON #{@db.escape_table}#{@db.esc_table(self.name)}#{@db.escape_table} ("
391
+ sql = "CREATE INDEX '#{@db.esc_col(name)}' ON `#{@db.esc_table(self.name)}` ("
392
392
 
393
393
  first = true
394
394
  index_data["columns"].each do |col_name|
395
395
  sql << ", " if !first
396
396
  first = false if first
397
397
 
398
- sql << "#{@db.escape_col}#{@db.esc_col(col_name)}#{@db.escape_col}"
398
+ sql << "`#{@db.esc_col(col_name)}`"
399
399
  end
400
400
 
401
401
  sql << ")"
data/spec/objects_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Objects" do
4
4
  it "should be able to cache rows" do
5
- require "~/Dev/Ruby/array_enumerator/lib/array_enumerator"
5
+ require "#{File.dirname(__FILE__)}/../../array_enumerator/lib/array_enumerator"
6
6
  require "sqlite3" if RUBY_ENGINE != "jruby"
7
7
 
8
8
  $db_path = "#{Knj::Os.tmpdir}/knjrbfw_objects_cache_test.sqlite3"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.67
5
+ version: 0.0.68
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-24 00:00:00 +02:00
13
+ date: 2012-07-26 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -348,7 +348,6 @@ files:
348
348
  - lib/knj/thread2.rb
349
349
  - lib/knj/threadhandler.rb
350
350
  - lib/knj/threadpool.rb
351
- - lib/knj/threadsafe.rb
352
351
  - lib/knj/translations.rb
353
352
  - lib/knj/unix_proc.rb
354
353
  - lib/knj/web.rb
@@ -388,7 +387,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
388
387
  requirements:
389
388
  - - ">="
390
389
  - !ruby/object:Gem::Version
391
- hash: 1657712883441742083
390
+ hash: -3521471445860246373
392
391
  segments:
393
392
  - 0
394
393
  version: "0"
@@ -1,120 +0,0 @@
1
- require "monitor"
2
-
3
- #This module contains various tools to handle thread-safety easily and pretty.
4
- module Knj::Threadsafe
5
- #JRuby can corrupt an array in a threadded env. Use this method to only get a synchronized array when running JRuby and not having to write "if RUBY_ENGINE"-stuff.
6
- def self.std_array
7
- return Synced_array.new if RUBY_ENGINE == "jruby"
8
- return []
9
- end
10
-
11
- #Instances of this class proxies calls to a given-object by using a mutex or monitor.
12
- #
13
- #==== Examples
14
- # threadsafe_array = Knj::Threadsafe::Proxy.new(:obj => [])
15
- # threadsafe_array << 5
16
- # ret = threadsafe_array[0]
17
- #
18
- # threadsafe_array = Knj::Threadsafe::Proxy.new(:obj => [], :monitor => true)
19
- class Proxy
20
- #Spawn needed vars.
21
- def initialize(args)
22
- if args[:monitor]
23
- @mutex = Monitor.new
24
- elsif args[:mutex]
25
- @mutex = args[:mutex]
26
- else
27
- @mutex = Mutex.new
28
- end
29
-
30
- @obj = args[:obj]
31
- end
32
-
33
- #Proxies all calls to this object through the mutex.
34
- def method_missing(method_name, *args, &block)
35
- @mutex.synchronize do
36
- @obj.__send__(method_name, *args, &block)
37
- end
38
- end
39
- end
40
-
41
- #This module can be included on a class to make all method-calls synchronized (by using monitor). Examples with array and hash are below.
42
- #
43
- #===Examples
44
- # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
45
- # include Knj::Threadsafe::Monitored
46
- # end
47
- module Monitored
48
- def self.included(base)
49
- Knj::Strings.const_get_full(base.to_s).class_eval do
50
- self.instance_methods.each do |method_name|
51
- #These two methods create warnings under JRuby.
52
- if RUBY_ENGINE == "jruby"
53
- next if method_name == :instance_exec or method_name == :instance_eval
54
- end
55
-
56
- new_method_name = "_ts_#{method_name}"
57
- alias_method(new_method_name, method_name)
58
-
59
- define_method method_name do |*args, &block|
60
- #Need to use monitor, since the internal calls might have to run not-synchronized, and we have just overwritten the internal methods.
61
- @_ts_mutex = Monitor.new if !@_ts_mutex
62
- @_ts_mutex.synchronize do
63
- return self._ts___send__(new_method_name, *args, &block)
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
70
-
71
- #This module can be included on a class to make all method-calls synchronized (by using mutex). Examples with array and hash are below.
72
- #
73
- #===Examples
74
- # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
75
- # include Knj::Threadsafe::Mutexed
76
- # end
77
- module Mutexed
78
- def self.included(base)
79
- Knj::Strings.const_get_full(base.to_s).class_eval do
80
- self.instance_methods.each do |method_name|
81
- #These two methods create warnings under JRuby.
82
- if RUBY_ENGINE == "jruby"
83
- next if method_name == :instance_exec or method_name == :instance_eval
84
- end
85
-
86
- new_method_name = "_ts_#{method_name}"
87
- alias_method(new_method_name, method_name)
88
-
89
- define_method method_name do |*args, &block|
90
- #Need to use monitor, since the internal calls might have to run not-synchronized, and we have just overwritten the internal methods.
91
- @_ts_mutex = Mutex.new if !@_ts_mutex
92
- @_ts_mutex.synchronize do
93
- return self._ts___send__(new_method_name, *args, &block)
94
- end
95
- end
96
- end
97
- end
98
- end
99
- end
100
-
101
- #Predefined synchronized array.
102
- #
103
- #===Examples
104
- # arr = Knj::Threadsafe::Synced_array.new
105
- # arr << 5
106
- # ret = arr[0]
107
- class Synced_array < ::Array
108
- include Monitored
109
- end
110
-
111
- #Predefined synchronized hash.
112
- #
113
- #===Examples
114
- # h = Knj::Threadsafe::Synced_hash.new
115
- # h['test'] = 'trala'
116
- # ret = h['test']
117
- class Synced_hash < ::Hash
118
- include Monitored
119
- end
120
- end