friedmag-dmenu 0.0.1

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 (4) hide show
  1. data/README +5 -0
  2. data/dmenu.gemspec +32 -0
  3. data/lib/dmenu.rb +44 -0
  4. metadata +61 -0
data/README ADDED
@@ -0,0 +1,5 @@
1
+ Primitive wrapper around DMenu, appropriate for using DMenu as an input/output (selection) interface.
2
+
3
+ To use, simply:
4
+ require 'rubygems'
5
+ require 'dmenu'
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{dmenu}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Gary Friedman"]
9
+ s.date = %q{2009-05-13}
10
+ s.description = %q{Simple Ruby wrapper around DMenu}
11
+ s.email = %q{friedmagb@gmail.com}
12
+ s.extra_rdoc_files = ["lib/dmenu.rb", "README"]
13
+ s.files = ["lib/dmenu.rb", "README", "dmenu.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/friedmag/dmenu}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "DMenu", "--main", "README"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{dmenu}
19
+ s.rubygems_version = %q{1.3.0}
20
+ s.summary = %q{Simple Ruby wrapper around DMenu}
21
+ s.test_files = []
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+
3
+ class DMenu
4
+
5
+ class Helper
6
+
7
+ def self.getopts(args, *opts)
8
+ values = []
9
+ ret = []
10
+ hash = args.inject({}) do |hash, arg|
11
+ if Hash === arg
12
+ hash.merge!(arg)
13
+ end
14
+ hash
15
+ end
16
+ args.each {|arg| values.push arg unless Hash === arg}
17
+ opts.each do |opt|
18
+ if hash[opt]
19
+ ret.push hash[opt]
20
+ else
21
+ ret.push nil
22
+ end
23
+ end
24
+ ret.push values
25
+ end
26
+
27
+ end
28
+
29
+ def self.dmenu(*args)
30
+ cmd, values = Helper.getopts(args, :cmd)
31
+ dm = IO.popen((cmd or 'dmenu'), 'w+')
32
+ values.each do |value|
33
+ dm.puts value
34
+ end
35
+ dm.close_write
36
+ value = dm.read
37
+ dm.close
38
+ unless $? == 0
39
+ raise 'Operation cancelled'
40
+ end
41
+ value
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: friedmag-dmenu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gary Friedman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Simple Ruby wrapper around DMenu
17
+ email: friedmagb@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/dmenu.rb
24
+ - README
25
+ files:
26
+ - lib/dmenu.rb
27
+ - README
28
+ - dmenu.gemspec
29
+ has_rdoc: true
30
+ homepage: http://github.com/friedmag/dmenu
31
+ post_install_message:
32
+ rdoc_options:
33
+ - --line-numbers
34
+ - --inline-source
35
+ - --title
36
+ - DMenu
37
+ - --main
38
+ - README
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "1.2"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project: dmenu
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: Simple Ruby wrapper around DMenu
60
+ test_files: []
61
+