Permalink
Browse files

implement PodSpec

  • Loading branch information...
1 parent b191071 commit dcba327d21a27cb73655c7bb184a7c83bb623a8a @Watson1978 committed Nov 22, 2011
Showing with 3,094 additions and 1,206 deletions.
  1. +8 −0 PodCreator.xcodeproj/project.pbxproj
  2. +0 −56 PodCreator/AppDelegate.rb
  3. +65 −0 PodCreator/PodFile.rb
  4. +85 −0 PodCreator/PodSpec.rb
  5. +2,936 −1,150 PodCreator/en.lproj/MainMenu.xib
@@ -17,6 +17,8 @@
A988D41E1477DFDC00878C5C /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41D1477DFDC00878C5C /* rb_main.rb */; };
A988D4201477DFDC00878C5C /* AppDelegate.rb in Resources */ = {isa = PBXBuildFile; fileRef = A988D41F1477DFDC00878C5C /* AppDelegate.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 */; };
/* End PBXBuildFile section */
@@ -44,6 +46,8 @@
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>"; };
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>"; };
/* End PBXFileReference section */
@@ -91,7 +95,9 @@
children = (
A988D4291477E2F100878C5C /* ButtonBarView.rb */,
A988D41F1477DFDC00878C5C /* AppDelegate.rb */,
+ A994BFA2147BC04F00994C85 /* PodFile.rb */,
A90E74BD1478A7F700493C4C /* PodList.rb */,
+ A994BFA0147BC00900994C85 /* PodSpec.rb */,
A988D4181477DFDC00878C5C /* Resources */,
A988D41C1477DFDC00878C5C /* Other Sources */,
A988D4101477DFDB00878C5C /* Supporting Files */,
@@ -204,6 +210,8 @@
A90E74BB1478A7CC00493C4C /* PodList.xib in Resources */,
A90E74BE1478A7F700493C4C /* PodList.rb in Resources */,
A9E35580147937F60002A1A3 /* PodCreator.icns in Resources */,
+ A994BFA1147BC00900994C85 /* PodSpec.rb in Resources */,
+ A994BFA3147BC04F00994C85 /* PodFile.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -4,68 +4,12 @@
#
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)
- @podList = PodList.alloc.init
- @podList.delegate = self
end
def windowWillClose(a_notification)
NSApp.terminate(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
View
@@ -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
View
@@ -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
+
Oops, something went wrong.

0 comments on commit dcba327

Please sign in to comment.