knjrbfw 0.0.113 → 0.0.115
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.
- checksums.yaml +5 -5
- data/Rakefile +0 -14
- data/lib/knj/autoload/magick.rb +2 -2
- data/lib/knj/event_handler.rb +16 -16
- data/lib/knj/image.rb +1 -3
- data/lib/knj/web.rb +0 -10
- data/lib/knj/webscripts/image_subproc.rhtml +39 -39
- metadata +4 -24
- data/.document +0 -5
- data/.rspec +0 -1
- data/Gemfile +0 -22
- data/Gemfile.lock +0 -90
- data/VERSION +0 -1
- data/knjrbfw.gemspec +0 -286
- data/lib/knj/.gitignore +0 -1
- data/lib/knj/sshrobot/sshrobot.rb +0 -135
- data/lib/knj/sshrobot.rb +0 -1
- data/spec/amixer_spec.rb +0 -32
- data/spec/arrayext_spec.rb +0 -42
- data/spec/autoload_spec.rb +0 -7
- data/spec/cmd_parser_spec.rb +0 -25
- data/spec/knjrbfw_spec.rb +0 -109
- data/spec/locales_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -12
- data/spec/strings_spec.rb +0 -65
- data/spec/web_spec.rb +0 -77
- data/testfiles/image.jpg +0 -0
data/knjrbfw.gemspec
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: knjrbfw 0.0.113 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "knjrbfw"
|
9
|
-
s.version = "0.0.113"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Kasper Johansen"]
|
14
|
-
s.date = "2015-04-21"
|
15
|
-
s.description = "Including stuff for HTTP, SSH and much more."
|
16
|
-
s.email = "k@spernj.org"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.rdoc"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".rspec",
|
24
|
-
"Gemfile",
|
25
|
-
"Gemfile.lock",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.rdoc",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"knjrbfw.gemspec",
|
31
|
-
"lib/knj/.gitignore",
|
32
|
-
"lib/knj/amixer.rb",
|
33
|
-
"lib/knj/arrayext.rb",
|
34
|
-
"lib/knj/autoload.rb",
|
35
|
-
"lib/knj/autoload/activesupport.rb",
|
36
|
-
"lib/knj/autoload/backups/facets_dictionary.rb",
|
37
|
-
"lib/knj/autoload/backups/parsedate.rb",
|
38
|
-
"lib/knj/autoload/backups/ping.rb",
|
39
|
-
"lib/knj/autoload/cinch.rb",
|
40
|
-
"lib/knj/autoload/erubis.rb",
|
41
|
-
"lib/knj/autoload/facebooker.rb",
|
42
|
-
"lib/knj/autoload/facets_dictionary.rb",
|
43
|
-
"lib/knj/autoload/gd2.rb",
|
44
|
-
"lib/knj/autoload/gettext.rb",
|
45
|
-
"lib/knj/autoload/gtk2.rb",
|
46
|
-
"lib/knj/autoload/json.rb",
|
47
|
-
"lib/knj/autoload/magick.rb",
|
48
|
-
"lib/knj/autoload/mysql.rb",
|
49
|
-
"lib/knj/autoload/parsedate.rb",
|
50
|
-
"lib/knj/autoload/ping.rb",
|
51
|
-
"lib/knj/autoload/rexml.rb",
|
52
|
-
"lib/knj/autoload/soap.rb",
|
53
|
-
"lib/knj/autoload/sqlite3.rb",
|
54
|
-
"lib/knj/autoload/tmail.rb",
|
55
|
-
"lib/knj/autoload/tzinfo.rb",
|
56
|
-
"lib/knj/autoload/wref.rb",
|
57
|
-
"lib/knj/autoload/xmlsimple.rb",
|
58
|
-
"lib/knj/autoload/zip.rb",
|
59
|
-
"lib/knj/cmd_gen.rb",
|
60
|
-
"lib/knj/cmd_parser.rb",
|
61
|
-
"lib/knj/compiler.rb",
|
62
|
-
"lib/knj/cpufreq.rb",
|
63
|
-
"lib/knj/csv.rb",
|
64
|
-
"lib/knj/degulesider.rb",
|
65
|
-
"lib/knj/erb/apache_knjerb.conf",
|
66
|
-
"lib/knj/erb/cache/README",
|
67
|
-
"lib/knj/erb/erb.rb",
|
68
|
-
"lib/knj/erb/erb_1.9.rb",
|
69
|
-
"lib/knj/erb/erb_cache_clean.rb",
|
70
|
-
"lib/knj/erb/erb_fcgi.rb",
|
71
|
-
"lib/knj/erb/erb_fcgi_1.9.rb",
|
72
|
-
"lib/knj/erb/erb_fcgi_jruby.rb",
|
73
|
-
"lib/knj/erb/erb_jruby.rb",
|
74
|
-
"lib/knj/erb/include.rb",
|
75
|
-
"lib/knj/errors.rb",
|
76
|
-
"lib/knj/eruby.rb",
|
77
|
-
"lib/knj/event_filemod.rb",
|
78
|
-
"lib/knj/event_handler.rb",
|
79
|
-
"lib/knj/exchangerates.rb",
|
80
|
-
"lib/knj/facebook_connect.rb",
|
81
|
-
"lib/knj/filesystem.rb",
|
82
|
-
"lib/knj/fs/drivers/filesystem.rb",
|
83
|
-
"lib/knj/fs/drivers/ftp.rb",
|
84
|
-
"lib/knj/fs/drivers/ssh.rb",
|
85
|
-
"lib/knj/fs/fs.rb",
|
86
|
-
"lib/knj/gettext_fallback.rb",
|
87
|
-
"lib/knj/gettext_threadded.rb",
|
88
|
-
"lib/knj/google_sitemap.rb",
|
89
|
-
"lib/knj/gtk2.rb",
|
90
|
-
"lib/knj/gtk2_cb.rb",
|
91
|
-
"lib/knj/gtk2_menu.rb",
|
92
|
-
"lib/knj/gtk2_msgbox.rb",
|
93
|
-
"lib/knj/gtk2_statuswindow.rb",
|
94
|
-
"lib/knj/gtk2_tv.rb",
|
95
|
-
"lib/knj/gtk2_window.rb",
|
96
|
-
"lib/knj/hash_methods.rb",
|
97
|
-
"lib/knj/image.rb",
|
98
|
-
"lib/knj/includes/appserver_cli.rb",
|
99
|
-
"lib/knj/includes/require_info.rb",
|
100
|
-
"lib/knj/iotop.rb",
|
101
|
-
"lib/knj/ip2location.rb",
|
102
|
-
"lib/knj/ironruby-gtk2/button.rb",
|
103
|
-
"lib/knj/ironruby-gtk2/dialog.rb",
|
104
|
-
"lib/knj/ironruby-gtk2/entry.rb",
|
105
|
-
"lib/knj/ironruby-gtk2/gdk_event.rb",
|
106
|
-
"lib/knj/ironruby-gtk2/gdk_eventbutton.rb",
|
107
|
-
"lib/knj/ironruby-gtk2/gdk_pixbuf.rb",
|
108
|
-
"lib/knj/ironruby-gtk2/gladexml.rb",
|
109
|
-
"lib/knj/ironruby-gtk2/glib.rb",
|
110
|
-
"lib/knj/ironruby-gtk2/gtk2.rb",
|
111
|
-
"lib/knj/ironruby-gtk2/gtk_builder.rb",
|
112
|
-
"lib/knj/ironruby-gtk2/gtk_cellrenderertext.rb",
|
113
|
-
"lib/knj/ironruby-gtk2/gtk_combobox.rb",
|
114
|
-
"lib/knj/ironruby-gtk2/gtk_filechooserbutton.rb",
|
115
|
-
"lib/knj/ironruby-gtk2/gtk_liststore.rb",
|
116
|
-
"lib/knj/ironruby-gtk2/gtk_menu.rb",
|
117
|
-
"lib/knj/ironruby-gtk2/gtk_menuitem.rb",
|
118
|
-
"lib/knj/ironruby-gtk2/gtk_statusicon.rb",
|
119
|
-
"lib/knj/ironruby-gtk2/gtk_treeiter.rb",
|
120
|
-
"lib/knj/ironruby-gtk2/gtk_treeselection.rb",
|
121
|
-
"lib/knj/ironruby-gtk2/gtk_treeview.rb",
|
122
|
-
"lib/knj/ironruby-gtk2/gtk_treeviewcolumn.rb",
|
123
|
-
"lib/knj/ironruby-gtk2/iconsize.rb",
|
124
|
-
"lib/knj/ironruby-gtk2/image.rb",
|
125
|
-
"lib/knj/ironruby-gtk2/label.rb",
|
126
|
-
"lib/knj/ironruby-gtk2/stock.rb",
|
127
|
-
"lib/knj/ironruby-gtk2/tests/test.glade",
|
128
|
-
"lib/knj/ironruby-gtk2/tests/test_2.rb",
|
129
|
-
"lib/knj/ironruby-gtk2/tests/test_ironruby_window.rb",
|
130
|
-
"lib/knj/ironruby-gtk2/vbox.rb",
|
131
|
-
"lib/knj/ironruby-gtk2/window.rb",
|
132
|
-
"lib/knj/jruby-gtk2/builder.rb",
|
133
|
-
"lib/knj/jruby-gtk2/builder/test_builder.glade",
|
134
|
-
"lib/knj/jruby-gtk2/builder/test_builder.rb",
|
135
|
-
"lib/knj/jruby-gtk2/builder/test_builder.ui",
|
136
|
-
"lib/knj/jruby-gtk2/cellrenderertext.rb",
|
137
|
-
"lib/knj/jruby-gtk2/checkbutton.rb",
|
138
|
-
"lib/knj/jruby-gtk2/combobox.rb",
|
139
|
-
"lib/knj/jruby-gtk2/dialog.rb",
|
140
|
-
"lib/knj/jruby-gtk2/eventbutton.rb",
|
141
|
-
"lib/knj/jruby-gtk2/gladexml.rb",
|
142
|
-
"lib/knj/jruby-gtk2/gtk2.rb",
|
143
|
-
"lib/knj/jruby-gtk2/hbox.rb",
|
144
|
-
"lib/knj/jruby-gtk2/iconsize.rb",
|
145
|
-
"lib/knj/jruby-gtk2/image.rb",
|
146
|
-
"lib/knj/jruby-gtk2/liststore.rb",
|
147
|
-
"lib/knj/jruby-gtk2/menu.rb",
|
148
|
-
"lib/knj/jruby-gtk2/progressbar.rb",
|
149
|
-
"lib/knj/jruby-gtk2/statusicon.rb",
|
150
|
-
"lib/knj/jruby-gtk2/stock.rb",
|
151
|
-
"lib/knj/jruby-gtk2/tests/test_glade_window.glade",
|
152
|
-
"lib/knj/jruby-gtk2/tests/test_glade_window.rb",
|
153
|
-
"lib/knj/jruby-gtk2/tests/test_normal_window.rb",
|
154
|
-
"lib/knj/jruby-gtk2/tests/test_trayicon.png",
|
155
|
-
"lib/knj/jruby-gtk2/tests/test_trayicon.rb",
|
156
|
-
"lib/knj/jruby-gtk2/treeview.rb",
|
157
|
-
"lib/knj/jruby-gtk2/vbox.rb",
|
158
|
-
"lib/knj/jruby-gtk2/window.rb",
|
159
|
-
"lib/knj/jruby_compiler.rb",
|
160
|
-
"lib/knj/knj.rb",
|
161
|
-
"lib/knj/knj_controller.rb",
|
162
|
-
"lib/knj/kvm.rb",
|
163
|
-
"lib/knj/libqt.rb",
|
164
|
-
"lib/knj/libqt_window.rb",
|
165
|
-
"lib/knj/locale_strings.rb",
|
166
|
-
"lib/knj/locales.rb",
|
167
|
-
"lib/knj/maemo/fremantle-calendar/fremantle-calendar.rb",
|
168
|
-
"lib/knj/mail.rb",
|
169
|
-
"lib/knj/mailobj.rb",
|
170
|
-
"lib/knj/memory_analyzer.rb",
|
171
|
-
"lib/knj/mount.rb",
|
172
|
-
"lib/knj/mutexcl.rb",
|
173
|
-
"lib/knj/notify.rb",
|
174
|
-
"lib/knj/nvidia_settings.rb",
|
175
|
-
"lib/knj/objects/objects_sqlhelper.rb",
|
176
|
-
"lib/knj/opts.rb",
|
177
|
-
"lib/knj/os.rb",
|
178
|
-
"lib/knj/php_parser/arguments.rb",
|
179
|
-
"lib/knj/php_parser/functions.rb",
|
180
|
-
"lib/knj/php_parser/php_parser.rb",
|
181
|
-
"lib/knj/php_parser/tests/test.rb",
|
182
|
-
"lib/knj/php_parser/tests/test_function.php",
|
183
|
-
"lib/knj/php_parser/tests/test_function_run.rb",
|
184
|
-
"lib/knj/power_manager.rb",
|
185
|
-
"lib/knj/rand.rb",
|
186
|
-
"lib/knj/rhodes/mutex.rb",
|
187
|
-
"lib/knj/rhodes/rhodes.js",
|
188
|
-
"lib/knj/rhodes/rhodes.rb",
|
189
|
-
"lib/knj/rhodes/youtube_embed.erb",
|
190
|
-
"lib/knj/rhodes/youtube_open.erb",
|
191
|
-
"lib/knj/rsvgbin.rb",
|
192
|
-
"lib/knj/scripts/degulesider.rb",
|
193
|
-
"lib/knj/scripts/filesearch.rb",
|
194
|
-
"lib/knj/scripts/ip2location.rb",
|
195
|
-
"lib/knj/scripts/keepalive.rb",
|
196
|
-
"lib/knj/scripts/php_to_rb_helper.rb",
|
197
|
-
"lib/knj/scripts/speed_test.rb",
|
198
|
-
"lib/knj/scripts/svn_merge.rb",
|
199
|
-
"lib/knj/scripts/upgrade_knjrbfw_checker.rb",
|
200
|
-
"lib/knj/sms.rb",
|
201
|
-
"lib/knj/sshrobot.rb",
|
202
|
-
"lib/knj/sshrobot/sshrobot.rb",
|
203
|
-
"lib/knj/strings.rb",
|
204
|
-
"lib/knj/sysuser.rb",
|
205
|
-
"lib/knj/table_writer.rb",
|
206
|
-
"lib/knj/tests/compiler/compiler_test.rb",
|
207
|
-
"lib/knj/tests/compiler/compiler_test_file.rb",
|
208
|
-
"lib/knj/tests/test_degulesider.rb",
|
209
|
-
"lib/knj/tests/test_http2.rb",
|
210
|
-
"lib/knj/tests/test_http2_proxy.rb",
|
211
|
-
"lib/knj/tests/test_mount.rb",
|
212
|
-
"lib/knj/thread.rb",
|
213
|
-
"lib/knj/thread2.rb",
|
214
|
-
"lib/knj/threadhandler.rb",
|
215
|
-
"lib/knj/unix_proc.rb",
|
216
|
-
"lib/knj/web.rb",
|
217
|
-
"lib/knj/webscripts/image.rhtml",
|
218
|
-
"lib/knj/webscripts/image_subproc.rhtml",
|
219
|
-
"lib/knj/win.rb",
|
220
|
-
"lib/knj/win_registry.rb",
|
221
|
-
"lib/knj/win_tightvnc.rb",
|
222
|
-
"lib/knj/x11vnc.rb",
|
223
|
-
"lib/knj/youtube.rb",
|
224
|
-
"lib/knjrbfw.rb",
|
225
|
-
"spec/amixer_spec.rb",
|
226
|
-
"spec/arrayext_spec.rb",
|
227
|
-
"spec/autoload_spec.rb",
|
228
|
-
"spec/cmd_parser_spec.rb",
|
229
|
-
"spec/knjrbfw_spec.rb",
|
230
|
-
"spec/locales_spec.rb",
|
231
|
-
"spec/spec_helper.rb",
|
232
|
-
"spec/strings_spec.rb",
|
233
|
-
"spec/web_spec.rb",
|
234
|
-
"testfiles/image.jpg"
|
235
|
-
]
|
236
|
-
s.homepage = "http://github.com/kaspernj/knjrbfw"
|
237
|
-
s.licenses = ["MIT"]
|
238
|
-
s.rubygems_version = "2.4.0"
|
239
|
-
s.summary = "A framework with lots of stuff for Ruby."
|
240
|
-
|
241
|
-
if s.respond_to? :specification_version then
|
242
|
-
s.specification_version = 4
|
243
|
-
|
244
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
245
|
-
s.add_runtime_dependency(%q<wref>, [">= 0.0.8"])
|
246
|
-
s.add_runtime_dependency(%q<tsafe>, [">= 0"])
|
247
|
-
s.add_runtime_dependency(%q<datet>, [">= 0"])
|
248
|
-
s.add_runtime_dependency(%q<http2>, [">= 0"])
|
249
|
-
s.add_runtime_dependency(%q<php4r>, [">= 0"])
|
250
|
-
s.add_runtime_dependency(%q<ruby_process>, [">= 0"])
|
251
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
252
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
253
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
254
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
255
|
-
s.add_development_dependency(%q<rmagick>, [">= 0"])
|
256
|
-
s.add_development_dependency(%q<array_enumerator>, [">= 0"])
|
257
|
-
else
|
258
|
-
s.add_dependency(%q<wref>, [">= 0.0.8"])
|
259
|
-
s.add_dependency(%q<tsafe>, [">= 0"])
|
260
|
-
s.add_dependency(%q<datet>, [">= 0"])
|
261
|
-
s.add_dependency(%q<http2>, [">= 0"])
|
262
|
-
s.add_dependency(%q<php4r>, [">= 0"])
|
263
|
-
s.add_dependency(%q<ruby_process>, [">= 0"])
|
264
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
265
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
266
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
267
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
268
|
-
s.add_dependency(%q<rmagick>, [">= 0"])
|
269
|
-
s.add_dependency(%q<array_enumerator>, [">= 0"])
|
270
|
-
end
|
271
|
-
else
|
272
|
-
s.add_dependency(%q<wref>, [">= 0.0.8"])
|
273
|
-
s.add_dependency(%q<tsafe>, [">= 0"])
|
274
|
-
s.add_dependency(%q<datet>, [">= 0"])
|
275
|
-
s.add_dependency(%q<http2>, [">= 0"])
|
276
|
-
s.add_dependency(%q<php4r>, [">= 0"])
|
277
|
-
s.add_dependency(%q<ruby_process>, [">= 0"])
|
278
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
279
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
280
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
281
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
282
|
-
s.add_dependency(%q<rmagick>, [">= 0"])
|
283
|
-
s.add_dependency(%q<array_enumerator>, [">= 0"])
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
data/lib/knj/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
erb/cache/*
|
@@ -1,135 +0,0 @@
|
|
1
|
-
class Knj::SSHRobot
|
2
|
-
def initialize(args)
|
3
|
-
require "net/ssh"
|
4
|
-
|
5
|
-
@forwards = []
|
6
|
-
@args = Knj::ArrayExt.hash_sym(args)
|
7
|
-
@args[:port] = 22 if !@args.key?(:port)
|
8
|
-
|
9
|
-
if block_given?
|
10
|
-
begin
|
11
|
-
yield(self)
|
12
|
-
ensure
|
13
|
-
self.close
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
#Spawns a session if it hasnt already been spawned and returns it.
|
19
|
-
def session
|
20
|
-
@session = self.session_spawn if !@session
|
21
|
-
return @session
|
22
|
-
end
|
23
|
-
|
24
|
-
#Spawns a new net-ssh-instance.
|
25
|
-
def session_spawn
|
26
|
-
return Net::SSH.start(@args[:host], @args[:user], :password => @args[:passwd], :port => @args[:port].to_i)
|
27
|
-
end
|
28
|
-
|
29
|
-
#Returns the a shell-session.
|
30
|
-
def shell
|
31
|
-
return self.session.shell.sync
|
32
|
-
end
|
33
|
-
|
34
|
-
def sftp
|
35
|
-
@sftp = Net::SFTP.start(@args[:host], @args[:user], @args[:passwd], :port => @args[:port].to_i)
|
36
|
-
end
|
37
|
-
|
38
|
-
#Executes a command.
|
39
|
-
def exec(command, &block)
|
40
|
-
if block
|
41
|
-
return self.session.exec!(command) do |channel, stream, line|
|
42
|
-
block.call(:channel => channel, :stream => stream, :line => line)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
return self.session.exec!(command)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
#Executes a command as "root" via "sudo". Accepts the "sudo"-password and a command.
|
50
|
-
def sudo_exec(sudo_passwd, command)
|
51
|
-
result = ""
|
52
|
-
|
53
|
-
self.session.open_channel do |ch|
|
54
|
-
ch.request_pty
|
55
|
-
|
56
|
-
ch.exec("sudo #{command}") do |ch, success|
|
57
|
-
ch.on_data do |ch, data|
|
58
|
-
if data =~ /^\[sudo\] password for (.+):\s*$/
|
59
|
-
ch.send_data("#{sudo_passwd}\n")
|
60
|
-
else
|
61
|
-
result << data
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
self.session.loop
|
68
|
-
return result
|
69
|
-
end
|
70
|
-
|
71
|
-
def fileExists(filepath)
|
72
|
-
result = self.exec("ls #{Strings.UnixSafe(filepath)}").strip
|
73
|
-
return true if result == filepath
|
74
|
-
return false
|
75
|
-
end
|
76
|
-
|
77
|
-
def forward(args)
|
78
|
-
Knj::ArrayExt.hash_sym(args)
|
79
|
-
args[:type] = "local" if !args[:type]
|
80
|
-
args[:session] = self.session_spawn if !args[:session]
|
81
|
-
args[:host_local] = "0.0.0.0" if !args[:host_local]
|
82
|
-
return SSHRobot::Forward.new(args)
|
83
|
-
end
|
84
|
-
|
85
|
-
alias getShell shell
|
86
|
-
alias getSFTP sftp
|
87
|
-
alias shellCMD exec
|
88
|
-
|
89
|
-
def close
|
90
|
-
@session.close if @session
|
91
|
-
@session = nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Knj::SSHRobot::Forward
|
96
|
-
attr_reader :open
|
97
|
-
|
98
|
-
def initialize(args)
|
99
|
-
@open = true
|
100
|
-
@args = args
|
101
|
-
@thread = Knj::Thread.new do
|
102
|
-
begin
|
103
|
-
#args[:session].logger.sev_threshold = Logger::Severity::DEBUG
|
104
|
-
if args[:type] == "local"
|
105
|
-
@args[:session].forward.local(@args[:host_local], @args[:port_local].to_i, @args[:host], @args[:port_remote].to_i)
|
106
|
-
elsif args[:type] == "remote"
|
107
|
-
@args[:session].forward.remote_to(@args[:port_local], @args[:host], @args[:port_remote], @args[:host_local])
|
108
|
-
else
|
109
|
-
raise "No valid type given."
|
110
|
-
end
|
111
|
-
|
112
|
-
@args[:session].loop do
|
113
|
-
true
|
114
|
-
end
|
115
|
-
rescue => e
|
116
|
-
puts e.inspect
|
117
|
-
puts e.backtrace
|
118
|
-
|
119
|
-
@open = false
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def close
|
125
|
-
if !@args
|
126
|
-
return nil
|
127
|
-
end
|
128
|
-
|
129
|
-
@args[:session].close
|
130
|
-
@open = false
|
131
|
-
@thread.exit
|
132
|
-
@args = nil
|
133
|
-
@thread = nil
|
134
|
-
end
|
135
|
-
end
|
data/lib/knj/sshrobot.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "#{$knjpath}sshrobot/sshrobot"
|
data/spec/amixer_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Amixer" do
|
4
|
-
it "should load by using autoload" do
|
5
|
-
if Knj::Os.os == "linux"
|
6
|
-
require "knjrbfw"
|
7
|
-
$amixer = Knj::Amixer.new
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should register various devices" do
|
12
|
-
if Knj::Os.os == "linux"
|
13
|
-
$devices = $amixer.devices
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should register various mixers and do various operations on them" do
|
18
|
-
if Knj::Os.os == "linux"
|
19
|
-
$devices.each do |name, device|
|
20
|
-
mixers = device.mixers
|
21
|
-
|
22
|
-
if device.active?(:stream => "PLAYBACK")
|
23
|
-
mixers.each do |name, mixer|
|
24
|
-
next if !mixer.volume?
|
25
|
-
mixer.vol_add -5
|
26
|
-
mixer.vol_add 3
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/arrayext_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "ArrayExt" do
|
4
|
-
it "should be able to do powersets" do
|
5
|
-
ps = Knj::ArrayExt.powerset(:arr => [1, 2, 3, 4]).to_a
|
6
|
-
raise "Expected length of 16 but it wasnt: #{ps.length}" if ps.length != 16
|
7
|
-
|
8
|
-
ite = 0
|
9
|
-
Knj::ArrayExt.powerset(:arr => [1, 2, 3, 4]) do |arr|
|
10
|
-
ite += 1
|
11
|
-
end
|
12
|
-
|
13
|
-
raise "Expected block to be executed 16 times but it wasnt: #{ite}" if ite != 16
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should be able to divide arrays" do
|
17
|
-
arr = [1, 2, 3, 4, 6, 7, 8, 9, 15, 16, 17, 18]
|
18
|
-
res = Knj::ArrayExt.divide(:arr => arr) do |a, b|
|
19
|
-
if (b - a) > 1
|
20
|
-
false
|
21
|
-
else
|
22
|
-
true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
raise "Expected length of 3 but it wasnt: #{res.length}" if res.length != 3
|
27
|
-
raise "Expected length of 4 but it wasnt: #{res[0].length}" if res[0].length != 4
|
28
|
-
raise "Expected length of 3 but it wasnt: #{res[1].length}" if res[1].length != 3
|
29
|
-
raise "Expected length of 3 but it wasnt: #{res[2].length}" if res[2].length != 3
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should be able to make ago-strings" do
|
33
|
-
arr = [1, 2]
|
34
|
-
Knj::ArrayExt.force_no_cols(:arr => arr, :no => 1)
|
35
|
-
raise "Expected length of 1 but got: #{arr.length}" if arr.length != 1
|
36
|
-
raise "Expected element to be 1 but it wasnt: #{arr[0]}" if arr[0] != 1
|
37
|
-
|
38
|
-
Knj::ArrayExt.force_no_cols(:arr => arr, :no => 3, :empty => "test")
|
39
|
-
raise "Expected length of 3 but got: #{arr.lengtj}" if arr.length != 3
|
40
|
-
raise "Expected element 2 to be 'test' but it wasnt: #{arr[2]}" if arr[2] != "test"
|
41
|
-
end
|
42
|
-
end
|
data/spec/autoload_spec.rb
DELETED
data/spec/cmd_parser_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Cmd_parser" do
|
4
|
-
it "should be able to parse various strings" do
|
5
|
-
require "knjrbfw"
|
6
|
-
require "knj/cmd_parser"
|
7
|
-
require "php4r" if !Kernel.const_defined?(:Php4r)
|
8
|
-
|
9
|
-
strs = [
|
10
|
-
"-rw-r--r-- 1 admin administ 186.3M Aug 30 18:09 b4u_synoptik_2011_08_30_17_57_32.sql.gz\n",
|
11
|
-
"-rw-r--r-- 1 admin administ 2 Nov 21 18:12 test\n",
|
12
|
-
"-rw-r--r-- 1 kaspernj kaspernj 279943393 2011-07-27 09:28 dbdump_2011_07_27_03_07_36.sql\n",
|
13
|
-
"-rw-rw-r-- 1 kaspernj kaspernj 58648 2011-10-28 18:33 2011-11-28 - Programmerings aften hos Anders - mad - 600 kr.pdf\n",
|
14
|
-
"-rw-r--r-- 1 www-data www-data 4,0K 2011-05-16 23:21 dbbackup_2011_05_16-23:21:10.sql.gz\n"
|
15
|
-
]
|
16
|
-
|
17
|
-
strs.each do |str|
|
18
|
-
res = Knj::Cmd_parser.lsl(str)
|
19
|
-
|
20
|
-
res.each do |file|
|
21
|
-
raise "Byte was not numeric in: '#{str}'." if !(Float(file[:size]) rescue false)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/knjrbfw_spec.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Knjrbfw" do
|
4
|
-
it "should be able to join arrays with callbacks." do
|
5
|
-
res = Knj::ArrayExt.join(:arr => [1, 2, 3], :sep => ",", :callback => proc{|value| "'#{value}'"})
|
6
|
-
raise "Unexpected result from ArrayExt." if res != "'1','2','3'"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should be able to draw rounded transparent corners on images." do
|
10
|
-
require "rubygems"
|
11
|
-
require "RMagick"
|
12
|
-
|
13
|
-
pic = Magick::Image.read("#{File.dirname(__FILE__)}/../testfiles/image.jpg").first
|
14
|
-
pic.format = "png"
|
15
|
-
|
16
|
-
Knj::Image.rounded_corners(
|
17
|
-
:img => pic,
|
18
|
-
:radius => 10
|
19
|
-
)
|
20
|
-
|
21
|
-
blob_cont = pic.to_blob
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should be possible to use Strings.html_links-method." do
|
25
|
-
teststr = "This is a test. http://www.google.com This is a test."
|
26
|
-
|
27
|
-
#Test normal usage.
|
28
|
-
test1 = Knj::Strings.html_links(teststr)
|
29
|
-
raise "Unexpected string: '#{teststr}'" if test1 != "This is a test. <a href=\"http://www.google.com\">http://www.google.com</a> This is a test."
|
30
|
-
|
31
|
-
|
32
|
-
#Test with a block.
|
33
|
-
test2 = Knj::Strings.html_links(teststr) do |data|
|
34
|
-
data[:str].gsub(data[:match][0], "TEST")
|
35
|
-
end
|
36
|
-
|
37
|
-
raise "Unexpected string: '#{test2}'." if test2 != "This is a test. TEST This is a test."
|
38
|
-
end
|
39
|
-
|
40
|
-
=begin
|
41
|
-
it "should be able to use Knj::Mutexcl with advanced arguments." do
|
42
|
-
mutex = Knj::Mutexcl.new(
|
43
|
-
:modes => {
|
44
|
-
:reader => {
|
45
|
-
:blocks => [:writer]
|
46
|
-
},
|
47
|
-
:writer => {
|
48
|
-
:blocks => [:reader, :writer]
|
49
|
-
}
|
50
|
-
}
|
51
|
-
)
|
52
|
-
|
53
|
-
$count = 0
|
54
|
-
|
55
|
-
Knj::Thread.new do
|
56
|
-
mutex.sync(:reader) do
|
57
|
-
sleep 0.2
|
58
|
-
$count += 1
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
mutex.sync(:reader) do
|
63
|
-
$count += 1
|
64
|
-
end
|
65
|
-
|
66
|
-
raise "Count should be 1 by now but it wasnt: '#{$count}'." if $count != 1
|
67
|
-
sleep 0.3
|
68
|
-
raise "Count should be 2 by now but it wasnt: '#{$count}'." if $count != 2
|
69
|
-
|
70
|
-
|
71
|
-
$count = 0
|
72
|
-
Knj::Thread.new do
|
73
|
-
mutex.sync(:reader) do
|
74
|
-
sleep 2
|
75
|
-
$count += 1
|
76
|
-
end
|
77
|
-
end
|
78
|
-
sleep 0.1
|
79
|
-
|
80
|
-
Knj::Thread.new do
|
81
|
-
mutex.sync(:writer) do
|
82
|
-
$count += 1
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
sleep 1
|
87
|
-
raise "Count should be 0 but it wasnt: '#{$count}'." if $count != 0
|
88
|
-
sleep 1.1
|
89
|
-
raise "Count should be 2 but it wasnt: '#{$count}'." if $count != 2
|
90
|
-
|
91
|
-
Knj::Thread.new do
|
92
|
-
mutex.sync(:reader) do
|
93
|
-
sleep 0.2
|
94
|
-
$count += 1
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
Knj::Thread.new do
|
99
|
-
mutex.sync(:reader) do
|
100
|
-
sleep 0.2
|
101
|
-
$count += 1
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
sleep 0.35
|
106
|
-
raise "Count should be 4 but it wasnt: '#{$count}'." if $count != 4
|
107
|
-
end
|
108
|
-
=end
|
109
|
-
end
|
data/spec/locales_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
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
|
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
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
|
-
|
12
|
-
end
|