knjappserver 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,9 +11,9 @@ gem "tsafe"
11
11
  # Add dependencies to develop your gem here.
12
12
  # Include everything needed to run rake, tests, features, etc.
13
13
  group :development do
14
+ gem "json"
14
15
  gem "rspec", "~> 2.3.0"
15
16
  gem "bundler", ">= 1.0.0"
16
17
  gem "jeweler", "~> 1.6.3"
17
- gem "rcov", ">= 0"
18
18
  gem "sqlite3" if RUBY_ENGINE != "jruby"
19
19
  end
data/Gemfile.lock CHANGED
@@ -9,16 +9,17 @@ GEM
9
9
  bundler (~> 1.0)
10
10
  git (>= 1.2.5)
11
11
  rake
12
- knjrbfw (0.0.8)
13
- mail (2.3.0)
12
+ json (1.7.3)
13
+ knjrbfw (0.0.53)
14
+ tsafe
15
+ wref
16
+ mail (2.4.4)
14
17
  i18n (>= 0.4.0)
15
18
  mime-types (~> 1.16)
16
19
  treetop (~> 1.4.8)
17
- mime-types (1.17.2)
18
- polyglot (0.3.2)
20
+ mime-types (1.19)
21
+ polyglot (0.3.3)
19
22
  rake (0.9.2.2)
20
- rcov (0.9.11)
21
- rcov (0.9.11-java)
22
23
  rspec (2.3.0)
23
24
  rspec-core (~> 2.3.0)
24
25
  rspec-expectations (~> 2.3.0)
@@ -27,23 +28,23 @@ GEM
27
28
  rspec-expectations (2.3.0)
28
29
  diff-lcs (~> 1.1.2)
29
30
  rspec-mocks (2.3.0)
30
- sqlite3 (1.3.4)
31
+ sqlite3 (1.3.6)
31
32
  treetop (1.4.10)
32
33
  polyglot
33
34
  polyglot (>= 0.3.1)
34
35
  tsafe (0.0.1)
36
+ wref (0.0.4)
35
37
 
36
38
  PLATFORMS
37
- java
38
39
  ruby
39
40
 
40
41
  DEPENDENCIES
41
42
  bundler (>= 1.0.0)
42
43
  erubis
43
44
  jeweler (~> 1.6.3)
45
+ json
44
46
  knjrbfw
45
47
  mail
46
- rcov
47
48
  rspec (~> 2.3.0)
48
49
  sqlite3
49
50
  tsafe
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.25
1
+ 0.0.26
data/knjappserver.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjappserver}
8
- s.version = "0.0.25"
8
+ s.version = "0.0.26"
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-06-28}
12
+ s.date = %q{2012-07-04}
13
13
  s.description = %q{Which supports a lot of undocumented stuff.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.executables = ["check_running.rb", "knjappserver_start.rb"]
@@ -104,20 +104,20 @@ Gem::Specification.new do |s|
104
104
  s.add_runtime_dependency(%q<erubis>, [">= 0"])
105
105
  s.add_runtime_dependency(%q<mail>, [">= 0"])
106
106
  s.add_runtime_dependency(%q<tsafe>, [">= 0"])
107
+ s.add_development_dependency(%q<json>, [">= 0"])
107
108
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
108
109
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
109
110
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
110
- s.add_development_dependency(%q<rcov>, [">= 0"])
111
111
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
112
112
  else
113
113
  s.add_dependency(%q<knjrbfw>, [">= 0"])
114
114
  s.add_dependency(%q<erubis>, [">= 0"])
115
115
  s.add_dependency(%q<mail>, [">= 0"])
116
116
  s.add_dependency(%q<tsafe>, [">= 0"])
117
+ s.add_dependency(%q<json>, [">= 0"])
117
118
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
118
119
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
119
120
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
120
- s.add_dependency(%q<rcov>, [">= 0"])
121
121
  s.add_dependency(%q<sqlite3>, [">= 0"])
122
122
  end
123
123
  else
@@ -125,10 +125,10 @@ Gem::Specification.new do |s|
125
125
  s.add_dependency(%q<erubis>, [">= 0"])
126
126
  s.add_dependency(%q<mail>, [">= 0"])
127
127
  s.add_dependency(%q<tsafe>, [">= 0"])
128
+ s.add_dependency(%q<json>, [">= 0"])
128
129
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
129
130
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
130
131
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
131
- s.add_dependency(%q<rcov>, [">= 0"])
132
132
  s.add_dependency(%q<sqlite3>, [">= 0"])
133
133
  end
134
134
  end
@@ -128,11 +128,10 @@ class Knjappserver::Httpsession
128
128
  STDOUT.print "#{__id__} - Closing httpsession because of timeout.\n" if @debug
129
129
  rescue Errno::ECONNRESET, Errno::ENOTCONN, Errno::EPIPE => e
130
130
  STDOUT.print "#{__id__} - Connection error (#{e.inspect})...\n" if @debug
131
- rescue SystemExit, Interrupt => e
131
+ rescue Interrupt => e
132
132
  raise e
133
133
  rescue Exception => e
134
- STDOUT.puts e.inspect
135
- STDOUT.puts e.backtrace
134
+ STDOUT.puts Knj::Errors.error_str(e)
136
135
  ensure
137
136
  self.destruct
138
137
  end
@@ -298,11 +297,9 @@ class Knjappserver::Httpsession
298
297
  Thread.current[:knjappserver][:contentgroup] = @cgroup
299
298
  time_start = Time.now.to_f if @debug
300
299
 
301
- @kas.events.call(:request_begin, {
302
- :httpsession => self
303
- }) if @kas.events
304
-
305
300
  begin
301
+ @kas.events.call(:request_begin, :httpsession => self) if @kas.events
302
+
306
303
  Timeout.timeout(@kas.config[:timeout]) do
307
304
  if @handlers_cache.key?(@ext)
308
305
  STDOUT.print "Calling handler.\n" if @debug
@@ -349,6 +346,8 @@ class Knjappserver::Httpsession
349
346
  end
350
347
  end
351
348
  end
349
+ rescue SystemExit
350
+ #do nothing - ignore.
352
351
  rescue Timeout::Error
353
352
  @resp.status = 500
354
353
  print "The request timed out."
@@ -291,12 +291,13 @@ class Knjappserver
291
291
 
292
292
  #Deletes all logs for an object.
293
293
  def logs_delete(obj)
294
- @ob.list(:Log_link, {"object_class" => obj.class.name, "object_id" => obj.id}) do |log_link|
295
- log = log_link.log
296
- @ob.delete(log_link)
294
+ @db.q_buffer do |db_buffer|
295
+ buffer_hash = {:db_buffer => db_buffer}
297
296
 
298
- if log
299
- @ob.delete(log) if log.links("count" => true) <= 0
297
+ @ob.list(:Log_link, {"object_class" => obj.class.name, "object_id" => obj.id}) do |log_link|
298
+ log = log_link.log
299
+ @ob.delete(log_link, buffer_hash)
300
+ @ob.delete(log, buffer_hash) if log and log.links("count" => true) <= 0
300
301
  end
301
302
  end
302
303
  end
@@ -5,14 +5,11 @@ describe "Knjappserver" do
5
5
  require "rubygems"
6
6
  require "knjappserver"
7
7
  require "knjrbfw"
8
- require "knj/autoload"
8
+ require "sqlite3" if RUBY_ENGINE != "jruby"
9
9
 
10
10
  db_path = "#{Knj::Os.tmpdir}/knjappserver_rspec.sqlite3"
11
11
  File.unlink(db_path) if File.exists?(db_path)
12
12
 
13
- require "knj/knjdb/libknjdb.rb"
14
- #require "sqlite3" if RUBY_ENGINE != "jruby"
15
-
16
13
  begin
17
14
  db = Knj::Db.new(
18
15
  :type => "sqlite3",
@@ -160,6 +157,43 @@ describe "Knjappserver" do
160
157
  raise data["data"] if data["data"] != "123+456%789%20"
161
158
  end
162
159
 
160
+ it "should be able to do logging" do
161
+ class ::TestModels
162
+ class Person < Knj::Datarow
163
+
164
+ end
165
+ end
166
+
167
+ Knj::Db::Revision.new.init_db("db" => $appserver.db, "schema" => {
168
+ "tables" => {
169
+ "Person" => {
170
+ "columns" => [
171
+ {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
172
+ {"name" => "name", "type" => "varchar"}
173
+ ]
174
+ }
175
+ }
176
+ })
177
+
178
+ ob = Knj::Objects.new(
179
+ :db => $appserver.db,
180
+ :datarow => true,
181
+ :require => false,
182
+ :module => ::TestModels
183
+ )
184
+
185
+ person = ob.add(:Person, :name => "Kasper")
186
+
187
+ $appserver.log("This is a test", person)
188
+ logs = $appserver.ob.list(:Log, "object_lookup" => person).to_a
189
+ raise "Expected count to be 1 but got: #{logs.length}" if logs.length != 1
190
+
191
+ $appserver.logs_delete(person)
192
+
193
+ logs = $appserver.ob.list(:Log, "object_lookup" => person).to_a
194
+ raise "Expected count to be 0 but got: #{logs.length}" if logs.length != 0
195
+ end
196
+
163
197
  it "should be able to stop." do
164
198
  $appserver.stop
165
199
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knjappserver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.25
5
+ version: 0.0.26
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-06-28 00:00:00 +02:00
13
+ date: 2012-07-04 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -58,46 +58,46 @@ dependencies:
58
58
  prerelease: false
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: rspec
61
+ name: json
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
- - - ~>
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 2.3.0
67
+ version: "0"
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
72
- name: bundler
72
+ name: rspec
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
- - - ">="
76
+ - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: 1.0.0
78
+ version: 2.3.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: *id006
82
82
  - !ruby/object:Gem::Dependency
83
- name: jeweler
83
+ name: bundler
84
84
  requirement: &id007 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ~>
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.6.3
89
+ version: 1.0.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
94
- name: rcov
94
+ name: jeweler
95
95
  requirement: &id008 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
- - - ">="
98
+ - - ~>
99
99
  - !ruby/object:Gem::Version
100
- version: "0"
100
+ version: 1.6.3
101
101
  type: :development
102
102
  prerelease: false
103
103
  version_requirements: *id008
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  requirements:
209
209
  - - ">="
210
210
  - !ruby/object:Gem::Version
211
- hash: 1244618300287044198
211
+ hash: -3766508252438613801
212
212
  segments:
213
213
  - 0
214
214
  version: "0"