Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

does not show the Pod which do not match platform

  • Loading branch information...
commit 685dd5d29b1b18b78326d2627e1fc4b1b4c786af 1 parent 6b83adf
@Watson1978 authored
Showing with 36 additions and 7 deletions.
  1. +13 −4 PodCreator/PodFile.rb
  2. +23 −3 PodCreator/PodList.rb
View
17 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
View
26 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
Please sign in to comment.
Something went wrong with that request. Please try again.