mrdialog 1.0.6 → 1.0.7

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.
data/samples/checklist.rb CHANGED
@@ -32,25 +32,25 @@ EOF
32
32
  checklist_data = Struct.new(:tag, :item, :select)
33
33
 
34
34
  data = checklist_data.new
35
- data.tag = "Apple"
35
+ data.tag = "Apple One"
36
36
  data.item = "It's an applie"
37
37
  data.select = false
38
38
  items.push(data.to_a)
39
39
 
40
40
  data = checklist_data.new
41
- data.tag = "Dog"
41
+ data.tag = "Dog Two"
42
42
  data.item = "No it's not my dog"
43
43
  data.select = true
44
44
  items.push(data.to_a)
45
45
 
46
46
  data = checklist_data.new
47
- data.tag = "Orange"
47
+ data.tag = "Orange Three"
48
48
  data.item = "Yeah! it is juicy"
49
49
  data.select = false
50
50
  items.push(data.to_a)
51
51
 
52
52
  data = checklist_data.new
53
- data.tag = "Chicken"
53
+ data.tag = "Chicken Four"
54
54
  data.item = "Normally not a pet"
55
55
  data.select = true
56
56
  items.push(data.to_a)
@@ -60,6 +60,7 @@ EOF
60
60
  # dialog.dialog_options = "--no-tags"
61
61
  dialog.clear = true
62
62
  dialog.title = "CHECKLIST"
63
+ dialog.dialog_options = "--separator '|' --single-quoted"
63
64
  dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
64
65
 
65
66
  selected_items = dialog.checklist(text, items)
@@ -67,8 +68,18 @@ EOF
67
68
  puts selected_items.class
68
69
  puts "Exit code: #{exit_code}"
69
70
  if selected_items
70
- puts "Selected Items:"
71
- selected_items.each do |item|
71
+ # selected_items is an array with 1 element the array looks something
72
+ # like '|'Dog Two'|'Chicken Four''
73
+ # convert the output to an array with selected items
74
+ x = selected_items.join() # a string
75
+ a = []
76
+ aa = x.split('|')
77
+ aa.each do |e|
78
+ e = e.gsub(/\'/,'')
79
+ next if e.length == 0
80
+ a << e
81
+ end
82
+ a.each do |item|
72
83
  puts " '#{item}'"
73
84
  end
74
85
  end
data/samples/form3.rb CHANGED
@@ -1,26 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  ########################################################################
4
- # Culculate the max length of key as the x for the item
3
+ # Calculate the max length of key as the x for the item
5
4
  ########################################################################
6
5
  require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
7
6
  require 'pp'
8
7
 
9
8
  class TestForm
10
- ME = File.basename($0)
11
- HIDDEN = 1
12
- READ_ONLY = 2
13
- if ENV['CHANGE_TITLE']
14
- if ME =~ /(.+)\.rb$/
15
- base = $1
16
- puts "\033]0;mrdialog - #{base}\007"
17
- end
9
+ ME = File.basename($0)
10
+ HIDDEN = 1
11
+ READ_ONLY = 2
12
+
13
+ if ENV['CHANGE_TITLE']
14
+ if ME =~ /(.+)\.rb$/
15
+ base = $1
16
+ puts "\033]0;mrdialog - #{base}\007"
18
17
  end
18
+ end
19
+
19
20
  def initialize
20
21
  @a = []
21
22
  @h = {}
22
23
  end
23
-
24
+
24
25
  def populate_data
25
26
  @a << "Base DN: "
26
27
  @a << "LDAP URI: "
@@ -28,7 +29,6 @@ class TestForm
28
29
  @a << "LDAP Bind DN: "
29
30
  @a << "LDAP Bind Password: "
30
31
  @a << "Login Attribute: "
31
-
32
32
  @h[@a[0]] = "dc=example,dc=com"
33
33
  @h[@a[1]] = "ldap://192.168.1.1:389"
34
34
  @h[@a[2]] = "3"
@@ -36,7 +36,7 @@ class TestForm
36
36
  @h[@a[4]] = "secret"
37
37
  @h[@a[5]] = "sAMAccountName"
38
38
  end
39
-
39
+
40
40
  def max_key_len
41
41
  len = 0
42
42
  @a.each do |v|
@@ -46,16 +46,16 @@ class TestForm
46
46
  end
47
47
  return len
48
48
  end
49
-
49
+
50
50
  def show_form
51
51
  items = []
52
52
  form_data = Struct.new(:label, :ly, :lx, :item, :iy, :ix, :flen, :ilen, :attr)
53
-
54
53
  ly = 1
55
54
  lx = 1
56
55
  iy = 1
57
- ix = max_key_len
58
- flen = 1024
56
+ ix = max_key_len + 2 # Add some padding
57
+ flen = 40 # More reasonable field length
58
+
59
59
  @a.each do |key|
60
60
  data = form_data.new
61
61
  data.label = key
@@ -74,29 +74,78 @@ class TestForm
74
74
  items.push(data.to_a)
75
75
  ly = ly + 1
76
76
  end
77
-
77
+
78
78
  dialog = MRDialog.new
79
79
  dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
80
80
  dialog.clear = true
81
81
  dialog.insecure = true
82
82
  dialog.title = "MIXEDFORM"
83
-
83
+
84
84
  text = <<EOF
85
85
  In this example of mixedform, the x co-ordinate of the items
86
86
  are calculated dynamically. The longest value among the keys
87
87
  is the x value for the items.
88
+
89
+ Try entering special characters in the password field:
90
+ Examples: p@ss'word, test"123, my$pass`word, etc.
88
91
  EOF
92
+
89
93
  height = 20
90
94
  width = 70
91
95
  result_hash = dialog.mixedform(text, items, height, width, 0)
96
+
97
+ # Return the result_hash so doit can use it
98
+ return result_hash
92
99
  end
93
-
100
+
94
101
  def doit
95
102
  populate_data
96
- show_form
103
+ result_hash = show_form
104
+
105
+ # Display the results
106
+ if result_hash
107
+ puts "\nForm Results:"
108
+ puts "=" * 50
109
+ result_hash.each do |key, value|
110
+ puts "#{key} => #{value}"
111
+ end
112
+
113
+ # Check if password contains special characters
114
+ password_key = @a.find { |k| k =~ /password/i }
115
+ if password_key && result_hash[password_key]
116
+ password = result_hash[password_key]
117
+ puts "\n" + "=" * 50
118
+ puts "Password Analysis (for testing only!):"
119
+ puts "Password entered: '#{password}'"
120
+ puts "Length: #{password.length}"
121
+
122
+ special_chars = password.scan(/[^a-zA-Z0-9]/)
123
+ if special_chars.any?
124
+ puts "Special characters found: #{special_chars.uniq.join(', ')}"
125
+ else
126
+ puts "No special characters found"
127
+ end
128
+
129
+ # Test for problematic characters
130
+ if password.include?("'")
131
+ puts "✓ Contains apostrophe - testing quote handling"
132
+ end
133
+ if password.include?('"')
134
+ puts "✓ Contains double quote - testing quote handling"
135
+ end
136
+ if password.include?('$')
137
+ puts "✓ Contains dollar sign - testing variable expansion prevention"
138
+ end
139
+ if password.include?('`')
140
+ puts "✓ Contains backtick - testing command substitution prevention"
141
+ end
142
+ end
143
+ else
144
+ puts "\nForm was cancelled"
145
+ end
97
146
  end
98
147
  end
99
148
 
100
149
  if __FILE__ == $0
101
- TestForm.new.doit
102
- end
150
+ TestForm.new.doit
151
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
4
+ require 'tempfile'
5
+ require 'pp'
6
+
7
+ # By Claude AI Opus 4
8
+ # Oct-18-2025
9
+
10
+ dialog = MRDialog.new
11
+ dialog.clear = true
12
+ dialog.title = "Textbox Examples"
13
+
14
+ # Create test files with various filenames
15
+ test_files = []
16
+
17
+ # File with spaces in name
18
+ file1 = Tempfile.new(['test file with spaces', '.txt'])
19
+ file1.write("This is a test file with spaces in its filename.\n")
20
+ file1.write("It should display correctly in the textbox.\n")
21
+ file1.close
22
+ test_files << file1
23
+
24
+ # File with apostrophe in name
25
+ file2 = Tempfile.new(["test's file", '.txt'])
26
+ file2.write("This file has an apostrophe in its name.\n")
27
+ file2.write("Testing special characters in filenames.\n")
28
+ file2.close
29
+ test_files << file2
30
+
31
+ # File with various special characters
32
+ file3 = Tempfile.new(['test$file (special)', '.txt'])
33
+ file3.write("This file has $ and parentheses in its name.\n")
34
+ file3.write("All special characters should work fine.\n")
35
+ file3.close
36
+ test_files << file3
37
+
38
+ begin
39
+ # Example 1: Regular textbox
40
+ dialog.msgbox("Let's view some files with special characters in their names", 6, 50)
41
+
42
+ test_files.each_with_index do |file, index|
43
+ dialog.title = "Textbox Example #{index + 1}"
44
+ result = dialog.textbox(file.path, "text", 15, 60)
45
+
46
+ if dialog.exit_code == 0
47
+ dialog.msgbox("File displayed successfully!", 5, 40)
48
+ end
49
+ end
50
+
51
+ # Example 2: Tailbox mode
52
+ dialog.title = "Tailbox Example"
53
+ log_file = Tempfile.new(['app-log', '.log'])
54
+ log_file.write("Initial log entry\n")
55
+ log_file.close
56
+
57
+ # Show tailbox (you'd normally append to the file from another process)
58
+ dialog.msgbox("Now showing tailbox mode (press OK to continue)", 5, 50)
59
+ dialog.textbox(log_file.path, "tail", 15, 60)
60
+
61
+ ensure
62
+ # Clean up
63
+ test_files.each(&:unlink)
64
+ log_file.unlink if log_file
65
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrdialog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleks Clark
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-16 00:00:00.000000000 Z
12
+ date: 2025-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -31,42 +31,42 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '3.12'
34
+ version: 6.1.2.1
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '3.12'
41
+ version: 6.1.2.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.0'
48
+ version: 2.1.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.0'
55
+ version: 2.1.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: juwelier
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 2.1.0
62
+ version: 2.4.9
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 2.1.0
69
+ version: 2.4.9
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simplecov
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,15 @@ files:
112
112
  - ChangeLog.md
113
113
  - Gemfile
114
114
  - LICENSE.txt
115
+ - Makefile
116
+ - Notes.txt
115
117
  - README.md
116
118
  - Rakefile
117
119
  - VERSION
120
+ - docs/ChangeLog.md
121
+ - docs/README.md
118
122
  - lib/mrdialog.rb
119
123
  - lib/mrdialog/mrdialog.rb
120
- - mrdialog.gemspec
121
- - pkg/md5.txt
122
- - pkg/mrdialog-1.0.5.gem
123
124
  - samples/buildlist.rb
124
125
  - samples/calendar.rb
125
126
  - samples/checklist.rb
@@ -155,6 +156,7 @@ files:
155
156
  - samples/radiolist.rb
156
157
  - samples/run_all.rb
157
158
  - samples/shortlist
159
+ - samples/textbox.rb
158
160
  - samples/timebox.rb
159
161
  - samples/treeview.rb
160
162
  - samples/treeview2.rb
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
211
  - !ruby/object:Gem::Version
210
212
  version: '0'
211
213
  requirements: []
212
- rubygems_version: 3.2.3
214
+ rubygems_version: 3.4.10
213
215
  signing_key:
214
216
  specification_version: 4
215
217
  summary: A ruby gem for ncurses dialog program, based on the gem rdialog
data/mrdialog.gemspec DELETED
@@ -1,124 +0,0 @@
1
- # Generated by juwelier
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: mrdialog 1.0.4 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "mrdialog"
9
- s.version = "1.0.4"
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 = ["Aleks Clark", "Muhammad Muquit"]
14
- s.date = "2018-04-12"
15
- s.description = "A ruby gem for ncurses dialog program.\n This gem is based on rdialog (http://rdialog.rubyforge.org/) by\n Aleks Clark. I added support for missing widgets, fixed \n bugs and wrote the sample apps. I am \n also renaming the class to MRDialog to avoid conflicts.\n Please look at ChangeLog.md for details. "
16
- s.email = "muquit@gmail.com"
17
- s.extra_rdoc_files = [
18
- "ChangeLog.md",
19
- "LICENSE.txt",
20
- "README.md"
21
- ]
22
- s.files = [
23
- ".document",
24
- "ChangeLog.md",
25
- "Gemfile",
26
- "Gemfile.lock",
27
- "LICENSE.txt",
28
- "README.md",
29
- "Rakefile",
30
- "VERSION",
31
- "lib/mrdialog.rb",
32
- "lib/mrdialog/mrdialog.rb",
33
- "pkg/md5.txt",
34
- "pkg/mrdialog-1.0.4.gem",
35
- "samples/buildlist.rb",
36
- "samples/calendar.rb",
37
- "samples/checklist.rb",
38
- "samples/editbox.rb",
39
- "samples/form1.rb",
40
- "samples/form2.rb",
41
- "samples/form3.rb",
42
- "samples/fselect.rb",
43
- "samples/gauge.rb",
44
- "samples/infobox.rb",
45
- "samples/inputbox.rb",
46
- "samples/menubox.rb",
47
- "samples/mixedform1.rb",
48
- "samples/msgbox.rb",
49
- "samples/password.rb",
50
- "samples/password2.rb",
51
- "samples/passwordform.rb",
52
- "samples/pause.rb",
53
- "samples/prgbox.rb",
54
- "samples/program.rb",
55
- "samples/progress.rb",
56
- "samples/radiolist.rb",
57
- "samples/run_all.rb",
58
- "samples/shortlist",
59
- "samples/timebox.rb",
60
- "samples/treeview.rb",
61
- "samples/treeview2.rb",
62
- "samples/yesno.rb",
63
- "screenshots/README.txt",
64
- "screenshots/all.gif",
65
- "screenshots/buildlist.png",
66
- "screenshots/calendar.png",
67
- "screenshots/checklist.png",
68
- "screenshots/editbox.png",
69
- "screenshots/form1.png",
70
- "screenshots/form2.png",
71
- "screenshots/form3.png",
72
- "screenshots/fselect.png",
73
- "screenshots/gauge.png",
74
- "screenshots/infobox.png",
75
- "screenshots/inputbox.png",
76
- "screenshots/menubox.png",
77
- "screenshots/mixedform1.png",
78
- "screenshots/msgbox.png",
79
- "screenshots/password.png",
80
- "screenshots/password2.png",
81
- "screenshots/passwordform.png",
82
- "screenshots/pause.png",
83
- "screenshots/prgbox.png",
84
- "screenshots/program.png",
85
- "screenshots/progress.png",
86
- "screenshots/radiolist.png",
87
- "screenshots/take_shots.rb",
88
- "screenshots/timebox.png",
89
- "screenshots/treeview.png",
90
- "screenshots/treeview2.png",
91
- "screenshots/yesno.png",
92
- "test/helper.rb",
93
- "test/test_mrdialog.rb"
94
- ]
95
- s.homepage = "http://github.com/muquit/mrdialog"
96
- s.licenses = ["MIT"]
97
- s.rubygems_version = "2.5.2.1"
98
- s.summary = "A ruby gem for ncurses dialog program, based on the gem rdialog"
99
-
100
- if s.respond_to? :specification_version then
101
- s.specification_version = 4
102
-
103
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
104
- s.add_development_dependency(%q<shoulda>, [">= 0"])
105
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
106
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
107
- s.add_development_dependency(%q<juwelier>, ["~> 2.0.1"])
108
- s.add_development_dependency(%q<simplecov>, [">= 0"])
109
- else
110
- s.add_dependency(%q<shoulda>, [">= 0"])
111
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
112
- s.add_dependency(%q<bundler>, ["~> 1.0"])
113
- s.add_dependency(%q<juwelier>, ["~> 2.0.1"])
114
- s.add_dependency(%q<simplecov>, [">= 0"])
115
- end
116
- else
117
- s.add_dependency(%q<shoulda>, [">= 0"])
118
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
119
- s.add_dependency(%q<bundler>, ["~> 1.0"])
120
- s.add_dependency(%q<juwelier>, ["~> 2.0.1"])
121
- s.add_dependency(%q<simplecov>, [">= 0"])
122
- end
123
- end
124
-
data/pkg/md5.txt DELETED
@@ -1 +0,0 @@
1
- 376e4b7f9cd6bc76a4444c4979a87bda mrdialog-1.0.5.gem
Binary file