Permalink
Browse files

Release 0.3.0

  • Loading branch information...
1 parent 3856463 commit 010656f301426513881dd092b78c962706e24a16 @RobertLowe committed Jun 5, 2011
View
15 CHANGES
@@ -1 +1,14 @@
-None yet!
+v 0.3.0
+====
+* Changed how blocks are passed and received
+* Slight changes the API
+* New example scripts
+* Added a bunch of commands, see `examples/` directory for details
+* Added `open` command
+* Added `link` command
+* Added `terminal` command (best used with one terminal window and/or visor)
+* Added `menu` command
+
+v 0.2.5
+====
+ * Initial release
View
142 README.md
@@ -6,50 +6,42 @@ A simple DSL to create a systembar menu with macruby in OSX
![](http://i.imgur.com/yQBEE.png)
1. `gem install mynu`
-2. `macruby examples/hello-mynu.rb`
-
-
-An example of abusing `open [-a]`
-
-`macruby examples/workflow.rb`
-
-
-Or if your feeling bohemian:
-
-`macruby examples/queen.rb`
+2. `macruby examples/dsl.rb`
+Usage example:
+`macruby examples/dsl.rb`
require 'rubygems'
require 'mynu'
mynu = Mynu.new
- mynu.item "Hello World!" do |menu|
+ mynu.menu "Hello World!" do |menu|
puts "Inside menu setup!"
menu.title = "Good Bye World!"
- menu.item "Option 1" do |sub_menu|
- sub_menu.execute do
+ menu.item "Option 1" do |item|
+ item.execute do
puts "Execution block"
- sub_menu.title = "Dynamically changed!"
+ item.title = "Dynamically changed!"
end
end
- menu.item "Option 2" do |sub_menu|
- sub_menu.item "Option 2a" do
+ menu.menu "Option 2" do |menu|
+ menu.item "Option 2a" do
puts "Option 2a clicked!"
end
- sub_menu.item "Option 2b" do
+ menu.item "Option 2b" do
puts "Option 2b clicked!"
end
- sub_menu.execute do
- puts "Execution block and items"
- sub_menu.title = "Dynamically changed!"
+ menu.execute do
+ puts "Menu item clicked!"
+ menu.title = "Dynamically changed!"
end
end
- capture_menu_item = menu.item "Disabled" do |sub_menu|
- sub_menu.disabled
+ capture_menu_item = menu.item "Disabled" do |item|
+ item.disabled
end
- menu.item "Enable `Disabled`" do |sub_menu|
- sub_menu.execute do
+ menu.item "Enable `Disabled`" do |item|
+ item.execute do
capture_menu_item.enabled
capture_menu_item.execute do
capture_menu_item.title = "Disabled (Again)!"
@@ -67,77 +59,85 @@ Or if your feeling bohemian:
====
- require 'rubygems'
- require 'mynu'
+A workflow example:
+`macruby examples/workflow.rb`
mynu = Mynu.new
- mynu.item "Applications" do |applications|
- applications.item "Terminal" do
- # TODO: AppleScript a tab, this does nothing if terminal is open
- `open -a /Applications/Utilities/Terminal.app`
- end
+ mynu.menu "Applications" do |applications|
+ applications.app "TextEdit", "/Applications/Utilities/Terminal.app"
end
- mynu.item "Project" do |project|
- project.item "Live" do
- `open http://example.com`
- end
- project.item "Staging" do
- `open http://user:pass@staging.example.com`
- end
- project.item "Development" do
- `open http://example.dev`
- end
- project.item "Repos" do |repos|
- repos.item "Example" do
- `open ~/example`
- end
- repos.item "Resources" do
- `open ~/example-resources`
- end
+ mynu.menu "Project" do |project|
+ project.link "Live", "http://example.com"
+ project.link "Staging", "http://user:pass@staging.example.com"
+ project.link "Development", "http://example.dev"
+ project.menu "Repos" do |repos|
+ repos.open "Example", "~/example"
+ repos.open "Resources", "~/example-resources"
end
end
- mynu.items << NSMenuItem.separatorItem
+ mynu.separator
- mynu.item "Development" do |development|
- development.item "Rails" do |development_mynu|
- development_mynu.item "Github" do
- `open http://github.com/rails/rails`
- end
- development_mynu.item "Repo" do
- `open ~/workspace/rails`
- end
+ mynu.menu "Development" do |development|
+ development.menu "Rails" do |rails|
+ rails.link "Github", "http://github.com/rails/rails"
+ rails.open "Repo", "~/workspace/rails"
end
end
- mynu.items << NSMenuItem.separatorItem
+ mynu.separator
+ mynu.open "Downloads", "~/Downloads"
+ mynu.separator
+ mynu.open "Desktop", "~/Desktop"
+ mynu.separator
+
+ mynu.run
- mynu.item "Downloads" do
- `open ~/Downloads`
- end
- mynu.items << NSMenuItem.separatorItem
+A terminal example (best used with Visor and one terminal window!):
+`macruby examples/terminal.rb`
- desktop = mynu.item "Desktop" do
- `open ~/Desktop`
+ require 'rubygems'
+ require 'mynu'
+
+ mynu = Mynu.new
+
+ #############################################################
+ # Warning!
+ #
+ # This makes the assumation you use Visor and only manage
+ # one terminal window. Otherwise tabs will only be created
+ # in your first/primary terminal window.
+ #
+ # You can get Visor at: http://visor.binaryage.com/
+ #
+ #############################################################
+
+ # Normal usage will return to the frontmost app at execution
+ mynu.terminal "Echo & Disable Item", "echo hello" do
+ disabled
end
- mynu.items << NSMenuItem.separatorItem
+ mynu.terminal "Echo & Exit", "echo hello", :exit => true do
+ disabled
+ end
+ mynu.terminal "Keeps focus on Terminal Tab", "echo hello", :focus => true do
+ disabled
+ end
mynu.run
Todo
=====
- * Lots
- * Reloading
- * Crash Handling
+ * Improved API (done!)
+ * Reloading?
+ * Crash Handling?
* FileMenuItem
- * Improved API
- * Simple Dialogs?
+ * Simple Dialogs
# Copyright (C) 2011 by Robert Lowe <rob[!]iblargz.com> - MIT
View
@@ -0,0 +1,39 @@
+# Copyright (C) 2011 by Robert Lowe <rob[!]iblargz.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+require 'rubygems'
+require 'mynu'
+
+mynu = Mynu.new
+
+mynu.app "TextEdit", "/Applications/TextEdit.app"
+
+mynu.app "TextEdit", "/Applications/TextEdit.app" do
+ p self # BlockMenuItem
+ setTitle "TextEdit - Clicked"
+end
+
+mynu.link "TextEdit & Disable", "/Applications/TextEdit.app" do |item|
+ p item # BlockMenuItem
+ item.setTitle "TextEdit Disabled!"
+ item.disabled
+end
+
+mynu.run
@@ -23,32 +23,34 @@
mynu = Mynu.new
-mynu.item "Hello World!" do |menu|
+mynu.menu "Hello World!" do |menu|
puts "Inside menu setup!"
menu.title = "Good Bye World!"
- menu.item "Option 1" do |sub_menu|
- sub_menu.execute do
+ menu.item "Option 1" do |item|
+ item.execute do
puts "Execution block"
- sub_menu.title = "Dynamically changed!"
+ item.title = "Dynamically changed!"
end
end
- menu.item "Option 2" do |sub_menu|
- sub_menu.item "Option 2a" do
+ menu.menu "Option 2" do |menu|
+ menu.item "Option 2a" do
puts "Option 2a clicked!"
end
- sub_menu.item "Option 2b" do
+ menu.item "Option 2b" do
puts "Option 2b clicked!"
end
- sub_menu.execute do
- puts "Execution block and items"
- sub_menu.title = "Dynamically changed!"
+ menu.execute do |menu|
+ puts "Menu clicked!"
+ menu.title = "Dynamically changed!"
end
end
- capture_menu_item = menu.item "Disabled" do |sub_menu|
- sub_menu.disabled
+ capture_menu_item = menu.item "Disabled" do |item|
+ item.disabled
end
- menu.item "Enable `Disabled`" do |sub_menu|
- sub_menu.execute do
+ capture_menu_item.disabled
+ menu.item "Enable `Disabled`" do |item|
+ capture_menu_item.enabled
+ item.execute do
capture_menu_item.enabled
capture_menu_item.execute do
capture_menu_item.title = "Disabled (Again)!"
View
@@ -0,0 +1,39 @@
+# Copyright (C) 2011 by Robert Lowe <rob[!]iblargz.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+require 'rubygems'
+require 'mynu'
+
+mynu = Mynu.new
+
+mynu.link "Google", "http://google.com"
+
+mynu.link "Google", "http://google.com" do
+ p self # BlockMenuItem
+ setTitle "New"
+end
+
+mynu.link "Google (Will disable)", "http://google.com" do |item|
+ p item # BlockMenuItem
+ item.setTitle "Disabled!"
+ item.disabled
+end
+
+mynu.run
View
@@ -0,0 +1,51 @@
+# Copyright (C) 2011 by Robert Lowe <rob[!]iblargz.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+require 'rubygems'
+require 'mynu'
+
+mynu = Mynu.new
+
+mynu.menu "Menu 1" do
+ self.link "Google", "http://google.com" do
+ p self # BlockMenuItem
+ setTitle "New"
+ end
+ self.link "Google (Will disable)", "http://google.com" do |item|
+ p item # BlockMenuItem
+ item.setTitle "Disabled!"
+ item.disabled
+ end
+end
+
+mynu.menu "Menu 2" do |menu|
+ menu.link "Google", "http://google.com" do
+ p self # BlockMenuItem
+ setTitle "New"
+ end
+ menu.link "Google (Will disable)", "http://google.com" do |item|
+ p item # BlockMenuItem
+ item.setTitle "Disabled!"
+ item.disabled
+ end
+end
+
+
+mynu.run
Oops, something went wrong.

0 comments on commit 010656f

Please sign in to comment.