ffetch 0.1.0 → 0.1.1

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.
Files changed (4) hide show
  1. data/lib/data.rb +4 -0
  2. data/lib/fetch.rbw +27 -0
  3. data/lib/gui.rb +158 -0
  4. metadata +4 -4
data/lib/data.rb ADDED
@@ -0,0 +1,4 @@
1
+ # DATA FILE
2
+ $title = "Find Files with Regex"
3
+ $header_text = "FIND FILES WITH REGEX"
4
+ $default = "c:/your_default_folder_here"
data/lib/fetch.rbw ADDED
@@ -0,0 +1,27 @@
1
+ #MAIN FILE
2
+ require 'tk'
3
+ require 'find'
4
+ require_relative 'gui'
5
+ require_relative 'data'
6
+
7
+ Gui.root{title "#$title"}
8
+ Gui.header("#$header_text", 0, 0, 1, 4)
9
+ Gui.label("Enter Search term", 1, 0, 1, 1)
10
+ Gui.entry($var1, 1, 1, 1, 1)
11
+ Gui.button("OK", "m(*$folder)", 1, 2, 1, 1)
12
+ Gui.textfield("Enter Search Term and Click OK", 3, 0, 1, 4)
13
+ Gui.menu
14
+ def m(folder = $default)
15
+ pat = "#$var1"
16
+ files = []
17
+ Find.find(folder) do |path|
18
+ files << path if path =~ /#{pat}.*\.txt$/i
19
+ list = files.join("\n")
20
+ $text.delete('1.0', 'end')
21
+ $text.insert('1.0', "#{list}")
22
+ end
23
+ end
24
+ $text.tag_bind('sel', '1', proc{system "start #{$text.get('sel.first', 'sel.last')}"})
25
+ Gui.show
26
+
27
+
data/lib/gui.rb ADDED
@@ -0,0 +1,158 @@
1
+ # GUI FILE
2
+ require 'tk'
3
+ require 'data'
4
+
5
+ class Gui
6
+ #__________________ ROOT __________________________
7
+ def self.root
8
+ root = TkRoot.new{
9
+ title "#$title"
10
+ }
11
+ end
12
+ root['geometry'] = '300x200+0+0'
13
+
14
+ #_________________ LABELS _______________________________________
15
+ def self.header(text, x, y, xx, yy)
16
+ $header = TkLabel.new(root){
17
+ text "#{text}"
18
+ font TkFont.new('Times 14 bold')
19
+ borderwidth 4
20
+ relief "groove"
21
+ justify "left"
22
+ }.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy, 'sticky' => 'WE')
23
+ end
24
+
25
+ def self.label(text, x, y, xx, yy)
26
+ $header = TkLabel.new(root){
27
+ text "#{text}"
28
+ font TkFont.new('Times 14 bold')
29
+ borderwidth 4
30
+ background "yellow"
31
+ relief "groove"
32
+ justify "left"
33
+ }.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy)
34
+ end
35
+
36
+ #______________ BUTTON ________________________
37
+ def self.button(its_text, its_command, x, y, xx, yy)
38
+ button = TkButton.new(root){
39
+ text "#{its_text}"
40
+ command(its_command)
41
+ borderwidth 4
42
+ font TkFont.new('times 10 bold')
43
+ background "green"
44
+ relief "groove"
45
+ justify "left"
46
+ }.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy)
47
+ #button_click = Proc.new{system 'notepad'}
48
+ #button.command = button_click
49
+ end
50
+ #its_command = proc.new{system 'notepad'}
51
+ #_________________________ LISTBOXES __________________________
52
+ def self.listbox(name, listvar, x, y, xx, yy)
53
+ name = TkListbox.new(root){
54
+ setgrid 1
55
+ height 5
56
+ width 20
57
+ font TkFont.new('Tahoma 14 normal')
58
+ listvariable listvar
59
+ }.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy)
60
+ end
61
+
62
+ #__________________________________________________________
63
+ #global variables declared for use in the class methods
64
+ $var1 = TkVariable.new
65
+ $var2 = TkVariable.new
66
+ $var3 = TkVariable.new
67
+ #________________________________________________________
68
+ #method to draw an entry field sending value to variable (var)[ use $var1 to $var3]
69
+ def self.entry(var, x, y, xx, yy)
70
+ TkEntry.new(root){
71
+ textvariable var
72
+ borderwidth 5
73
+ }.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy)
74
+ end
75
+ #____________________________ TEXT ____________________________
76
+ def self.textfield(data, x, y, xx, yy)
77
+ $text = TkText.new(root) do
78
+ width 70
79
+ height 20
80
+ setgrid 'true'
81
+ background "black"
82
+ foreground "white"
83
+ font TkFont.new('tahoma 16 normal')
84
+ wrap 'word'
85
+ insertbackground "yellow"
86
+ insertwidth 10
87
+ cursor "draft_large"
88
+ end.grid('row' => x, 'column' => y, 'rowspan' => xx, 'columnspan' => yy)
89
+
90
+ $text.focus
91
+ $text.insert('1.0', "#{data}")
92
+ end
93
+ #____________________ SCROLLBARS _______________________________
94
+
95
+ def self.scrollbar
96
+ $scrollbar = TkScrollbar.new(root){command proc{ |*args|
97
+ list_right.yview(* args)
98
+ list_left.yview(* args)}
99
+ }
100
+
101
+ list_right.yscrollcommand(proc { |first, last|
102
+ scrollbar1.set(first, last)
103
+ }
104
+ )
105
+
106
+ list_left.yscrollcommand(proc { |first, last|
107
+ scrollbar1.set(first, last)
108
+ }
109
+ )
110
+ end
111
+ #___________________MENU_____________________________
112
+ def self.menu
113
+ TkOption.add '*tearOff', 0
114
+ $folder =TkVariable.new
115
+ #___________________________________
116
+ default = Proc.new{$folder = $default}
117
+ #________________________
118
+ chooseDir = Proc.new{
119
+ $folder = " "
120
+ $folder = Tk::chooseDirectory
121
+ $text.delete(1.0, 'end')
122
+ $text.insert('end', "#$folder")
123
+ }
124
+ #___________________________________
125
+ closefile = Proc.new{$text.delete(1.0, 'end')}
126
+ exitapp = Proc.new{exit}
127
+ ###################### Menu ###################
128
+ file_menu = TkMenu.new(root)
129
+ #______________________________
130
+ file_menu.add('command',
131
+ 'label' => "Default Folder",
132
+ 'command' => default,
133
+ 'underline' => 0)
134
+ file_menu.add('command',
135
+ 'label' => "Choose Folder",
136
+ 'command' => chooseDir,
137
+ 'underline' => 0)
138
+ file_menu.add('command',
139
+ 'label' => 'Close',
140
+ 'command' => closefile,
141
+ 'underline' => 0)
142
+ file_menu.add('command',
143
+ 'label' => "Exit",
144
+ 'command' => exitapp,
145
+ 'underline' => 3)
146
+ #_________________________________________
147
+ menu_bar = TkMenu.new
148
+ menu_bar.add('cascade',
149
+ 'menu' => file_menu,
150
+ 'label' => "Directory")
151
+ root.menu(menu_bar)
152
+ end
153
+ #______________________ SHOW _______________________________
154
+ def self.show
155
+ Tk.mainloop
156
+ end
157
+
158
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,6 +20,9 @@ extensions: []
20
20
  extra_rdoc_files:
21
21
  - README.md
22
22
  files:
23
+ - lib/data.rb
24
+ - lib/gui.rb
25
+ - lib/fetch.rbw
23
26
  - README.md
24
27
  homepage: http://sabryfattah.com
25
28
  licenses:
@@ -28,9 +31,6 @@ post_install_message:
28
31
  rdoc_options:
29
32
  - --main
30
33
  - README.md
31
- - lib/data.rb
32
- - lib/gui.rb
33
- - lib/fetch.rbw
34
34
  require_paths:
35
35
  - lib
36
36
  required_ruby_version: !ruby/object:Gem::Requirement