Browse files

refactor the workspace parsing to use nokogiri

  • Loading branch information...
1 parent b552a20 commit 2b2265b2783c982b5877c27afbd2e32ac5697569 @siuying committed Apr 11, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/xcode/workspace.rb
View
9 lib/xcode/workspace.rb
@@ -1,4 +1,5 @@
require 'xcode/project'
+require 'nokogiri'
module Xcode
class Workspace
@@ -11,9 +12,11 @@ def initialize(path)
@projects = []
@path = File.expand_path path
- File.open(@path).read.split(/<FileRef/).each do |line|
- if line=~/location\s*=\s*[\"\']group\:(.+?)[\"\']/
- project_path = "#{workspace_root}/#{$1}"
+ doc = Nokogiri::XML(open(@path))
+ doc.search("FileRef").each do |file|
+ location = file["location"]
+ if matcher = location.match(/^group:(.+)$/)
+ project_path = "#{workspace_root}/#{matcher[1]}"
@projects << Xcode::Project.new(project_path)
end
end

0 comments on commit 2b2265b

Please sign in to comment.