Class: Xcode::Project::Packer
- Inherits:
-
Object
- Object
- Xcode::Project::Packer
- Defined in:
- lib/xcode/project/packer.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(project) ⇒ Packer
constructor
A new instance of Packer.
- #pack ⇒ Object
- #pack_description ⇒ Object
- #pack_path ⇒ Object
- #product_names ⇒ Object
- #products_dir ⇒ Object
- #release ⇒ Object
Constructor Details
#initialize(project) ⇒ Packer
Returns a new instance of Packer.
8 9 10 |
# File 'lib/xcode/project/packer.rb', line 8 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/xcode/project/packer.rb', line 7 def project @project end |
Instance Method Details
#build ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/xcode/project/packer.rb', line 39 def build arguments = %w[xcodebuild] arguments += %W[-project #{project.path}] arguments += %W[-configuration #{project.configuration}] arguments += %w[-nodependencies] arguments += project.variables.map{ |key, value| "#{key}=#{value}" } arguments += %w[clean build] sh *arguments end |
#pack ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/xcode/project/packer.rb', line 50 def pack if pack_path.exist? abort "#{pack_path} already exists" else build arguments = %W[tar -cjf #{pack_path.}] arguments += product_names Dir.chdir products_dir do sh *arguments end end end |
#pack_description ⇒ Object
20 21 22 |
# File 'lib/xcode/project/packer.rb', line 20 def pack_description @pack_description ||= "#{project.name} v#{project.version}" end |
#pack_path ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/xcode/project/packer.rb', line 12 def pack_path @pack_path ||= begin pkg_dir = Pathname('pkg') pkg_dir.mkpath pkg_dir + "#{project.name}-#{project.version}.tbz" end end |
#product_names ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xcode/project/packer.rb', line 24 def product_names [].tap do |names| objects = project.config.root['objects'] objects.each do |_, object| if reference = object['productReference'] names << objects[reference]['path'] end end end end |
#products_dir ⇒ Object
35 36 37 |
# File 'lib/xcode/project/packer.rb', line 35 def products_dir Pathname('build') + project.configuration end |
#release ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/xcode/project/packer.rb', line 65 def release unless `git remote -v` =~ /git@github\.com:([^\/]+)\/(.+?)\.git/ abort 'can\'t find github remote' else login, repos = $1, $2 token = Keychain.items.find{ |item| item.label[/^github.com/] && item.account == "#{login}/token" }.password pack uploader = Net::GitHub::Upload.new(:login => login, :token => token) uploader.upload(:repos => repos, :file => pack_path.to_s, :description => pack_description) end end |