knjrbfw 0.0.101 → 0.0.102

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,13 +7,14 @@ gem "tsafe"
7
7
  gem "datet"
8
8
  gem "http2"
9
9
  gem "php4r"
10
+ gem "ruby_process"
10
11
 
11
12
  # Add dependencies to develop your gem here.
12
13
  # Include everything needed to run rake, tests, features, etc.
13
14
  group :development do
14
- gem "rspec", "~> 2.3.0"
15
- gem "bundler", ">= 1.0.0"
16
- gem "jeweler", "~> 1.6.3"
15
+ gem "rspec"
16
+ gem "bundler"
17
+ gem "jeweler"
17
18
  gem "sqlite3" if RUBY_ENGINE != "jruby"
18
19
  gem "rmagick" if RUBY_ENGINE != "jruby"
19
20
  gem "rmagick4j" if RUBY_ENGINE == "jruby"
data/Gemfile.lock CHANGED
@@ -1,28 +1,35 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- datet (0.0.20)
5
- diff-lcs (1.1.3)
4
+ datet (0.0.21)
5
+ diff-lcs (1.2.1)
6
6
  git (1.2.5)
7
- http2 (0.0.10)
8
- jeweler (1.6.4)
7
+ http2 (0.0.13)
8
+ jeweler (1.8.4)
9
9
  bundler (~> 1.0)
10
10
  git (>= 1.2.5)
11
11
  rake
12
+ rdoc
13
+ json (1.7.7)
12
14
  php4r (0.0.3)
13
15
  datet
14
16
  http2
15
- rake (0.9.2.2)
16
- rmagick (2.13.1)
17
- rspec (2.3.0)
18
- rspec-core (~> 2.3.0)
19
- rspec-expectations (~> 2.3.0)
20
- rspec-mocks (~> 2.3.0)
21
- rspec-core (2.3.1)
22
- rspec-expectations (2.3.0)
23
- diff-lcs (~> 1.1.2)
24
- rspec-mocks (2.3.0)
25
- sqlite3 (1.3.6)
17
+ rake (10.0.3)
18
+ rdoc (4.0.0)
19
+ json (~> 1.4)
20
+ rmagick (2.13.2)
21
+ rspec (2.13.0)
22
+ rspec-core (~> 2.13.0)
23
+ rspec-expectations (~> 2.13.0)
24
+ rspec-mocks (~> 2.13.0)
25
+ rspec-core (2.13.0)
26
+ rspec-expectations (2.13.0)
27
+ diff-lcs (>= 1.1.3, < 2.0)
28
+ rspec-mocks (2.13.0)
29
+ ruby_process (0.0.8)
30
+ tsafe
31
+ wref
32
+ sqlite3 (1.3.7)
26
33
  tsafe (0.0.11)
27
34
  wref (0.0.5)
28
35
 
@@ -30,13 +37,14 @@ PLATFORMS
30
37
  ruby
31
38
 
32
39
  DEPENDENCIES
33
- bundler (>= 1.0.0)
40
+ bundler
34
41
  datet
35
42
  http2
36
- jeweler (~> 1.6.3)
43
+ jeweler
37
44
  php4r
38
45
  rmagick
39
- rspec (~> 2.3.0)
46
+ rspec
47
+ ruby_process
40
48
  sqlite3
41
49
  tsafe
42
50
  wref
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  task :default => :spec
40
40
 
41
- require 'rake/rdoctask'
41
+ require 'rdoc/task'
42
42
  Rake::RDocTask.new do |rdoc|
43
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.101
1
+ 0.0.102
data/knjrbfw.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{knjrbfw}
8
- s.version = "0.0.101"
7
+ s.name = "knjrbfw"
8
+ s.version = "0.0.102"
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-10-12}
13
- s.description = %q{Including stuff for HTTP, SSH and much more.}
14
- s.email = %q{k@spernj.org}
12
+ s.date = "2013-03-03"
13
+ s.description = "Including stuff for HTTP, SSH and much more."
14
+ s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -61,7 +61,6 @@ Gem::Specification.new do |s|
61
61
  "lib/knj/csv.rb",
62
62
  "lib/knj/datarow.rb",
63
63
  "lib/knj/datarow_custom.rb",
64
- "lib/knj/datestamp.rb",
65
64
  "lib/knj/db.rb",
66
65
  "lib/knj/degulesider.rb",
67
66
  "lib/knj/erb/apache_knjerb.conf",
@@ -263,11 +262,11 @@ Gem::Specification.new do |s|
263
262
  "spec/web_spec.rb",
264
263
  "testfiles/image.jpg"
265
264
  ]
266
- s.homepage = %q{http://github.com/kaspernj/knjrbfw}
265
+ s.homepage = "http://github.com/kaspernj/knjrbfw"
267
266
  s.licenses = ["MIT"]
268
267
  s.require_paths = ["lib"]
269
- s.rubygems_version = %q{1.6.2}
270
- s.summary = %q{A framework with lots of stuff for Ruby.}
268
+ s.rubygems_version = "1.8.25"
269
+ s.summary = "A framework with lots of stuff for Ruby."
271
270
 
272
271
  if s.respond_to? :specification_version then
273
272
  s.specification_version = 3
@@ -278,9 +277,10 @@ Gem::Specification.new do |s|
278
277
  s.add_runtime_dependency(%q<datet>, [">= 0"])
279
278
  s.add_runtime_dependency(%q<http2>, [">= 0"])
280
279
  s.add_runtime_dependency(%q<php4r>, [">= 0"])
281
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
282
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
283
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
280
+ s.add_runtime_dependency(%q<ruby_process>, [">= 0"])
281
+ s.add_development_dependency(%q<rspec>, [">= 0"])
282
+ s.add_development_dependency(%q<bundler>, [">= 0"])
283
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
284
284
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
285
285
  s.add_development_dependency(%q<rmagick>, [">= 0"])
286
286
  else
@@ -289,9 +289,10 @@ Gem::Specification.new do |s|
289
289
  s.add_dependency(%q<datet>, [">= 0"])
290
290
  s.add_dependency(%q<http2>, [">= 0"])
291
291
  s.add_dependency(%q<php4r>, [">= 0"])
292
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
293
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
294
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
292
+ s.add_dependency(%q<ruby_process>, [">= 0"])
293
+ s.add_dependency(%q<rspec>, [">= 0"])
294
+ s.add_dependency(%q<bundler>, [">= 0"])
295
+ s.add_dependency(%q<jeweler>, [">= 0"])
295
296
  s.add_dependency(%q<sqlite3>, [">= 0"])
296
297
  s.add_dependency(%q<rmagick>, [">= 0"])
297
298
  end
@@ -301,9 +302,10 @@ Gem::Specification.new do |s|
301
302
  s.add_dependency(%q<datet>, [">= 0"])
302
303
  s.add_dependency(%q<http2>, [">= 0"])
303
304
  s.add_dependency(%q<php4r>, [">= 0"])
304
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
305
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
306
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
305
+ s.add_dependency(%q<ruby_process>, [">= 0"])
306
+ s.add_dependency(%q<rspec>, [">= 0"])
307
+ s.add_dependency(%q<bundler>, [">= 0"])
308
+ s.add_dependency(%q<jeweler>, [">= 0"])
307
309
  s.add_dependency(%q<sqlite3>, [">= 0"])
308
310
  s.add_dependency(%q<rmagick>, [">= 0"])
309
311
  end
@@ -1,6 +1 @@
1
- begin
2
- require "wref" if !Kernel.const_defined?(:Wref)
3
- rescue LoadError
4
- require "rubygems"
5
- require "wref" if !Kernel.const_defined?(:Wref)
6
- end
1
+ Knj.gem_require(:Wref, :wref)
@@ -1,3 +1,5 @@
1
+ Knj.gem_require(:Datet, :datet)
2
+
1
3
  #This class can help you parse results from command-line commands.
2
4
  class Knj::Cmd_parser
3
5
  #Parses the results of "ls -l".
data/lib/knj/datarow.rb CHANGED
@@ -160,32 +160,7 @@ class Knj::Datarow
160
160
  where_args = nil
161
161
  end
162
162
 
163
- define_method(methodname) do |*args, &block|
164
- if args and args[0]
165
- list_args = args[0]
166
- else
167
- list_args = {}
168
- end
169
-
170
- list_args.merge!(where_args) if where_args
171
- list_args[colname.to_s] = self.id
172
-
173
- return self.class.ob.list(classname, list_args, &block)
174
- end
175
-
176
- define_method("#{methodname}_count".to_sym) do |*args|
177
- list_args = args[0] if args and args[0]
178
- list_args = {} if !list_args
179
- list_args[colname.to_s] = self.id
180
- list_args["count"] = true
181
-
182
- return self.class.ob.list(classname, list_args)
183
- end
184
-
185
- define_method("#{methodname}_last".to_sym) do |args|
186
- args = {} if !args
187
- return self.class.ob.list(classname, {"orderby" => [["id", "desc"]], "limit" => 1}.merge(args))
188
- end
163
+ self.define_many_methods(classname, methodname, colname, where_args)
189
164
 
190
165
  self.joined_tables(
191
166
  classname => {
@@ -251,26 +226,7 @@ class Knj::Datarow
251
226
 
252
227
  methodname = classname.to_s.downcase if !methodname
253
228
  colname = "#{classname.to_s.downcase}_id".to_sym if !colname
254
-
255
- define_method(methodname) do
256
- return self.class.ob.get_try(self, colname, classname)
257
- end
258
-
259
- methodname_html = "#{methodname}_html".to_sym
260
- define_method(methodname_html) do |*args|
261
- obj = self.__send__(methodname)
262
- return self.class.ob.events.call(:no_html, classname) if !obj
263
-
264
- raise "Class '#{classname}' does not have a 'html'-method." if !obj.respond_to?(:html)
265
- return obj.html(*args)
266
- end
267
-
268
- methodname_name = "#{methodname}_name".to_sym
269
- define_method(methodname_name) do |*args|
270
- obj = self.__send__(methodname)
271
- return self.class.ob.events.call(:no_name, classname) if !obj
272
- return obj.name(*args)
273
- end
229
+ self.define_one_methods(classname, methodname, colname)
274
230
 
275
231
  self.joined_tables(
276
232
  classname => {
@@ -368,12 +324,13 @@ class Knj::Datarow
368
324
  sqlhelper_args[:table] = @table
369
325
 
370
326
  @db.tables[table].columns do |col_obj|
371
- col_name = col_obj.name
327
+ col_name = col_obj.name.to_s
328
+ col_name_sym = col_name.to_sym
372
329
  col_type = col_obj.type
373
330
  col_type = :int if col_type == :bigint or col_type == :tinyint or col_type == :mediumint or col_type == :smallint
374
331
  sqlhelper_args[:cols][col_name] = true
375
332
 
376
- self.define_bool_methods(:inst_methods => inst_methods, :col_name => col_name)
333
+ self.define_bool_methods(inst_methods, col_name)
377
334
 
378
335
  if col_type == :enum and col_obj.maxlength == "'0','1'"
379
336
  sqlhelper_args[:cols_bools] << col_name
@@ -385,19 +342,19 @@ class Knj::Datarow
385
342
  sqlhelper_args[:cols_str] << col_name
386
343
  elsif col_type == :date or col_type == :datetime
387
344
  sqlhelper_args[:cols_date] << col_name
388
- self.define_date_methods(:inst_methods => inst_methods, :col_name => col_name)
345
+ self.define_date_methods(inst_methods, col_name_sym)
389
346
  end
390
347
 
391
348
  if col_type == :int or col_type == :decimal
392
- self.define_numeric_methods(:inst_methods => inst_methods, :col_name => col_name)
349
+ self.define_numeric_methods(inst_methods, col_name_sym)
393
350
  end
394
351
 
395
352
  if col_type == :int or col_type == :varchar
396
- self.define_text_methods(:inst_methods => inst_methods, :col_name => col_name)
353
+ self.define_text_methods(inst_methods, col_name_sym)
397
354
  end
398
355
 
399
356
  if col_type == :time
400
- self.define_time_methods(:inst_methods => inst_methods, :col_name => col_name)
357
+ self.define_time_methods(inst_methods, col_name_sym)
401
358
  end
402
359
  end
403
360
 
@@ -801,46 +758,41 @@ class Knj::Datarow
801
758
  end
802
759
 
803
760
  #Defines the boolean-methods based on enum-columns.
804
- def self.define_bool_methods(args)
761
+ def self.define_bool_methods(inst_methods, col_name)
805
762
  #Spawns a method on the class which returns true if the data is 1.
806
- method_name = "#{args[:col_name]}?".to_sym
807
-
808
- if args[:inst_methods].index(method_name) == nil
809
- define_method(method_name) do
810
- return true if self[args[:col_name].to_sym].to_s == "1"
763
+ if !inst_methods.include?("#{col_name}?".to_sym)
764
+ define_method("#{col_name}?") do
765
+ return true if self[col_name.to_sym].to_s == "1"
811
766
  return false
812
767
  end
813
768
  end
814
769
  end
815
770
 
816
771
  #Defines date- and time-columns based on datetime- and date-columns.
817
- def self.define_date_methods(args)
818
- method_name = "#{args[:col_name]}_str".to_sym
819
- if args[:inst_methods].index(method_name) == nil
820
- define_method(method_name) do |*method_args|
821
- if Datet.is_nullstamp?(self[args[:col_name].to_sym])
772
+ def self.define_date_methods(inst_methods, col_name)
773
+ if !inst_methods.include?("#{col_name}_str".to_sym)
774
+ define_method("#{col_name}_str") do |*method_args|
775
+ if Datet.is_nullstamp?(self[col_name])
822
776
  return self.class.ob.events.call(:no_date, self.class.name)
823
777
  end
824
778
 
825
- return Datet.in(self[args[:col_name].to_sym]).out(*method_args)
779
+ return Datet.in(self[col_name]).out(*method_args)
826
780
  end
827
781
  end
828
782
 
829
- method_name = "#{args[:col_name]}".to_sym
830
- if args[:inst_methods].index(method_name) == nil
831
- define_method(method_name) do |*method_args|
832
- return false if Datet.is_nullstamp?(self[args[:col_name].to_sym])
833
- return Datet.in(self[args[:col_name].to_sym])
783
+ if !inst_methods.include?(col_name)
784
+ define_method(col_name) do |*method_args|
785
+ return false if Datet.is_nullstamp?(self[col_name])
786
+ return Datet.in(self[col_name])
834
787
  end
835
788
  end
836
789
  end
837
790
 
838
791
  #Define various methods based on integer-columns.
839
- def self.define_numeric_methods(args)
840
- method_name = "#{args[:col_name]}_format"
841
- if args[:inst_methods].index(method_name) == nil
842
- define_method(method_name) do |*method_args|
843
- return Knj::Locales.number_out(self[args[:col_name].to_sym], *method_args)
792
+ def self.define_numeric_methods(inst_methods, col_name)
793
+ if !inst_methods.include?("#{col_name}_format".to_sym)
794
+ define_method("#{col_name}_format") do |*method_args|
795
+ return Knj::Locales.number_out(self[col_name], *method_args)
844
796
  end
845
797
  end
846
798
  end
@@ -849,22 +801,73 @@ class Knj::Datarow
849
801
  #===Examples
850
802
  # user = Models::User.by_username('John Doe')
851
803
  # print user.id
852
- def self.define_text_methods(args)
853
- method_name = "by_#{args[:col_name]}".to_sym
854
- if args[:inst_methods].index(method_name) == nil and RUBY_VERSION.to_s.slice(0, 3) != "1.8"
855
- define_singleton_method(method_name) do |arg|
856
- return self.class.ob.get_by(self.class.table, {args[:col_name].to_s => arg})
804
+ def self.define_text_methods(inst_methods, col_name)
805
+ if !inst_methods.include?("by_#{col_name}".to_sym) and RUBY_VERSION.to_s.slice(0, 3) != "1.8"
806
+ define_singleton_method("by_#{col_name}") do |arg|
807
+ return self.class.ob.get_by(self.class.table, {col_name.to_s => arg})
857
808
  end
858
809
  end
859
810
  end
860
811
 
861
812
  #Defines dbtime-methods based on time-columns.
862
- def self.define_time_methods(args)
863
- method_name = "#{args[:col_name]}_dbt"
864
- if args[:inst_methods].index(method_name) == nil
865
- define_method(method_name) do
866
- return Knj::Db::Dbtime.new(self[args[:col_name].to_sym])
813
+ def self.define_time_methods(inst_methods, col_name)
814
+ if !inst_methods.include?("#{col_name}_dbt".to_sym)
815
+ define_method("#{col_name}_dbt") do
816
+ return Knj::Db::Dbtime.new(self[col_name.to_sym])
817
+ end
818
+ end
819
+ end
820
+
821
+ #Memory friendly helper method that defines methods for 'has_many'.
822
+ def self.define_many_methods(classname, methodname, colname, where_args)
823
+ define_method(methodname) do |*args, &block|
824
+ if args and args[0]
825
+ list_args = args[0]
826
+ else
827
+ list_args = {}
867
828
  end
829
+
830
+ list_args.merge!(where_args) if where_args
831
+ list_args[colname.to_s] = self.id
832
+
833
+ return self.class.ob.list(classname, list_args, &block)
834
+ end
835
+
836
+ define_method("#{methodname}_count".to_sym) do |*args|
837
+ list_args = args[0] if args and args[0]
838
+ list_args = {} if !list_args
839
+ list_args[colname.to_s] = self.id
840
+ list_args["count"] = true
841
+
842
+ return self.class.ob.list(classname, list_args)
843
+ end
844
+
845
+ define_method("#{methodname}_last".to_sym) do |args|
846
+ args = {} if !args
847
+ return self.class.ob.list(classname, {"orderby" => [["id", "desc"]], "limit" => 1}.merge(args))
848
+ end
849
+ end
850
+
851
+ #Memory friendly helper method that defines methods for 'has_one'.
852
+ def self.define_one_methods(classname, methodname, colname)
853
+ define_method(methodname) do
854
+ return self.class.ob.get_try(self, colname, classname)
855
+ end
856
+
857
+ methodname_html = "#{methodname}_html".to_sym
858
+ define_method(methodname_html) do |*args|
859
+ obj = self.__send__(methodname)
860
+ return self.class.ob.events.call(:no_html, classname) if !obj
861
+
862
+ raise "Class '#{classname}' does not have a 'html'-method." if !obj.respond_to?(:html)
863
+ return obj.html(*args)
864
+ end
865
+
866
+ methodname_name = "#{methodname}_name".to_sym
867
+ define_method(methodname_name) do |*args|
868
+ obj = self.__send__(methodname)
869
+ return self.class.ob.events.call(:no_name, classname) if !obj
870
+ return obj.name(*args)
868
871
  end
869
872
  end
870
873
  end
data/lib/knj/eruby.rb CHANGED
@@ -94,6 +94,8 @@ class Knj::Eruby
94
94
  @error = true
95
95
  self.handle_error(e)
96
96
  end
97
+
98
+ return nil
97
99
  end
98
100
 
99
101
  #Destroyes this object unsetting all variables and clearing all cache.
@@ -109,6 +111,8 @@ class Knj::Eruby
109
111
  @connects = nil
110
112
  @headers = nil
111
113
  @cookies = nil
114
+
115
+ return nil
112
116
  end
113
117
 
114
118
  #Returns various headers as one complete string ready to be used in a HTTP-request.
@@ -140,28 +144,33 @@ class Knj::Eruby
140
144
  #Resets all connections.
141
145
  def reset_connects
142
146
  @connects = {}
147
+ return nil
143
148
  end
144
149
 
145
150
  #Resets all headers.
146
151
  def reset_headers
147
152
  @headers = []
148
153
  @cookies = []
154
+ return nil
149
155
  end
150
156
 
151
157
  #Adds a new header to the list.
152
158
  def header(key, value)
153
159
  @headers << [key, value]
160
+ return nil
154
161
  end
155
162
 
156
163
  #Adds a new cookie to the list.
157
164
  def cookie(cookie_data)
158
165
  @cookies << cookie_data
166
+ return nil
159
167
  end
160
168
 
161
169
  #Connects a block to a certain event.
162
170
  def connect(signal, &block)
163
171
  @connects[signal] = [] if !@connects.key?(signal)
164
172
  @connects[signal] << block
173
+ return nil
165
174
  end
166
175
 
167
176
  def printcont(tmp_out, args = {})
@@ -183,6 +192,8 @@ class Knj::Eruby
183
192
  print tmp_out.read
184
193
  end
185
194
  end
195
+
196
+ return nil
186
197
  end
187
198
 
188
199
  def load_return(filename, args = {})
@@ -221,6 +232,8 @@ class Knj::Eruby
221
232
  self.handle_error(e)
222
233
  self.printcont(tmp_out, args)
223
234
  end
235
+
236
+ return nil
224
237
  end
225
238
 
226
239
  #This method will handle an error without crashing simply adding the error to the print-queue.
@@ -253,6 +266,8 @@ class Knj::Eruby
253
266
  end
254
267
 
255
268
  print "</pre>"
269
+
270
+ return nil
256
271
  end
257
272
  end
258
273
 
@@ -10,30 +10,34 @@ class Knj::Google_sitemap
10
10
  require "time"
11
11
 
12
12
  #REXML is known to leak memory - use subprocess.
13
- @subproc = Knj::Process_meta.new("id" => "google_sitemap", "debug_err" => true)
13
+ Knj.gem_require(:Ruby_process)
14
14
 
15
15
  begin
16
- @subproc.static("Object", "require", "rexml/rexml")
17
- @subproc.static("Object", "require", "rexml/document")
18
-
19
- @doc = @subproc.new("REXML::Document")
20
-
21
- xmldecl = @subproc.new("REXML::XMLDecl", "1.0", "UTF-8")
22
- @doc._pm_send_noret("<<", xmldecl)
23
-
24
- urlset = @subproc.proxy_from_call(@doc, "add_element", "urlset")
25
- urlset._pm_send_noret("add_attributes", {"xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9"})
26
-
27
- @root = @subproc.proxy_from_call(@doc, "root")
28
- yield(self)
16
+ Ruby_process::Cproxy.run do |data|
17
+ @subproc = data[:subproc]
18
+ @subproc.static(:Object, :require, "rexml/rexml")
19
+ @subproc.static(:Object, :require, "rexml/document")
20
+ @subproc.static(:Object, :require, "rexml/element")
21
+
22
+ @doc = @subproc.new("REXML::Document")
23
+
24
+ xmldecl = @subproc.new("REXML::XMLDecl", "1.0", "UTF-8")
25
+ @doc << xmldecl
26
+
27
+ urlset = @doc.add_element("urlset")
28
+ urlset.add_attributes("xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9")
29
+
30
+ @root = @doc.root
31
+ yield(self)
32
+ end
29
33
  ensure
30
34
  @doc = nil
31
35
  @root = nil
32
- @subproc.destroy
33
36
  @subproc = nil
34
37
  end
35
38
  end
36
39
 
40
+ #Adds a URL to the XML.
37
41
  def add_url(url_value, lastmod_value, cf_value = nil, priority_value = nil)
38
42
  if !lastmod_value or lastmod_value.to_i == 0
39
43
  raise sprintf("Invalid date: %1$s, url: %2$s", lastmod_value.to_s, url_value)
@@ -41,27 +45,27 @@ class Knj::Google_sitemap
41
45
 
42
46
  el = @subproc.new("REXML::Element", "url")
43
47
 
44
- loc = @subproc.proxy_from_call(el, "add_element", "loc")
45
- loc._pm_send_noret("text=", url_value)
48
+ loc = el.add_element("loc")
49
+ loc.text = url_value
46
50
 
47
- lm = @subproc.proxy_from_call(el, "add_element", "lastmod")
51
+ lm = el.add_element("lastmod")
48
52
  if @args.key?(:date_min) and @args[:date_min] > lastmod_value
49
53
  lastmod_value = @args[:date_min]
50
54
  end
51
55
 
52
- lm._pm_send_noret("text=", lastmod_value.iso8601)
56
+ lm.text = lastmod_value.iso8601
53
57
 
54
58
  if cf_value
55
- cf = @subproc.proxy_from_call(el, "add_element", "changefreq")
56
- cf._pm_send_noret("text=", cf_value)
59
+ cf = el.add_element("changefreq")
60
+ cf.text = cf_value
57
61
  end
58
62
 
59
63
  if priority_value
60
- priority = @subproc.proxy_from_call("el", "add_element", "priority")
61
- priority._pm_send_noret("text=", priority_value)
64
+ priority = el.add_element("priority")
65
+ priority.text = priority_value
62
66
  end
63
67
 
64
- @root._pm_send_noret("<<", el)
68
+ @root << el
65
69
  end
66
70
 
67
71
  #This will return a non-human-readable XML-string.
@@ -75,24 +79,21 @@ class Knj::Google_sitemap
75
79
  end
76
80
 
77
81
  #This will print the result.
78
- def write
82
+ def write(io = $stdout)
79
83
  #Require and spawn StringIO in the subprocess.
80
- @subproc.static("Object", "require", "stringio")
81
- string_io = @subproc.spawn_object("StringIO")
84
+ @subproc.static(:Object, :require, "stringio")
85
+ string_io = @subproc.new("StringIO")
82
86
 
83
87
  #We want a human-readable print.
84
- writer = @subproc.spawn_object("REXML::Formatters::Pretty", 5)
85
- writer._pm_send_noret("write", @doc, string_io)
88
+ writer = @subproc.new("REXML::Formatters::Pretty", 5)
89
+ writer.write(@doc, string_io)
86
90
 
87
91
  #Prepare printing by rewinding StringIO to read from beginning.
88
- string_io._pm_send_noret("rewind")
89
-
90
- #Buffer results from subprocess in order to speed up printing.
91
- string_io._process_meta_block_buffer_use = true
92
+ string_io.rewind
92
93
 
93
94
  #Print out the result in bits to avoid raping the memory (subprocess is already raped - no question there...).
94
- string_io._pm_send_noret("each", 4096) do |str|
95
- print str
95
+ string_io.each(4096) do |str|
96
+ io.print(str)
96
97
  end
97
98
  end
98
99
  end
@@ -1,6 +1,7 @@
1
+ Knj.gem_require(:wref)
2
+
1
3
  #Containing various helper methods for Gtk2-windows.
2
4
  class Knj::Gtk2::Window
3
- require "wref" if !Kernel.const_defined?(:Wref)
4
5
  @@uniques = Wref_map.new
5
6
 
6
7
  #Used to make a window-instance unique. If it already exists when unique! is called, then it will pass focus to the existing window instead of yielding the block, which should contain code to create the window.