everyday-menu 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a54828a0a7db304a577074de86e42c80ce795a12
4
- data.tar.gz: f82ed542d84b73465072a5e8c9c6b55d43924498
3
+ metadata.gz: 66daeba8da989301477c3d0b2474c5d32ad19011
4
+ data.tar.gz: 9d47532f129aaea7c5057dba34872fd588b19401
5
5
  SHA512:
6
- metadata.gz: e45812b9c587be046d51056505a761dd8a2439f082fca92cdee33700c8990e3d09c41a59e7b22706fc6695df774c63425e2e7bea399e62927b21d2754135561d
7
- data.tar.gz: 411691c2aa1fc7a8aacd7636da4ffb6023f04bb45d244dde1b0801201acbd3506252c878451ffbffdd91bb4c75652501e5bc9233402ca4843e5cd8069a80d634
6
+ metadata.gz: cf969107f17c26e64f3e19e64ddb1e9b251f8c432c7f563cc6633fac82cf8a98375d9b7fb065b08a6883e65a3a19e0019e604dff2925c7b217d145d59cb78e05
7
+ data.tar.gz: 3b34fa1275f028cda1ae152809f0f559b89a5663d3c13574636852eda8b2d1a29079943633dd0f58e599c0c74874d4a072804231ab0081a7e08c24f47d969ac7
data/README.md CHANGED
@@ -86,9 +86,13 @@ class AppDelegate
86
86
  MainMenu[:app].subscribe(:hide_others) { |_, _| NSApp.hideOtherApplications(self) }
87
87
  MainMenu[:app].subscribe(:quit) { |_, _| NSApp.terminate(self) }
88
88
 
89
- MainMenu[:file].subscribe(:start_stop) { |command, _|
89
+ MainMenu[:file].subscribe(:start_stop, :start_stop_command_id) { |command, _|
90
90
  @started = !@started
91
91
  command.parent[:title] = @started ? 'Stop' : 'Start'
92
+ puts "subscribe 1 command id: #{command.command_id}"
93
+ }
94
+ MainMenu[:file].subscribe(:start_stop, :start_stop_command_id2) { |command, _|
95
+ puts "subscribe 2 command id: #{command.command_id}"
92
96
  }
93
97
  MainMenu[:file].subscribe(:new) { |_, _|
94
98
  @has_open = true
@@ -16,9 +16,13 @@ class AppDelegate
16
16
  @has_open = true
17
17
  puts 'open'
18
18
  }
19
- MainMenu[:file].subscribe(:start_stop) { |command, _|
19
+ MainMenu[:file].subscribe(:start_stop, :start_stop_command_id) { |command, _|
20
20
  @started = !@started
21
21
  command.parent[:title] = @started ? 'Stop' : 'Start'
22
+ puts "subscribe 1 command id: #{command.command_id}"
23
+ }
24
+ MainMenu[:file].subscribe(:start_stop, :start_stop_command_id2) { |command, _|
25
+ puts "subscribe 2 command id: #{command.command_id}"
22
26
  }
23
27
  MainMenu[:statusbar].subscribe(:status_new) { |_, _|
24
28
  @has_open = true
@@ -48,8 +48,8 @@ module EverydayMenu
48
48
 
49
49
  alias :menu_item :menuItem
50
50
 
51
- def subscribe(label, &block)
52
- self.items[label].subscribe(&block)
51
+ def subscribe(label, command_id = nil, &block)
52
+ self.items[label].subscribe(command_id, &block)
53
53
  end
54
54
 
55
55
  def <<(item)
@@ -120,8 +120,8 @@ module EverydayMenu
120
120
  @onBuild << block
121
121
  end
122
122
 
123
- def subscribe(&block)
124
- @menuItem.subscribe(self, self.label, &block)
123
+ def subscribe(command_id = nil, &block)
124
+ @menuItem.subscribe(self, self.label, command_id, &block)
125
125
  end
126
126
 
127
127
  def execute
@@ -133,9 +133,9 @@ end
133
133
  class NSMenuItem
134
134
  attr_reader :commands
135
135
 
136
- def subscribe(parent, label, &block)
136
+ def subscribe(parent, label, command_id = nil, &block)
137
137
  @commands ||= EverydayMenu::CommandList.new(parent, label)
138
- @commands.add &block
138
+ @commands.add command_id, &block
139
139
  command = @commands.last
140
140
  self.enabled = @commands.canExecute
141
141
  unless @boundEnabled
@@ -1,18 +1,20 @@
1
1
  module EverydayMenu
2
2
  class EverydayCommand
3
- attr_reader :label, :parent
3
+ attr_reader :label, :parent, :command_id
4
4
  attr_writer :canExecute
5
5
 
6
- def initialize(parent, label, canExecute = true, &block)
6
+ def initialize(parent, label, command_id = nil, canExecute = true, &block)
7
7
  @parent = parent
8
8
  @label = label
9
9
  @block = block
10
+ @command_id = command_id
10
11
  @canExecute = canExecute
11
12
  @canExecuteBlock = nil
12
13
  end
13
14
 
14
15
  def canExecuteBlock(&block)
15
16
  @canExecuteBlock = block
17
+ self
16
18
  end
17
19
 
18
20
  def canExecute
@@ -33,8 +35,8 @@ module EverydayMenu
33
35
  @items = []
34
36
  end
35
37
 
36
- def add(&block)
37
- @items << EverydayCommand.new(@parent, @label, &block)
38
+ def add(command_id = nil, &block)
39
+ @items << EverydayCommand.new(@parent, @label, command_id, &block)
38
40
  end
39
41
 
40
42
  def last
@@ -1,3 +1,3 @@
1
1
  module EverydayMenu
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everyday-menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson