Hi,

after migrating to Snow Leopard (clean install --> the long way) I had some time for my MacRuby-Plugin-Project:

First I changed the make-Script for libgit2 to (eliminated the ruby part and made a "make clean" detection):

export PATH=$PATH:$HOME/bin:$HOME/local/bin:/sw/bin:/opt/local/ bin:`"$TARGET_BUILD_DIR"/gitx --git-path`
git submodule init
git submodule update
cd libgit2
ARCHS=""
for a in `echo $VALID_ARCHS`; do ARCHS="$ARCHS -arch $a"; done
ARCHSFILE="archs"
touch $ARCHSFILE
OLDARCHS=`cat $ARCHSFILE`
if [ "$OLDARCHS" != "$ARCHS" ]; then
 make clean
fi
echo "$ARCHS" > $ARCHSFILE
rm -f libgit2.a
make CFLAGS="$ARCHS"
ranlib libgit2.a

--------

For rapid development I implemented a simple PluginController, which looks for a special hotplug file. If it is present a menu is created for loading the file and reloading it, if it is edited.

All this can be done without exiting the running GitX, even XCode is not required or to be more precisely, in the moment it is abused for the output in the Debugger Console Window.


# File: PluginController.rb

HOTPLUGFILE = File.expand_path "~/Library/GitX/hotplug.rb"

class PluginController

    attr_accessor :menuPlugin
    attr_accessor :menu

    def PluginController.instance
          @@xinstance
        end

        def awakeFromNib
          @@xinstance = self
          @menuitems = []
      if File.exists? HOTPLUGFILE
mi = NSMenuItem.alloc.initWithTitle( "Load Hotplug", action:'loadHotplug:', keyEquivalent:'+')
                mi.setTarget self
            menuPlugin.addItem mi
          end
        end

    def addMenuItemWithTitle( title, action:action, keyEquivalent:key)
@menuitems.push( menu.addItemWithTitle( title, action:action, keyEquivalent:key))
        end

    def loadHotplug(sender)
      puts "*** load hotplug ***"
          @menuitems.each { |i| menu.removeItem i }
          @menuitems = []
          load HOTPLUGFILE, true
    end

end



# File: ~/Library/GitX/hotplug.rb

#puts "hello hotplug"

class PBGitHistoryController

    def my_working_dir
      repository.workingDirectory
    end

    def showSome(sender)
      puts "working_dir: #{my_working_dir}"
p PBEasyPipe.outputForCommand(PBGitBinary.path, withArgs: ['status'])
    end

    def showPath(sender)
      puts "showPath: #{PBGitBinary.path}"
    end

    def showMore(sender)
      puts "showMore"
      p repository.outputForCommand "cat-file commit HEAD"
# p PBEasyPipe.outputForCommand(PBGitBinary.path, withArgs: ['blame','-p','-L 1,4','TODO'], inDir:repository.workingDirectory)
    end

end

pc = PluginController.instance
pc.addMenuItemWithTitle( "showSome", action:'showSome:', keyEquivalent:'7') pc.addMenuItemWithTitle( "showPath", action:'showPath:', keyEquivalent:'8') pc.addMenuItemWithTitle( "showMore", action:'showMore:', keyEquivalent:'9')



Reply via email to