knjrbfw 0.0.72 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/VERSION +1 -1
- data/knjrbfw.gemspec +4 -3
- data/lib/knj/arrayext.rb +7 -5
- data/lib/knj/datarow.rb +6 -0
- data/lib/knj/datarow_custom.rb +4 -0
- data/lib/knj/datestamp.rb +4 -4
- data/lib/knj/degulesider.rb +1 -1
- data/lib/knj/erb/include.rb +1 -1
- data/lib/knj/fs/fs.rb +3 -3
- data/lib/knj/gtk2_menu.rb +1 -1
- data/lib/knj/hash_methods.rb +9 -0
- data/lib/knj/iotop.rb +1 -1
- data/lib/knj/ironruby-gtk2/gladexml.rb +1 -1
- data/lib/knj/jruby-gtk2/gladexml.rb +1 -1
- data/lib/knj/jruby-gtk2/tests/test_glade_window.rb +1 -1
- data/lib/knj/knj.rb +2 -2
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3.rb +1 -1
- data/lib/knj/knjdb/libknjdb.rb +2 -2
- data/lib/knj/knjdb/libknjdb_row.rb +4 -0
- data/lib/knj/locales.rb +1 -1
- data/lib/knj/notify.rb +1 -1
- data/lib/knj/objects.rb +4 -4
- data/lib/knj/objects/objects_sqlhelper.rb +1 -1
- data/lib/knj/php_parser/php_parser.rb +1 -1
- data/lib/knj/php_parser/tests/test.rb +2 -2
- data/lib/knj/power_manager.rb +1 -1
- data/lib/knj/process.rb +1 -0
- data/lib/knj/scripts/ip2location.rb +2 -2
- data/lib/knj/scripts/php_to_rb_helper.rb +6 -6
- data/lib/knj/scripts/process_meta_exec.rb +1 -1
- data/lib/knj/sms.rb +3 -3
- data/lib/knj/strings.rb +3 -1
- data/lib/knj/table_writer.rb +4 -4
- data/lib/knj/tests/test_degulesider.rb +1 -1
- data/lib/knj/tests/test_http2.rb +1 -1
- data/lib/knj/tests/test_mount.rb +1 -1
- data/lib/knj/tests/test_retry.rb +1 -1
- data/lib/knj/unix_proc.rb +5 -0
- data/lib/knj/web.rb +11 -9
- data/spec/cmd_parser_spec.rb +2 -2
- data/spec/process_spec.rb +1 -1
- data/spec/web_spec.rb +1 -1
- metadata +23 -14
- data/lib/knj/php.rb +0 -978
- data/spec/php_spec.rb +0 -98
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,6 +9,9 @@ GEM
|
|
9
9
|
bundler (~> 1.0)
|
10
10
|
git (>= 1.2.5)
|
11
11
|
rake
|
12
|
+
php4r (0.0.0)
|
13
|
+
datet
|
14
|
+
http2
|
12
15
|
rake (0.9.2.2)
|
13
16
|
rmagick (2.13.1)
|
14
17
|
rspec (2.3.0)
|
@@ -31,6 +34,7 @@ DEPENDENCIES
|
|
31
34
|
datet
|
32
35
|
http2
|
33
36
|
jeweler (~> 1.6.3)
|
37
|
+
php4r
|
34
38
|
rmagick
|
35
39
|
rspec (~> 2.3.0)
|
36
40
|
sqlite3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.74
|
data/knjrbfw.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{knjrbfw}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.74"
|
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"]
|
@@ -198,7 +198,6 @@ Gem::Specification.new do |s|
|
|
198
198
|
"lib/knj/objects/objects_sqlhelper.rb",
|
199
199
|
"lib/knj/opts.rb",
|
200
200
|
"lib/knj/os.rb",
|
201
|
-
"lib/knj/php.rb",
|
202
201
|
"lib/knj/php_parser/arguments.rb",
|
203
202
|
"lib/knj/php_parser/functions.rb",
|
204
203
|
"lib/knj/php_parser/php_parser.rb",
|
@@ -259,7 +258,6 @@ Gem::Specification.new do |s|
|
|
259
258
|
"spec/db_spec_encoding_test_file.txt",
|
260
259
|
"spec/knjrbfw_spec.rb",
|
261
260
|
"spec/objects_spec.rb",
|
262
|
-
"spec/php_spec.rb",
|
263
261
|
"spec/process_meta_spec.rb",
|
264
262
|
"spec/process_spec.rb",
|
265
263
|
"spec/spec_helper.rb",
|
@@ -281,6 +279,7 @@ Gem::Specification.new do |s|
|
|
281
279
|
s.add_runtime_dependency(%q<tsafe>, [">= 0"])
|
282
280
|
s.add_runtime_dependency(%q<datet>, [">= 0"])
|
283
281
|
s.add_runtime_dependency(%q<http2>, [">= 0"])
|
282
|
+
s.add_runtime_dependency(%q<php4r>, [">= 0"])
|
284
283
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
285
284
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
286
285
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
|
@@ -291,6 +290,7 @@ Gem::Specification.new do |s|
|
|
291
290
|
s.add_dependency(%q<tsafe>, [">= 0"])
|
292
291
|
s.add_dependency(%q<datet>, [">= 0"])
|
293
292
|
s.add_dependency(%q<http2>, [">= 0"])
|
293
|
+
s.add_dependency(%q<php4r>, [">= 0"])
|
294
294
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
295
295
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
296
296
|
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
@@ -302,6 +302,7 @@ Gem::Specification.new do |s|
|
|
302
302
|
s.add_dependency(%q<tsafe>, [">= 0"])
|
303
303
|
s.add_dependency(%q<datet>, [">= 0"])
|
304
304
|
s.add_dependency(%q<http2>, [">= 0"])
|
305
|
+
s.add_dependency(%q<php4r>, [">= 0"])
|
305
306
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
306
307
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
307
308
|
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
data/lib/knj/arrayext.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "php4r"
|
2
|
+
|
1
3
|
module Knj::ArrayExt
|
2
4
|
def self.join(args = {}, key = nil, sep = nil)
|
3
5
|
if args.is_a?(Array) and sep
|
@@ -13,7 +15,7 @@ module Knj::ArrayExt
|
|
13
15
|
str = ""
|
14
16
|
first = true
|
15
17
|
|
16
|
-
|
18
|
+
Php4r.foreach(args[:arr]) do |key, value|
|
17
19
|
if first
|
18
20
|
first = false
|
19
21
|
else
|
@@ -30,7 +32,7 @@ module Knj::ArrayExt
|
|
30
32
|
if args[:callback].is_a?(Proc) or args[:callback].is_a?(Method)
|
31
33
|
value = args[:callback].call(value)
|
32
34
|
else
|
33
|
-
value =
|
35
|
+
value = Php4r.call_user_func(args[:callback], value) if args[:callback]
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -58,7 +60,7 @@ module Knj::ArrayExt
|
|
58
60
|
def self.hash_numeric_keys?(hash)
|
59
61
|
all_num = true
|
60
62
|
hash.each do |key, val|
|
61
|
-
if !
|
63
|
+
if !Php4r.is_numeric(key)
|
62
64
|
all_num = false
|
63
65
|
break
|
64
66
|
end
|
@@ -212,10 +214,10 @@ module Knj::ArrayExt
|
|
212
214
|
return hash if !hash
|
213
215
|
|
214
216
|
hash = hash.clone
|
215
|
-
|
217
|
+
Php4r.foreach(hash) do |key, val|
|
216
218
|
if val.is_a?(String)
|
217
219
|
begin
|
218
|
-
hash[key] =
|
220
|
+
hash[key] = Php4r.utf8_encode(val)
|
219
221
|
rescue Encoding::UndefinedConversionError => e
|
220
222
|
if args["ignore_encoding_errors"]
|
221
223
|
next
|
data/lib/knj/datarow.rb
CHANGED
@@ -732,6 +732,12 @@ class Knj::Datarow
|
|
732
732
|
return @data.each(*args, &block)
|
733
733
|
end
|
734
734
|
|
735
|
+
#Hash-compatible.
|
736
|
+
def to_hash
|
737
|
+
self.reload if @should_reload
|
738
|
+
return @data.clone
|
739
|
+
end
|
740
|
+
|
735
741
|
#Returns a default-URL to show the object.
|
736
742
|
def url
|
737
743
|
cname = self.class.classname.to_s.downcase
|
data/lib/knj/datarow_custom.rb
CHANGED
data/lib/knj/datestamp.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Knj::Datestamp
|
2
2
|
def self.in(time = Time.new)
|
3
|
-
if
|
3
|
+
if Php4r.is_numeric(time)
|
4
4
|
time = Time.at(time.to_i)
|
5
5
|
elsif time.is_a?(String)
|
6
6
|
time = Time.local(*ParseDate.parsedate(time))
|
@@ -14,7 +14,7 @@ class Knj::Datestamp
|
|
14
14
|
time = Time.new
|
15
15
|
end
|
16
16
|
|
17
|
-
if
|
17
|
+
if Php4r.is_numeric(time)
|
18
18
|
time = Time.at(time.to_i)
|
19
19
|
elsif time.is_a?(String)
|
20
20
|
begin
|
@@ -42,10 +42,10 @@ class Knj::Datestamp
|
|
42
42
|
|
43
43
|
time = Time.new if !time
|
44
44
|
|
45
|
-
if
|
45
|
+
if Php4r.is_numeric(time)
|
46
46
|
time = Time.at(time.to_i)
|
47
47
|
elsif time.is_a?(String)
|
48
|
-
time = Time.at(
|
48
|
+
time = Time.at(Php4r.strtotime(time))
|
49
49
|
end
|
50
50
|
|
51
51
|
str = ""
|
data/lib/knj/degulesider.rb
CHANGED
data/lib/knj/erb/include.rb
CHANGED
@@ -30,7 +30,7 @@ class ERuby
|
|
30
30
|
Dir.chdir(File.dirname(filename))
|
31
31
|
|
32
32
|
fpath = "#{KnjEruby.filepath}/cache/#{filename.gsub("/", "_").gsub(".", "_")}"
|
33
|
-
pi =
|
33
|
+
pi = Php4r.pathinfo(filename)
|
34
34
|
cachename = fpath + ".cache"
|
35
35
|
|
36
36
|
filetime = File.mtime(filename)
|
data/lib/knj/fs/fs.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Knj::Fs
|
2
2
|
@drivers = []
|
3
|
-
drivers_path =
|
3
|
+
drivers_path = Php4r.realpath("#{File.dirname(__FILE__)}/drivers")
|
4
4
|
Dir.new(drivers_path).each do |file|
|
5
5
|
fn = "#{drivers_path}/#{file}"
|
6
6
|
next if file == "." or file == ".." or File.directory?(fn)
|
7
7
|
|
8
|
-
class_name =
|
8
|
+
class_name = Php4r.ucwords(file.slice(0..-4)).to_sym
|
9
9
|
print "Classname: #{class_name}\n"
|
10
10
|
autoload class_name, fn
|
11
11
|
|
@@ -24,7 +24,7 @@ class Knj::Fs
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def spawn_driver
|
27
|
-
class_name =
|
27
|
+
class_name = Php4r.ucwords(@args[:driver])
|
28
28
|
@driver = self.class.const_get(class_name).new(:fs => self, :args => @args)
|
29
29
|
end
|
30
30
|
end
|
data/lib/knj/gtk2_menu.rb
CHANGED
data/lib/knj/hash_methods.rb
CHANGED
@@ -28,6 +28,15 @@ class Knj::Hash_methods < Hash
|
|
28
28
|
return self[:data]
|
29
29
|
end
|
30
30
|
|
31
|
+
def to_hash
|
32
|
+
h = {}
|
33
|
+
self.each do |key, val|
|
34
|
+
h[k] = val
|
35
|
+
end
|
36
|
+
|
37
|
+
return h
|
38
|
+
end
|
39
|
+
|
31
40
|
#Proxies methods into the hash as keys.
|
32
41
|
def method_missing(method, *args)
|
33
42
|
method = method.to_sym
|
data/lib/knj/iotop.rb
CHANGED
@@ -14,7 +14,7 @@ class GladeXML
|
|
14
14
|
@cont = filename
|
15
15
|
@data = XmlSimple.xml_in(@cont)
|
16
16
|
window_name = self.find_window(data)
|
17
|
-
|
17
|
+
Php4r.file_put_contents("temp.glade", @cont)
|
18
18
|
@glade = Glade::XML.new("temp.glade", window_name, nil)
|
19
19
|
FileUtils.rm("temp.glade")
|
20
20
|
end
|
@@ -14,7 +14,7 @@ class GladeXML
|
|
14
14
|
cont = filename
|
15
15
|
@data = XmlSimple.xml_in(cont)
|
16
16
|
window_name = self.find_window(data)
|
17
|
-
|
17
|
+
Php4r.file_put_contents("temp.glade", cont)
|
18
18
|
@glade = org.gnome.glade.Glade::parse("temp.glade", window_name)
|
19
19
|
FileUtils.rm("temp.glade")
|
20
20
|
end
|
data/lib/knj/knj.rb
CHANGED
@@ -30,9 +30,9 @@ module Knj
|
|
30
30
|
return File.realpath(File.dirname(__FILE__))
|
31
31
|
end
|
32
32
|
|
33
|
-
#Shortcut to
|
33
|
+
#Shortcut to Php4r.print_r.
|
34
34
|
def self.p(*args, &block)
|
35
|
-
return
|
35
|
+
return Php4r.print_r(*args, &block)
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.handle_return(args)
|
data/lib/knj/knjdb/libknjdb.rb
CHANGED
@@ -401,8 +401,8 @@ class Knj::Db
|
|
401
401
|
end
|
402
402
|
|
403
403
|
if args["limit_from"] and args["limit_to"]
|
404
|
-
raise "'limit_from' was not numeric: '#{args["limit_from"]}'." if !
|
405
|
-
raise "'limit_to' was not numeric: '#{args["limit_to"]}'." if !
|
404
|
+
raise "'limit_from' was not numeric: '#{args["limit_from"]}'." if !Php4r.is_numeric(args["limit_from"])
|
405
|
+
raise "'limit_to' was not numeric: '#{args["limit_to"]}'." if !Php4r.is_numeric(args["limit_to"])
|
406
406
|
sql << " LIMIT #{args["limit_from"]}, #{args["limit_to"]}"
|
407
407
|
end
|
408
408
|
end
|
data/lib/knj/locales.rb
CHANGED
@@ -51,7 +51,7 @@ module Knj::Locales
|
|
51
51
|
# Knj::Locales.number_out(123456.68) #=> "123,456.68"
|
52
52
|
def self.number_out(num_str, dec = 2)
|
53
53
|
lc = Knj::Locales.localeconv
|
54
|
-
return
|
54
|
+
return Php4r.number_format(num_str, dec, lc["decimal_point"], lc["thousands_sep"])
|
55
55
|
end
|
56
56
|
|
57
57
|
#Returns the current locale for the current environment (_session[:locale] or Thread.current[:locale]).
|
data/lib/knj/notify.rb
CHANGED
data/lib/knj/objects.rb
CHANGED
@@ -41,7 +41,7 @@ class Knj::Objects
|
|
41
41
|
file_parsed = file
|
42
42
|
file_parsed.gsub!(@args[:class_pre], "") if @args.key?(:class_pre)
|
43
43
|
file_parsed.gsub!(/\.rb$/, "")
|
44
|
-
file_parsed =
|
44
|
+
file_parsed = Php4r.ucwords(file_parsed)
|
45
45
|
|
46
46
|
loads << file_parsed
|
47
47
|
self.requireclass(file_parsed, {:load => false})
|
@@ -186,7 +186,7 @@ class Knj::Objects
|
|
186
186
|
|
187
187
|
callback["block"].call(*callargs)
|
188
188
|
elsif callback["callback"]
|
189
|
-
|
189
|
+
Php4r.call_user_func(callback["callback"], args)
|
190
190
|
else
|
191
191
|
raise "No valid callback given."
|
192
192
|
end
|
@@ -403,7 +403,7 @@ class Knj::Objects
|
|
403
403
|
def get_try(obj, col_name, obj_name = nil)
|
404
404
|
if !obj_name
|
405
405
|
if match = col_name.to_s.match(/^(.+)_id$/)
|
406
|
-
obj_name =
|
406
|
+
obj_name = Php4r.ucwords(match[1]).to_sym
|
407
407
|
else
|
408
408
|
raise "Could not figure out objectname for: #{col_name}."
|
409
409
|
end
|
@@ -557,7 +557,7 @@ class Knj::Objects
|
|
557
557
|
list_args = {}
|
558
558
|
end
|
559
559
|
|
560
|
-
if RUBY_VERSION[0..2] == 1.8 and
|
560
|
+
if RUBY_VERSION[0..2] == 1.8 and Php4r.class_exists("Dictionary")
|
561
561
|
list = Dictionary.new
|
562
562
|
else
|
563
563
|
list = {}
|
@@ -109,7 +109,7 @@ class Knj::Objects
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
raise "No such joined table on '#{args[:table]}': '#{col.first}' (#{col.first.class.name}) with the following joined table:\n#{
|
112
|
+
raise "No such joined table on '#{args[:table]}': '#{col.first}' (#{col.first.class.name}) with the following joined table:\n#{Php4r.print_r(args[:joined_tables], true)}" if !found
|
113
113
|
elsif col.is_a?(String) or col.is_a?(Symbol)
|
114
114
|
col_str = "#{table_def}`#{col}`"
|
115
115
|
found = true
|
@@ -7,7 +7,7 @@ class Knj::Php_parser
|
|
7
7
|
|
8
8
|
if !args.key?("require_requirements") or args["require_requirements"]
|
9
9
|
@retcont = "require \"knj/autoload\"\n"
|
10
|
-
@retcont << "require \"
|
10
|
+
@retcont << "require \"php4r\"\n"
|
11
11
|
@retcont << "require \"knj/php_parser/php_parser\"\n"
|
12
12
|
@retcont << "\n"
|
13
13
|
else
|
@@ -4,8 +4,8 @@ require "#{$knjpath}php_parser/php_parser"
|
|
4
4
|
|
5
5
|
module Knj::Php_parser::Functions
|
6
6
|
def self.my_function(phpvar_arg)
|
7
|
-
|
8
|
-
|
7
|
+
Php4r.print("Hejsa.\n")
|
8
|
+
Php4r.print(phpvar_arg + "\n")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
Knj::Php_parser::Functions.my_function("Helloworld.")
|
data/lib/knj/power_manager.rb
CHANGED
data/lib/knj/process.rb
CHANGED