Zenity.rb 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.
Files changed (5) hide show
  1. data/COPYING +20 -0
  2. data/README.rdoc +23 -0
  3. data/demo.rb +5 -0
  4. data/lib/zenity.rb +42 -0
  5. metadata +56 -0
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Vikhyat Korrapati
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
data/README.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ = zenity.rb
2
+
3
+ Zenity is a tool that is used to display GTK dialog boxes from the command line,
4
+ often from shell scripts. From it's {Freshmeat page}[http://freshmeat.net/projects/zenity],
5
+
6
+ Zenity is a tool that allows you to display Gtk+ dialog boxes from the command
7
+ line and through shell scripts. It is similar to gdialog, but is intended to
8
+ be saner. It comes from the same family as dialog, Xdialog, and cdialog,
9
+ but it surpasses those projects by having a cooler name.
10
+
11
+ This tool offers a easy way to use Zenity in your scripts with a Ruby-ish
12
+ syntax. For example, this code:
13
+
14
+ Zenity::entry(:title => 'Enter some text', :text => 'This is a password dialog.', :arg => ['hide-text'])
15
+
16
+ gets translated to this bash command:
17
+
18
+ zenity --entry --title='Enter some text' --text='This is a password dialog.' --hide-text
19
+
20
+ == LICENSE
21
+
22
+ Look at the COPYING file. (It's the MIT License)
23
+
data/demo.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'lib/zenity'
2
+
3
+ puts Zenity::entry(:title => 'Enter some text', :text => 'This is a password dialog.', :arg => ['hide-text'])
4
+ puts Zenity::calendar(:title => 'Select a date')
5
+
data/lib/zenity.rb ADDED
@@ -0,0 +1,42 @@
1
+ module Zenity
2
+ class << self
3
+
4
+ # Let's just use method_missing instead of defining all of those.
5
+ def method_missing(m, options=false)
6
+ # Check if the dialog box we have to show is allowed
7
+ if [ :calendar, :entry, :error, :'file-selection', :info, :list,
8
+ :notification, :progress, :question, :'text-info', :warning, :scale
9
+ ].include? m
10
+ # It's in the array and everything seems to be fine
11
+ ret = %x[ #{parseopts('zenity --' + m.to_s, options)} ]
12
+ else
13
+ # We don't know about this dialog, raise an error
14
+ raise "Unknown dialog #{m}"
15
+ end
16
+ # Check if any of the options passed were invalid.
17
+ if ret.rstrip == 'This option is not available. Please see --help for all possible usages.'
18
+ # Write a message to STDERR if there were invalid options, but don't
19
+ # raise an error.
20
+ STDERR << "Invalid option"
21
+ else
22
+ # Everything looks fine. Return what we got.
23
+ return ret
24
+ end
25
+ end
26
+
27
+
28
+ private
29
+ # Very confusing code that generates the shell command.
30
+ def parseopts(cmd, options)
31
+ if options != false
32
+ options.each do |k, v|
33
+ cmd << " --#{k}='#{v}'" if k != :arg
34
+ end
35
+ options[:arg].each { |opt| cmd << " --#{opt}" } if options.has_key?(:arg)
36
+ end
37
+ cmd
38
+ end
39
+
40
+ end
41
+ end
42
+
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Zenity.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vikhyat Korrapati
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-10 00:00:00 +05:30
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Zenity.rb allows you to use Zenity to display GTK dialog boxes with a ruby-ish syntax.
17
+ email: vikhyatk@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - COPYING
26
+ - README.rdoc
27
+ - demo.rb
28
+ - lib/zenity.rb
29
+ has_rdoc: false
30
+ homepage: http://aetus.net/
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.3.1
52
+ signing_key:
53
+ specification_version: 2
54
+ summary: Ruby-ish syntax for zenity dialogs.
55
+ test_files: []
56
+