everyday-menu 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/README.md +24 -3
- data/everyday-menu.gemspec +2 -0
- data/examples/basic_main_menu/app_delegate.rb +8 -3
- data/lib/everyday-menu/menu_item.rb +7 -4
- data/lib/everyday-menu/utils.rb +22 -4
- data/lib/everyday-menu/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 070446116cd1b8619df4634a2615d0fe56bd54b7
|
4
|
+
data.tar.gz: 625c092f45698dab96d3fe6bc50218eeb3dbeba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b692b467c2bcf26a9c4a31f83003135a8766cf36ab80968f7237f28d22196d0a1d788e5cdf53854948e5bdea9e6497a18da5fb8cd4e0f780de84478f11e90e1
|
7
|
+
data.tar.gz: 17a5b9ada1e707ada94b4406cd51591ba423db275e3ce31436cf1e2ff256ae1bd87ce422c35f141376975f433411dbaded4804ed1ed7464e56061c1db1e7ceac
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,34 @@
|
|
1
1
|
# EverydayMenu
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/everyday-menu)
|
4
|
+
|
3
5
|
## Updates
|
6
|
+
* 0.2.0:
|
7
|
+
* Create `EverydayCommand` to allow control of enablement of menu items
|
8
|
+
* 0.2.1:
|
9
|
+
* Fix a set method issue and resolve the error messages about missing methods
|
10
|
+
* 0.3.0:
|
11
|
+
* Add handling for `NSApp.servicesMenu`, `NSApp.windowsMenu`, and `NSApp.helpMenu`
|
4
12
|
* 0.4.0:
|
5
13
|
* Please see the "Introducing Presets!" section below for an awesome new feature!
|
6
14
|
* 1.0.0:
|
7
15
|
* Please see the "Introducing Statusbar Menus!" section below for another awesome new feature!
|
16
|
+
* 1.1.0:
|
17
|
+
* Added reference to parent `MenuItem` instance to `EverydayCommand`
|
18
|
+
* 1.2.0:
|
19
|
+
* Added the ability to have individual ids for each command
|
20
|
+
* 1.3.0:
|
21
|
+
* Commands now get a random id if you don't give them one
|
22
|
+
* You can now access a command by id
|
23
|
+
* I now have a runtime dependency, the gem `rm-digest`, but it has the necessary objective-c code built-in, so there shouldn't be any extra work for users of `everyday-menu`
|
8
24
|
|
9
25
|
## Issue Tracking
|
10
26
|
Please use <https://everydayprogramminggenius.atlassian.net/browse/EM> for issue tracking.
|
11
27
|
|
12
28
|
## Credit
|
13
|
-
Please note that this gem is
|
29
|
+
Please note that this gem is based off of Joe Fiorini's `drink-menu` gem (with a little code copy-paste and lots of test and readme copy-paste), which I couldn't get to work for me.
|
14
30
|
|
15
|
-
You can find his gem at <https://github.com/joefiorini/drink-menu>. He doesn't get all of the credit, but he gets a
|
31
|
+
You can find his gem at <https://github.com/joefiorini/drink-menu>. He doesn't get all of the credit, but he gets a fair amount of it.
|
16
32
|
|
17
33
|
## Installation
|
18
34
|
|
@@ -104,10 +120,15 @@ class AppDelegate
|
|
104
120
|
puts 'close'
|
105
121
|
}.canExecuteBlock { |_| @has_open }
|
106
122
|
|
107
|
-
MainMenu[:file].subscribe(:open) { |
|
123
|
+
MainMenu[:file].subscribe(:open) { |command, _|
|
108
124
|
@has_open = true
|
109
125
|
puts 'open'
|
126
|
+
puts "open subscribe 1 command id: #{command.command_id}"
|
127
|
+
}
|
128
|
+
MainMenu[:file].subscribe(:open) { |command, _|
|
129
|
+
puts "open subscribe 2 command id: #{command.command_id}"
|
110
130
|
}
|
131
|
+
puts "start_stop subscribe 1 parent label: #{MainMenu[:file].items[:start_stop][:commands][:start_stop_command_id].label}"
|
111
132
|
end
|
112
133
|
end
|
113
134
|
```
|
data/everyday-menu.gemspec
CHANGED
@@ -12,17 +12,21 @@ class AppDelegate
|
|
12
12
|
@has_open = false
|
13
13
|
puts 'close'
|
14
14
|
}.canExecuteBlock { |_| @has_open }
|
15
|
-
MainMenu[:file].subscribe(:open) { |
|
15
|
+
MainMenu[:file].subscribe(:open) { |command, _|
|
16
16
|
@has_open = true
|
17
17
|
puts 'open'
|
18
|
+
puts "open subscribe 1 command id: #{command.command_id}"
|
19
|
+
}
|
20
|
+
MainMenu[:file].subscribe(:open) { |command, _|
|
21
|
+
puts "open subscribe 2 command id: #{command.command_id}"
|
18
22
|
}
|
19
23
|
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id) { |command, _|
|
20
24
|
@started = !@started
|
21
25
|
command.parent[:title] = @started ? 'Stop' : 'Start'
|
22
|
-
puts "subscribe 1 command id: #{command.command_id}"
|
26
|
+
puts "start_stop subscribe 1 command id: #{command.command_id}"
|
23
27
|
}
|
24
28
|
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id2) { |command, _|
|
25
|
-
puts "subscribe 2 command id: #{command.command_id}"
|
29
|
+
puts "start_stop subscribe 2 command id: #{command.command_id}"
|
26
30
|
}
|
27
31
|
MainMenu[:statusbar].subscribe(:status_new) { |_, _|
|
28
32
|
@has_open = true
|
@@ -36,5 +40,6 @@ class AppDelegate
|
|
36
40
|
@has_open = true
|
37
41
|
puts 'status-open'
|
38
42
|
}
|
43
|
+
puts "start_stop subscribe 1 parent label: #{MainMenu[:file].items[:start_stop][:commands][:start_stop_command_id].label}"
|
39
44
|
end
|
40
45
|
end
|
@@ -127,6 +127,10 @@ module EverydayMenu
|
|
127
127
|
def execute
|
128
128
|
@menuItem.runBlock(self)
|
129
129
|
end
|
130
|
+
|
131
|
+
def commands
|
132
|
+
@commands ||= EverydayMenu::CommandList.new(self, self.label)
|
133
|
+
end
|
130
134
|
end
|
131
135
|
end
|
132
136
|
|
@@ -134,10 +138,9 @@ class NSMenuItem
|
|
134
138
|
attr_reader :commands
|
135
139
|
|
136
140
|
def subscribe(parent, label, command_id = nil, &block)
|
137
|
-
@commands
|
138
|
-
|
139
|
-
|
140
|
-
self.enabled = @commands.canExecute
|
141
|
+
@commands ||= parent.commands
|
142
|
+
command = parent.commands.add command_id, &block
|
143
|
+
self.enabled = parent.commands.canExecute
|
141
144
|
unless @boundEnabled
|
142
145
|
@boundEnabled = true
|
143
146
|
self.bind(NSEnabledBinding, toObject: self.commands, withKeyPath: 'canExecute', options: nil)
|
data/lib/everyday-menu/utils.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
class EverydayRmDigest
|
2
|
+
include RmDigest
|
3
|
+
end
|
4
|
+
|
1
5
|
module EverydayMenu
|
2
6
|
class EverydayCommand
|
3
7
|
attr_reader :label, :parent, :command_id
|
@@ -32,11 +36,25 @@ module EverydayMenu
|
|
32
36
|
def initialize(parent, label)
|
33
37
|
@parent = parent
|
34
38
|
@label = label
|
35
|
-
@items =
|
39
|
+
@items = {}
|
40
|
+
@rand = Random.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def unique_id
|
44
|
+
EverydayRmDigest::MD5.hexdigest("#{@rand.rand}#{@rand.rand}")
|
45
|
+
end
|
46
|
+
|
47
|
+
def rand_id
|
48
|
+
:"command_id_#{unique_id}"
|
36
49
|
end
|
37
50
|
|
38
51
|
def add(command_id = nil, &block)
|
39
|
-
|
52
|
+
id = command_id || rand_id
|
53
|
+
@items[id] = EverydayCommand.new(@parent, @label, id, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def [](id)
|
57
|
+
@items[id]
|
40
58
|
end
|
41
59
|
|
42
60
|
def last
|
@@ -44,11 +62,11 @@ module EverydayMenu
|
|
44
62
|
end
|
45
63
|
|
46
64
|
def execute(sender)
|
47
|
-
@items.each { |item| item.execute(sender) }
|
65
|
+
@items.values.each { |item| item.execute(sender) }
|
48
66
|
end
|
49
67
|
|
50
68
|
def canExecute
|
51
|
-
@items.any? { |item| item.canExecute }
|
69
|
+
@items.values.any? { |item| item.canExecute }
|
52
70
|
end
|
53
71
|
end
|
54
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: everyday-menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Henderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rm-digest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: An easy way to define menu items and visually lay out menus for your
|
42
56
|
OSX apps. Based strongly on the drink-menu gem that I couldn't get to work for me.
|
43
57
|
email:
|