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

Commit

Permalink
implement PodSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Nov 22, 2011
1 parent b191071 commit dcba327
Show file tree
Hide file tree
Showing 5 changed files with 3,094 additions and 1,206 deletions.
8 changes: 8 additions & 0 deletions PodCreator.xcodeproj/project.pbxproj
Expand Up @@ -17,6 +17,8 @@
A988D41E1477DFDC00878C5C /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41D1477DFDC00878C5C /* rb_main.rb */; }; A988D41E1477DFDC00878C5C /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41D1477DFDC00878C5C /* rb_main.rb */; };
A988D4201477DFDC00878C5C /* AppDelegate.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41F1477DFDC00878C5C /* AppDelegate.rb */; }; A988D4201477DFDC00878C5C /* AppDelegate.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41F1477DFDC00878C5C /* AppDelegate.rb */; };
A988D42A1477E2F100878C5C /* ButtonBarView.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D4291477E2F100878C5C /* ButtonBarView.rb */; }; A988D42A1477E2F100878C5C /* ButtonBarView.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D4291477E2F100878C5C /* ButtonBarView.rb */; };
A994BFA1147BC00900994C85 /* PodSpec.rb in Resources */ = {isa = PBXBuildFile; fileRef = A994BFA0147BC00900994C85 /* PodSpec.rb */; };
A994BFA3147BC04F00994C85 /* PodFile.rb in Resources */ = {isa = PBXBuildFile; fileRef = A994BFA2147BC04F00994C85 /* PodFile.rb */; };
A9E35580147937F60002A1A3 /* PodCreator.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9E3557F147937F60002A1A3 /* PodCreator.icns */; }; A9E35580147937F60002A1A3 /* PodCreator.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9E3557F147937F60002A1A3 /* PodCreator.icns */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */


Expand Down Expand Up @@ -44,6 +46,8 @@
A988D41D1477DFDC00878C5C /* rb_main.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = rb_main.rb; sourceTree = "<group>"; }; A988D41D1477DFDC00878C5C /* rb_main.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = rb_main.rb; sourceTree = "<group>"; };
A988D41F1477DFDC00878C5C /* AppDelegate.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = AppDelegate.rb; sourceTree = "<group>"; }; A988D41F1477DFDC00878C5C /* AppDelegate.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = AppDelegate.rb; sourceTree = "<group>"; };
A988D4291477E2F100878C5C /* ButtonBarView.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = ButtonBarView.rb; sourceTree = "<group>"; }; A988D4291477E2F100878C5C /* ButtonBarView.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = ButtonBarView.rb; sourceTree = "<group>"; };
A994BFA0147BC00900994C85 /* PodSpec.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = PodSpec.rb; sourceTree = "<group>"; };
A994BFA2147BC04F00994C85 /* PodFile.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = PodFile.rb; sourceTree = "<group>"; };
A9E3557F147937F60002A1A3 /* PodCreator.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = PodCreator.icns; sourceTree = "<group>"; }; A9E3557F147937F60002A1A3 /* PodCreator.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = PodCreator.icns; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */


Expand Down Expand Up @@ -91,7 +95,9 @@
children = ( children = (
A988D4291477E2F100878C5C /* ButtonBarView.rb */, A988D4291477E2F100878C5C /* ButtonBarView.rb */,
A988D41F1477DFDC00878C5C /* AppDelegate.rb */, A988D41F1477DFDC00878C5C /* AppDelegate.rb */,
A994BFA2147BC04F00994C85 /* PodFile.rb */,
A90E74BD1478A7F700493C4C /* PodList.rb */, A90E74BD1478A7F700493C4C /* PodList.rb */,
A994BFA0147BC00900994C85 /* PodSpec.rb */,
A988D4181477DFDC00878C5C /* Resources */, A988D4181477DFDC00878C5C /* Resources */,
A988D41C1477DFDC00878C5C /* Other Sources */, A988D41C1477DFDC00878C5C /* Other Sources */,
A988D4101477DFDB00878C5C /* Supporting Files */, A988D4101477DFDB00878C5C /* Supporting Files */,
Expand Down Expand Up @@ -204,6 +210,8 @@
A90E74BB1478A7CC00493C4C /* PodList.xib in Resources */, A90E74BB1478A7CC00493C4C /* PodList.xib in Resources */,
A90E74BE1478A7F700493C4C /* PodList.rb in Resources */, A90E74BE1478A7F700493C4C /* PodList.rb in Resources */,
A9E35580147937F60002A1A3 /* PodCreator.icns in Resources */, A9E35580147937F60002A1A3 /* PodCreator.icns in Resources */,
A994BFA1147BC00900994C85 /* PodSpec.rb in Resources */,
A994BFA3147BC04F00994C85 /* PodFile.rb in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
56 changes: 0 additions & 56 deletions PodCreator/AppDelegate.rb
Expand Up @@ -4,68 +4,12 @@
# #


class AppDelegate class AppDelegate
attr_accessor :window
attr_accessor :platformButton
attr_accessor :bridgeSupportCheckBox
attr_accessor :tableView
attr_accessor :arrayController

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


def applicationDidFinishLaunching(a_notification) def applicationDidFinishLaunching(a_notification)
@podList = PodList.alloc.init
@podList.delegate = self
end end


def windowWillClose(a_notification) def windowWillClose(a_notification)
NSApp.terminate(self) NSApp.terminate(self)
end end

#----------------------------------------
def showList(sender)
NSApp.beginSheet(@podList.window,
modalForWindow:window,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)

NSApp.endSheet(@podList.window)
end

def remove(sender)
index = arrayController.selectionIndexes
arrayController.removeObjectsAtArrangedObjectIndexes(index)
end

def create(sender)
panel = NSSavePanel.savePanel
panel.setCanChooseDirectories(true)
result = panel.runModalForDirectory(NSHomeDirectory(),
file:"Podfile")
if(result == NSOKButton)
path = panel.filename
plat = platformButton.titleOfSelectedItem

File.open(path, "w") {|f|
f.puts "platform #{PLATFORM[plat]}"
ary = arrayController.arrangedObjects
ary.each do |item|
f.puts "dependency '#{item['name']}'"
end

if bridgeSupportCheckBox.state == NSOnState
f.puts "generate_bridge_support!"
end
}

system "open -a TextEdit '#{path}'"
end
end

#----------------------------------------
def addPod(pod)
arrayController.addObject(pod.dup)
end

end end


65 changes: 65 additions & 0 deletions PodCreator/PodFile.rb
@@ -0,0 +1,65 @@
#
# Podfile.rb
# PodCreator
#

class PodFile
attr_accessor :window
attr_accessor :platformButton
attr_accessor :bridgeSupportCheckBox
attr_accessor :tableView
attr_accessor :arrayController

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

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

#----------------------------------------
def showList(sender)
NSApp.beginSheet(@podList.window,
modalForWindow:window,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)

NSApp.endSheet(@podList.window)
end

def remove(sender)
index = arrayController.selectionIndexes
arrayController.removeObjectsAtArrangedObjectIndexes(index)
end

def create(sender)
panel = NSSavePanel.savePanel
panel.setCanChooseDirectories(true)
result = panel.runModalForDirectory(NSHomeDirectory(),
file:"Podfile")
if(result == NSOKButton)
path = panel.filename
plat = platformButton.titleOfSelectedItem

File.open(path, "w") {|f|
f.puts "platform #{PLATFORM[plat]}"
ary = arrayController.arrangedObjects
ary.each do |item|
f.puts "dependency '#{item['name']}'"
end

if bridgeSupportCheckBox.state == NSOnState
f.puts "generate_bridge_support!"
end
}

system "open -a TextEdit '#{path}'"
end
end

#----------------------------------------
def addPod(pod)
arrayController.addObject(pod.dup)
end
end
85 changes: 85 additions & 0 deletions PodCreator/PodSpec.rb
@@ -0,0 +1,85 @@
#
# PodSpec.rb
# PodCreator
#

class PodSpec
attr_accessor :repoButton
attr_accessor :repoTagCombo
attr_accessor :objectController

def create(sender)
objectController.commitEditing
content = objectController.content

panel = NSSavePanel.savePanel
panel.setAllowedFileTypes(["podspec"])
panel.setExtensionHidden(false)
result = panel.runModalForDirectory(NSHomeDirectory(),
file:"")
if(result == NSOKButton)
path = panel.filename
File.open(path, "w") {|f|
@io = f
f.puts "Pod::Spec.new do |s|"

content.keys.each do |k|
case k

when "author_name"
str = "{ '#{content[k]}' "
str += "=> '#{content['author_mail']}' " if content['author_mail'].length > 0
str += "}"
out_spec("author", str)

when "repo_url"
type = repoButton.titleOfSelectedItem
str = "{ :#{type} => '#{content[k]}'"
i = repoTagCombo.indexOfSelectedItem
str += ", :#{repoTagCombo.itemObjectValueAtIndex(i)} => '#{content['repo_tag']}'" if i >= 0
str += " }"
out_spec("source", str)

when "dep_framework"
out_specs("framework", "frameworks", content[k])

when "dep_library"
out_specs("library", "libraries", content[k])

when "source_files"
out_specs("source_files", "source_files", content[k])

when "require_arc"
out_spec(k, content[k].to_s)

when "author_mail", "repo_tag"
# ignore

else
out_spec(k, "'#{content[k]}'")
end
end

f.puts "end"
}

system "open -a TextEdit '#{path}'"
end
end

def out_specs(key_s, key_m, data)
ary = data.split(',')
if ary.size > 1
data = ary.map{ |x| "'#{x.strip}'" }.join(', ')
out_spec(key_m, data)
else
out_spec(key_s, "'#{data.strip}'")
end
end

def out_spec(key, data)
@io.puts " s.#{key} = #{data}"
end

end

0 comments on commit dcba327

Please sign in to comment.