Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
mynu - A simple DSL to create a systembar menu with macruby on OSX
branch: master

This branch is even with RobertLowe:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
.gitignore
.rvmrc
CHANGES
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
mynu.gemspec

README.md

Mynu

A simple DSL to create a systembar menu with macruby in OSX

  1. gem install mynu
  2. macruby examples/dsl.rb

Usage example: macruby examples/dsl.rb

  require 'rubygems'
  require 'mynu'

  mynu = Mynu.new

  mynu.menu "Hello World!" do |menu|
    puts "Inside menu setup!"
    menu.title = "Good Bye World!"
    menu.item "Option 1" do |item|
      item.execute do
        puts "Execution block"
        item.title = "Dynamically changed!"
      end
    end
    menu.menu "Option 2" do |menu|
      menu.item "Option 2a" do
        puts "Option 2a clicked!"
      end
      menu.item "Option 2b" do
        puts "Option 2b clicked!"
      end
      menu.execute do |menu|
        puts "Menu clicked!"
        menu.title = "Dynamically changed!"
      end
    end
    capture_menu_item = menu.item "Disabled" do |item|
      item.disabled
    end
    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)!"
          capture_menu_item.disabled
        end
      end
    end
  end

  mynu.item "Simple Item" do
    puts "Hello World!"
  end

  mynu.run

A workflow example: macruby examples/workflow.rb

  mynu = Mynu.new

  mynu.menu "Applications" do |applications|
    applications.app "TextEdit", "/Applications/TextEdit.app"
  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.separator

  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.separator
  mynu.open "Downloads", "~/Downloads"
  mynu.separator
  mynu.open "Desktop", "~/Desktop"
  mynu.separator

  mynu.run

A terminal example (best used with Visor and one terminal window!): macruby examples/terminal.rb

  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.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

  • Improved API (done!)
  • Reloading?
  • Crash Handling?
  • FileMenuItem
  • Simple Dialogs

Copyright (C) 2011 by Robert Lowe - MIT

Something went wrong with that request. Please try again.