mrdialog 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +42 -22
  3. data/LICENSE.txt +1 -1
  4. data/README.md +181 -0
  5. data/VERSION +1 -1
  6. data/lib/mrdialog/mrdialog.rb +18 -1
  7. data/pkg/mrdialog-1.0.1.gem +0 -0
  8. data/samples/buildlist.rb +9 -1
  9. data/samples/calendar.rb +7 -0
  10. data/samples/checklist.rb +17 -4
  11. data/samples/editbox.rb +7 -0
  12. data/samples/form1.rb +8 -2
  13. data/samples/form2.rb +7 -0
  14. data/samples/form3.rb +7 -1
  15. data/samples/fselect.rb +7 -0
  16. data/samples/gauge.rb +7 -0
  17. data/samples/infobox.rb +7 -0
  18. data/samples/inputbox.rb +7 -0
  19. data/samples/menubox.rb +7 -0
  20. data/samples/mixedform1.rb +7 -2
  21. data/samples/msgbox.rb +7 -0
  22. data/samples/password.rb +7 -0
  23. data/samples/password2.rb +7 -0
  24. data/samples/passwordform.rb +8 -2
  25. data/samples/pause.rb +7 -0
  26. data/samples/prgbox.rb +7 -0
  27. data/samples/program.rb +7 -0
  28. data/samples/progress.rb +7 -0
  29. data/samples/radiolist.rb +8 -0
  30. data/samples/run_all.rb +52 -0
  31. data/samples/timebox.rb +7 -0
  32. data/samples/treeview.rb +7 -0
  33. data/samples/treeview2.rb +7 -0
  34. data/samples/yesno.rb +7 -0
  35. data/screenshots/README.txt +10 -0
  36. data/screenshots/all.gif +0 -0
  37. data/screenshots/buildlist.png +0 -0
  38. data/screenshots/calendar.png +0 -0
  39. data/screenshots/checklist.png +0 -0
  40. data/screenshots/editbox.png +0 -0
  41. data/screenshots/form1.png +0 -0
  42. data/screenshots/form2.png +0 -0
  43. data/screenshots/form3.png +0 -0
  44. data/screenshots/fselect.png +0 -0
  45. data/screenshots/gauge.png +0 -0
  46. data/screenshots/infobox.png +0 -0
  47. data/screenshots/inputbox.png +0 -0
  48. data/screenshots/menubox.png +0 -0
  49. data/screenshots/mixedform1.png +0 -0
  50. data/screenshots/msgbox.png +0 -0
  51. data/screenshots/password.png +0 -0
  52. data/screenshots/password2.png +0 -0
  53. data/screenshots/passwordform.png +0 -0
  54. data/screenshots/pause.png +0 -0
  55. data/screenshots/prgbox.png +0 -0
  56. data/screenshots/program.png +0 -0
  57. data/screenshots/progress.png +0 -0
  58. data/screenshots/radiolist.png +0 -0
  59. data/screenshots/take_shots.rb +111 -0
  60. data/screenshots/timebox.png +0 -0
  61. data/screenshots/treeview.png +0 -0
  62. data/screenshots/treeview2.png +0 -0
  63. data/screenshots/yesno.png +0 -0
  64. metadata +48 -18
  65. data/README.rdoc +0 -52
data/samples/pause.rb CHANGED
@@ -6,6 +6,13 @@ require 'pp'
6
6
 
7
7
  class PauseBox
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  def initialize
10
17
  end
11
18
 
data/samples/prgbox.rb CHANGED
@@ -6,7 +6,14 @@ require 'pp'
6
6
 
7
7
  class TestPrgBox1
8
8
  ME = File.basename($0)
9
+
9
10
  def initialize
11
+ if ENV['CHANGE_TITLE']
12
+ if ME =~ /(.+)\.rb$/
13
+ base = $1
14
+ puts "\033]0;mrdialog - #{base}\007"
15
+ end
16
+ end
10
17
  end
11
18
 
12
19
  def doit
data/samples/program.rb CHANGED
@@ -6,6 +6,13 @@
6
6
  require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
7
7
  begin
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  text = "Hi, this is a gauge widget"
10
17
 
11
18
  height = 20
data/samples/progress.rb CHANGED
@@ -6,6 +6,13 @@
6
6
  require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
7
7
  begin
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  text = "Hi, this is a gauge widget"
10
17
 
11
18
  height = 20
data/samples/radiolist.rb CHANGED
@@ -6,7 +6,14 @@ require 'pp'
6
6
 
7
7
  class TestRadiolist
8
8
  ME = File.basename($0)
9
+
9
10
  def initialize
11
+ if ENV['CHANGE_TITLE']
12
+ if ME =~ /(.+)\.rb$/
13
+ base = $1
14
+ puts "\033]0;mrdialog - #{base}\007"
15
+ end
16
+ end
10
17
  end
11
18
 
12
19
  def doit
@@ -50,6 +57,7 @@ EOF
50
57
  data.select = false
51
58
  items.push(data.to_a)
52
59
 
60
+ dialog.title = "RADIOLIST"
53
61
  selected_item = dialog.radiolist(text, items)
54
62
  exit_code = dialog.exit_code
55
63
  case exit_code
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # run all the sample apps
4
+ # muquit@muquit.com Apr-26-2014
5
+
6
+ require 'logger'
7
+
8
+ class RunSampleApps
9
+ ME = File.basename($0)
10
+
11
+ def initialize
12
+ @logger = Logger.new(STDERR)
13
+ @sleep_secs = 5
14
+ end
15
+
16
+ def log(msg)
17
+ @logger.info "#{msg}"
18
+ end
19
+
20
+ trap('INT') {
21
+ puts "Interrupt caught.. exiting"
22
+ exit 1
23
+ }
24
+
25
+ def check_args
26
+ if ARGV.length != 1
27
+ puts <<EOF
28
+ Usage: #{ME} <sleep in secs>
29
+ Specify the number of seconds to sleep between apps
30
+ Example: #{ME} 5
31
+ EOF
32
+ exit 1
33
+ end
34
+ @sleep_secs = 5
35
+ end
36
+
37
+ def doit
38
+ # check_args
39
+ pwd = Dir.pwd
40
+ entries = Dir.entries(pwd)
41
+ entries.each do |prog|
42
+ next if prog == '.' || prog == '..' || prog =~ /run_all.rb/
43
+ cmd = ""
44
+ cmd << "ruby ./#{prog}"
45
+ system(cmd)
46
+ end
47
+ end
48
+ end
49
+
50
+ if __FILE__ == $0
51
+ RunSampleApps.new.doit
52
+ end
data/samples/timebox.rb CHANGED
@@ -6,6 +6,13 @@ require 'pp'
6
6
 
7
7
  begin
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  text = <<EOF
10
17
  Please set the time...
11
18
  EOF
data/samples/treeview.rb CHANGED
@@ -6,6 +6,13 @@ require 'pp'
6
6
 
7
7
  begin
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  text = <<-EOF
10
17
  This example is taken from dialog/samples/treeview1
11
18
  shell script.
data/samples/treeview2.rb CHANGED
@@ -6,6 +6,13 @@ require 'pp'
6
6
 
7
7
  begin
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  text = <<-EOF
10
17
  This example is taken from dialog/samples/treeview2
11
18
  shell script.
data/samples/yesno.rb CHANGED
@@ -6,6 +6,13 @@ require 'pp'
6
6
 
7
7
  class TestYesNo
8
8
  ME = File.basename($0)
9
+ if ENV['CHANGE_TITLE']
10
+ if ME =~ /(.+)\.rb$/
11
+ base = $1
12
+ puts "\033]0;mrdialog - #{base}\007"
13
+ end
14
+ end
15
+
9
16
  def initialize
10
17
  end
11
18
 
@@ -0,0 +1,10 @@
1
+ The screenshots of the sample apps are taken on a Mac automatically by the
2
+ script take_shots.rb.
3
+
4
+ All the widgets can be viewed by looking at the animated GIF file 'all.gif',
5
+ created by running the 'convert' program from ImageMagick.
6
+
7
+ $ convert -delay 170 -loop 1 *.png all.gif
8
+
9
+ --
10
+ muquit@muquit.com Apr-26-2014
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,111 @@
1
+ #!/usr/local/bin/macruby
2
+
3
+ ########################################################################
4
+ # This script runs on mac....
5
+ #
6
+ # A tiny ruby script for myself to take screenshots of the sample apps
7
+ # terminal window automatically. I run run_all.rb script from the samples
8
+ # directory and then run this script. This script find out the window by
9
+ # the title and take a screenthot and kill the dialog for the next app.
10
+ #
11
+ # muquit@muquit.com Apr-26-2014
12
+ ########################################################################
13
+
14
+ framework 'Foundation'
15
+ framework 'ScriptingBridge'
16
+
17
+ class TakeScreenShots
18
+ def initialze
19
+ $stderr.sync = true
20
+ $stdout.sync = true
21
+ @app_name = ''
22
+ @window_id = ''
23
+ end
24
+
25
+ def log(msg)
26
+ d = Time.new
27
+ puts "[#{d}]: #{msg}"
28
+ end
29
+
30
+ #-------------------------------------------------
31
+ # check if any mrdialog app is running, if so
32
+ # populate @window_id and @app_name. They will be
33
+ # used to capture the window.
34
+ #-------------------------------------------------
35
+ def find_app
36
+ terminal = SBApplication.applicationWithBundleIdentifier("com.apple.Terminal")
37
+ terminal.windows.each do |window|
38
+ title = window.name
39
+ id = window.id
40
+ encoding_options =
41
+ {
42
+ :invalid => :replace,
43
+ :undef => :replace,
44
+ :replace => '',
45
+ :universal_newline => true
46
+ }
47
+ title = title.encode(Encoding.find('ASCII'),encoding_options)
48
+ if title =~ /samples\s+mrdialog - (.+)\s+dialog.*$/i
49
+ @app_name = $1
50
+ @app_name = @app_name.gsub(/\s/,'')
51
+ @window_id = id
52
+ return true
53
+ break
54
+ end
55
+ end
56
+ return false
57
+ end
58
+
59
+ def doit
60
+ loop do
61
+ rc = false
62
+ @window_id = ''
63
+ @app_name = ''
64
+ log "\n***Checking if any mrdialog app is runing..."
65
+ mx = 10
66
+ 0.upto(mx) do |t|
67
+ @window_id = ''
68
+ @app_name = ''
69
+ log " Try: #{t}/#{mx}"
70
+ rc = find_app
71
+ break if rc
72
+ sleep 2
73
+ end
74
+ if !rc
75
+ log "Error: Could not find any mrdiag sample app..."
76
+ exit 1
77
+ end
78
+ log "Found app: #{@app_name}"
79
+ log "Window id: #{@window_id}"
80
+ c = 0
81
+ pid = ''
82
+ # kill the program after taking the screenshot
83
+ log "Trying to find the PID of dialog.."
84
+ loop do
85
+ c = c + 1
86
+ pid=`pidof dialog`
87
+ if pid.length == 0
88
+ print "c: #{c}"
89
+ exit if c >= 5
90
+ print "#"
91
+ sleep 2
92
+ end
93
+ break if pid.length > 0
94
+ end #end loop
95
+ log "Found PID: #{pid}"
96
+ next if pid.length == 0
97
+ log "Taking screenshot of widget: #{@app_name}"
98
+ cmd = "screencapture -o -l #{@window_id} #{@app_name}.png"
99
+ log "Command: #{cmd}"
100
+ system(cmd)
101
+ log "Kill dialog with PID: #{pid}"
102
+ system("kill #{pid}")
103
+ log "Sleeping 5 secs"
104
+ sleep 3
105
+ end
106
+ end
107
+ end
108
+
109
+ if __FILE__ == $0
110
+ TakeScreenShots.new.doit
111
+ end
Binary file
Binary file
Binary file
Binary file
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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleks Clark
@@ -9,76 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-20 00:00:00.000000000 Z
12
+ date: 2016-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rdoc
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3.12'
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
41
  version: '3.12'
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
48
  version: '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
55
  version: '1.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: jeweler
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: 2.0.1
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
69
  version: 2.0.1
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simplecov
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  description: "A ruby gem for ncurses dialog program.\n This gem is based on rdialog
@@ -92,14 +92,14 @@ extensions: []
92
92
  extra_rdoc_files:
93
93
  - ChangeLog.md
94
94
  - LICENSE.txt
95
- - README.rdoc
95
+ - README.md
96
96
  files:
97
- - .document
97
+ - ".document"
98
98
  - ChangeLog.md
99
99
  - Gemfile
100
100
  - Gemfile.lock
101
101
  - LICENSE.txt
102
- - README.rdoc
102
+ - README.md
103
103
  - Rakefile
104
104
  - VERSION
105
105
  - lib/mrdialog.rb
@@ -127,11 +127,41 @@ files:
127
127
  - samples/program.rb
128
128
  - samples/progress.rb
129
129
  - samples/radiolist.rb
130
+ - samples/run_all.rb
130
131
  - samples/shortlist
131
132
  - samples/timebox.rb
132
133
  - samples/treeview.rb
133
134
  - samples/treeview2.rb
134
135
  - samples/yesno.rb
136
+ - screenshots/README.txt
137
+ - screenshots/all.gif
138
+ - screenshots/buildlist.png
139
+ - screenshots/calendar.png
140
+ - screenshots/checklist.png
141
+ - screenshots/editbox.png
142
+ - screenshots/form1.png
143
+ - screenshots/form2.png
144
+ - screenshots/form3.png
145
+ - screenshots/fselect.png
146
+ - screenshots/gauge.png
147
+ - screenshots/infobox.png
148
+ - screenshots/inputbox.png
149
+ - screenshots/menubox.png
150
+ - screenshots/mixedform1.png
151
+ - screenshots/msgbox.png
152
+ - screenshots/password.png
153
+ - screenshots/password2.png
154
+ - screenshots/passwordform.png
155
+ - screenshots/pause.png
156
+ - screenshots/prgbox.png
157
+ - screenshots/program.png
158
+ - screenshots/progress.png
159
+ - screenshots/radiolist.png
160
+ - screenshots/take_shots.rb
161
+ - screenshots/timebox.png
162
+ - screenshots/treeview.png
163
+ - screenshots/treeview2.png
164
+ - screenshots/yesno.png
135
165
  - test/helper.rb
136
166
  - test/test_mrdialog.rb
137
167
  homepage: http://github.com/muquit/mrdialog
@@ -144,17 +174,17 @@ require_paths:
144
174
  - lib
145
175
  required_ruby_version: !ruby/object:Gem::Requirement
146
176
  requirements:
147
- - - '>='
177
+ - - ">="
148
178
  - !ruby/object:Gem::Version
149
179
  version: '0'
150
180
  required_rubygems_version: !ruby/object:Gem::Requirement
151
181
  requirements:
152
- - - '>='
182
+ - - ">="
153
183
  - !ruby/object:Gem::Version
154
184
  version: '0'
155
185
  requirements: []
156
186
  rubyforge_project:
157
- rubygems_version: 2.0.3
187
+ rubygems_version: 2.2.2
158
188
  signing_key:
159
189
  specification_version: 4
160
190
  summary: A ruby gem for ncurses dialog program, based on the gem rdialog
data/README.rdoc DELETED
@@ -1,52 +0,0 @@
1
- = MRDialog
2
-
3
- mrdialog is a pure ruby library for the ncurses dialog program. dialog is
4
- a command line tool that can present questions, messages, forms using
5
- dialog boxes from a shell script. However, it is painful to program dialog
6
- from shell scripts due to lack of data structure etc. You constactly have
7
- to watch if the correct number of items are specified, if the arguments
8
- are in correct order for example.
9
-
10
- MRDialog is based on the rdialog ruby gem (http://rdialog.rubyforge.org/) by
11
- Aleks Clark.
12
-
13
- The original license is MIT and my code is also free to use under the
14
- terms of the MIT license. Please look at the LICENSE.txt file for
15
- details.
16
-
17
- I added support for all of the missing widgets, fixed bugs, implemented
18
- the examples for all the widgets. Please look at the ChangeLog.md file
19
- for details.
20
-
21
- Please look at the examples in the "samples" directory to see how the API works.
22
-
23
- TODO: write the API document here
24
-
25
- === Requirements
26
-
27
- * dialog must be installed. dialog home is:
28
- http://invisible-island.net/dialog/dialog.html
29
-
30
- === To build
31
-
32
- $ rake build
33
-
34
- Will create the gem inside the pkg directory
35
-
36
- === To install the built gem
37
-
38
- $ sudo gem install --local pkg/mrdialog-1.0.1.gem
39
-
40
- === To install using rake
41
-
42
- $ sudo rake install
43
-
44
- === To install the gem to a specific directory:
45
-
46
- $ GEM_HOME=/tmp gem install --local pkg/mrdialog-1.0.1.gem
47
-
48
- The gem will be installed in /tmp/gems directory
49
-
50
- --
51
- Muhammad Muquit, muquit@muquit.com
52
- Apr-05-2014 - first cut