From 685dd5d29b1b18b78326d2627e1fc4b1b4c786af Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 23 Nov 2011 14:43:58 +0900 Subject: [PATCH] does not show the Pod which do not match platform --- PodCreator/PodFile.rb | 17 +++++++++++++---- PodCreator/PodList.rb | 26 +++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/PodCreator/PodFile.rb b/PodCreator/PodFile.rb index 8c92857..5f89033 100644 --- a/PodCreator/PodFile.rb +++ b/PodCreator/PodFile.rb @@ -10,8 +10,6 @@ class PodFile attr_accessor :tableView attr_accessor :arrayController - PLATFORM = {'iOS' => ":ios", 'Mac' => ":osx" } - def init @podList = PodList.alloc.init @podList.delegate = self @@ -19,6 +17,9 @@ def init #---------------------------------------- def showList(sender) + plat = getSelectedPlatform + @podList.setPlatform(plat[1..-1].to_sym) + NSApp.beginSheet(@podList.window, modalForWindow:window, modalDelegate:self, @@ -40,10 +41,9 @@ def create(sender) file:"Podfile") if(result == NSOKButton) path = panel.filename - plat = platformButton.titleOfSelectedItem File.open(path, "w") {|f| - f.puts "platform #{PLATFORM[plat]}" + f.puts "platform #{getSelectedPlatform}" ary = arrayController.arrangedObjects ary.each do |item| f.puts "dependency '#{item['name']}'" @@ -62,4 +62,13 @@ def create(sender) def addPod(pod) arrayController.addObject(pod.dup) end + + #---------------------------------------- + PLATFORM = {'iOS' => ":ios", 'Mac' => ":osx" } + + def getSelectedPlatform + plat = platformButton.titleOfSelectedItem + PLATFORM[plat] + end + end diff --git a/PodCreator/PodList.rb b/PodCreator/PodList.rb index edda455..4d5d545 100644 --- a/PodCreator/PodList.rb +++ b/PodCreator/PodList.rb @@ -11,7 +11,7 @@ def list pods = Pod::Source::search_by_name("", false) pods.each do |pod| h = {} - ['name', 'homepage', 'version', 'license'].each do |item| + ['name', 'homepage', 'version', 'license', 'platform'].each do |item| h[item] = eval("pod.specification.#{item}") || "" end @@ -38,6 +38,7 @@ class PodList < NSWindowController attr_accessor :arrayController def init + @platform = "" @pods = Spec::list super @@ -47,17 +48,36 @@ def init def awakeFromNib tableView.setTarget(self) tableView.setDoubleAction("selectPods:") + + center = NSNotificationCenter.defaultCenter + center.addObserver(self, + selector:"prepareList:", + name:"NSWindowWillBeginSheetNotification", + object:nil) + end + + #---------------------------------------- + def prepareList(sender) + obj = arrayController.arrangedObjects + arrayController.removeObjects(obj) + @pods.each do |pod| - arrayController.addObject(pod) + if pod['platform'].size == 0 || pod['platform'] == @platform + arrayController.addObject(pod) + end end end - #---------------------------------------- def selectPods(sender) obj = arrayController.selectedObjects.first delegate.addPod(obj) self.window.orderOut(self) end + #---------------------------------------- + def setPlatform(platform) + @platform = platform + end + end