dmenu 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/LICENSE +1 -1
  2. data/lib/dmenu.rb +37 -18
  3. metadata +23 -42
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) <YEAR>, Dominik Honnef <dominikho@gmx.net>
1
+ Copyright (c) 2014, Dominik Honnef <dominikh@fork-bomb.org>
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -1,4 +1,3 @@
1
- require "shellwords"
2
1
  require "dmenu/item"
3
2
 
4
3
  # @example A simple menu
@@ -7,7 +6,7 @@ require "dmenu/item"
7
6
  #
8
7
  # menu.run # this will return a Dmenu::Item, according to what the user selected.
9
8
  class Dmenu
10
- VERSION = "0.0.2"
9
+ VERSION = "1.0.0"
11
10
 
12
11
  # @return [Array<#to_s, Item>] Items to display in the menu. Items
13
12
  # that are not an instance of the {Item} class will transparently
@@ -50,8 +49,6 @@ class Dmenu
50
49
  # @return [Item, nil] Returns the selected item or nil, if the user
51
50
  # didn't make any selection (i.e. pressed ESC)
52
51
  def run
53
- command = "dmenu #{args}"
54
- puts command
55
52
  pipe = IO.popen(command, "w+")
56
53
 
57
54
  items = @items.map {|item|
@@ -74,6 +71,7 @@ class Dmenu
74
71
  return nil
75
72
  end
76
73
 
74
+ value.chomp!
77
75
  selection = items.find {|item|
78
76
  item.key.to_s == value
79
77
  }
@@ -81,19 +79,40 @@ class Dmenu
81
79
  return selection
82
80
  end
83
81
 
84
- def args
85
- args = []
86
- args << "-b" if @position == :bottom
87
- args << "-i" if @case_insensitive
88
- args << "-l #@lines" if @lines > 1
89
- args << "-fn " + Shellwords.escape(@font) if @font
90
- args << "-nb " + Shellwords.escape(@background) if @background
91
- args << "-nf " + Shellwords.escape(@foreground) if @foreground
92
- args << "-sb " + Shellwords.escape(@selected_background) if @selected_background
93
- args << "-sf " + Shellwords.escape(@selected_foreground) if @selected_foreground
94
- args << "-p " + Shellwords.escape(@prompt) if @prompt
95
-
96
- args.join(" ")
82
+ private
83
+
84
+ def command
85
+ args = ["dmenu"]
86
+
87
+ if @position == :bottom
88
+ args << "-b"
89
+ end
90
+
91
+ if @case_insensitive
92
+ args << "-i"
93
+ end
94
+
95
+ if @lines > 1
96
+ args << "-l"
97
+ args << lines.to_s
98
+ end
99
+
100
+ h = {
101
+ "fn" => @font,
102
+ "nb" => @background,
103
+ "nf" => @foreground,
104
+ "sb" => @selected_background,
105
+ "sf" => @selected_foreground,
106
+ "p" => @prompt,
107
+ }
108
+
109
+ h.each do |flag, value|
110
+ if value
111
+ args << "-#{flag}"
112
+ args << value
113
+ end
114
+ end
115
+
116
+ return args
97
117
  end
98
- private :args
99
118
  end
metadata CHANGED
@@ -1,69 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dmenu
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Dominik Honnef
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-03 00:00:00 +02:00
18
- default_executable:
12
+ date: 2014-05-10 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: A Ruby OOP wrapper around dmenu.
22
15
  email: dominikh@fork-bomb.org
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
30
- - lib/dmenu/item.rb
19
+ files:
31
20
  - lib/dmenu.rb
21
+ - lib/dmenu/item.rb
32
22
  - README
33
23
  - LICENSE
34
- has_rdoc: yard
35
- homepage: http://fork-bomb.org
36
- licenses: []
37
-
24
+ homepage:
25
+ licenses:
26
+ - BSD
38
27
  post_install_message:
39
28
  rdoc_options: []
40
-
41
- require_paths:
29
+ require_paths:
42
30
  - lib
43
- required_ruby_version: !ruby/object:Gem::Requirement
31
+ required_ruby_version: !ruby/object:Gem::Requirement
44
32
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- segments:
49
- - 1
50
- - 9
51
- - 1
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
52
36
  version: 1.9.1
53
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
38
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
- version: "0"
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
61
43
  requirements: []
62
-
63
44
  rubyforge_project:
64
- rubygems_version: 1.3.7
45
+ rubygems_version: 1.8.23
65
46
  signing_key:
66
47
  specification_version: 3
67
48
  summary: A Ruby OOP wrapper around dmenu.
68
49
  test_files: []
69
-
50
+ has_rdoc: yard