Permalink
Browse files

Snipe from CocoaPods

  • Loading branch information...
0 parents commit a7a028fc6b53f9147b6a073ab9fbb32425a6c7ac @nolanw nolanw committed Nov 11, 2011
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Eloy Durán <eloy.de.enige@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,48 @@
+# xcodeproj
+
+xcodeproj is an Xcode project, workspace, and configuration helper.
+
+
+## Installing xcodeproj
+
+You’ll need MacRuby. xcodeproj itself installs through RubyGems, the Ruby
+package manager. Download and install [version 0.10][macruby] and then perform
+the following command:
+
+ $ sudo macgem install xcodeproj
+
+The load time can be improved a bit by compiling the Ruby source files:
+
+ $ sudo macgem install rubygems-compile
+ $ sudo macgem compile xcodeproj
+
+
+## Contributing
+
+* File [tickets][tickets] for anything you need!
+
+* It'd be nice to support plain Ruby as well as MacRuby. (MacRuby is currently
+ only used for property list (de)serialization and UUID generation.)
+
+
+## Contact
+
+* #cocoapods on `irc.freenode.net` (xcodeproj is borne of CocoaPods.)
+
+Eloy Durán:
+
+* http://github.com/alloy
+* http://twitter.com/alloy
+* eloy.de.enige@gmail.com
+
+
+## LICENSE
+
+These works are available under the MIT license. See the [LICENSE][license] file
+for more info.
+
+
+[macruby]: http://www.macruby.org/files
+[xcodeproj]: https://github.com/alloy/xcodeproj
+[tickets]: https://github.com/alloy/xcodeproj/issues
+[license]: xcodeproj/blob/master/LICENSE
@@ -0,0 +1,62 @@
+desc "Compile the source files (as rbo files)"
+task :compile do
+ Dir.glob("lib/**/*.rb").each do |file|
+ sh "macrubyc #{file} -C -o #{file}o"
+ end
+end
+
+desc "Remove rbo files"
+task :clean do
+ sh "rm -f lib/**/*.rbo"
+ sh "rm -f lib/**/*.o"
+ sh "rm -f *.gem"
+end
+
+desc "Install a gem version of the current code"
+task :install do
+ require 'lib/xcode'
+ sh "gem build xcodeproj.gemspec"
+ sh "sudo macgem install xcodeproj-#{Xcode::VERSION}.gem"
+ sh "sudo macgem compile xcodeproj"
+end
+
+namespace :spec do
+ task :all do
+ sh "macbacon -a"
+ end
+end
+
+desc "Dumps a Xcode project as YAML, meant for diffing"
+task :dump_xcodeproj do
+ require 'yaml'
+ hash = NSDictionary.dictionaryWithContentsOfFile(File.join(ENV['xcodeproj'], 'project.pbxproj'))
+ objects = hash['objects']
+ result = objects.values.map do |object|
+ if children = object['children']
+ object['children'] = children.map do |uuid|
+ child = objects[uuid]
+ child['path'] || child['name']
+ end.sort
+ elsif files = object['files']
+ object['files'] = files.map do |uuid|
+ build_file = objects[uuid]
+ file = objects[build_file['fileRef']]
+ file['path']
+ end
+ elsif file_ref = object['fileRef']
+ file = objects[file_ref]
+ object['file'] = file['path']
+ end
+ object
+ end
+ result.each do |object|
+ object.delete('fileRef')
+ end
+ result = result.sort_by do |object|
+ [object['isa'], object['file'], object['path'], object['name']].compact
+ end
+ puts result.to_yaml
+end
+
+desc "Run all specs"
+task :spec => 'spec:all'
@@ -0,0 +1,7 @@
+module Xcode
+ VERSION = '0.0.1'
+
+ autoload :Config, 'xcodeproj/config'
+ autoload :Project, 'xcodeproj/project'
+ autoload :Workspace, 'xcodeproj/workspace'
+end
@@ -0,0 +1,31 @@
+module Xcode
+ class Config
+ def initialize(xcconfig = {})
+ @attributes = {}
+ merge!(xcconfig)
+ end
+
+ def to_hash
+ @attributes
+ end
+
+ def merge!(xcconfig)
+ xcconfig.to_hash.each do |key, value|
+ if existing_value = @attributes[key]
+ @attributes[key] = "#{existing_value} #{value}"
+ else
+ @attributes[key] = value
+ end
+ end
+ end
+ alias_method :<<, :merge!
+
+ def to_s
+ @attributes.map { |key, value| "#{key} = #{value}" }.join("\n")
+ end
+
+ def save_as(pathname)
+ pathname.open('w') { |file| file << to_s }
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit a7a028f

Please sign in to comment.