accutronic 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/accu-encrypt.rb +24 -23
- data/lib/accu-file.rb +22 -20
- data/lib/accu-window.rb +83 -26
- metadata +3 -3
data/lib/accu-encrypt.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
+
#--
|
5
|
+
# Copyright 2014 Luke Spangler
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#++
|
19
|
+
|
4
20
|
# This is a library which contains a single module
|
5
21
|
# which implements an encryption algorithm of my
|
6
22
|
# own design. It creates a combined password using
|
@@ -56,7 +72,7 @@ module EncryptDecrypt
|
|
56
72
|
puts "Connection refused."
|
57
73
|
end
|
58
74
|
else
|
59
|
-
send_code
|
75
|
+
send_code 0
|
60
76
|
puts "Connection refused."
|
61
77
|
end
|
62
78
|
server.close
|
@@ -388,8 +404,8 @@ module EncryptDecrypt
|
|
388
404
|
pass,output = *self.encrypt(pass,file.read)
|
389
405
|
file.close
|
390
406
|
File.delete filename
|
391
|
-
File.open(filename,"w") do |
|
392
|
-
|
407
|
+
File.open(filename,"w") do |filer|
|
408
|
+
filer << output
|
393
409
|
end
|
394
410
|
else
|
395
411
|
self.encrypt_file(filename,pass)
|
@@ -408,8 +424,8 @@ module EncryptDecrypt
|
|
408
424
|
pass,output = *self.decrypt(pass,file.read)
|
409
425
|
file.close
|
410
426
|
File.delete filename
|
411
|
-
File.open(filename,"w") do |
|
412
|
-
|
427
|
+
File.open(filename,"w") do |filer|
|
428
|
+
filer << output
|
413
429
|
end
|
414
430
|
else
|
415
431
|
self.decrypt_file(filename,pass)
|
@@ -577,16 +593,15 @@ module EncryptDecrypt
|
|
577
593
|
def self.windows(manager)
|
578
594
|
#--
|
579
595
|
# Page 1 - Simple window.
|
580
|
-
page1_win1 = WindowTerminal::
|
581
|
-
|
582
|
-
page1_win1.add_object page1_text1
|
596
|
+
page1_win1 = WindowTerminal::Templates.simple()[0]
|
597
|
+
page1_win1.set_name "Lobby"
|
583
598
|
manager.new_page(page1_win1)
|
584
599
|
# Page 2 - Help
|
585
600
|
page2_win1 = WindowTerminal::Window.new(WindowTerminal::Orientation.new,"Help")
|
586
601
|
page2_text1 = WindowTerminal::ColoredWrappedText.new(WindowTerminal::Orientation.new,self.InteractiveHelp.gsub(/-/,""),6)
|
587
602
|
page2_win1.add_objects(page2_text1)
|
588
603
|
manager.new_page(page2_win1)
|
589
|
-
return
|
604
|
+
return page1_win1.objects[2]
|
590
605
|
#++
|
591
606
|
end
|
592
607
|
|
@@ -807,17 +822,3 @@ module EncryptDecrypt
|
|
807
822
|
@@mode.dup
|
808
823
|
end
|
809
824
|
end
|
810
|
-
|
811
|
-
# Copyright 2014 Luke Spangler
|
812
|
-
#
|
813
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
814
|
-
# you may not use this file except in compliance with the License.
|
815
|
-
# You may obtain a copy of the License at
|
816
|
-
#
|
817
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
818
|
-
#
|
819
|
-
# Unless required by applicable law or agreed to in writing, software
|
820
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
821
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
822
|
-
# See the License for the specific language governing permissions and
|
823
|
-
# limitations under the License.
|
data/lib/accu-file.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
+
#--
|
5
|
+
# Copyright 2014 Luke Spangler
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#++
|
19
|
+
|
4
20
|
# Simple library which provides a simple
|
5
21
|
# command line "File Manager" interface.
|
6
22
|
#
|
@@ -39,7 +55,7 @@ module FileLibrary
|
|
39
55
|
# navigation system.
|
40
56
|
def self.SelectFile()
|
41
57
|
#--
|
42
|
-
origDir = Dir.pwd
|
58
|
+
#origDir = Dir.pwd
|
43
59
|
currentDirectory = ""
|
44
60
|
selection = ""
|
45
61
|
request = ""
|
@@ -56,7 +72,7 @@ module FileLibrary
|
|
56
72
|
puts "---------"
|
57
73
|
request = gets
|
58
74
|
request.slice!(-1)
|
59
|
-
while not (File.exists? request) do
|
75
|
+
while (not (File.exists? request)) do
|
60
76
|
puts "Invalid: |" + request + "|"
|
61
77
|
puts "Please enter a valid file name or directory."
|
62
78
|
request = gets
|
@@ -92,14 +108,14 @@ module FileLibrary
|
|
92
108
|
def self.SelectFile_With_Windows(manager=WindowTerminal::WindowManager.new)
|
93
109
|
#--
|
94
110
|
# Declarations
|
95
|
-
origDir = Dir.pwd
|
111
|
+
#origDir = Dir.pwd
|
96
112
|
currentDirectory = ""
|
97
113
|
selection = ""
|
98
114
|
request = ""
|
99
115
|
# Define window.
|
100
116
|
window = WindowTerminal::Window.new(WindowTerminal::Orientation.new,"Browse for file.")
|
101
117
|
text = WindowTerminal::WrappedText.new(WindowTerminal::Orientation.new(-1,0),"",5,:preserve)
|
102
|
-
text2 = WindowTerminal::
|
118
|
+
text2 = WindowTerminal::Text.new(WindowTerminal::Orientation.new(1,0),"",5)
|
103
119
|
window.add_objects text2,text
|
104
120
|
num = manager.new_page window
|
105
121
|
manager.display_page num
|
@@ -142,10 +158,10 @@ module FileLibrary
|
|
142
158
|
text2.set_text "File: "
|
143
159
|
WindowTerminal.screen_render
|
144
160
|
request = ""
|
145
|
-
while not (File.exists? request) do
|
161
|
+
while (not (File.exists? request)) do
|
146
162
|
text2.set_text "Invalid: |" + request + "| Please enter a valid file name or directory." if request != ""
|
147
163
|
WindowTerminal.screen_render
|
148
|
-
request = WindowTerminal.getchrs { |
|
164
|
+
request = WindowTerminal.getchrs { |c,full|
|
149
165
|
text2.set_text "File: " + full
|
150
166
|
#WindowTerminal.screen_render
|
151
167
|
}
|
@@ -182,17 +198,3 @@ module FileLibrary
|
|
182
198
|
#++
|
183
199
|
end
|
184
200
|
end
|
185
|
-
|
186
|
-
# Copyright 2014 Luke Spangler
|
187
|
-
#
|
188
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
189
|
-
# you may not use this file except in compliance with the License.
|
190
|
-
# You may obtain a copy of the License at
|
191
|
-
#
|
192
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
193
|
-
#
|
194
|
-
# Unless required by applicable law or agreed to in writing, software
|
195
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
196
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
197
|
-
# See the License for the specific language governing permissions and
|
198
|
-
# limitations under the License.
|
data/lib/accu-window.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2014 Luke Spangler
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#++
|
16
|
+
|
1
17
|
# This is a library which uses some hacky references
|
2
18
|
# together with lots of math and loops to split
|
3
19
|
# a terminal into windows, via the module WindowTerminal.
|
@@ -180,18 +196,30 @@ module WindowTerminal
|
|
180
196
|
|
181
197
|
# Initializes a ColoredText object.
|
182
198
|
def initialize(orientation,text,y,color=:green)
|
199
|
+
@color = color
|
200
|
+
text = colorize(text)
|
201
|
+
super(orientation,text,y)
|
202
|
+
end
|
203
|
+
|
204
|
+
def colorize(text)
|
183
205
|
if WindowTerminal.os == :linux then
|
184
|
-
if color == :green then
|
206
|
+
if @color == :green then
|
185
207
|
text = "\e[#{32}m#{text}\e[0m"
|
186
|
-
elsif color == :red then
|
208
|
+
elsif @color == :red then
|
187
209
|
text = "\e[#{31}m#{text}\e[0m"
|
188
|
-
elsif color == :yellow then
|
210
|
+
elsif @color == :yellow then
|
189
211
|
text = "\e[#{33}m#{text}\e[0m"
|
190
|
-
elsif color == :pink then
|
212
|
+
elsif @color == :pink then
|
191
213
|
text = "\e[#{35}m#{text}\e[0m"
|
192
214
|
end
|
193
215
|
end
|
194
|
-
|
216
|
+
text
|
217
|
+
end
|
218
|
+
|
219
|
+
# Sets text while taking into
|
220
|
+
# account colorization.
|
221
|
+
def set_text(text)
|
222
|
+
super(colorize(text))
|
195
223
|
end
|
196
224
|
end
|
197
225
|
|
@@ -308,7 +336,7 @@ module WindowTerminal
|
|
308
336
|
# The main class which handles each individual
|
309
337
|
# terminal window.
|
310
338
|
class Window
|
311
|
-
attr_reader :orientation,:
|
339
|
+
attr_reader :orientation,:objects
|
312
340
|
|
313
341
|
# Initializes Window object.
|
314
342
|
def initialize(orientation,name)
|
@@ -329,7 +357,7 @@ module WindowTerminal
|
|
329
357
|
# Adds a single object to the Window's
|
330
358
|
# object list.
|
331
359
|
def add_object(object)
|
332
|
-
raise ArgumentError "Argument must be a renderable object." if not (object.respond_to?(:render_line) or object.respond_to?(:render))
|
360
|
+
raise ArgumentError "Argument must be a renderable object." if (not (object.respond_to?(:render_line) or object.respond_to?(:render)))
|
333
361
|
@objects << object
|
334
362
|
end
|
335
363
|
|
@@ -350,6 +378,23 @@ module WindowTerminal
|
|
350
378
|
}
|
351
379
|
end
|
352
380
|
|
381
|
+
# Sets the Window's current
|
382
|
+
# name and changes the
|
383
|
+
# displayed name accordingly.
|
384
|
+
def set_name(name)
|
385
|
+
raise TypeError "Name must be an string!" if (not name.is_a? String)
|
386
|
+
@name = name
|
387
|
+
if @objects[0].respond_to? :set_text then
|
388
|
+
@objects[0].set_text @name
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
# Returns Window's current
|
393
|
+
# name.
|
394
|
+
def get_name()
|
395
|
+
@name
|
396
|
+
end
|
397
|
+
|
353
398
|
# Includes the Window in the
|
354
399
|
# WindowTerminal module screen_render.
|
355
400
|
def include_in_render(bool=true)
|
@@ -393,7 +438,7 @@ module WindowTerminal
|
|
393
438
|
# Displays the page at the number
|
394
439
|
# specified; defaults to one.
|
395
440
|
def display_page(num=1)
|
396
|
-
raise(ArgumentError, "Argument 1 must be a valid integer!") if not (num.is_a? Fixnum)
|
441
|
+
raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum))
|
397
442
|
hide_page(@displayed_page)
|
398
443
|
@pages[num-1].each { |item|
|
399
444
|
WindowTerminal.add_window(item)
|
@@ -410,7 +455,7 @@ module WindowTerminal
|
|
410
455
|
# defaults to doing nothing.
|
411
456
|
def hide_page(num=nil)
|
412
457
|
if num then
|
413
|
-
raise(ArgumentError, "Argument 1 must be a valid integer!") if not (num.is_a? Fixnum)
|
458
|
+
raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum))
|
414
459
|
if num == @displayed_page then
|
415
460
|
@pages[num-1].each { |item|
|
416
461
|
WindowTerminal.remove_window(item)
|
@@ -432,7 +477,7 @@ module WindowTerminal
|
|
432
477
|
|
433
478
|
# Delete a page by page number.
|
434
479
|
def remove_page(num)
|
435
|
-
raise(ArgumentError, "Argument 1 must be a valid integer!") if not (num.is_a? Fixnum)
|
480
|
+
raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum))
|
436
481
|
hide_page(num)
|
437
482
|
@pages.delete_at(num-1)
|
438
483
|
end
|
@@ -441,12 +486,12 @@ module WindowTerminal
|
|
441
486
|
# objects on the page given and
|
442
487
|
# returns them all as an array.
|
443
488
|
def get_page_text(num)
|
444
|
-
raise(ArgumentError, "Argument 1 must be a valid integer!") if not (num.is_a? Fixnum)
|
489
|
+
raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum))
|
445
490
|
array = []
|
446
491
|
@pages[num-1].each {|window|
|
447
492
|
array << window.objects.dup
|
448
493
|
array[-1].each {|item|
|
449
|
-
if not (item.respond_to? :set_text) then
|
494
|
+
if (not (item.respond_to? :set_text)) then
|
450
495
|
array[-1].delete(item)
|
451
496
|
end
|
452
497
|
}
|
@@ -461,6 +506,32 @@ module WindowTerminal
|
|
461
506
|
end
|
462
507
|
end
|
463
508
|
|
509
|
+
# This module contains methods that generate
|
510
|
+
# simple window setups (perhaps for use
|
511
|
+
# with WindowManager.)
|
512
|
+
module Templates
|
513
|
+
# Returns an array containing the
|
514
|
+
# window objects generated by
|
515
|
+
# the template number passed.
|
516
|
+
def self.generate(num)
|
517
|
+
raise TypeError "Num must be an integer!" if (not num.is_a? Fixnum)
|
518
|
+
if num == 1 then
|
519
|
+
self.simple()
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
# Creates a simple, one window
|
524
|
+
# setup.
|
525
|
+
#
|
526
|
+
# Corresponds to generate(1)
|
527
|
+
def self.simple()
|
528
|
+
win = WindowTerminal::Window.new(WindowTerminal::Orientation.new,"Window")
|
529
|
+
text = WindowTerminal::WrappedText.new(WindowTerminal::Orientation.new,"",8,:preserve)
|
530
|
+
win.add_object text
|
531
|
+
return [win]
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
464
535
|
# Gets current terminal size based
|
465
536
|
# on the operating system and
|
466
537
|
# returns the result.
|
@@ -740,17 +811,3 @@ module WindowTerminal
|
|
740
811
|
end
|
741
812
|
end
|
742
813
|
end
|
743
|
-
|
744
|
-
# Copyright 2014 Luke Spangler
|
745
|
-
#
|
746
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
747
|
-
# you may not use this file except in compliance with the License.
|
748
|
-
# You may obtain a copy of the License at
|
749
|
-
#
|
750
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
751
|
-
#
|
752
|
-
# Unless required by applicable law or agreed to in writing, software
|
753
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
754
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
755
|
-
# See the License for the specific language governing permissions and
|
756
|
-
# limitations under the License.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accutronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abc
|
@@ -89,5 +89,5 @@ rubyforge_project:
|
|
89
89
|
rubygems_version: 1.8.23
|
90
90
|
signing_key:
|
91
91
|
specification_version: 3
|
92
|
-
summary:
|
92
|
+
summary: A simple set of libraries and executables for personal use.
|
93
93
|
test_files: []
|