├── .rspec
├── lib
├── knj
│ ├── .gitignore
│ ├── autoload
│ │ ├── wref.rb
│ │ ├── cinch.rb
│ │ ├── gd2.rb
│ │ ├── tzinfo.rb
│ │ ├── activesupport.rb
│ │ ├── parsedate.rb
│ │ ├── soap.rb
│ │ ├── gtk2.rb
│ │ ├── facebooker.rb
│ │ ├── mysql.rb
│ │ ├── tmail.rb
│ │ ├── zip.rb
│ │ ├── magick.rb
│ │ ├── sqlite3.rb
│ │ ├── xmlsimple.rb
│ │ ├── erubis.rb
│ │ ├── facets_dictionary.rb
│ │ ├── gettext.rb
│ │ ├── json.rb
│ │ ├── rexml.rb
│ │ ├── backups
│ │ │ ├── parsedate.rb
│ │ │ └── ping.rb
│ │ └── ping.rb
│ ├── erb
│ │ ├── cache
│ │ │ └── README
│ │ ├── erb_fcgi_jruby.rb
│ │ ├── apache_knjerb.conf
│ │ ├── erb_1.9.rb
│ │ ├── erb_cache_clean.rb
│ │ ├── erb.rb
│ │ ├── erb_jruby.rb
│ │ ├── erb_fcgi.rb
│ │ └── erb_fcgi_1.9.rb
│ ├── php_parser
│ │ ├── arguments.rb
│ │ ├── tests
│ │ │ ├── test_function.php
│ │ │ ├── test.rb
│ │ │ └── test_function_run.rb
│ │ ├── php_parser.rb
│ │ └── functions.rb
│ ├── ironruby-gtk2
│ │ ├── iconsize.rb
│ │ ├── gtk_menu.rb
│ │ ├── gdk_event.rb
│ │ ├── stock.rb
│ │ ├── vbox.rb
│ │ ├── gtk_cellrenderertext.rb
│ │ ├── gtk_filechooserbutton.rb
│ │ ├── gtk_menuitem.rb
│ │ ├── entry.rb
│ │ ├── gtk_statusicon.rb
│ │ ├── gdk_eventbutton.rb
│ │ ├── gdk_pixbuf.rb
│ │ ├── glib.rb
│ │ ├── gtk_treeselection.rb
│ │ ├── image.rb
│ │ ├── gtk_treeview.rb
│ │ ├── gtk_combobox.rb
│ │ ├── gtk_liststore.rb
│ │ ├── tests
│ │ │ ├── test_2.rb
│ │ │ ├── test.glade
│ │ │ └── test_ironruby_window.rb
│ │ ├── button.rb
│ │ ├── label.rb
│ │ ├── window.rb
│ │ ├── gtk_treeiter.rb
│ │ ├── gtk_builder.rb
│ │ ├── gtk_treeviewcolumn.rb
│ │ ├── dialog.rb
│ │ ├── gladexml.rb
│ │ └── gtk2.rb
│ ├── scripts
│ │ ├── keepalive.rb
│ │ ├── degulesider.rb
│ │ ├── ip2location.rb
│ │ ├── svn_merge.rb
│ │ ├── upgrade_knjrbfw_checker.rb
│ │ ├── filesearch.rb
│ │ └── speed_test.rb
│ ├── jruby-gtk2
│ │ ├── tests
│ │ │ ├── test_trayicon.png
│ │ │ ├── test_normal_window.rb
│ │ │ ├── test_trayicon.rb
│ │ │ └── test_glade_window.rb
│ │ ├── checkbutton.rb
│ │ ├── iconsize.rb
│ │ ├── image.rb
│ │ ├── cellrenderertext.rb
│ │ ├── hbox.rb
│ │ ├── stock.rb
│ │ ├── statusicon.rb
│ │ ├── window.rb
│ │ ├── vbox.rb
│ │ ├── progressbar.rb
│ │ ├── builder
│ │ │ ├── test_builder.rb
│ │ │ ├── test_builder.ui
│ │ │ └── test_builder.glade
│ │ ├── eventbutton.rb
│ │ ├── combobox.rb
│ │ ├── builder.rb
│ │ ├── menu.rb
│ │ ├── dialog.rb
│ │ ├── liststore.rb
│ │ ├── treeview.rb
│ │ └── gladexml.rb
│ ├── win.rb
│ ├── tests
│ │ ├── test_degulesider.rb
│ │ ├── compiler
│ │ │ ├── compiler_test.rb
│ │ │ └── compiler_test_file.rb
│ │ ├── test_http2.rb
│ │ ├── test_http2_proxy.rb
│ │ └── test_mount.rb
│ ├── rhodes
│ │ ├── mutex.rb
│ │ ├── rhodes.js
│ │ ├── youtube_embed.erb
│ │ └── youtube_open.erb
│ ├── fs
│ │ ├── drivers
│ │ │ ├── filesystem.rb
│ │ │ ├── ssh.rb
│ │ │ └── ftp.rb
│ │ └── fs.rb
│ ├── filesystem.rb
│ ├── libqt_window.rb
│ ├── includes
│ │ ├── require_info.rb
│ │ └── appserver_cli.rb
│ ├── jruby_compiler.rb
│ ├── rand.rb
│ ├── ip2location.rb
│ ├── sysuser.rb
│ ├── rsvgbin.rb
│ ├── gettext_fallback.rb
│ ├── knj_controller.rb
│ ├── csv.rb
│ ├── power_manager.rb
│ ├── thread.rb
│ ├── exchangerates.rb
│ ├── youtube.rb
│ ├── gtk2_msgbox.rb
│ ├── nvidia_settings.rb
│ ├── thread2.rb
│ ├── notify.rb
│ ├── x11vnc.rb
│ ├── hash_methods.rb
│ ├── mutexcl.rb
│ ├── gtk2_window.rb
│ ├── opts.rb
│ ├── degulesider.rb
│ ├── errors.rb
│ ├── cpufreq.rb
│ ├── gtk2_menu.rb
│ ├── gtk2_statuswindow.rb
│ ├── maemo
│ │ └── fremantle-calendar
│ │ │ └── fremantle-calendar.rb
│ ├── event_filemod.rb
│ ├── sms.rb
│ ├── win_registry.rb
│ ├── compiler.rb
│ ├── iotop.rb
│ ├── locale_strings.rb
│ ├── mail.rb
│ ├── libqt.rb
│ ├── mailobj.rb
│ ├── cmd_gen.rb
│ ├── knj.rb
│ ├── cmd_parser.rb
│ ├── google_sitemap.rb
│ ├── gettext_threadded.rb
│ ├── autoload.rb
│ ├── mount.rb
│ ├── locales.rb
│ ├── kvm.rb
│ ├── event_handler.rb
│ ├── facebook_connect.rb
│ ├── win_tightvnc.rb
│ ├── gtk2_cb.rb
│ ├── amixer.rb
│ ├── threadhandler.rb
│ ├── unix_proc.rb
│ └── webscripts
│ │ └── image.rhtml
└── knjrbfw.rb
├── Gemfile
├── .document
├── testfiles
└── image.jpg
├── spec
├── autoload_spec.rb
├── locales_spec.rb
├── spec_helper.rb
├── amixer_spec.rb
├── cmd_parser_spec.rb
├── arrayext_spec.rb
├── strings_spec.rb
├── web_spec.rb
└── knjrbfw_spec.rb
├── .github
└── dependabot.yml
├── peak_flow.yml
├── README.rdoc
├── Rakefile
├── .gitignore
├── LICENSE.txt
├── knjrbfw.gemspec
└── Gemfile.lock
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 |
--------------------------------------------------------------------------------
/lib/knj/.gitignore:
--------------------------------------------------------------------------------
1 | erb/cache/*
2 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 | gemspec
3 |
--------------------------------------------------------------------------------
/lib/knj/autoload/wref.rb:
--------------------------------------------------------------------------------
1 | Knj.gem_require(:Wref, :wref)
--------------------------------------------------------------------------------
/lib/knj/autoload/cinch.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "cinch"
--------------------------------------------------------------------------------
/lib/knj/autoload/gd2.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "gd2"
--------------------------------------------------------------------------------
/lib/knj/autoload/tzinfo.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "tzinfo"
--------------------------------------------------------------------------------
/lib/knj/autoload/activesupport.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "active_support"
--------------------------------------------------------------------------------
/lib/knj/autoload/parsedate.rb:
--------------------------------------------------------------------------------
1 | require "#{$knjpath}autoload/backups/parsedate.rb"
--------------------------------------------------------------------------------
/.document:
--------------------------------------------------------------------------------
1 | lib/**/*.rb
2 | bin/*
3 | -
4 | features/**/*.feature
5 | LICENSE.txt
6 |
--------------------------------------------------------------------------------
/lib/knj/erb/cache/README:
--------------------------------------------------------------------------------
1 | This is where cache-files are stored for fast execution.
2 |
--------------------------------------------------------------------------------
/testfiles/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaspernj/knjrbfw/HEAD/testfiles/image.jpg
--------------------------------------------------------------------------------
/lib/knj/autoload/soap.rb:
--------------------------------------------------------------------------------
1 | module SOAP
2 | autoload :WSDLDriverFactory, "soap/wsdlDriver"
3 | end
--------------------------------------------------------------------------------
/lib/knj/php_parser/arguments.rb:
--------------------------------------------------------------------------------
1 | class Knj::Php_parser
2 | def args
3 |
4 | end
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/iconsize.rb:
--------------------------------------------------------------------------------
1 | class Gtk::IconSize
2 | DIALOG = RealGtk::IconSize.Dialog
3 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/gtk2.rb:
--------------------------------------------------------------------------------
1 | require "gtk2"
2 |
3 | module Gtk
4 | autoload :MozEmbed, "gtkmozembed"
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_menu.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Menu
2 | def popup(*paras)
3 | @ob.popup
4 | end
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gdk_event.rb:
--------------------------------------------------------------------------------
1 | class Gdk::Event
2 | BUTTON_PRESS = RealGdk::EventType.ButtonPress
3 | end
--------------------------------------------------------------------------------
/lib/knj/scripts/keepalive.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | while true
4 | print "Keel-alive\n"
5 | sleep 1
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/facebooker.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "#{File.dirname(__FILE__)}/json_autoload"
3 | require "facebooker"
--------------------------------------------------------------------------------
/lib/knj/autoload/mysql.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "mysql"
3 | rescue LoadError
4 | require "rubygems"
5 | require "mysql"
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/tmail.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "tmail"
3 | rescue LoadError
4 | require "rubygems"
5 | require "tmail"
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/zip.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "zip/zip"
3 | rescue LoadError
4 | require "rubygems"
5 | require "zip"
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/magick.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "rmagick"
3 | rescue LoadError
4 | require "rubygems"
5 | require "rmagick"
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/sqlite3.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "sqlite3"
3 | rescue LoadError
4 | require "rubygems"
5 | require "sqlite3"
6 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/stock.rb:
--------------------------------------------------------------------------------
1 | module Gtk::Stock
2 | OK = RealGtk::Stock.Ok
3 | DIALOG_WARNING = RealGtk::Stock.DialogWarning
4 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/tests/test_trayicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaspernj/knjrbfw/HEAD/lib/knj/jruby-gtk2/tests/test_trayicon.png
--------------------------------------------------------------------------------
/lib/knj/autoload/xmlsimple.rb:
--------------------------------------------------------------------------------
1 | begin
2 | require "xmlsimple"
3 | rescue LoadError
4 | require "rubygems"
5 | require "xmlsimple"
6 | end
--------------------------------------------------------------------------------
/lib/knjrbfw.rb:
--------------------------------------------------------------------------------
1 | module Knj
2 | end
3 |
4 | $knjpath = "knj/" if !$knjpath
5 | $: << File.dirname(__FILE__)
6 |
7 | require "#{$knjpath}knj"
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/vbox.rb:
--------------------------------------------------------------------------------
1 | class Gtk::VBox
2 | def pack_start(widget, arg1 = false, arg2 = false)
3 | @ob.PackStart(widget.ob)
4 | end
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_cellrenderertext.rb:
--------------------------------------------------------------------------------
1 | class Gtk::CellRendererText
2 | def initialize(*paras)
3 | @ob = RealGtk::CellRendererText.new
4 | end
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_filechooserbutton.rb:
--------------------------------------------------------------------------------
1 | class Gtk::FileChooserButton
2 | def filename=(newfilename)
3 | @ob.set_filename(newfilename)
4 | end
5 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/checkbutton.rb:
--------------------------------------------------------------------------------
1 | class Gtk::CheckButton
2 | #nothing here yet... once there were something here... but that was a long long time ago...
3 | end
--------------------------------------------------------------------------------
/lib/knj/win.rb:
--------------------------------------------------------------------------------
1 | module Knj::Win
2 | #Autoloader.
3 | def self.const_missing(name)
4 | require "#{$knjpath}knj/win_#{name.to_s.downcase}"
5 | end
6 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/erubis.rb:
--------------------------------------------------------------------------------
1 | module Erubis; end #bugfix
2 |
3 | begin
4 | require "erubis"
5 | rescue LoadError
6 | require "rubygems"
7 | require "erubis"
8 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_menuitem.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["MenuItem"] = {
2 | "activate" => "activated"
3 | }
4 |
5 | class Gtk::MenuItem
6 | #nothing here yet.
7 | end
--------------------------------------------------------------------------------
/lib/knj/erb/erb_fcgi_jruby.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/jruby
2 |
3 | require "fcgi"
4 | FCGI.each_cgi do |fcgi|
5 | print "Content-Type: text/html\n\n"
6 | print "Hello world."
7 | end
8 |
--------------------------------------------------------------------------------
/lib/knj/php_parser/tests/test_function.php:
--------------------------------------------------------------------------------
1 |
2 | function my_function($arg){
3 | print "Hejsa.\n";
4 | print $arg . "\n";
5 | }
6 |
7 | my_function("Hello world.");
8 | ?>
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/iconsize.rb:
--------------------------------------------------------------------------------
1 | class Gtk::IconSize
2 | DIALOG = org.gnome.gtk.IconSize::DIALOG
3 | BUTTON = org.gnome.gtk.IconSize::BUTTON
4 | MENU = org.gnome.gtk.IconSize::MENU
5 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/entry.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["Entry"] = {
2 | "activate" => "activate"
3 | }
4 |
5 | class Gtk::Entry
6 | def set_text(newtext)
7 | @ob.text = newtext
8 | end
9 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/facets_dictionary.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 |
3 | begin
4 | require "facets/dictionary"
5 | rescue LoadError
6 | require File.dirname(__FILE__) + "/backups/facets_dictionary"
7 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_statusicon.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["StatusIcon"] = {
2 | "activate" => "activate",
3 | "popup-menu" => "popup_menu"
4 | }
5 |
6 | class Gtk::StatusIcon
7 | #nothing here yet.
8 | end
--------------------------------------------------------------------------------
/spec/autoload_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2 |
3 | describe "Autoload" do
4 | it "Wref" do
5 | require "#{File.dirname(__FILE__)}/../lib/knj/autoload/wref.rb"
6 | end
7 | end
--------------------------------------------------------------------------------
/lib/knj/tests/test_degulesider.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "knj/autoload"
4 |
5 | dgs = Knj::Degulesider.new
6 | results = dgs.search(
7 | :where => "Engvej 3, 4970 Rødby"
8 | )
9 |
10 | Php4r.print_r(results)
--------------------------------------------------------------------------------
/lib/knj/rhodes/mutex.rb:
--------------------------------------------------------------------------------
1 | class Mutex
2 | def synchronize
3 | sleep 0.05 while @working
4 | @working = true
5 |
6 | begin
7 | yield
8 | ensure
9 | @working = false
10 | end
11 | end
12 | end
--------------------------------------------------------------------------------
/lib/knj/erb/apache_knjerb.conf:
--------------------------------------------------------------------------------
1 | AddType text/html .rhtml
2 |
3 | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
4 |
5 |
6 | AddType application/x-httpd-knj .rhtml
7 | Action application/x-httpd-knj "/cgi-bin/knjerb"
8 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: bundler
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: "01:00"
8 | timezone: Europe/Copenhagen
9 | open-pull-requests-limit: 99
10 |
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gdk_eventbutton.rb:
--------------------------------------------------------------------------------
1 | class Gdk::EventButton
2 | def initialize(*paras)
3 | #take no args.
4 | end
5 |
6 | def button
7 | #do nothing.
8 | end
9 |
10 | def time
11 | #do nothing.
12 | end
13 | end
--------------------------------------------------------------------------------
/lib/knj/scripts/degulesider.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "knj/autoload"
4 | include Knj
5 |
6 | dgs = Degulesider.new
7 | res = dgs.search(
8 | :where => ARGV[0],
9 | :what => ARGV[1]
10 | )
11 |
12 | print JSON.generate(res)
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/image.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Image
2 | def initialize(arg1, arg2)
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | @ob = Gtk.evalob("org.gnome.gtk.Image").new(arg1, arg2)
8 | end
9 | end
10 | end
--------------------------------------------------------------------------------
/lib/knj/scripts/ip2location.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "knj/autoload"
4 | ip2loc = Knj::Ip2location.new
5 |
6 | data = ip2loc.lookup(ARGV[0])
7 |
8 | if ARGV[1] == "json"
9 | print Php4r.json_encode(data)
10 | else
11 | Php4r.print_r(data)
12 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/gettext.rb:
--------------------------------------------------------------------------------
1 | #In some version just requiring gettext givet an error because you have to define the constant first... weird...
2 | module GetText; end
3 |
4 | begin
5 | require "gettext"
6 | rescue LoadError
7 | require "rubygems"
8 | require "gettext"
9 | end
--------------------------------------------------------------------------------
/lib/knj/fs/drivers/filesystem.rb:
--------------------------------------------------------------------------------
1 | class Knj::Fs::Filesystem
2 | def self.args
3 | return [
4 | {
5 | "title" => "Path",
6 | "name" => "texpath"
7 | }
8 | ]
9 | end
10 |
11 | def initialize(args)
12 | @args = args
13 | end
14 | end
--------------------------------------------------------------------------------
/lib/knj/filesystem.rb:
--------------------------------------------------------------------------------
1 | class Knj::Filesystem
2 | def self.copy(args)
3 | FileUtils.rm(args[:to]) if args[:replace] and File.exist?(args[:to])
4 | FileUtils.cp(args[:from], args[:to])
5 | mod = File.lstat(args[:from]).mode & 0777
6 | File.chmod(mod, args[:to])
7 | end
8 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/cellrenderertext.rb:
--------------------------------------------------------------------------------
1 | class Gtk::CellRendererText
2 | def initialize
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | end
7 | end
8 |
9 | def init(tcol)
10 | @ob = org.gnome.gtk.CellRendererText.new(tcol.ob)
11 | end
12 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/hbox.rb:
--------------------------------------------------------------------------------
1 | class Gtk::HBox
2 | def initialize(homogeneous = false, spacing = 0)
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | @ob = Gtk.evalob("org.gnome.gtk.HBox").new(homogeneous, spacing)
8 | end
9 | end
10 | end
--------------------------------------------------------------------------------
/lib/knj/rhodes/rhodes.js:
--------------------------------------------------------------------------------
1 | function knj_rhodes_html_links(args){
2 | $.ajax({type: "POST", data: {"url": args.url}, url: "/app/Knj/html_links"})
3 | }
4 |
5 | function knj_rhodes_youtube_open_in_app(args){
6 | $.ajax({type: "POST", data: {"youtube_id": args.youtube_id}, url: "/app/Knj/youtube_open_in_app"})
7 | }
--------------------------------------------------------------------------------
/lib/knj/libqt_window.rb:
--------------------------------------------------------------------------------
1 | class QtWindow
2 | def self.doCenter(tha_window)
3 | qdw = Qt::DesktopWidget.new
4 |
5 | move_left = (qdw.width / 2) - (tha_window.width / 2)
6 | move_top = (qdw.height / 2) - (tha_window.height / 2)
7 |
8 | tha_window.move(move_left, move_top)
9 | end
10 | end
--------------------------------------------------------------------------------
/peak_flow.yml:
--------------------------------------------------------------------------------
1 | rvm: true
2 | builds:
3 | build_1:
4 | environment:
5 | RUBY_VERSION: 2.7.8
6 | name: Ruby 2.7.8
7 | script:
8 | - bundle exec rspec
9 | build_2:
10 | environment:
11 | RUBY_VERSION: 3.2.2
12 | name: Ruby 3.2.2
13 | script:
14 | - bundle exec rspec
15 |
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/stock.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Stock
2 | OK = org.gnome.gtk.Stock::OK
3 | YES = org.gnome.gtk.Stock::YES
4 | NO = org.gnome.gtk.Stock::NO
5 | DIALOG_WARNING = org.gnome.gtk.Stock::DIALOG_WARNING
6 | DIALOG_QUESTION = org.gnome.gtk.Stock::DIALOG_QUESTION
7 | DIALOG_INFO = org.gnome.gtk.Stock::DIALOG_INFO
8 | end
--------------------------------------------------------------------------------
/lib/knj/tests/compiler/compiler_test.rb:
--------------------------------------------------------------------------------
1 | require "knj/knj"
2 | require "#{$knjpath}compiler"
3 |
4 | compiler = Knj::Compiler.new
5 |
6 | time_start = Time.new.to_f
7 |
8 | #0.upto(10000) do
9 | compiler.eval_file("compiler_test_file.rb")
10 | #end
11 |
12 | time_spent = Time.new.to_f - time_start
13 | print "#{time_spent}\n"
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/statusicon.rb:
--------------------------------------------------------------------------------
1 | Gtk.events << ["StatusIcon", "activate", org.gnome.gtk.StatusIcon::Activate, :onActivate, nil]
2 | Gtk.events << ["StatusIcon", "popup-menu", org.gnome.gtk.StatusIcon::PopupMenu, :onPopupMenu, nil]
3 |
4 | class Gtk::StatusIcon
5 | def pixbuf=(newpixbuf)
6 | @ob.from_pixbuf = newpixbuf.ob
7 | end
8 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/window.rb:
--------------------------------------------------------------------------------
1 | Gtk.events << ["Window", "destroy", org.gnome.gtk.Window::DeleteEvent, :onDeleteEvent, false]
2 |
3 | class Gtk::Window
4 | def destroy
5 | @ob.hide #destroy does not exist in the Java-version? - knj
6 | end
7 |
8 | def set_frame_dimensions(arg1, arg2, arg3, arg4)
9 | @ob.border_width = arg1
10 | end
11 | end
--------------------------------------------------------------------------------
/lib/knj/includes/require_info.rb:
--------------------------------------------------------------------------------
1 | Knj::REQUIRE_INFO = {}
2 |
3 | class Object
4 | alias_method :require_knj, :require
5 |
6 | def require(path)
7 | stat = require_knj(path)
8 |
9 | if stat and !Knj::REQUIRE_INFO.key?(path)
10 | Knj::REQUIRE_INFO[path] = {:caller => caller}
11 | end
12 |
13 | return stat
14 | end
15 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gdk_pixbuf.rb:
--------------------------------------------------------------------------------
1 | class Gdk::Pixbuf
2 | def initialize(*args)
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | @ob = Kernel.const_get("RealGdk").const_get("Pixbuf").method(:new).overload(System::String).call(System::String.new(args[0]))
8 | #method.call("")
9 | end
10 | end
11 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/vbox.rb:
--------------------------------------------------------------------------------
1 | class Gtk::VBox
2 | def initialize
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | splitted = self.class.to_s.split("::")
8 | javaname = "org.gnome." + splitted.first.downcase + "." + splitted.last
9 | @ob = Gtk.evalob(javaname).new(false, 0)
10 | end
11 | end
12 | end
--------------------------------------------------------------------------------
/lib/knj/jruby_compiler.rb:
--------------------------------------------------------------------------------
1 | class Knj::Jruby_compiler
2 | def initialize(args = {})
3 | @args = args
4 |
5 | factory = javax.script.ScriptEngineManager.new
6 | engine = factory.getEngineByName("jruby")
7 | code = File.read(args[:path])
8 | @script = engine.compile(code)
9 | end
10 |
11 | def run
12 | @script.eval
13 | end
14 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/json.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 |
3 | begin
4 | if RUBY_ENGINE == "jruby"
5 | require "json/pure" #normal json has utf-8 encoding problems - knj.
6 | else
7 | require "json/pure"
8 |
9 | #deactivated because of problems with utf-8 encoding.
10 | #require "json/ext"
11 | end
12 | rescue LoadError
13 | require "json/pure"
14 | end
--------------------------------------------------------------------------------
/lib/knj/erb/erb_1.9.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby1.9
2 |
3 | knjdir = File.dirname(File.realpath(__FILE__)) + "/../"
4 |
5 | require knjdir + "autoload"
6 | require knjdir + "/erb/include"
7 |
8 | $knj_eruby = KnjEruby
9 |
10 | filename = ENV["PATH_TRANSLATED"] if ENV and ENV["PATH_TRANSLATED"]
11 | filename = ARGV[0] if ARGV and ARGV[0]
12 |
13 | KnjEruby.load(filename)
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/progressbar.rb:
--------------------------------------------------------------------------------
1 | class Gtk::ProgressBar
2 | def initialize
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | splitted = self.class.to_s.split("::")
8 | javaname = "org.gnome." + splitted.first.downcase + "." + splitted.last
9 | @ob = Gtk.evalob(javaname).new
10 | end
11 | end
12 | end
--------------------------------------------------------------------------------
/lib/knj/autoload/rexml.rb:
--------------------------------------------------------------------------------
1 | require "rexml/rexml"
2 |
3 | module REXML
4 | autoload :Document, "rexml/document"
5 | autoload :ParseException, "rexml/parseexception"
6 | end
7 |
8 | module REXML::Formatters
9 | autoload :Default, "rexml/formatters/default"
10 | autoload :Pretty, "rexml/formatters/pretty"
11 | autoload :Transitive, "rexml/formatters/transitive"
12 | end
--------------------------------------------------------------------------------
/spec/locales_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2 |
3 | describe "Locales" do
4 | it "should do convertions of short formats" do
5 | Thread.current[:locale] = "en"
6 | res = Knj::Locales.lang
7 | raise "Result wasnt as expected: '#{res}'." if res["first"] != "en" or res["second"] != "GB" or res["full"] != "en_GB"
8 | end
9 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/glib.rb:
--------------------------------------------------------------------------------
1 | module GLib
2 | class Timeout
3 | def self.add(time, &block)
4 | Thread.new(time, block) do |time, block|
5 | begin
6 | sleep(time / 1000)
7 | block.call
8 | rescue Exception => e
9 | puts e.inspect
10 | puts e.backtrace
11 | end
12 | end
13 | end
14 | end
15 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/tests/test_normal_window.rb:
--------------------------------------------------------------------------------
1 | require "knj/autoload"
2 |
3 | button = Gtk::Button.new("Test")
4 | button.signal_connect("clicked") do
5 | print "Clicked!\n"
6 | end
7 |
8 | win = Gtk::Window.new("Trala")
9 | win.add(button)
10 | win.show_all
11 |
12 | win.signal_connect("destroy") do
13 | print "Destroy!\n"
14 | Gtk.main_quit
15 | end
16 |
17 | Gtk.main
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_treeselection.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["TreeSelection"] = {
2 | "changed" => "changed"
3 | }
4 |
5 | class Gtk::TreeSelection
6 | def selected_rows
7 | ret = []
8 | sel_rows = @ob.GetSelectedRows
9 | sel_rows.each do |tpath|
10 | Gtk.takeob = tpath
11 | ret << Gtk::TreePath.new
12 | end
13 |
14 | return ret
15 | end
16 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/tests/test_trayicon.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/jruby
2 |
3 | require "knj/autoload"
4 |
5 | pixbuf = Gdk::Pixbuf.new("test_trayicon.png")
6 |
7 | icon = Gtk::StatusIcon.new
8 | icon.pixbuf = pixbuf
9 |
10 | icon.signal_connect("activate") do
11 | print "Activate\n"
12 | end
13 |
14 | icon.signal_connect("popup-menu") do
15 | print "Popup-menu\n"
16 | end
17 |
18 | Gtk.main
--------------------------------------------------------------------------------
/lib/knj/php_parser/tests/test.rb:
--------------------------------------------------------------------------------
1 | require "knj/autoload"
2 | require "php4r" if !Kernel.const_defined?(:Php4r)
3 | require "#{$knjpath}php_parser/php_parser"
4 |
5 | module Knj::Php_parser::Functions
6 | def self.my_function(phpvar_arg)
7 | Php4r.print("Hejsa.\n")
8 | Php4r.print(phpvar_arg + "\n")
9 | end
10 | end
11 | Knj::Php_parser::Functions.my_function("Helloworld.")
12 |
13 |
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/image.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Image
2 | def initialize(*paras)
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | splitted = self.class.to_s.split("::")
8 | @ob = RealGtk.const_get(splitted.last).new(*paras)
9 | end
10 |
11 | if !@ob
12 | raise "Object was not spawned: #{self.class.to_s}"
13 | end
14 | end
15 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_treeview.rb:
--------------------------------------------------------------------------------
1 | class Gtk::TreeView
2 | def selection
3 | if !@selection
4 | Gtk.takeob = @ob.selection
5 | @selection = Gtk::TreeSelection.new
6 | end
7 |
8 | return @selection
9 | end
10 |
11 | def model=(newmodel)
12 | @model = newmodel
13 | @ob.model = newmodel.ob
14 | end
15 |
16 | def model
17 | return @model
18 | end
19 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/builder/test_builder.rb:
--------------------------------------------------------------------------------
1 | require "knj/autoload"
2 |
3 | class TestWindow
4 | def initialize
5 | @gui = Gtk::Builder.new
6 | @gui.add_from_file("test_builder.ui")
7 | @gui.connect_signals(){|h|method(h)}
8 |
9 | @gui["window1"].show_all
10 | end
11 |
12 | def on_window1_destroy
13 | Gtk.main_quit
14 | end
15 | end
16 |
17 | TestWindow.new
18 |
19 | Gtk.main
--------------------------------------------------------------------------------
/lib/knj/rand.rb:
--------------------------------------------------------------------------------
1 | #This module is used to handel various random handeling.
2 | module Knj::Rand
3 | #Returns a random integer between the two integers given.
4 | def self.range(first, last)
5 | return first.to_i + rand(last.to_i - first.to_i)
6 | end
7 |
8 | #Returns a random element in the given array.
9 | def self.array(arr)
10 | key = rand(arr.length)
11 | return arr[key]
12 | end
13 | end
--------------------------------------------------------------------------------
/lib/knj/php_parser/tests/test_function_run.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "knj/autoload"
4 | include Knj
5 |
6 | parser = Php_parser.new(
7 | "file" => File.dirname(__FILE__) + "/test_function.php"
8 | )
9 |
10 | begin
11 | cont = parser.parse
12 | rescue RuntimeError => e
13 | print "Retcont:\n#{parser.retcont}\n\n"
14 | print "Cont:\n#{parser.cont}\n\n"
15 |
16 | raise e
17 | end
18 |
19 | print cont + "\n"
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_combobox.rb:
--------------------------------------------------------------------------------
1 | class Gtk::ComboBox
2 | def pack_start(widget, val)
3 | @ob.pack_start(widget.ob, val)
4 | @ob.add_attribute(widget.ob, "text", 0)
5 | end
6 |
7 | def add_attribute(*paras)
8 | #this should not do anything.
9 | end
10 |
11 | def model=(newmodel)
12 | @model = newmodel
13 | @ob.model = newmodel.ob
14 | end
15 |
16 | def model
17 | return @model
18 | end
19 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_liststore.rb:
--------------------------------------------------------------------------------
1 | class Gtk::ListStore
2 | def initialize(*args)
3 | args_cons = []
4 | args.each do |col_name|
5 | args_cons << System::String.to_clr_type
6 | end
7 |
8 | @ob = RealGtk::ListStore.new(*args_cons)
9 | end
10 |
11 | def append
12 | Gtk.takeob = @ob.append
13 | retob = Gtk::TreeIter.new
14 | retob.liststore = self
15 |
16 | return retob
17 | end
18 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/tests/test_2.rb:
--------------------------------------------------------------------------------
1 | require "knj/autoload"
2 |
3 | class MainWindow
4 | def initialize
5 | button = Gtk::Button.new("Test")
6 |
7 | button.signal_connect("clicked") do
8 | Gtk.main_quit
9 | end
10 |
11 | win = Gtk::Window.new
12 | win.add button
13 | win.show_all
14 | end
15 |
16 | def on_button1_clicked(object, event)
17 | print "hmm\n"
18 | end
19 | end
20 |
21 | main_window = MainWindow.new
22 | Gtk.main
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2 | $LOAD_PATH.unshift(File.dirname(__FILE__))
3 | require 'rspec'
4 | require 'knjrbfw'
5 |
6 | # Requires supporting files with custom matchers and macros, etc,
7 | # in ./support/ and its subdirectories.
8 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9 |
10 | RSpec.configure do |config|
11 | config.expect_with(:rspec) { |c| c.syntax = :should }
12 | end
13 |
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/button.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["Button"] = {
2 | "clicked" => "clicked"
3 | }
4 |
5 | class Gtk::Button
6 | def initialize(title = "")
7 | if Gtk.takeob
8 | @ob = Gtk.takeob
9 | Gtk.takeob = nil
10 | else
11 | splitted = self.class.to_s.split("::")
12 | @ob = RealGtk.const_get(splitted.last).new(title)
13 | end
14 |
15 | if !@ob
16 | raise "Object was not spawned: #{self.class.to_s}"
17 | end
18 | end
19 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/label.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Label
2 | def initialize(title = "")
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | splitted = self.class.to_s.split("::")
8 | @ob = RealGtk.const_get(splitted.last).new(title)
9 | end
10 |
11 | if !@ob
12 | raise "Object was not spawned: #{self.class.to_s}"
13 | end
14 | end
15 |
16 | def label=(newlabel)
17 | @ob.label_prop = newlabel
18 | end
19 | end
--------------------------------------------------------------------------------
/lib/knj/erb/erb_cache_clean.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "knj/autoload"
4 | include Knj
5 | Os.chdir_file(__FILE__)
6 |
7 | curtime = Time.new.to_i
8 |
9 | Dir.new("cache").each do |filename|
10 | if filename != "." and filename != ".." and filename != "README"
11 | fn = "cache/#{filename}"
12 | file = File.new(fn)
13 | mtime = file.mtime.to_i
14 | diftime = curtime - mtime
15 |
16 | if diftime >= (3600 * 48)
17 | File.delete(fn)
18 | end
19 | end
20 | end
--------------------------------------------------------------------------------
/lib/knj/rhodes/youtube_embed.erb:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/eventbutton.rb:
--------------------------------------------------------------------------------
1 | class Gdk::EventButton
2 | def initialize(eventtype)
3 | if Gtk.takeob
4 | @ob = Gtk.takeob
5 | Gtk.takeob = nil
6 | else
7 | splitted = self.class.to_s.split("::")
8 | classname = splitted[splitted.length - 1]
9 | class_spawn = Gtk.evalob("org.gnome.gdk." + classname)
10 | #@ob = class_spawn.new
11 | end
12 | end
13 |
14 | def button
15 | return 2
16 | end
17 |
18 | def time
19 | return 0
20 | end
21 | end
--------------------------------------------------------------------------------
/lib/knj/erb/erb.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | def File::realpath(path)
4 | if File.symlink?(path)
5 | return self.realpath(File.readlink(path))
6 | end
7 |
8 | return path
9 | end
10 |
11 | knjdir = File.dirname(File.realpath(__FILE__)) + "/../"
12 |
13 | require knjdir + "autoload"
14 | require knjdir + "erb/include"
15 |
16 | $knj_eruby = KnjEruby
17 |
18 | filename = ENV["PATH_TRANSLATED"] if ENV and ENV["PATH_TRANSLATED"]
19 | filename = ARGV[0] if ARGV and ARGV[0]
20 |
21 | KnjEruby.load(filename)
--------------------------------------------------------------------------------
/lib/knj/tests/test_http2.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby1.9.1
2 |
3 | Dir.chdir(File.dirname(__FILE__))
4 | require "../../knjrbfw.rb"
5 |
6 | require "../autoload"
7 |
8 | http = Http2.new(:host => "www.partyworm.dk", :port => 80, :ssl => false)
9 | resp = http.get(:url => "/?show=frontpage")
10 | resp = http.get(:url => "/?show=login")
11 |
12 | #print "Wee!\n"
13 | #exit
14 |
15 | http = Http2.new(:host => "mexico.balance4u.com", :port => 443, :ssl => true)
16 | resp = http.get(:url => "/")
17 |
18 | Php4r.print_r(http.cookies)
--------------------------------------------------------------------------------
/lib/knj/erb/erb_jruby.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/jruby
2 |
3 | def File::realpath(path)
4 | if File.symlink?(path)
5 | return self.realpath(File.readlink(path))
6 | end
7 |
8 | return path
9 | end
10 |
11 | knjdir = File.dirname(File.realpath(__FILE__)) + "/../"
12 |
13 | require knjdir + "autoload"
14 | require "erubis"
15 | require knjdir + "/erb/include"
16 |
17 | $knj_eruby = KnjEruby
18 |
19 | filename = ENV["PATH_TRANSLATED"] if ENV and ENV["PATH_TRANSLATED"]
20 | filename = ARGV[0] if ARGV and ARGV[0]
21 |
22 | KnjEruby.load(filename)
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/window.rb:
--------------------------------------------------------------------------------
1 | Gtk.events["Gtk"]["Window"] = {
2 | "destroy" => "destroyed"
3 | }
4 |
5 | class Gtk::Window
6 | def initialize(title = "")
7 | if Gtk.takeob
8 | @ob = Gtk.takeob
9 | Gtk.takeob = nil
10 | else
11 | splitted = self.class.to_s.split("::")
12 | @ob = RealGtk.const_get(splitted.last).new(title)
13 | end
14 |
15 | if !@ob
16 | raise "Object was not spawned: #{self.class.to_s}"
17 | end
18 | end
19 |
20 | def add(widget)
21 | @ob.add(widget.ob)
22 | end
23 | end
--------------------------------------------------------------------------------
/lib/knj/ip2location.rb:
--------------------------------------------------------------------------------
1 | class Knj::Ip2location
2 | def initialize(args = {})
3 | @args = args
4 | @http = Knj::Http.new(
5 | "host" => "www.ip2location.com",
6 | "port" => 80
7 | )
8 | end
9 |
10 | def lookup(ip)
11 | raise "Invalid IP: #{ip}." if !ip.to_s.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
12 |
13 | html = @http.get("/#{ip}")["data"]
14 | ret = {}
15 |
16 | html.scan(/(.+?)<\/span>/) do |match|
17 | ret[match[0]] = match[1]
18 | end
19 |
20 | return ret
21 | end
22 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/tests/test.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | button
9 | True
10 | True
11 | True
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/lib/knj/fs/drivers/ssh.rb:
--------------------------------------------------------------------------------
1 | class Knj::Fs::Ssh
2 | def self.args
3 | return [
4 | {
5 | "title" => "Hostname",
6 | "name" => "texhostname"
7 | },
8 | {
9 | "title" => "Port",
10 | "name" => "texport"
11 | },
12 | {
13 | "title" => "Username",
14 | "name" => "texusername"
15 | },
16 | {
17 | "title" => "Password",
18 | "name" => "texpassword",
19 | "type" => "password"
20 | }
21 | ]
22 | end
23 |
24 | def initialize(args)
25 | @args = args
26 | raise "Stub!"
27 | end
28 | end
--------------------------------------------------------------------------------
/lib/knj/sysuser.rb:
--------------------------------------------------------------------------------
1 | class Knj::Sysuser
2 | def initialize(data)
3 | @data = data
4 | end
5 |
6 | def self.list(paras = {})
7 | cont = File.read("/etc/passwd")
8 |
9 | list = []
10 | cont.split("\n").each do |line|
11 | linearr = line.split(":")
12 |
13 | list << Knj::Sysuser.new(
14 | "nick" => linearr[0],
15 | "home" => linearr[5],
16 | "shell" => linearr[6]
17 | )
18 | end
19 |
20 | return list
21 | end
22 |
23 | def [](key)
24 | raise "No such key: " + key if !@data.key?(key)
25 | return @data[key]
26 | end
27 | end
--------------------------------------------------------------------------------
/lib/knj/rsvgbin.rb:
--------------------------------------------------------------------------------
1 | class Knj::RSVGBIN
2 | def self.test_version
3 | test_version = %x[rsvg-convert -v]
4 | if !test_version.match(/^rsvg-convert version [0-9\.]+$/)
5 | raise "No valid version of rsvg-bin was found."
6 | end
7 | end
8 |
9 | def self.png_content_from_file(file_from)
10 | RSVGBIN.test_version
11 | return %x[rsvg-convert #{Strings.unixsafe(file_from)}]
12 | end
13 |
14 | def self.convert_file(file_from, file_to)
15 | RSVGBIN.test_version
16 |
17 | png_content = RSVGBIN.png_content_from_file(file_from)
18 | Php.file_put_contents(file_to, png_content)
19 | end
20 | end
--------------------------------------------------------------------------------
/lib/knj/gettext_fallback.rb:
--------------------------------------------------------------------------------
1 | #A fallback GetText implementation that basically returns the given strings, but can be useful for using methods that uses GetText without using an actual GetText implementation.
2 | module GetText
3 | #Returns the given string.
4 | def self._(string)
5 | return string
6 | end
7 |
8 | #Returns the given string.
9 | def _(string)
10 | return string
11 | end
12 |
13 | #Returns the given string.
14 | def gettext(string)
15 | return string
16 | end
17 |
18 | #Doesnt do anything.
19 | def bindtextdomain(temp1 = nil, temp2 = nil, temp3 = nil)
20 | #nothing here.
21 | end
22 | end
--------------------------------------------------------------------------------
/lib/knj/scripts/svn_merge.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 |
3 | require "knj/autoload"
4 |
5 | path_to = ARGV[0]
6 |
7 | Dir.glob(File.join("**", ".svn")).each do |dir|
8 | newdir = path_to + "/" + dir
9 |
10 | #print dir + "\n"
11 | #print newdir + "\n"
12 |
13 | if File.exist?(newdir)
14 | print "Remove: " + newdir.to_s + "\n"
15 | FileUtils.rm_r(newdir)
16 | end
17 |
18 | begin
19 | #print "Move: " + dir + "\n"
20 | #FileUtils.mv(dir, newdir)
21 |
22 | print "Copy: " + dir + "\n"
23 | FileUtils.cp_r(dir, newdir)
24 | rescue => e
25 | print "Failed: " + e.message + "\n"
26 | end
27 |
28 | #print "\n"
29 | end
--------------------------------------------------------------------------------
/lib/knj/php_parser/php_parser.rb:
--------------------------------------------------------------------------------
1 | class Knj::Php_parser
2 | attr_reader :cont, :retcont
3 |
4 | def initialize(args)
5 | @args = args
6 | @cont = File.read(@args["file"])
7 |
8 | if !args.key?("require_requirements") or args["require_requirements"]
9 | @retcont = "require \"knj/autoload\"\n"
10 | @retcont << "require \"php4r\"\n"
11 | @retcont << "require \"knj/php_parser/php_parser\"\n"
12 | @retcont << "\n"
13 | else
14 | @retcont = ""
15 | end
16 | end
17 | end
18 |
19 | require File.dirname(__FILE__) + "/functions.rb"
20 |
21 | module Knj::Php_parser::Functions
22 | #nothing here.
23 | end
--------------------------------------------------------------------------------
/lib/knj/ironruby-gtk2/gtk_treeiter.rb:
--------------------------------------------------------------------------------
1 | class Gtk::TreeIter
2 | def initialize(*paras)
3 | if Gtk.takeob
4 | print "TreeIter from takeob.\n"
5 | @ob = Gtk.takeob
6 | Gtk.takeob = nil
7 | else
8 | print "TreeIter from constructor.\n"
9 | @ob = RealGtk::TreeIter.new(*paras)
10 | end
11 | end
12 |
13 | def liststore=(newliststore)
14 | @liststore = newliststore
15 | end
16 |
17 | def []=(key, value)
18 | return @liststore.ob.method(:set_value).overload(RealGtk::TreeIter, Fixnum, System::String).call(@ob, key, value)
19 | end
20 |
21 | def [](key)
22 | return @liststore.ob.get_value(@ob, key)
23 | end
24 | end
--------------------------------------------------------------------------------
/lib/knj/includes/appserver_cli.rb:
--------------------------------------------------------------------------------
1 | require "knj/autoload"
2 | require "#{$knjpath}web"
3 |
4 | class Appserver_cli
5 | def self.loadfile(filepath)
6 | require filepath
7 | end
8 |
9 | def self._(str)
10 | return str
11 | end
12 |
13 | def self.gettext
14 | return self
15 | end
16 |
17 | def self.lang_opts
18 | return []
19 | end
20 | end
21 |
22 | def _kas
23 | return Appserver_cli
24 | end
25 |
26 | def _db
27 | return $db
28 | end
29 |
30 | def _ob
31 | return $ob
32 | end
33 |
34 | autoinc_cli_path = "../include/autoinclude_cli.rb"
35 | if File.exist?(autoinc_cli_path)
36 | require autoinc_cli_path
37 | else
38 | require "../include/autoinclude.rb"
39 | end
--------------------------------------------------------------------------------
/lib/knj/knj_controller.rb:
--------------------------------------------------------------------------------
1 | #This files makes the framework able to receive calls from the Rhodes framework from RhoMobile.
2 | class KnjController < Rho::RhoController
3 | #GET /Server
4 | def index
5 | render
6 | end
7 |
8 | def html_links
9 | System.open_url(@params["url"])
10 | end
11 |
12 | def callback
13 | block = $rhodes.callbacks(@params["callback_id"])
14 | block.call(:params => @params)
15 | end
16 |
17 | def youtube_embed
18 | @iframe_height = System.get_property("screen_height").to_i - 40
19 | render :file => "Knj/rhodes/youtube_embed.erb"
20 | end
21 |
22 | def youtube_open
23 | render :file => "Knj/rhodes/youtube_open.erb"
24 | end
25 | end
--------------------------------------------------------------------------------
/lib/knj/csv.rb:
--------------------------------------------------------------------------------
1 | #Contains various methods for handeling CSV-stuff.
2 | class Knj::Csv
3 | #Converts a given array to a CSV-string.
4 | #===Examples
5 | # str = Knj::Csv.arr_to_csv([1, 2, 3], ";", "'") #=> "'1';'2';'3'\n"
6 | def self.arr_to_csv(arr, del, encl)
7 | raise "No delimiter given." if !del
8 | raise "No enclosure given." if !encl
9 |
10 | str = ""
11 | first = true
12 | arr.each do |val|
13 | if first
14 | first = false
15 | else
16 | str << del
17 | end
18 |
19 | val = val.to_s.encode("utf-8").gsub(del, "").gsub(encl, "")
20 | str << "#{encl}#{val}#{encl}"
21 | end
22 |
23 | str << "\n"
24 |
25 | return str
26 | end
27 | end
--------------------------------------------------------------------------------
/lib/knj/fs/drivers/ftp.rb:
--------------------------------------------------------------------------------
1 | class Knj::Fs::Ftp
2 | def self.args
3 | return [
4 | {
5 | "title" => "Hostname",
6 | "name" => "texhost"
7 | },
8 | {
9 | "title" => "Port",
10 | "name" => "texport"
11 | },
12 | {
13 | "title" => "Username",
14 | "name" => "texusername"
15 | },
16 | {
17 | "title" => "Password",
18 | "name" => "texpassword",
19 | "type" => "password"
20 | },
21 | {
22 | "title" => "Passive?",
23 | "name" => "chepassive",
24 | "type" => "checkbox"
25 | }
26 | ]
27 | end
28 |
29 | def initialize(args)
30 | @args = args
31 | raise "Stub!"
32 | end
33 | end
--------------------------------------------------------------------------------
/lib/knj/tests/test_http2_proxy.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby1.9.1
2 |
3 | require "#{File.dirname(__FILE__)}/../../knjrbfw.rb"
4 | require "knj/autoload"
5 |
6 | proxy_settings = Marshal.load(File.read("#{File.dirname(__FILE__)}/test_http2_proxy_settings.marshal"))
7 |
8 | http = Http2.new(
9 | :host => "www.partyworm.dk",
10 | :proxy => proxy_settings
11 | )
12 |
13 | urls = [
14 | "?show=users_search",
15 | "?show=users_online",
16 | "?show=drinksdb",
17 | "?show=forum&fid=9&tid=1917&page=0"
18 | ]
19 | urls = ["robots.txt"]
20 |
21 | 0.upto(105) do |count|
22 | url = urls[rand(urls.size)]
23 | print "Doing request #{count} of 200 (#{url}).\n"
24 | res = http.get(:url => url)
25 | raise "Body was empty." if res.body.to_s.length <= 0
26 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/combobox.rb:
--------------------------------------------------------------------------------
1 | class Gtk::ComboBox
2 | def pack_start(widget, arg1, arg2 = false)
3 | #widget is useually a Gtk::CellRendererText which is started by this way in Java GTK.
4 | @renderer = widget
5 | widget.init(self)
6 |
7 | if self.model
8 | widget.text = self.model.dcol[0]
9 | @renderer_set = true
10 | end
11 | end
12 |
13 | def add_attribute(arg1, arg2, arg3)
14 | #do nothing - this method does not exist on Java GTK's ComboBox.
15 | end
16 |
17 | def model=(newmodel)
18 | @model = newmodel
19 | @ob.model = newmodel.ob
20 |
21 | if !@renderer_set
22 | @renderer.text = self.model.dcol[0]
23 | end
24 | end
25 |
26 | def model
27 | return @model
28 | end
29 | end
--------------------------------------------------------------------------------
/lib/knj/tests/test_mount.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | Dir.chdir(File.dirname(__FILE__))
4 | require "../autoload"
5 |
6 | print "Listing all mounts.\n"
7 | mounts = Knj::Mount.list
8 | mounts.each do |mount|
9 | Php4r.print_r(mount.data)
10 | print "Access: #{mount.access?}\n\n"
11 | end
12 |
13 | mounts = Knj::Mount.list("from_search" => "test_dir")
14 | mounts.each do |mount|
15 | print "Unmounting test_dir.\n"
16 | mount.umount
17 | end
18 |
19 | print "Mount binding test_dir to test_dir_to.\n"
20 | Knj::Mount.mount(
21 | "from" => "test_dir",
22 | "to" => "test_dir_to",
23 | "bind" => true
24 | )
25 |
26 | mounts = Knj::Mount.list("from_search" => "test_dir")
27 | mounts.each do |mount|
28 | print "Unmounting test_dir.\n"
29 | mount.umount
30 | end
--------------------------------------------------------------------------------
/lib/knj/power_manager.rb:
--------------------------------------------------------------------------------
1 | class Knj::Power_manager
2 | def initialize(args = {})
3 | @args = args
4 |
5 | if !File.exist?("/proc/acpi/ac_adapter")
6 | raise "Could not find the proc-acpi folder."
7 | end
8 |
9 | Dir.new("/proc/acpi/ac_adapter").each do |file|
10 | next if file == "." or file == ".."
11 | fn = "/proc/acpi/ac_adapter/#{file}"
12 |
13 | if File.directory?(fn)
14 | @ac_folder = Php4r.realpath(fn)
15 | break
16 | end
17 | end
18 |
19 | raise "Could not register ac-folder." if !@ac_folder
20 | end
21 |
22 | def state
23 | cont = File.read("#{@ac_folder}/state")
24 |
25 | if match = cont.match(/state:\s*(.+)\s*/)
26 | return match[1]
27 | end
28 |
29 | raise "Could not figure out state."
30 | end
31 | end
--------------------------------------------------------------------------------
/lib/knj/thread.rb:
--------------------------------------------------------------------------------
1 | #This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.
2 | class Knj::Thread < Thread
3 | attr_accessor :data
4 |
5 | #Initializes the thread and passes any given arguments to the thread-block.
6 | def initialize(*args)
7 | raise "No block was given." unless block_given?
8 |
9 | super(*args) do
10 | begin
11 | yield(*args)
12 | rescue SystemExit, Interrupt
13 | raise
14 | rescue Exception => e
15 | print "#{Knj::Errors.error_str(e)}\n\n"
16 | end
17 | end
18 |
19 | @data = {}
20 | end
21 |
22 | #Returns a key from the data-hash.
23 | def [](key)
24 | return @data[key]
25 | end
26 |
27 | #Sets a key on the data-hash.
28 | def []=(key, value)
29 | return @data[key] = value
30 | end
31 | end
--------------------------------------------------------------------------------
/lib/knj/jruby-gtk2/builder.rb:
--------------------------------------------------------------------------------
1 | class Gtk::Builder
2 | def initialize
3 |
4 | end
5 |
6 | def add_from_file(filename)
7 | cont = File.read(filename).gsub("", "").gsub("", "")
8 | cont = cont.gsub("