Skip to content
This repository has been archived by the owner on Sep 2, 2018. It is now read-only.

Commit

Permalink
does not show the Pod which do not match platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Nov 23, 2011
1 parent 6b83adf commit 685dd5d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
17 changes: 13 additions & 4 deletions PodCreator/PodFile.rb
Expand Up @@ -10,15 +10,16 @@ class PodFile
attr_accessor :tableView
attr_accessor :arrayController

PLATFORM = {'iOS' => ":ios", 'Mac' => ":osx" }

def init
@podList = PodList.alloc.init
@podList.delegate = self
end

#----------------------------------------
def showList(sender)
plat = getSelectedPlatform
@podList.setPlatform(plat[1..-1].to_sym)

NSApp.beginSheet(@podList.window,
modalForWindow:window,
modalDelegate:self,
Expand All @@ -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']}'"
Expand All @@ -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
26 changes: 23 additions & 3 deletions PodCreator/PodList.rb
Expand Up @@ -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

Expand All @@ -38,6 +38,7 @@ class PodList < NSWindowController
attr_accessor :arrayController

def init
@platform = ""
@pods = Spec::list

super
Expand All @@ -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

0 comments on commit 685dd5d

Please sign in to comment.