mrdialog 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # muquit@muquit.com Apr-20-2014
4
+ require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
5
+ require 'pp'
6
+
7
+ begin
8
+ ME = File.basename($0)
9
+ text = <<-EOF
10
+ This example is taken from dialog/samples/treeview1
11
+ shell script.
12
+
13
+ EOF
14
+ items = []
15
+ Struct.new("TreeviewData", :tag, :item, :status, :depth)
16
+ data = Struct::TreeviewData.new
17
+
18
+ data.tag = "tag1"
19
+ data.item = "Item number 1"
20
+ data.status = false
21
+ data.depth = 0
22
+ items.push(data.to_a)
23
+
24
+ data = Struct::TreeviewData.new
25
+ data.tag = "tag2"
26
+ data.item = "Item number 2"
27
+ data.status = false
28
+ data.depth = 1
29
+ items.push(data.to_a)
30
+
31
+ data = Struct::TreeviewData.new
32
+ data.tag = "tag3"
33
+ data.item = "Item number 3"
34
+ data.status = true
35
+ data.depth = 2
36
+ items.push(data.to_a)
37
+
38
+ data = Struct::TreeviewData.new
39
+ data.tag = "tag4"
40
+ data.item = "Item number 4"
41
+ data.status = false
42
+ data.depth = 1
43
+ items.push(data.to_a)
44
+
45
+ data = Struct::TreeviewData.new
46
+ data.tag = "tag5"
47
+ data.item = "Item number 5"
48
+ data.status = false
49
+ data.depth = 2
50
+ items.push(data.to_a)
51
+
52
+ data = Struct::TreeviewData.new
53
+ data.tag = "tag6"
54
+ data.item = "Item number 6"
55
+ data.status = false
56
+ data.depth = 3
57
+ items.push(data.to_a)
58
+
59
+ data = Struct::TreeviewData.new
60
+ data.tag = "tag7"
61
+ data.item = "Item number 7"
62
+ data.status = false
63
+ data.depth = 3
64
+ items.push(data.to_a)
65
+
66
+ data = Struct::TreeviewData.new
67
+ data.tag = "tag8"
68
+ data.item = "Item number 8"
69
+ data.status = false
70
+ data.depth = 4
71
+ items.push(data.to_a)
72
+
73
+ data = Struct::TreeviewData.new
74
+ data.tag = "tag9"
75
+ data.item = "Item number 9"
76
+ data.status = false
77
+ data.depth = 1
78
+ items.push(data.to_a)
79
+
80
+ dialog = MRDialog.new
81
+ dialog.clear = true
82
+ dialog.title = "TREEVIEW"
83
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
84
+
85
+ height = 0
86
+ width = 0
87
+ listheight = 0
88
+
89
+ selected_tag = dialog.treeview(text, items, height, width, listheight)
90
+ exit_code = dialog.exit_code
91
+ puts "Exit code: #{exit_code}"
92
+ if exit_code == 0
93
+ puts "Selecetd tag: #{selected_tag}"
94
+ end
95
+
96
+ rescue => e
97
+ puts "#{$!}"
98
+ t = e.backtrace.join("\n\t")
99
+ puts "Error: #{t}"
100
+ end
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # muquit@muquit.com Apr-20-2014
4
+ require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
5
+ require 'pp'
6
+
7
+ begin
8
+ ME = File.basename($0)
9
+ text = <<-EOF
10
+ This example is taken from dialog/samples/treeview2
11
+ shell script.
12
+
13
+ EOF
14
+ items = []
15
+ item_list = ''
16
+ input = []
17
+ input << "tag1:one:off:0"
18
+ input << "tag2:two:off:1"
19
+ input << "tag3:three:on:2"
20
+ input << "tag4:four:off:1"
21
+ input << "tag5:five:off:2"
22
+ input << "tag6:six:off:3"
23
+ input << "tag7:seven:off:3"
24
+ input << "tag8:eight:off:4"
25
+ input << "tag11:1one:off:0"
26
+ input << "tag12:1two:off:1"
27
+ input << "tag13:1three:on:2"
28
+ input << "tag14:1four:off:1"
29
+ input << "tag15:1five:off:2"
30
+ input << "tag16:1six:off:3"
31
+ input << "tag17:1seven:off:3"
32
+ input << "tag18:1eight:off:4"
33
+ input << "tag21:2one:off:0"
34
+ input << "tag22:2two:off:1"
35
+ input << "tag23:2three:on:2"
36
+ input << "tag24:2four:off:1"
37
+ input << "tag25:2five:off:2"
38
+ input << "tag26:2six:off:3"
39
+ input << "tag27:2seven:off:3"
40
+ input << "tag28:2eight:off:4"
41
+ input << "tag9:nine:off:1"
42
+
43
+
44
+ Struct.new("TreeviewData", :tag, :item, :status, :depth)
45
+ input.each do |ii|
46
+ data = Struct::TreeviewData.new
47
+ a = ii.split(/:/)
48
+ data.tag = a[0]
49
+ data.item = a[1]
50
+ if a[2] == 'on'
51
+ data.status = true
52
+ else
53
+ data.status = false
54
+ end
55
+ data.depth = a[3]
56
+ items.push(data.to_a)
57
+ end
58
+
59
+ dialog = MRDialog.new
60
+ dialog.clear = true
61
+ dialog.scrollbar = true
62
+ dialog.title = "TREEVIEW"
63
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
64
+
65
+ height = 0
66
+ width = 0
67
+ listheight = 10
68
+
69
+ selected_tag = dialog.treeview(text, items, height, width, listheight)
70
+ exit_code = dialog.exit_code
71
+ puts "Exit code: #{exit_code}"
72
+ if exit_code == 0
73
+ puts "Selecetd tag: #{selected_tag}"
74
+ end
75
+
76
+ rescue => e
77
+ puts "#{$!}"
78
+ t = e.backtrace.join("\n\t")
79
+ puts "Error: #{t}"
80
+ end
data/samples/yesno.rb ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # muquit@muquit.com Apr-01-2014
4
+ require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
5
+ require 'pp'
6
+
7
+ class TestYesNo
8
+ ME = File.basename($0)
9
+ def initialize
10
+ end
11
+
12
+ def doit
13
+ text = <<EOF
14
+ Hi, this is a yes/no dialog box. You can use this to ask
15
+ questions that have an answer of either yes or no.
16
+ BTW, do you notice that long lines will be automatically
17
+ wrapped around so that they can fit in the box? You can
18
+ also control line breaking explicitly by inserting
19
+ 'backslash n' at any place you like, but in this case,
20
+ auto wrap around will be disabled and you will have to
21
+ control line breaking yourself.
22
+
23
+ EOF
24
+ dialog = MRDialog.new
25
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
26
+ dialog.clear = true
27
+ dialog.title = "YES/NO BOX"
28
+ # dialog.ascii_lines = true
29
+
30
+ yesno = dialog.yesno(text,0, 0)
31
+
32
+ puts "yesno: #{yesno}"
33
+
34
+ end
35
+ end
36
+
37
+ if __FILE__ == $0
38
+ TestYesNo.new.doit
39
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'mrdialog'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestMrdialog < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mrdialog
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aleks Clark
8
+ - Muhammad Muquit
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rdoc
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '3.12'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '3.12'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: jeweler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.1
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.1
70
+ - !ruby/object:Gem::Dependency
71
+ name: simplecov
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: "A ruby gem for ncurses dialog program.\n This gem is based on rdialog
85
+ (http://rdialog.rubyforge.org/) by\n Aleks Clark. I added support for missing
86
+ widgets, fixed \n bugs and wrote the sample apps. I am \n also renaming
87
+ the class to MRDialog to avoid conflicts.\n Please look at ChangeLog.md for
88
+ details. "
89
+ email: muquit@gmail.com
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files:
93
+ - ChangeLog.md
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ files:
97
+ - .document
98
+ - ChangeLog.md
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - LICENSE.txt
102
+ - README.rdoc
103
+ - Rakefile
104
+ - VERSION
105
+ - lib/mrdialog.rb
106
+ - lib/mrdialog/mrdialog.rb
107
+ - pkg/mrdialog-1.0.1.gem
108
+ - samples/buildlist.rb
109
+ - samples/calendar.rb
110
+ - samples/checklist.rb
111
+ - samples/editbox.rb
112
+ - samples/form1.rb
113
+ - samples/form2.rb
114
+ - samples/form3.rb
115
+ - samples/fselect.rb
116
+ - samples/gauge.rb
117
+ - samples/infobox.rb
118
+ - samples/inputbox.rb
119
+ - samples/menubox.rb
120
+ - samples/mixedform1.rb
121
+ - samples/msgbox.rb
122
+ - samples/password.rb
123
+ - samples/password2.rb
124
+ - samples/passwordform.rb
125
+ - samples/pause.rb
126
+ - samples/prgbox.rb
127
+ - samples/program.rb
128
+ - samples/progress.rb
129
+ - samples/radiolist.rb
130
+ - samples/shortlist
131
+ - samples/timebox.rb
132
+ - samples/treeview.rb
133
+ - samples/treeview2.rb
134
+ - samples/yesno.rb
135
+ - test/helper.rb
136
+ - test/test_mrdialog.rb
137
+ homepage: http://github.com/muquit/mrdialog
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.0.3
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: A ruby gem for ncurses dialog program, based on the gem rdialog
161
+ test_files: []