knjrbfw 0.0.94 → 0.0.95
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/knjrbfw.gemspec +2 -2
- data/lib/knj/errors.rb +1 -1
- data/lib/knj/gettext_threadded.rb +2 -2
- data/lib/knj/gtk2_tv.rb +2 -3
- data/lib/knj/objects.rb +21 -5
- data/spec/objects_spec.rb +9 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.95
|
data/knjrbfw.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "knjrbfw"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.95"
|
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 = "2012-09-
|
12
|
+
s.date = "2012-09-12"
|
13
13
|
s.description = "Including stuff for HTTP, SSH and much more."
|
14
14
|
s.email = "k@spernj.org"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/knj/errors.rb
CHANGED
@@ -15,7 +15,7 @@ module Knj::Errors
|
|
15
15
|
# print Knj::Errors.error_str(e, :html => true)
|
16
16
|
# end
|
17
17
|
def self.error_str(err, args = {})
|
18
|
-
if !err.is_a?(Exception) and err.class.
|
18
|
+
if !err.is_a?(Exception) and err.class.name != "Java::JavaLang::LinkageError"
|
19
19
|
raise "Invalid object of class '#{err.class.name}' given."
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ class Knj::Gettext_threadded
|
|
23
23
|
@dirs << dir
|
24
24
|
check_folders = ["LC_MESSAGES", "LC_ALL"]
|
25
25
|
|
26
|
-
Dir.
|
26
|
+
Dir.foreach(dir) do |file|
|
27
27
|
fn = "#{dir}/#{file}"
|
28
28
|
if File.directory?(fn) and file.match(/^[a-z]{2}_[A-Z]{2}$/)
|
29
29
|
@langs[file] = {} if !@langs[file]
|
@@ -32,7 +32,7 @@ class Knj::Gettext_threadded
|
|
32
32
|
fpath = "#{dir}/#{file}/#{fname}"
|
33
33
|
|
34
34
|
if File.exists?(fpath) and File.directory?(fpath)
|
35
|
-
Dir.
|
35
|
+
Dir.foreach(fpath) do |pofile|
|
36
36
|
if pofile.match(/\.po$/)
|
37
37
|
pofn = "#{dir}/#{file}/#{fname}/#{pofile}"
|
38
38
|
|
data/lib/knj/gtk2_tv.rb
CHANGED
@@ -77,6 +77,8 @@ module Knj::Gtk2::Tv
|
|
77
77
|
elsif args[:type] == :combo
|
78
78
|
renderer = Gtk::CellRendererCombo.new
|
79
79
|
renderer.text_column = 0
|
80
|
+
renderer.model = args[:model] if args.key?(:model)
|
81
|
+
renderer.has_entry = args[:has_entry] if args.key?(:has_entry)
|
80
82
|
|
81
83
|
if args[:markup]
|
82
84
|
col_args = {:markup => count}
|
@@ -86,9 +88,6 @@ module Knj::Gtk2::Tv
|
|
86
88
|
|
87
89
|
col = Gtk::TreeViewColumn.new(args[:title], renderer, col_args)
|
88
90
|
col.resizable = true
|
89
|
-
|
90
|
-
renderer.model = args[:model] if args.key?(:model)
|
91
|
-
renderer.has_entry = args[:has_entry] if args.key?(:has_entry)
|
92
91
|
else
|
93
92
|
raise "Invalid type: '#{args[:type]}'."
|
94
93
|
end
|
data/lib/knj/objects.rb
CHANGED
@@ -3,9 +3,6 @@ class Knj::Objects
|
|
3
3
|
|
4
4
|
def initialize(args)
|
5
5
|
require "monitor"
|
6
|
-
require "#{$knjpath}arrayext"
|
7
|
-
require "#{$knjpath}event_handler"
|
8
|
-
require "#{$knjpath}hash_methods"
|
9
6
|
|
10
7
|
@callbacks = {}
|
11
8
|
@args = args
|
@@ -400,7 +397,7 @@ class Knj::Objects
|
|
400
397
|
self.requireclass(classname)
|
401
398
|
classob = @args[:module].const_get(classname)
|
402
399
|
|
403
|
-
raise "list-function has not been implemented for #{classname}" if !classob.respond_to?(
|
400
|
+
raise "list-function has not been implemented for '#{classname}'." if !classob.respond_to?(:list)
|
404
401
|
|
405
402
|
args["limit"] = 1
|
406
403
|
self.list(classname, args) do |obj|
|
@@ -830,7 +827,14 @@ class Knj::Objects
|
|
830
827
|
end
|
831
828
|
|
832
829
|
#Delete any translations that has been set on the object by 'has_translation'-method.
|
833
|
-
|
830
|
+
if object.class.translations
|
831
|
+
begin
|
832
|
+
_hb.trans_del(object)
|
833
|
+
rescue NameError
|
834
|
+
_kas.trans_del(object)
|
835
|
+
end
|
836
|
+
end
|
837
|
+
|
834
838
|
|
835
839
|
#If a buffer is given in arguments, then use that to delete the object.
|
836
840
|
if args and buffer = args[:db_buffer]
|
@@ -885,6 +889,18 @@ class Knj::Objects
|
|
885
889
|
end
|
886
890
|
end
|
887
891
|
|
892
|
+
#Deletes all objects with the given IDs 500 at a time to prevent memory exhaustion or timeout.
|
893
|
+
#===Examples
|
894
|
+
# ob.delete_ids(:class => :Person, :ids => [1, 3, 5, 6, 7, 8, 9])
|
895
|
+
def delete_ids(args)
|
896
|
+
while !args[:ids].empty? and ids = args[:ids].shift(500)
|
897
|
+
objs = self.list(:Person, "id" => ids)
|
898
|
+
self.deletes(objs)
|
899
|
+
end
|
900
|
+
|
901
|
+
return nil
|
902
|
+
end
|
903
|
+
|
888
904
|
#Try to clean up objects by unsetting everything, start the garbagecollector, get all the remaining objects via ObjectSpace and set them again. Some (if not all) should be cleaned up and our cache should still be safe... dirty but works.
|
889
905
|
def clean(classn)
|
890
906
|
if classn.is_a?(Array)
|
data/spec/objects_spec.rb
CHANGED
@@ -373,6 +373,15 @@ describe "Objects" do
|
|
373
373
|
raise "Expected timelog2's person-ID to be #{person2.id} but it wasnt: '#{timelog2[:person_id]}'." if timelog2[:person_id].to_i != person2.id.to_i
|
374
374
|
end
|
375
375
|
|
376
|
+
it "should be able to do multiple deletes from ids" do
|
377
|
+
ids = []
|
378
|
+
1.upto(10) do |count|
|
379
|
+
ids << $ob.add(:Person).id
|
380
|
+
end
|
381
|
+
|
382
|
+
$ob.delete_ids(:class => :Person, :ids => ids)
|
383
|
+
end
|
384
|
+
|
376
385
|
it "should delete the temp database again." do
|
377
386
|
db_path = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
|
378
387
|
File.unlink(db_path) if File.exists?(db_path)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: knjrbfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.95
|
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-09-
|
13
|
+
date: 2012-09-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: wref
|
@@ -390,7 +390,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
390
390
|
requirements:
|
391
391
|
- - ">="
|
392
392
|
- !ruby/object:Gem::Version
|
393
|
-
hash:
|
393
|
+
hash: 1443301324215731517
|
394
394
|
segments:
|
395
395
|
- 0
|
396
396
|
version: "0"
|