Class: XcodeProject::Project
- Inherits:
-
Object
- Object
- XcodeProject::Project
- Defined in:
- lib/xcodeproject/project.rb
Instance Attribute Summary collapse
-
#bundle_path ⇒ Object
readonly
Returns the value of attribute bundle_path.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #change {|data| ... } ⇒ Object
- #doctor ⇒ Object
-
#initialize(path) ⇒ Project
constructor
A new instance of Project.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(path) ⇒ Project
Returns a new instance of Project.
41 42 43 44 45 46 47 48 |
# File 'lib/xcodeproject/project.rb', line 41 def initialize (path) path = Pathname.new(path) raise FilePathError.new("No such project file '#{path}'.") unless path.exist? @bundle_path = path @file_path = bundle_path.join('project.pbxproj') @name = bundle_path.basename('.*').to_s end |
Instance Attribute Details
#bundle_path ⇒ Object (readonly)
Returns the value of attribute bundle_path.
30 31 32 |
# File 'lib/xcodeproject/project.rb', line 30 def bundle_path @bundle_path end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
31 32 33 |
# File 'lib/xcodeproject/project.rb', line 31 def file_path @file_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/xcodeproject/project.rb', line 32 def name @name end |
Class Method Details
.find(pattern = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/xcodeproject/project.rb', line 34 def self.find (pattern = nil) pattern = Pathname.new(pattern.to_s) pattern = pattern.join('*.xcodeproj') if pattern.extname != '.xcodeproj' Dir[ pattern ].map {|path| self.new(path) } end |
Instance Method Details
#change {|data| ... } ⇒ Object
50 51 52 53 54 |
# File 'lib/xcodeproject/project.rb', line 50 def change data = read yield data write data end |
#doctor ⇒ Object
66 67 68 |
# File 'lib/xcodeproject/project.rb', line 66 def doctor change {|data| data.doctor } end |
#read ⇒ Object
56 57 58 |
# File 'lib/xcodeproject/project.rb', line 56 def read Data.new(JSON.parse(`plutil -convert json -o - "#{file_path}"`), bundle_path.dirname) end |
#write(data) ⇒ Object
60 61 62 63 64 |
# File 'lib/xcodeproject/project.rb', line 60 def write (data) File.open(file_path, "w") do |file| file.write(data.to_plist) end end |