knjrbfw 0.0.72 → 0.0.74

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +4 -0
  3. data/VERSION +1 -1
  4. data/knjrbfw.gemspec +4 -3
  5. data/lib/knj/arrayext.rb +7 -5
  6. data/lib/knj/datarow.rb +6 -0
  7. data/lib/knj/datarow_custom.rb +4 -0
  8. data/lib/knj/datestamp.rb +4 -4
  9. data/lib/knj/degulesider.rb +1 -1
  10. data/lib/knj/erb/include.rb +1 -1
  11. data/lib/knj/fs/fs.rb +3 -3
  12. data/lib/knj/gtk2_menu.rb +1 -1
  13. data/lib/knj/hash_methods.rb +9 -0
  14. data/lib/knj/iotop.rb +1 -1
  15. data/lib/knj/ironruby-gtk2/gladexml.rb +1 -1
  16. data/lib/knj/jruby-gtk2/gladexml.rb +1 -1
  17. data/lib/knj/jruby-gtk2/tests/test_glade_window.rb +1 -1
  18. data/lib/knj/knj.rb +2 -2
  19. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3.rb +1 -1
  20. data/lib/knj/knjdb/libknjdb.rb +2 -2
  21. data/lib/knj/knjdb/libknjdb_row.rb +4 -0
  22. data/lib/knj/locales.rb +1 -1
  23. data/lib/knj/notify.rb +1 -1
  24. data/lib/knj/objects.rb +4 -4
  25. data/lib/knj/objects/objects_sqlhelper.rb +1 -1
  26. data/lib/knj/php_parser/php_parser.rb +1 -1
  27. data/lib/knj/php_parser/tests/test.rb +2 -2
  28. data/lib/knj/power_manager.rb +1 -1
  29. data/lib/knj/process.rb +1 -0
  30. data/lib/knj/scripts/ip2location.rb +2 -2
  31. data/lib/knj/scripts/php_to_rb_helper.rb +6 -6
  32. data/lib/knj/scripts/process_meta_exec.rb +1 -1
  33. data/lib/knj/sms.rb +3 -3
  34. data/lib/knj/strings.rb +3 -1
  35. data/lib/knj/table_writer.rb +4 -4
  36. data/lib/knj/tests/test_degulesider.rb +1 -1
  37. data/lib/knj/tests/test_http2.rb +1 -1
  38. data/lib/knj/tests/test_mount.rb +1 -1
  39. data/lib/knj/tests/test_retry.rb +1 -1
  40. data/lib/knj/unix_proc.rb +5 -0
  41. data/lib/knj/web.rb +11 -9
  42. data/spec/cmd_parser_spec.rb +2 -2
  43. data/spec/process_spec.rb +1 -1
  44. data/spec/web_spec.rb +1 -1
  45. metadata +23 -14
  46. data/lib/knj/php.rb +0 -978
  47. data/spec/php_spec.rb +0 -98
@@ -1,98 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Php" do
4
- it "explode" do
5
- teststr = "1;2;3"
6
- arr = Knj::Php.explode(";", teststr)
7
-
8
- raise "Invalid length." if arr.length != 3
9
- raise "Invalid first." if arr[0] != "1"
10
- raise "Invalid second." if arr[1] != "2"
11
- raise "Invalid third." if arr[2] != "3"
12
- end
13
-
14
- it "is_numeric" do
15
- raise "Failed." if !Knj::Php.is_numeric(123)
16
- raise "Failed." if !Knj::Php.is_numeric("123")
17
- raise "Failed." if Knj::Php.is_numeric("kasper123")
18
- raise "Failed." if Knj::Php.is_numeric("123kasper")
19
- raise "Failed." if !Knj::Php.is_numeric(123.12)
20
- raise "Failed." if !Knj::Php.is_numeric("123.12")
21
- end
22
-
23
- it "number_format" do
24
- tests = {
25
- Knj::Php.number_format(123123.12, 3, ",", ".") => "123.123,120",
26
- Knj::Php.number_format(123123.12, 4, ".", ",") => "123,123.1200",
27
- Knj::Php.number_format(-123123.12, 2, ",", ".") => "-123.123,12",
28
- Knj::Php.number_format(-120, 2, ",", ".") => "-120,00",
29
- Knj::Php.number_format(-12, 2, ".", ",") => "-12.00"
30
- }
31
-
32
- tests.each do |key, val|
33
- if key != val
34
- raise "Key was not the same as value (#{key}) (#{val})."
35
- end
36
- end
37
- end
38
-
39
- it "substr" do
40
- res = Knj::Php.substr("selcol_15", 7)
41
- raise "substr should have returned '15' but didnt: '#{res}'." if res != "15"
42
-
43
- res = Knj::Php.substr("test_kasper", -6, 6)
44
- raise "substr should have returned 'kasper' but didnt: '#{res}'." if res != "kasper"
45
-
46
- res = Knj::Php.substr("test_kasper", 1, 3)
47
- raise "substr should have returned 'est' but didnt: '#{res}'." if res != "est"
48
-
49
- res = Knj::Php.substr("test_kasper", 0, -3)
50
- raise "substr should have returned 'test_kas' but didnt: '#{res}'." if res != "test_kas"
51
- end
52
-
53
- it "parse_str" do
54
- teststr = "first=value&arr[]=foo+bar&arr[]=baz&hash[trala]=hmm&hash[trala2]=wtf"
55
-
56
- hash = {}
57
- Knj::Php.parse_str(teststr, hash)
58
-
59
- raise "Invalid value for first." if hash["first"] != "value"
60
- raise "Invalid value for first in arr." if hash["arr"]["0"] != "foo bar"
61
- raise "Invalid value for second in arr." if hash["arr"]["1"] != "baz"
62
- raise "Invalid value for hash-trala." if hash["hash"]["trala"] != "hmm"
63
- raise "Invalid value for hash-trala2." if hash["hash"]["trala2"] != "wtf"
64
- end
65
-
66
- it "file_get_contents - http" do
67
- cont = Knj::Php.file_get_contents("https://www.kaspernj.org/myip.php")
68
- raise "Not IP: '#{cont}'." if !cont.to_s.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)
69
- end
70
-
71
- #Moved from "knjrbfw_spec.rb".
72
- it "should be able to execute various Knj::Php functions correctly." do
73
- str = "Kasper Johansen"
74
-
75
- #substr
76
- teststr = Knj::Php.substr(str, 7, 8)
77
- if teststr != "Johansen"
78
- raise "substr did not return expected result: '#{teststr}'"
79
- end
80
-
81
- teststr = Knj::Php.substr(str, -8, 8)
82
- if teststr != "Johansen"
83
- raise "substr did not returned expected result when using negative positions: '#{teststr}'."
84
- end
85
-
86
- #strtoupper
87
- teststr = Knj::Php.strtoupper(str)
88
- if teststr != "KASPER JOHANSEN"
89
- raise "strtoupper did not return expected result: '#{teststr}'."
90
- end
91
-
92
- #strtolower
93
- teststr = Knj::Php.strtolower(str)
94
- if teststr != "kasper johansen"
95
- raise "strtolower did not return expected result: '#{teststr}'."
96
- end
97
- end
98
- end