class TripAdvisor::AbstractBuild
Attributes
info[R]
path[R]
pod_repo[RW]
remotes[RW]
repo[R]
reporter[RW]
version_prefix[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/trip_advisor/build.rb, line 50 def initialize(path) @path = path @repo = Rugged::Repository.new(path) @info = BuildInfo.new(repo) @pod_repo = 'tripadvisor-mobile-ta-specs' @reporter = ConsoleReporter.new @version_prefix = 'v' end
Public Instance Methods
build!()
click to toggle source
# File lib/trip_advisor/build.rb, line 59 def build! raise "Cannot build a TripAdvisor::AbstractBuild: Only concrete subclasses are buildable." end
commit!(files)
click to toggle source
# File lib/trip_advisor/build.rb, line 106 def commit!(files) say "Committing to #{path}" index = repo.index files.each { |f| index.add f } options = {} options[:tree] = index.write_tree(repo) options[:author] = author options[:committer] = author options[:message] = "Creating build #{version}" options[:parents] = [ repo.head.target ] options[:update_ref] = 'HEAD' Rugged::Commit.create(repo, options) end
pod_update!()
click to toggle source
# File lib/trip_advisor/build.rb, line 81 def pod_update! run("bundle exec pod update") end
podspec_file()
click to toggle source
# File lib/trip_advisor/build.rb, line 63 def podspec_file @podspec_file ||= Dir.entries(path).detect { |f| f =~ /.podspec$/ } end
push!()
click to toggle source
# File lib/trip_advisor/build.rb, line 131 def push! branch = info.branch remotes.each do |remote_name| say "Pushing to remote '#{remote_name}'" # NOTE: Rugged apparently cannot push to the repositories we need # remote = Rugged::Remote.lookup(@repo, remote_name) # remote.push ["refs/heads/#{info.branch}", "refs/tags/#{tag_name}"] run("git push #{remote_name} #{branch}:#{branch} --tags") end end
push_podspec!()
click to toggle source
# File lib/trip_advisor/build.rb, line 142 def push_podspec! run("bundle exec pod repo push --use-libraries --allow-warnings #{pod_repo} #{podspec_file}") end
release_version()
click to toggle source
# File lib/trip_advisor/build.rb, line 85 def release_version File.read(File.join(path, 'VERSION')).chomp end
run(command)
click to toggle source
# File lib/trip_advisor/build.rb, line 75 def run(command) unless system(command) raise "Build failed: Non-zero exit status returned while executing `#{command}`" end end
tag!(target)
click to toggle source
# File lib/trip_advisor/build.rb, line 123 def tag!(target) Rugged::Tag.create(repo, :name => tag_name, :message => "Tagging build #{version}", :target => target, :tagger => author) end
update_build_assets()
click to toggle source
# File lib/trip_advisor/build.rb, line 93 def update_build_assets info.version = version File.open('BUILD.json', 'w') { |f| f << Oj.dump(info.to_hash) } podspec_content = File.read(podspec_file) unless podspec_content.gsub!(/(\.version\s+=\s+)['"](.+)['"]$/, "\\1'#{version}'") raise "Unable to update version of Podspec: version attribute not matched." end unless podspec_content.gsub!(/(\:tag\s+=>\s+)['"](.+)['"]/, "\\1'#{tag_name}'") raise "Unable to update version of Podspec: version attribute not matched." end File.open(podspec_file, 'w') { |f| f << podspec_content } end
update_staging_area(files)
click to toggle source
# File lib/trip_advisor/build.rb, line 146 def update_staging_area(files) run("git add #{files.join(' ')}") end
Protected Instance Methods
say(message)
click to toggle source
# File lib/trip_advisor/build.rb, line 151 def say(message) reporter.say(message) end