knjrbfw 0.0.66 → 0.0.67

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -13,7 +13,6 @@ group :development do
13
13
  gem "rspec", "~> 2.3.0"
14
14
  gem "bundler", ">= 1.0.0"
15
15
  gem "jeweler", "~> 1.6.3"
16
- gem "rcov", ">= 0"
17
16
  gem "sqlite3" if RUBY_ENGINE != "jruby"
18
17
  gem "rmagick" if RUBY_ENGINE != "jruby"
19
18
  gem "rmagick4j" if RUBY_ENGINE == "jruby"
@@ -1,21 +1,15 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- datet (0.0.0)
4
+ datet (0.0.12)
5
5
  diff-lcs (1.1.3)
6
6
  git (1.2.5)
7
- http2 (0.0.0)
8
- knjrbfw
7
+ http2 (0.0.5)
9
8
  jeweler (1.6.4)
10
9
  bundler (~> 1.0)
11
10
  git (>= 1.2.5)
12
11
  rake
13
- knjrbfw (0.0.55)
14
- tsafe
15
- wref
16
12
  rake (0.9.2.2)
17
- rcov (0.9.11)
18
- rcov (0.9.11-java)
19
13
  rmagick (2.13.1)
20
14
  rspec (2.3.0)
21
15
  rspec-core (~> 2.3.0)
@@ -26,11 +20,10 @@ GEM
26
20
  diff-lcs (~> 1.1.2)
27
21
  rspec-mocks (2.3.0)
28
22
  sqlite3 (1.3.6)
29
- tsafe (0.0.0)
30
- wref (0.0.0)
23
+ tsafe (0.0.1)
24
+ wref (0.0.5)
31
25
 
32
26
  PLATFORMS
33
- java
34
27
  ruby
35
28
 
36
29
  DEPENDENCIES
@@ -38,7 +31,6 @@ DEPENDENCIES
38
31
  datet
39
32
  http2
40
33
  jeweler (~> 1.6.3)
41
- rcov
42
34
  rmagick
43
35
  rspec (~> 2.3.0)
44
36
  sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.66
1
+ 0.0.67
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjrbfw}
8
- s.version = "0.0.66"
8
+ s.version = "0.0.67"
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-17}
12
+ s.date = %q{2012-07-24}
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 = [
@@ -287,7 +287,6 @@ Gem::Specification.new do |s|
287
287
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
288
288
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
289
289
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
290
- s.add_development_dependency(%q<rcov>, [">= 0"])
291
290
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
292
291
  s.add_development_dependency(%q<rmagick>, [">= 0"])
293
292
  else
@@ -298,7 +297,6 @@ Gem::Specification.new do |s|
298
297
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
299
298
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
300
299
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
301
- s.add_dependency(%q<rcov>, [">= 0"])
302
300
  s.add_dependency(%q<sqlite3>, [">= 0"])
303
301
  s.add_dependency(%q<rmagick>, [">= 0"])
304
302
  end
@@ -310,7 +308,6 @@ Gem::Specification.new do |s|
310
308
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
311
309
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
312
310
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
313
- s.add_dependency(%q<rcov>, [">= 0"])
314
311
  s.add_dependency(%q<sqlite3>, [">= 0"])
315
312
  s.add_dependency(%q<rmagick>, [">= 0"])
316
313
  end
@@ -8,7 +8,7 @@ class Knj::Cmd_parser
8
8
  ret = []
9
9
 
10
10
  str.lines.each do |line|
11
- next if line.match(/^total ([\d\.,]+)(M|k|G|)$/)
11
+ next if line.match(/^total([A-z]*)\s+([\d\.,]+)(M|k|G|)$/)
12
12
  match = line.match(/^(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)\s+(\d+)\s+(.+)\s+([^\W].+?)\s+([\d\.,]+)(M|k|G|K|)\s+((\d+)-(\d+)-(\d+)|(([A-z]{3})\s+(\d+)))\s+((\d+):(\d+)|(\d{4}))\s+(.+)$/)
13
13
  raise "Could not match: '#{line}'." if !match
14
14
 
@@ -4,17 +4,27 @@
4
4
  # ob = Knj::Objects.new(:db => db, :datarow => true, :path => "path_of_model_class_files")
5
5
  # user = ob.get(:User, 1) #=> <Models::User> that extends <Knj::Datarow>
6
6
  class Knj::Datarow
7
- #Returns the data-hash that contains all the data from the database.
8
- def data
9
- self.reload if @should_reload
10
- return @data
11
- end
7
+ @@refs = {}
12
8
 
13
9
  #Returns the Knj::Objects which handels this model.
14
- attr_reader :ob
10
+ def ob
11
+ return self.class.ob
12
+ end
15
13
 
16
14
  #Returns the Knj::Db which handels this model.
17
- attr_reader :db
15
+ def db
16
+ return self.class.db
17
+ end
18
+
19
+ #Returns the 'Knj::Objects'-object that handels this class.
20
+ def self.ob
21
+ return @ob
22
+ end
23
+
24
+ #Returns the 'Knj::Db'-object that handels this class.
25
+ def self.db
26
+ return @db
27
+ end
18
28
 
19
29
  #This is used by 'Knj::Objects' to find out what data is required for this class. Returns the array that tells about required data.
20
30
  #===Examples
@@ -44,7 +54,7 @@ class Knj::Datarow
44
54
 
45
55
  #Returns true if this class has been initialized.
46
56
  def self.initialized?
47
- return false if !@ob or !@columns_sqlhelper_args
57
+ return false if !@columns_sqlhelper_args
48
58
  return true
49
59
  end
50
60
 
@@ -61,11 +71,6 @@ class Knj::Datarow
61
71
  return @autodelete_data
62
72
  end
63
73
 
64
- #Get the 'Knj::Objects'-object that handels this class.
65
- def self.ob
66
- return @ob
67
- end
68
-
69
74
  #This helps various parts of the framework determine if this is a datarow class without requiring it.
70
75
  #===Examples
71
76
  # print "This is a knj-object." if obj.respond_to?("is_knj?")
@@ -152,7 +157,7 @@ class Knj::Datarow
152
157
  list_args.merge!(where_args) if where_args
153
158
  list_args[colname.to_s] = self.id
154
159
 
155
- return @ob.list(classname, list_args, &block)
160
+ return self.class.ob.list(classname, list_args, &block)
156
161
  end
157
162
 
158
163
  define_method("#{methodname}_count".to_sym) do |*args|
@@ -161,12 +166,12 @@ class Knj::Datarow
161
166
  list_args[colname.to_s] = self.id
162
167
  list_args["count"] = true
163
168
 
164
- return @ob.list(classname, list_args)
169
+ return self.class.ob.list(classname, list_args)
165
170
  end
166
171
 
167
172
  define_method("#{methodname}_last".to_sym) do |args|
168
173
  args = {} if !args
169
- return @ob.list(classname, {"orderby" => [["id", "desc"]], "limit" => 1}.merge(args))
174
+ return self.class.ob.list(classname, {"orderby" => [["id", "desc"]], "limit" => 1}.merge(args))
170
175
  end
171
176
 
172
177
  self.joined_tables(
@@ -235,13 +240,13 @@ class Knj::Datarow
235
240
  colname = "#{classname.to_s.downcase}_id".to_sym if !colname
236
241
 
237
242
  define_method(methodname) do
238
- return @ob.get_try(self, colname, classname)
243
+ return self.class.ob.get_try(self, colname, classname)
239
244
  end
240
245
 
241
246
  methodname_html = "#{methodname}_html".to_sym
242
247
  define_method(methodname_html) do |*args|
243
248
  obj = self.__send__(methodname)
244
- return @ob.events.call(:no_html, classname) if !obj
249
+ return self.class.ob.events.call(:no_html, classname) if !obj
245
250
 
246
251
  raise "Class '#{classname}' does not have a 'html'-method." if !obj.respond_to?(:html)
247
252
  return obj.html(*args)
@@ -250,7 +255,7 @@ class Knj::Datarow
250
255
  methodname_name = "#{methodname}_name".to_sym
251
256
  define_method(methodname_name) do |*args|
252
257
  obj = self.__send__(methodname)
253
- return @ob.events.call(:no_name, classname) if !obj
258
+ return self.class.ob.events.call(:no_name, classname) if !obj
254
259
  return obj.name(*args)
255
260
  end
256
261
 
@@ -313,34 +318,6 @@ class Knj::Datarow
313
318
  @columns_joined_tables.merge!(hash)
314
319
  end
315
320
 
316
- #Returns the table-name that should be used for this datarow.
317
- #===Examples
318
- # db.query("SELECT * FROM `#{Models::User.table}` WHERE username = 'John Doe'") do |data|
319
- # print data[:id]
320
- # end
321
- def self.table
322
- return @table if @table
323
- return self.name.split("::").last
324
- end
325
-
326
- #This can be used to manually set the table-name. Useful when meta-programming classes that extends the datarow-class.
327
- #===Examples
328
- # Models::User.table = "prefix_User"
329
- def self.table=(newtable)
330
- @table = newtable
331
- @columns_sqlhelper_args[:table] = @table if @columns_sqlhelper_args.is_a?(Hash)
332
- end
333
-
334
- #Returns the class-name but without having to call the class-table-method. To make code look shorter.
335
- #===Examples
336
- # user = ob.get_by(:User, {:username => 'John Doe'})
337
- # db.query("SELECT * FROM `#{user.table}` WHERE username = 'John Doe'") do |data|
338
- # print data[:id]
339
- # end
340
- def table
341
- return self.class.table
342
- end
343
-
344
321
  #Returns various data for the objects-sql-helper. This can be used to view various informations about the columns and more.
345
322
  def self.columns_sqlhelper_args
346
323
  raise "No SQLHelper arguments has been spawned yet." if !@columns_sqlhelper_args
@@ -349,17 +326,24 @@ class Knj::Datarow
349
326
 
350
327
  #Called by Knj::Objects to initialize the model and load column-data on-the-fly.
351
328
  def self.load_columns(d)
352
- @ob = d.ob if !@ob
329
+ @ob = d.ob
330
+ @db = d.db
353
331
 
354
- @classname = self.name.split("::").last if !@classname
332
+ @classname = self.name.split("::").last.to_sym if !@classname
333
+ @table = @classname if !@table
355
334
  @mutex = Monitor.new if !@mutex
356
335
 
336
+ #Cache these to avoid method-lookups.
337
+ @sep_col = @db.sep_col
338
+ @sep_table = @db.sep_table
339
+ @table_str = "#{@sep_table}#{@db.esc_table(@table)}#{@sep_table}"
340
+
357
341
  @mutex.synchronize do
358
342
  inst_methods = self.instance_methods(false)
359
343
 
360
344
  sqlhelper_args = {
361
- :db => d.db,
362
- :table => table,
345
+ :db => @db,
346
+ :table => @table,
363
347
  :cols_bools => [],
364
348
  :cols_date => [],
365
349
  :cols_dbrows => [],
@@ -368,9 +352,9 @@ class Knj::Datarow
368
352
  :cols => {}
369
353
  }
370
354
 
371
- sqlhelper_args[:table] = @table if @table
355
+ sqlhelper_args[:table] = @table
372
356
 
373
- d.db.tables[table].columns do |col_obj|
357
+ @db.tables[table].columns do |col_obj|
374
358
  col_name = col_obj.name
375
359
  col_type = col_obj.type
376
360
  col_type = :int if col_type == :bigint or col_type == :tinyint or col_type == :mediumint or col_type == :smallint
@@ -407,7 +391,7 @@ class Knj::Datarow
407
391
  if @columns_joined_tables
408
392
  @columns_joined_tables.each do |table_name, table_data|
409
393
  table_data[:where].each do |key, val|
410
- val[:table] = self.table.to_sym if val.is_a?(Hash) and !val.key?(:table) and val[:type].to_sym == :col
394
+ val[:table] = @table if val.is_a?(Hash) and !val.key?(:table) and val[:type].to_sym == :col
411
395
  end
412
396
 
413
397
  table_data[:datarow] = @ob.args[:module].const_get(table_name.to_sym) if !table_data.key?(:datarow)
@@ -431,32 +415,29 @@ class Knj::Datarow
431
415
  # array = ob.list(:User, {"id" => 1})
432
416
  # print array.length
433
417
  def self.list(d, &block)
434
- ec_col = d.db.enc_col
435
- ec_table = d.db.enc_table
436
-
437
- table_str = "#{ec_table}#{d.db.esc_table(self.table)}#{ec_table}"
418
+ args = d.args
438
419
 
439
- if d.args["count"]
420
+ if args["count"]
440
421
  count = true
441
- d.args.delete("count")
442
- sql = "SELECT COUNT(#{table_str}.#{ec_col}id#{ec_col}) AS count"
443
- elsif d.args["select_col_as_array"]
422
+ args.delete("count")
423
+ sql = "SELECT COUNT(#{@table_str}.#{@sep_col}id#{@sep_col}) AS count"
424
+ elsif args["select_col_as_array"]
444
425
  select_col_as_array = true
445
- sql = "SELECT #{table_str}.#{ec_col}#{d.args["select_col_as_array"]}#{ec_col} AS id"
446
- d.args.delete("select_col_as_array")
426
+ sql = "SELECT #{@table_str}.#{@sep_col}#{args["select_col_as_array"]}#{@sep_col} AS id"
427
+ args.delete("select_col_as_array")
447
428
  else
448
- sql = "SELECT #{table_str}.*"
429
+ sql = "SELECT #{@table_str}.*"
449
430
  end
450
431
 
451
432
  qargs = nil
452
433
  ret = self.list_helper(d)
453
434
 
454
- sql << " FROM #{table_str}"
435
+ sql << " FROM #{@table_str}"
455
436
  sql << ret[:sql_joins]
456
437
  sql << " WHERE 1=1"
457
438
  sql << ret[:sql_where]
458
439
 
459
- d.args.each do |key, val|
440
+ args.each do |key, val|
460
441
  case key
461
442
  when "return_sql"
462
443
  #ignore
@@ -470,7 +451,7 @@ class Knj::Datarow
470
451
  #The count will bug if there is a group-by-statement.
471
452
  grp_shown = false
472
453
  if !count and !ret[:sql_groupby]
473
- sql << " GROUP BY #{table_str}.#{ec_col}id#{ec_col}"
454
+ sql << " GROUP BY #{@table_str}.#{@sep_col}id#{@sep_col}"
474
455
  grp_shown = true
475
456
  end
476
457
 
@@ -487,11 +468,11 @@ class Knj::Datarow
487
468
  sql << ret[:sql_order]
488
469
  sql << ret[:sql_limit]
489
470
 
490
- return sql.to_s if d.args["return_sql"]
471
+ return sql.to_s if args["return_sql"]
491
472
 
492
473
  if select_col_as_array
493
474
  enum = Enumerator.new do |yielder|
494
- d.db.q(sql, qargs) do |data|
475
+ @db.q(sql, qargs) do |data|
495
476
  yielder << data[:id]
496
477
  end
497
478
  end
@@ -499,25 +480,25 @@ class Knj::Datarow
499
480
  if block
500
481
  enum.each(&block)
501
482
  return nil
502
- elsif d.ob.args[:array_enum]
483
+ elsif @ob.args[:array_enum]
503
484
  return Array_enumerator.new(enum)
504
485
  else
505
486
  return enum.to_a
506
487
  end
507
488
  elsif count
508
- ret = d.db.query(sql).fetch
489
+ ret = @db.query(sql).fetch
509
490
  return ret[:count].to_i if ret
510
491
  return 0
511
492
  end
512
493
 
513
- return d.ob.list_bysql(self.classname, sql, qargs, &block)
494
+ return @ob.list_bysql(self.classname, sql, qargs, &block)
514
495
  end
515
496
 
516
497
  #Helps call 'sqlhelper' on Knj::Objects to generate SQL-strings.
517
498
  def self.list_helper(d)
518
499
  self.load_columns(d) if !@columns_sqlhelper_args
519
- @columns_sqlhelper_args[:table] = @table if @table
520
- return d.ob.sqlhelper(d.args, @columns_sqlhelper_args)
500
+ @columns_sqlhelper_args[:table] = @table
501
+ return @ob.sqlhelper(d.args, @columns_sqlhelper_args)
521
502
  end
522
503
 
523
504
  #Returns the classname of the object without any subclasses.
@@ -530,14 +511,37 @@ class Knj::Datarow
530
511
  @classname = newclassname
531
512
  end
532
513
 
514
+ #Returns the table-name that should be used for this datarow.
515
+ #===Examples
516
+ # db.query("SELECT * FROM `#{Models::User.table}` WHERE username = 'John Doe'") do |data|
517
+ # print data[:id]
518
+ # end
519
+ def self.table
520
+ return @table
521
+ end
522
+
523
+ #This can be used to manually set the table-name. Useful when meta-programming classes that extends the datarow-class.
524
+ #===Examples
525
+ # Models::User.table = "prefix_User"
526
+ def self.table=(newtable)
527
+ @table = newtable
528
+ @columns_sqlhelper_args[:table] = @table if @columns_sqlhelper_args.is_a?(Hash)
529
+ end
530
+
531
+ #Returns the class-name but without having to call the class-table-method. To make code look shorter.
532
+ #===Examples
533
+ # user = ob.get_by(:User, {:username => 'John Doe'})
534
+ # db.query("SELECT * FROM `#{user.table}` WHERE username = 'John Doe'") do |data|
535
+ # print data[:id]
536
+ # end
537
+ def table
538
+ return self.class.table
539
+ end
540
+
533
541
  #Initializes the object. This should be called from 'Knj::Objects' and not manually.
534
542
  #===Examples
535
543
  # user = ob.get(:User, 3)
536
544
  def initialize(data, args = nil)
537
- @ob = self.class.ob
538
- raise "No ob given." if !@ob
539
- @db = ob.db
540
-
541
545
  if data.is_a?(Hash) and data.key?(:id)
542
546
  @data = data
543
547
  @id = @data[:id].to_i
@@ -545,9 +549,9 @@ class Knj::Datarow
545
549
  @id = data.to_i
546
550
 
547
551
  classname = self.class.classname.to_sym
548
- if @ob.ids_cache_should.key?(classname)
552
+ if self.class.ob.ids_cache_should.key?(classname)
549
553
  #ID caching is enabled for this model - dont reload until first use.
550
- raise Errno::ENOENT, "ID was not found in cache: '#{id}'." if !@ob.ids_cache[classname].key?(@id)
554
+ raise Errno::ENOENT, "ID was not found in cache: '#{id}'." if !self.class.ob.ids_cache[classname].key?(@id)
551
555
  @should_reload = true
552
556
  else
553
557
  #ID caching is not enabled - reload now to check if row exists. Else set 'should_reload'-variable if 'skip_reload' is set.
@@ -573,8 +577,8 @@ class Knj::Datarow
573
577
  # user.reload
574
578
  # print "The username changed in the database!" if user[:username] != old_username
575
579
  def reload
576
- @data = @db.single(self.table, {:id => @id})
577
- raise Errno::ENOENT, "Could not find any data for the object with ID: '#{@id}' in the table '#{self.table}'." if !@data
580
+ @data = self.class.db.single(self.class.table, {:id => @id})
581
+ raise Errno::ENOENT, "Could not find any data for the object with ID: '#{@id}' in the table '#{self.class.table}'." if !@data
578
582
  @should_reload = false
579
583
  end
580
584
 
@@ -587,20 +591,24 @@ class Knj::Datarow
587
591
  @data = nil
588
592
  end
589
593
 
594
+ #Returns the data-hash that contains all the data from the database.
595
+ def data
596
+ self.reload if @should_reload
597
+ return @data
598
+ end
599
+
590
600
  #Writes/updates new data for the object.
591
601
  #===Examples
592
602
  # user.update(:username => 'New username', :date_changed => Time.now)
593
603
  def update(newdata)
594
- @db.update(self.table, newdata, {:id => @id})
604
+ self.class.db.update(self.class.table, newdata, {:id => @id})
595
605
  self.should_reload
596
- @ob.call("object" => self, "signal" => "update") if @ob
606
+ self.class.ob.call("object" => self, "signal" => "update")
597
607
  end
598
608
 
599
609
  #Forcefully destroys the object. This is done after deleting it and should not be called manually.
600
610
  def destroy
601
611
  @id = nil
602
- @ob = nil
603
- @db = nil
604
612
  @data = nil
605
613
  @should_reload = nil
606
614
  end
@@ -618,17 +626,25 @@ class Knj::Datarow
618
626
  #===Examples
619
627
  # print "That user is deleted." if user.deleted?
620
628
  def deleted?
621
- return true if !@ob and !@data and !@id
629
+ return true if !@data and !@id
630
+ return false
631
+ end
632
+
633
+ #Returns true if the given object no longer exists in the database. Also destroys the data on the object and sets it to deleted-status, if it no longer exists.
634
+ #===Examples
635
+ # print "That user is deleted." if user.deleted_from_db?
636
+ def deleted_from_db?
637
+ #Try to avoid db-query if object is already deleted.
638
+ return true if self.deleted?
622
639
 
623
640
  #Try to reload data. Destroy object and return true if the row is gone from the database.
624
641
  begin
625
642
  self.reload
643
+ return false
626
644
  rescue Errno::ENOENT
627
645
  self.destroy
628
646
  return true
629
647
  end
630
-
631
- return false
632
648
  end
633
649
 
634
650
  #Returns a specific data from the object by key.
@@ -746,7 +762,7 @@ class Knj::Datarow
746
762
  if args[:inst_methods].index(method_name) == nil
747
763
  define_method(method_name) do |*method_args|
748
764
  if Datet.is_nullstamp?(self[args[:col_name].to_sym])
749
- return @ob.events.call(:no_date, self.class.name)
765
+ return self.class.ob.events.call(:no_date, self.class.name)
750
766
  end
751
767
 
752
768
  return Datet.in(self[args[:col_name].to_sym]).out(*method_args)
@@ -780,7 +796,7 @@ class Knj::Datarow
780
796
  method_name = "by_#{args[:col_name]}".to_sym
781
797
  if args[:inst_methods].index(method_name) == nil and RUBY_VERSION.to_s.slice(0, 3) != "1.8"
782
798
  define_singleton_method(method_name) do |arg|
783
- return d.ob.get_by(self.table, {args[:col_name].to_s => arg})
799
+ return self.class.ob.get_by(self.class.table, {args[:col_name].to_s => arg})
784
800
  end
785
801
  end
786
802
  end
@@ -7,7 +7,10 @@ class Knj::Eruby
7
7
  @args = args
8
8
 
9
9
  @tmpdir = "#{Knj::Os.tmpdir}/knj_erb"
10
- Dir.mkdir(@tmpdir, 0777) if !File.exists?(@tmpdir)
10
+ if !File.exists?(@tmpdir)
11
+ Dir.mkdir(@tmpdir, 0777)
12
+ File.chmod(0777, @tmpdir)
13
+ end
11
14
 
12
15
 
13
16
  #This argument can be used if a shared cache should be used to speed up performance.
@@ -2,8 +2,7 @@ class Knj::Facebook_connect
2
2
  attr_reader :args
3
3
 
4
4
  def initialize(args)
5
- require "#{$knjpath}http"
6
- require "#{$knjpath}http2"
5
+ require "http2"
7
6
 
8
7
  @args = args
9
8
 
@@ -1,15 +1,13 @@
1
1
  class KnjDB_mysql
2
- attr_reader :knjdb, :conn, :conns, :escape_table, :escape_col, :escape_val, :esc_table
2
+ attr_reader :knjdb, :conn, :conns, :sep_table, :sep_col, :sep_val
3
3
  attr_accessor :tables, :cols, :indexes
4
4
 
5
5
  def initialize(knjdb_ob)
6
6
  @knjdb = knjdb_ob
7
7
  @opts = @knjdb.opts
8
- @escape_table = "`"
9
- @escape_col = "`"
10
- @escape_val = "'"
11
- @esc_table = "`"
12
- @esc_col = "`"
8
+ @sep_table = "`"
9
+ @sep_col = "`"
10
+ @sep_val = "'"
13
11
 
14
12
  require "monitor"
15
13
  @mutex = Monitor.new
@@ -252,7 +250,7 @@ class KnjDB_mysql
252
250
  #Escapes a string to be safe to use as a column in a query.
253
251
  def esc_col(string)
254
252
  string = string.to_s
255
- raise "Invalid column-string: #{string}" if string.index(@escape_col) != nil
253
+ raise "Invalid column-string: #{string}" if string.index(@sep_col) != nil
256
254
  return string
257
255
  end
258
256
 
@@ -31,7 +31,7 @@ class KnjDB_mysql::Tables
31
31
  return table_obj if table_obj.name == table_name
32
32
  end
33
33
 
34
- raise Errno::ENOENT.new("Table was not found: #{table_name}.")
34
+ raise Errno::ENOENT, "Table was not found: #{table_name}."
35
35
  end
36
36
 
37
37
  #Yields the tables of the current database.
@@ -160,7 +160,7 @@ class KnjDB_mysql::Tables::Table
160
160
  return col if col.name == name
161
161
  end
162
162
 
163
- raise Errno::ENOENT.new("Column not found: '#{name}'.")
163
+ raise Errno::ENOENT, "Column not found: '#{name}'."
164
164
  end
165
165
 
166
166
  def columns(args = nil)
@@ -242,7 +242,7 @@ class KnjDB_mysql::Tables::Table
242
242
  return index if index.name.to_s == name
243
243
  end
244
244
 
245
- raise Errno::ENOENT.new("Index not found: #{name}.")
245
+ raise Errno::ENOENT, "Index not found: #{name}."
246
246
  end
247
247
 
248
248
  def create_columns(col_arr)
@@ -1,15 +1,13 @@
1
1
  #This class handels SQLite3-specific behaviour.
2
2
  class KnjDB_sqlite3
3
- attr_reader :knjdb, :conn, :escape_table, :escape_col, :escape_val, :esc_table, :esc_col, :symbolize
3
+ attr_reader :knjdb, :conn, :sep_table, :sep_col, :sep_val, :symbolize
4
4
  attr_accessor :tables, :cols, :indexes
5
5
 
6
6
  #Constructor. This should not be called manually.
7
7
  def initialize(knjdb_ob)
8
- @escape_table = "`"
9
- @escape_col = "`"
10
- @escape_val = "'"
11
- @esc_table = "`"
12
- @esc_col = "`"
8
+ @sep_table = "`"
9
+ @sep_col = "`"
10
+ @sep_val = "'"
13
11
 
14
12
  @knjdb = knjdb_ob
15
13
  @path = @knjdb.opts[:path] if @knjdb.opts[:path]
@@ -76,7 +74,7 @@ class KnjDB_sqlite3
76
74
  #Escapes a string to be used as a column.
77
75
  def esc_col(string)
78
76
  string = string.to_s
79
- raise "Invalid column-string: #{string}" if string.index(@escape_col) != nil
77
+ raise "Invalid column-string: #{string}" if string.index(@sep_col) != nil
80
78
  return string
81
79
  end
82
80
 
@@ -1,12 +1,6 @@
1
1
  require "rubygems"
2
-
3
- if !Kernel.const_defined?(:Wref)
4
- require "wref"
5
- end
6
-
7
- if !Kernel.const_defined?(:Datet)
8
- require "datet"
9
- end
2
+ require "wref" if !Kernel.const_defined?(:Wref)
3
+ require "datet" if !Kernel.const_defined?(:Datet)
10
4
 
11
5
  #A wrapper of several possible database-types.
12
6
  #
@@ -28,7 +22,7 @@ class Knj::Db
28
22
  return Knj::Db.const_get(name)
29
23
  end
30
24
 
31
- attr_reader :opts, :conn, :conns, :int_types
25
+ attr_reader :sep_col, :sep_table, :sep_val, :opts, :conn, :conns, :int_types
32
26
 
33
27
  def initialize(opts)
34
28
  require "#{$knjpath}threadhandler"
@@ -43,6 +37,13 @@ class Knj::Db
43
37
  end
44
38
 
45
39
  @debug = @opts[:debug]
40
+
41
+ self.conn_exec do |driver|
42
+ @sep_table = driver.sep_table
43
+ @sep_col = driver.sep_col
44
+ @sep_val = driver.sep_val
45
+ @esc_driver = driver
46
+ end
46
47
  end
47
48
 
48
49
  def args
@@ -239,43 +240,44 @@ class Knj::Db
239
240
  # id = db.insert(:users, {:name => "John", :lastname => "Doe"}, :return_id => true)
240
241
  # sql = db.insert(:users, {:name => "John", :lastname => "Doe"}, :return_sql => true) #=> "INSERT INTO `users` (`name`, `lastname`) VALUES ('John', 'Doe')"
241
242
  def insert(tablename, arr_insert, args = nil)
242
- self.conn_exec do |driver|
243
- sql = "INSERT INTO #{driver.escape_table}#{tablename.to_s}#{driver.escape_table}"
243
+ sql = "INSERT INTO #{@sep_table}#{tablename}#{@sep_table}"
244
+
245
+ if !arr_insert or arr_insert.empty?
246
+ #This is the correct syntax for inserting a blank row in MySQL.
247
+ sql << " VALUES ()"
248
+ else
249
+ sql << " ("
244
250
 
245
- if !arr_insert or arr_insert.empty?
246
- #This is the correct syntax for inserting a blank row in MySQL.
247
- sql << " VALUES ()"
248
- else
249
- sql << " ("
250
-
251
- first = true
252
- arr_insert.each do |key, value|
253
- if first
254
- first = false
255
- else
256
- sql << ", "
257
- end
258
-
259
- sql << "#{driver.escape_col}#{key.to_s}#{driver.escape_col}"
251
+ first = true
252
+ arr_insert.each do |key, value|
253
+ if first
254
+ first = false
255
+ else
256
+ sql << ", "
260
257
  end
261
258
 
262
- sql << ") VALUES ("
263
-
264
- first = true
265
- arr_insert.each do |key, value|
266
- if first
267
- first = false
268
- else
269
- sql << ", "
270
- end
271
-
272
- sql << "#{driver.escape_val}#{driver.escape(value.to_s)}#{driver.escape_val}"
259
+ sql << "#{@sep_col}#{key}#{@sep_col}"
260
+ end
261
+
262
+ sql << ") VALUES ("
263
+
264
+ first = true
265
+ arr_insert.each do |key, value|
266
+ if first
267
+ first = false
268
+ else
269
+ sql << ", "
273
270
  end
274
271
 
275
- sql << ")"
272
+ sql << "#{@sep_val}#{@esc_driver.escape(value)}#{@sep_val}"
276
273
  end
277
274
 
278
- return sql if args and args[:return_sql]
275
+ sql << ")"
276
+ end
277
+
278
+ return sql if args and args[:return_sql]
279
+
280
+ self.conn_exec do |driver|
279
281
  driver.query(sql)
280
282
  return driver.lastID if args and args[:return_id]
281
283
  return nil
@@ -292,29 +294,29 @@ class Knj::Db
292
294
  def insert_multi(tablename, arr_hashes, args = nil)
293
295
  return false if arr_hashes.empty?
294
296
 
295
- self.conn_exec do |driver|
296
- if driver.respond_to?(:insert_multi)
297
- if args and args[:return_sql]
298
- return [driver.insert_multi(tablename, arr_hashes, args)]
299
- else
300
- return driver.insert_multi(tablename, arr_hashes, args)
301
- end
302
- else
303
- ret = [] if args and (args[:return_id] or args[:return_sql])
304
- arr_hashes.each do |hash|
305
- if ret
306
- ret << self.insert(tablename, hash, args)
307
- else
308
- self.insert(tablename, hash, args)
309
- end
310
- end
311
-
297
+ if @esc_driver.respond_to?(:insert_multi)
298
+ if args and args[:return_sql]
299
+ return [@esc_driver.insert_multi(tablename, arr_hashes, args)]
300
+ end
301
+
302
+ self.conn_exec do |driver|
303
+ return driver.insert_multi(tablename, arr_hashes, args)
304
+ end
305
+ else
306
+ ret = [] if args and (args[:return_id] or args[:return_sql])
307
+ arr_hashes.each do |hash|
312
308
  if ret
313
- return ret
309
+ ret << self.insert(tablename, hash, args)
314
310
  else
315
- return nil
311
+ self.insert(tablename, hash, args)
316
312
  end
317
313
  end
314
+
315
+ if ret
316
+ return ret
317
+ else
318
+ return nil
319
+ end
318
320
  end
319
321
  end
320
322
 
@@ -325,30 +327,31 @@ class Knj::Db
325
327
  def update(tablename, arr_update, arr_terms = {}, args = nil)
326
328
  return false if arr_update.empty?
327
329
 
328
- self.conn_exec do |driver|
329
- sql = ""
330
- sql << "UPDATE #{driver.escape_col}#{tablename.to_s}#{driver.escape_col} SET "
331
-
332
- first = true
333
- arr_update.each do |key, value|
334
- if first
335
- first = false
336
- else
337
- sql << ", "
338
- end
339
-
340
- #Convert dates to valid dbstr.
341
- value = self.date_out(value) if value.is_a?(Datet) or value.is_a?(Time)
342
-
343
- sql << "#{driver.escape_col}#{key.to_s}#{driver.escape_col} = "
344
- sql << "#{driver.escape_val}#{driver.escape(value.to_s)}#{driver.escape_val}"
330
+ sql = ""
331
+ sql << "UPDATE #{@sep_col}#{tablename}#{@sep_col} SET "
332
+
333
+ first = true
334
+ arr_update.each do |key, value|
335
+ if first
336
+ first = false
337
+ else
338
+ sql << ", "
345
339
  end
346
340
 
347
- if arr_terms and arr_terms.length > 0
348
- sql << " WHERE #{self.makeWhere(arr_terms, driver)}"
349
- end
341
+ #Convert dates to valid dbstr.
342
+ value = self.date_out(value) if value.is_a?(Datet) or value.is_a?(Time)
350
343
 
351
- return sql if args and args[:return_sql]
344
+ sql << "#{@sep_col}#{key}#{@sep_col} = "
345
+ sql << "#{@sep_val}#{@esc_driver.escape(value)}#{@sep_val}"
346
+ end
347
+
348
+ if arr_terms and arr_terms.length > 0
349
+ sql << " WHERE #{self.makeWhere(arr_terms)}"
350
+ end
351
+
352
+ return sql if args and args[:return_sql]
353
+
354
+ self.conn_exec do |driver|
352
355
  driver.query(sql)
353
356
  end
354
357
  end
@@ -376,28 +379,25 @@ class Knj::Db
376
379
  end
377
380
  end
378
381
 
379
- #Get the driver and generate SQL.
380
- self.conn_exec do |driver|
381
- sql = "SELECT #{select_sql} FROM #{driver.escape_table}#{tablename.to_s}#{driver.escape_table}"
382
+ sql = "SELECT #{select_sql} FROM #{@sep_table}#{tablename}#{@sep_table}"
383
+
384
+ if arr_terms != nil and !arr_terms.empty?
385
+ sql << " WHERE #{self.makeWhere(arr_terms)}"
386
+ end
387
+
388
+ if args != nil
389
+ if args["orderby"]
390
+ sql << " ORDER BY #{args["orderby"]}"
391
+ end
382
392
 
383
- if arr_terms != nil and !arr_terms.empty?
384
- sql << " WHERE #{self.makeWhere(arr_terms, driver)}"
393
+ if args["limit"]
394
+ sql << " LIMIT #{args["limit"]}"
385
395
  end
386
396
 
387
- if args != nil
388
- if args["orderby"]
389
- sql << " ORDER BY #{args["orderby"]}"
390
- end
391
-
392
- if args["limit"]
393
- sql << " LIMIT #{args["limit"]}"
394
- end
395
-
396
- if args["limit_from"] and args["limit_to"]
397
- raise "'limit_from' was not numeric: '#{args["limit_from"]}'." if !Knj::Php.is_numeric(args["limit_from"])
398
- raise "'limit_to' was not numeric: '#{args["limit_to"]}'." if !Knj::Php.is_numeric(args["limit_to"])
399
- sql << " LIMIT #{args["limit_from"]}, #{args["limit_to"]}"
400
- end
397
+ if args["limit_from"] and args["limit_to"]
398
+ raise "'limit_from' was not numeric: '#{args["limit_from"]}'." if !Knj::Php.is_numeric(args["limit_from"])
399
+ raise "'limit_to' was not numeric: '#{args["limit_to"]}'." if !Knj::Php.is_numeric(args["limit_to"])
400
+ sql << " LIMIT #{args["limit_from"]}, #{args["limit_to"]}"
401
401
  end
402
402
  end
403
403
 
@@ -438,14 +438,15 @@ class Knj::Db
438
438
  #===Examples
439
439
  # db.delete(:users, {:lastname => "Doe"})
440
440
  def delete(tablename, arr_terms, args = nil)
441
+ sql = "DELETE FROM #{@sep_table}#{tablename}#{@sep_table}"
442
+
443
+ if arr_terms != nil and !arr_terms.empty?
444
+ sql << " WHERE #{self.makeWhere(arr_terms)}"
445
+ end
446
+
447
+ return sql if args and args[:return_sql]
448
+
441
449
  self.conn_exec do |driver|
442
- sql = "DELETE FROM #{driver.escape_table}#{tablename}#{driver.escape_table}"
443
-
444
- if arr_terms != nil and !arr_terms.empty?
445
- sql << " WHERE #{self.makeWhere(arr_terms, driver)}"
446
- end
447
-
448
- return sql if args and args[:return_sql]
449
450
  driver.query(sql)
450
451
  end
451
452
 
@@ -456,7 +457,7 @@ class Knj::Db
456
457
  #
457
458
  #===Examples
458
459
  # sql = db.makeWhere({:lastname => "Doe"}, driver_obj)
459
- def makeWhere(arr_terms, driver)
460
+ def makeWhere(arr_terms, driver = nil)
460
461
  sql = ""
461
462
 
462
463
  first = true
@@ -469,11 +470,11 @@ class Knj::Db
469
470
 
470
471
  if value.is_a?(Array)
471
472
  raise "Array for column '#{key}' was empty." if value.empty?
472
- sql << "#{driver.escape_col}#{key}#{driver.escape_col} IN (#{Knj::ArrayExt.join(:arr => value, :sep => ",", :surr => "'", :callback => proc{|ele| self.esc(ele)})})"
473
+ sql << "#{@sep_col}#{key}#{@sep_col} IN (#{Knj::ArrayExt.join(:arr => value, :sep => ",", :surr => "'", :callback => proc{|ele| self.esc(ele)})})"
473
474
  elsif value.is_a?(Hash)
474
475
  raise "Dont know how to handle hash."
475
476
  else
476
- sql << "#{driver.escape_col}#{key}#{driver.escape_col} = #{driver.escape_val}#{driver.escape(value)}#{driver.escape_val}"
477
+ sql << "#{@sep_col}#{key}#{@sep_col} = #{@sep_val}#{@esc_driver.escape(value)}#{@sep_val}"
477
478
  end
478
479
  end
479
480
 
@@ -637,57 +638,27 @@ class Knj::Db
637
638
  #===Examples
638
639
  # db.q("INSERT INTO users (name) VALUES ('#{db.esc('John')}')")
639
640
  def escape(string)
640
- self.conn_exec do |driver|
641
- return driver.escape(string)
642
- end
641
+ return @esc_driver.escape(string)
643
642
  end
644
643
 
645
644
  alias :esc :escape
646
645
 
647
646
  #Escapes the given string to be used as a column.
648
647
  def esc_col(str)
649
- self.conn_exec do |driver|
650
- return driver.esc_col(str)
651
- end
648
+ return @esc_driver.esc_col(str)
652
649
  end
653
650
 
654
651
  #Escapes the given string to be used as a table.
655
652
  def esc_table(str)
656
- self.conn_exec do |driver|
657
- return driver.esc_table(str)
658
- end
659
- end
660
-
661
- #Returns the sign for surrounding the string that should be used as a table.
662
- def enc_table
663
- if !@enc_table
664
- self.conn_exec do |driver|
665
- @enc_table = driver.escape_table
666
- end
667
- end
668
-
669
- return @enc_table
670
- end
671
-
672
- #Returns the sign for surrounding the string that should be used as a column.
673
- def enc_col
674
- if !@enc_col
675
- self.conn_exec do |driver|
676
- @enc_col = driver.escape_col
677
- end
678
- end
679
-
680
- return @enc_col
653
+ return @esc_driver.esc_table(str)
681
654
  end
682
655
 
683
656
  #Returns a string which can be used in SQL with the current driver.
684
657
  #===Examples
685
658
  # str = db.date_out(Time.now) #=> "2012-05-20 22:06:09"
686
659
  def date_out(date_obj = Datet.new, args = {})
687
- conn_exec do |driver|
688
- if driver.respond_to?(:date_out)
689
- return driver.date_out(date_obj, args)
690
- end
660
+ if @esc_driver.respond_to?(:date_out)
661
+ return @esc_driver.date_out(date_obj, args)
691
662
  end
692
663
 
693
664
  return Datet.in(date_obj).dbstr(args)
@@ -697,10 +668,8 @@ class Knj::Db
697
668
  #===Examples
698
669
  # db.date_in('2012-05-20 22:06:09') #=> 2012-05-20 22:06:09 +0200
699
670
  def date_in(date_obj)
700
- conn_exec do |driver|
701
- if driver.respond_to?(:date_in)
702
- return driver.date_in(date_obj)
703
- end
671
+ if @esc_driver.respond_to?(:date_in)
672
+ return @esc_driver.date_in(date_obj)
704
673
  end
705
674
 
706
675
  return Datet.in(date_obj)
@@ -708,16 +677,14 @@ class Knj::Db
708
677
 
709
678
  #Returns the table-module and spawns it if it isnt already spawned.
710
679
  def tables
711
- conn_exec do |driver|
712
- if !@tables
713
- require "#{File.dirname(__FILE__)}/drivers/#{@opts[:type]}/knjdb_#{@opts[:type]}_tables" if (!@opts.key?(:require) or @opts[:require])
714
- @tables = Kernel.const_get("KnjDB_#{@opts[:type]}".to_sym).const_get(:Tables).new(
715
- :db => self
716
- )
717
- end
718
-
719
- return @tables
680
+ if !@tables
681
+ require "#{File.dirname(__FILE__)}/drivers/#{@opts[:type]}/knjdb_#{@opts[:type]}_tables" if (!@opts.key?(:require) or @opts[:require])
682
+ @tables = Kernel.const_get("KnjDB_#{@opts[:type]}".to_sym).const_get(:Tables).new(
683
+ :db => self
684
+ )
720
685
  end
686
+
687
+ return @tables
721
688
  end
722
689
 
723
690
  #Returns the columns-module and spawns it if it isnt already spawned.
@@ -769,11 +736,6 @@ class Knj::Db
769
736
  end
770
737
  end
771
738
 
772
- #Returns the sign to be used for surrounding tables.
773
- def col_table
774
- return "`"
775
- end
776
-
777
739
  #Optimizes all tables in the database.
778
740
  def optimize(args = nil)
779
741
  STDOUT.puts "Beginning optimization of database." if @debug or (args and args[:debug])
@@ -98,10 +98,7 @@ module Knj::Os
98
98
  end
99
99
 
100
100
  def self.realpath(path)
101
- if File.symlink?(path)
102
- return self.realpath(File.readlink(path))
103
- end
104
-
101
+ return self.realpath(File.readlink(path)) if File.symlink?(path)
105
102
  return path
106
103
  end
107
104
 
@@ -219,7 +219,7 @@ module Knj::Php
219
219
  end
220
220
 
221
221
  def ucwords(string)
222
- return string.to_s.split(" ").select {|w| w.capitalize! || w }.join(" ")
222
+ return string.to_s.split(" ").select{|w| w.capitalize! or w }.join(" ")
223
223
  end
224
224
 
225
225
  def strtoupper(str)
@@ -703,7 +703,7 @@ module Knj::Php
703
703
  hour = cur_time.hour if hour == nil
704
704
  min = cur_time.min if min == nil
705
705
  sec = cur_time.sec if sec == nil
706
- date = cur_time.date if date == nil
706
+ date = cur_time.day if date == nil
707
707
  month = cur_time.month if month == nil
708
708
  year = cur_time.year if year == nil
709
709
 
@@ -44,6 +44,7 @@ class Knj::Process_meta
44
44
  if RUBY_ENGINE == "jruby"
45
45
  pid, @stdin, @stdout, @stderr = IO.popen4("#{exec_path} --#{RUBY_VERSION[0, 3]} \"#{exec_file}\" \"#{id}\"")
46
46
  else
47
+ require "open3"
47
48
  @stdin, @stdout, @stderr = Open3.popen3(cmd)
48
49
  end
49
50
 
@@ -65,8 +65,9 @@ class Knj::Threadhandler
65
65
 
66
66
  def check_inactive
67
67
  raise "Destroyed Knj::Threadhandler." if !@mutex
68
+ cur_time = Time.now.to_i - @args[:timeout]
69
+
68
70
  @mutex.synchronize do
69
- cur_time = Time.now.to_i - @args[:timeout]
70
71
  @objects.each do |data|
71
72
  if data[:free] and !data[:inactive] and data[:free] < cur_time
72
73
  @inactive_blocks.each do |block|
@@ -81,46 +82,48 @@ class Knj::Threadhandler
81
82
  def get_and_lock
82
83
  raise "Destroyed Knj::Threadhandler." if !@mutex
83
84
  newobj = nil
84
- sleep_do = false
85
85
 
86
86
  begin
87
+ retdata = nil
88
+
87
89
  @mutex.synchronize do
88
- retdata = false
89
90
  @objects.each do |data|
90
91
  if data[:free]
91
92
  retdata = data
92
93
  break
93
94
  end
94
95
  end
96
+ end
97
+
98
+ if retdata
99
+ #Test if object is still free - if not, try again - knj.
100
+ return get_and_lock if !retdata[:free]
101
+ retdata[:free] = false
95
102
 
96
- if retdata
97
- #Test if object is still free - if not, try again - knj.
98
- return get_and_lock if !retdata[:free]
99
- retdata[:free] = false
100
-
101
- if retdata[:inactive]
102
- @activate_blocks.each do |block|
103
- block.call(:obj => retdata[:object])
104
- end
105
-
106
- retdata.delete(:inactive)
103
+ if retdata[:inactive]
104
+ @activate_blocks.each do |block|
105
+ block.call(:obj => retdata[:object])
107
106
  end
108
107
 
109
- return retdata[:object]
108
+ retdata.delete(:inactive)
110
109
  end
111
110
 
112
- if @objects.length >= @args[:max]
113
- #The maximum amount of objects has already been spawned... Sleep 0.1 sec and try to lock an object again...
114
- raise Knj::Errors::Retry
115
- else
116
- #No free objects, but we can spawn a new one and use that...
117
- newobj = @spawn_new_block.call
111
+ return retdata[:object]
112
+ end
113
+
114
+ if @objects.length >= @args[:max]
115
+ #The maximum amount of objects has already been spawned... Sleep 0.1 sec and try to lock an object again...
116
+ raise Knj::Errors::Retry
117
+ else
118
+ #No free objects, but we can spawn a new one and use that...
119
+ newobj = @spawn_new_block.call
120
+ @mutex.synchronize do
118
121
  @objects << Tsafe::MonHash.new.merge(
119
122
  :free => false,
120
123
  :object => newobj
121
124
  )
122
- STDOUT.print "Spawned db and locked new.\n" if @args[:debug]
123
125
  end
126
+ STDOUT.print "Spawned db and locked new.\n" if @args[:debug]
124
127
  end
125
128
 
126
129
  return newobj
@@ -389,11 +389,17 @@ class Knj::Web
389
389
  elsif args[:type] == :fckeditor
390
390
  args[:height] = 400 if !args[:height]
391
391
 
392
- require "/usr/share/fckeditor/fckeditor.rb"
392
+ require "/usr/share/fckeditor/fckeditor.rb" if !Kernel.const_defined?(:FCKeditor)
393
393
  fck = FCKeditor.new(args[:name])
394
394
  fck.Height = args[:height].to_i
395
395
  fck.Value = value
396
396
  html << fck.CreateHtml
397
+ elsif args[:type] == :ckeditor
398
+ args[:height] = 400 if !args[:height]
399
+ require "ckeditor4ruby" if !Kernel.const_defined?(:CKEditor)
400
+ ck = CKEditor.new
401
+ ck.return_output = true
402
+ html << ck.editor(args[:name], value)
397
403
  elsif args[:type] == :select
398
404
  attr["multiple"] = "multiple" if args[:multiple]
399
405
  attr["size"] = args["size"] if args[:size]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.66
5
+ version: 0.0.67
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-17 00:00:00 +02:00
13
+ date: 2012-07-24 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -91,7 +91,7 @@ dependencies:
91
91
  prerelease: false
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
94
- name: rcov
94
+ name: sqlite3
95
95
  requirement: &id008 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
@@ -102,7 +102,7 @@ dependencies:
102
102
  prerelease: false
103
103
  version_requirements: *id008
104
104
  - !ruby/object:Gem::Dependency
105
- name: sqlite3
105
+ name: rmagick
106
106
  requirement: &id009 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
@@ -112,17 +112,6 @@ dependencies:
112
112
  type: :development
113
113
  prerelease: false
114
114
  version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: rmagick
117
- requirement: &id010 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: "0"
123
- type: :development
124
- prerelease: false
125
- version_requirements: *id010
126
115
  description: Including stuff for HTTP, SSH and much more.
127
116
  email: k@spernj.org
128
117
  executables: []
@@ -399,7 +388,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
399
388
  requirements:
400
389
  - - ">="
401
390
  - !ruby/object:Gem::Version
402
- hash: 2724841403555632511
391
+ hash: 1657712883441742083
403
392
  segments:
404
393
  - 0
405
394
  version: "0"