filejoiner 0.1.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjQzZGYxMmEzNTZjZDZmMjUxZTM1MWU5YTQ0NjYzMjg5NjVmMTQzYg==
5
+ data.tar.gz: !binary |-
6
+ OTM4ZDg3ZjAxMjg4ZjJiMzRmYTAyYmQ3M2M3ZDc1MDczZGY1YTQzNQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OTFmZTZiYzE0Y2RkNDhlMjM0YmI4N2I0ZWQ4MjEyMjhkM2U1NjZjODFjYzg2
10
+ YjU3MzdhMTBjZjU4ZDZkNjBjZDllNzcyN2I5M2VlYjg3MmNjODJlY2Q5ZGYz
11
+ YTlmZGMzN2ZjYzJkYWYwMGU5OGI1NzdlNmM1OTEzMzEyZjgyYzQ=
12
+ data.tar.gz: !binary |-
13
+ ZjViMDJkZjBjODRhMmNkZDk2YzBiZDkwYzFhMjhhYjEyYjAyZDNiYjAxNTJj
14
+ NjFjNzU3MzEzNmQzYjM5YWRhMjA0NjY4M2UxMmQ1ODdkMDEzZDMwOTc3MjAw
15
+ MWZhY2RhM2U5MDYwYThhY2IzNTRkOWNlY2QyM2QyNDMzMDc0ZGY=
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ Filejoiner is a simple app (using Tcl/Tk GUI) to join a number of text files into a single file.
2
+
3
+ USAGE:
4
+ =====
5
+ 1. Install the Filejoiner : gem install filejoiner
6
+ 2. create a text file containing:
7
+ require 'filejoiner'
8
+ Joiner.run
9
+ save it as "joiner.rb" on your desktop
10
+ if Ruby is in your PATH clicking on this file will start the app.
11
+ 3. Select from the Menu the directory where the separate files reside.
12
+ Once you select the folder, its file contents are shown in the text window.
13
+ 4. Enter the name of the new merged file in the entry field.
14
+ 5. To join these files, click the button "Join Files"
15
+ 6. The content of the merged file will appear in the text window.
16
+ 7. To clear the text area select "New" from the Dir Menu
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "filejoiner"
5
+ s.version = "0.1.0"
6
+ s.licenses = ['MIT']
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Sabry Fattah"]
9
+ s.date = "2015-02-20"
10
+ s.description = "Filejoiner is a simple app (using Tcl/Tk GUI) to join a number of text files into a single file."
11
+ s.email = "sabryabdelfattah@gmail.com"
12
+ s.extra_rdoc_files = ["README.md"]
13
+ s.files = ["filejoiner.gemspec", "lib/filejoiner.rb", "README.md", "lib/gui.rb", "lib/guide.rb", "lib/data.rb"]
14
+ s.homepage = "http://sabryfattah.com"
15
+ s.rdoc_options = ["--main", "README.md"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = "1.8.29"
18
+ s.summary = "tk-based Gui App. to join a number of text files into one"
19
+
20
+ if s.respond_to? :specification_version then
21
+ s.specification_version = 3
22
+
23
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
24
+ else
25
+ end
26
+ else
27
+ end
28
+ end
data/lib/data.rb ADDED
@@ -0,0 +1,20 @@
1
+ #Variables and Methods for App.
2
+ # Variables
3
+ $title = "Files Merger"
4
+ $header = 'Merge number of files into one'
5
+ $label1 = 'Joined Filename'
6
+ $buttontext = 'Join Files'
7
+ #__________________________________________________________
8
+ #global variables declared for use in the class method
9
+ $var1 = TkVariable.new
10
+ $filename =TkVariable.new
11
+
12
+ #_______METHODS __________________________________________
13
+ def m
14
+ file =[]
15
+ $file_list.each{|f| file.push(File.read("#$dir/#{f}"))}
16
+ string = file.join(" \n")
17
+ File.write("#$dir/#$var1", "#{string}")
18
+ $textfield.delete('1.0','end')
19
+ $textfield.insert('end', "#{string}")
20
+ end
data/lib/filejoiner.rb ADDED
@@ -0,0 +1,21 @@
1
+ require_relative 'gui'
2
+ require_relative 'data'
3
+
4
+
5
+ Gui.root
6
+ Gui.menu
7
+ Gui.header("#$header",1,2)
8
+ Gui.label("Merged Filename ", 1,0)
9
+ Gui.entry($var1, 1, 1)
10
+ Gui.textfield(40, 10, 3,3)
11
+ Gui.button("#$buttontext", "m", 6,0)
12
+ Gui.show
13
+
14
+ #________________ Link_Installer ________________________
15
+ class Joiner
16
+
17
+ def self.run
18
+ puts `filejoiner.rb`
19
+ end
20
+
21
+ end
data/lib/gui.rb ADDED
@@ -0,0 +1,149 @@
1
+ require 'tk'
2
+ require_relative 'guide'
3
+
4
+ class Gui
5
+ #A class which uses Tcl/Tk to build a GUI for user interaction
6
+ #_______________________________________________
7
+ #we start by building a Toplevel Help window which is used by a menu as a Help guide
8
+ def self.help_win
9
+ $win = TkToplevel.new{title "Help Window"}
10
+ $scrollbar = TkScrollbar.new($win){command proc{|*args| $textwin.yview(*args)}
11
+ }.pack('side' => 'right', 'fill' => 'y')
12
+ $textwin =TkText.new($win){
13
+ borderwidth 1
14
+ wrap 'word'
15
+ font TkFont.new('times 14 bold')
16
+ background "yellow"
17
+ pack('side' => 'left')
18
+ }
19
+ $guide = Guide.view
20
+ $textwin.insert(1.0, "#{$guide}")
21
+ $textwin.yscrollcommand(proc{|first, last| $scrollbar.set(first, last)})
22
+ end
23
+ #_______________________________________________________
24
+ #method to build the root main window
25
+ def self.root
26
+ TkRoot.new{
27
+ title "#$title"
28
+ }
29
+ end
30
+ #_______________________________________________________
31
+ #method to draw a label with text (lbltxt) and coordinates x,y in a grid
32
+ def self.label(lbltxt, x,y)
33
+ TkLabel.new(root){
34
+ text "#{lbltxt}"
35
+ grid('row' => x, 'column' => y, 'padx' => 10, 'pady' => 15)}
36
+ end
37
+ #_______________ HEADER _________________________________
38
+ def self.header(hdtxt, x, y)
39
+ TkLabel.new(root){
40
+ text "#{hdtxt}"
41
+ background "green"
42
+ borderwidth 4
43
+ font TkFont.new('Proxima 16 bold')
44
+ foreground "black"
45
+ 'padx' '10'
46
+ 'pady' '15'
47
+ justify "center"
48
+ relief 'raised'
49
+ grid('rowspan' => x, 'columnspan' => y, 'padx' => 10, 'pady' => 15)}
50
+ end
51
+ #________________________________________________________
52
+ #method to draw a button with text (btntxt), triggering method (m) and coordinates x,y
53
+ def self.button(btntxt, m, x,y)
54
+ TkButton.new(root){
55
+ text "#{btntxt}"
56
+ command(m)
57
+ grid('row' => x, 'column' => y, 'padx' => 10, 'pady' => 15)}
58
+ end
59
+
60
+ #________________________________________________________
61
+ #method to draw an entry field sending value to variable (var)[ use $var1 to $var3]
62
+ def self.entry(var, x, y)
63
+ TkEntry.new(root){
64
+ textvariable var
65
+ grid('row' => x, 'column' => y, 'padx' => 10, 'pady' => 15)}
66
+ end
67
+ #_____________________________________________________________
68
+ #method to draw a textfield with specific width (w), height (h), background color (bg)
69
+ #and foreground color (fg), and coordinates x, y, with vertical scrollbar
70
+ def self.textfield(w, h, x, y)
71
+ $textfield = TkText.new(root){
72
+ width w
73
+ height h
74
+ background "black"
75
+ foreground "white"
76
+ font TkFont.new('times 14 bold')
77
+ grid('rowspan' => x, 'columnspan' => y, 'padx' => 10, 'pady' => 15)
78
+ }
79
+ end
80
+ #____________________________________________________________
81
+ #The Scrollbar to use with textfield widget
82
+ def scroll
83
+ $scroll = TkScrollbar.new{command proc{|*args|
84
+ $textfield.yview(*args)
85
+ $textfield.yscrollcommand(proc {|first, last| $scroll.set(first, last)})
86
+ pack('side' => 'right', 'fill' => 'y')}
87
+ }
88
+ end
89
+ #______________ MENU _______________________________________________
90
+ def self.menu
91
+ #No tearoff marker
92
+ TkOption.add '*tearOff', 0
93
+ #____________________ METHODS _____________________________
94
+ #________________CLEAR TEXTFIELD ___________________________
95
+ newfile = Proc.new{$textfield.delete(1.0, 'end')}
96
+ #______________ OPEN DIRECTORY _____________________________
97
+ opendir = Proc.new{
98
+ $dir = Tk::chooseDirectory
99
+ $file_list = []
100
+ $file_list = Dir.entries($dir).select {|f| !File.directory? f}
101
+ $files = $file_list.join("\n")
102
+ $textfield.delete(1.0, 'end')
103
+ $textfield.insert('end', "#$files")
104
+ }
105
+ #___________________________________
106
+ exitapp = Proc.new{exit}
107
+ ###################### Menu ###################
108
+ ## Menu attached to root, file and help menu
109
+ menu_bar = TkMenu.new
110
+ root.menu(menu_bar)
111
+ file_menu = TkMenu.new(root)
112
+ helpMenu = TkMenu.new(root)
113
+ #_______________FILE MENU_______________
114
+ file_menu.add('command',
115
+ 'label' => "New...",
116
+ 'command' => newfile,
117
+ 'underline' => 0)
118
+ file_menu.add('command',
119
+ 'label' => "OpenDir",
120
+ 'command' => opendir,
121
+ 'underline' => 0)
122
+ file_menu.add('command',
123
+ 'label' => "Exit",
124
+ 'command' => exitapp,
125
+ 'underline' => 3)
126
+ #______________HELP MENU _________________________________
127
+ helpMenu.add('command',
128
+ 'label' => "Help",
129
+ 'command' => proc{help_win},
130
+ 'underline' => 3)
131
+
132
+ #_________________________________________
133
+ menu_bar.add('cascade',
134
+ 'menu' => file_menu,
135
+ 'label' => "Dir")
136
+ menu_bar.add('cascade',
137
+ 'menu' => helpMenu,
138
+ 'label' => "Help")
139
+
140
+ end
141
+ #____________________________________________________________
142
+ #The final and essential step, to run the mainloop for GUI to display
143
+ def self.show
144
+ Tk.mainloop
145
+ end
146
+
147
+ #________________ END OF CLASS _____________________
148
+
149
+ end
data/lib/guide.rb ADDED
@@ -0,0 +1,26 @@
1
+ #here document to use in Help Window accessed through the menu
2
+ class Guide
3
+ #__________________________________________________________
4
+ def self.view
5
+ return $guide
6
+ end
7
+ #__________________________________________________________
8
+ $guide = %q{
9
+ Filejoiner is a simple app using GUI to join a number of text files in a single file.
10
+
11
+ USAGE:
12
+ 1. Install the Filejoiner : gem install filejoiner
13
+ 2. create a text file containing:
14
+ require 'filejoiner'
15
+ Joiner.run
16
+ save it as "joiner.rb" on your desktop
17
+ if Ruby is in your PATH clicking on this file will start the app.
18
+ 3. Select from the Menu the directory where the separate files reside.
19
+ Once you select the folder, its file contents are shown in the text window.
20
+ 4. Enter the name of the new merged file in the entry field.
21
+ 5. To join these files, click the button "Join Files"
22
+ 6. The content of the merged file will appear in the text window.
23
+ 7. To clear the text area select "New" from the Dir Menu
24
+ }
25
+ #________________________________________________________
26
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filejoiner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sabry Fattah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Filejoiner is a simple app (using Tcl/Tk GUI) to join a number of text
14
+ files into a single file.
15
+ email: sabryabdelfattah@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - README.md
20
+ files:
21
+ - README.md
22
+ - filejoiner.gemspec
23
+ - lib/data.rb
24
+ - lib/filejoiner.rb
25
+ - lib/gui.rb
26
+ - lib/guide.rb
27
+ homepage: http://sabryfattah.com
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options:
33
+ - --main
34
+ - README.md
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.4.5
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: tk-based Gui App. to join a number of text files into one
53
+ test_files: []