class Timewizard::Versioner::Worklight
Represents the Worklight
implementation of the versioner spec. @author Richard Harrah @since 0.1.0
Constants
- SPACE_REGEX
Private functions (implementation specific)
Public Class Methods
new(path_to_file)
click to toggle source
Public functions (inherited from parent)
Calls superclass method
Timewizard::Versioner::Base::new
# File lib/timewizard/versioner/worklight.rb, line 16 def initialize(path_to_file) super path_to_file @file_contents = '' end
Private Instance Methods
change_build_numbers()
click to toggle source
# File lib/timewizard/versioner/worklight.rb, line 78 def change_build_numbers if @file_contents.nil? read_file end if @new_build_number.nil? read_build_numbers end # don't actually want to do anything for build numbers for worklight nil end
change_version_numbers()
click to toggle source
# File lib/timewizard/versioner/worklight.rb, line 89 def change_version_numbers if @file_contents.nil? read_file end if @new_version_number.nil? read_version_numbers end iphone = @file_contents.at_css('application iphone') android = @file_contents.at_css('application android') iphone['version'] = @new_version_number.to_s android['version'] = @new_version_number.to_s end
find_build_and_version_numbers()
click to toggle source
# File lib/timewizard/versioner/worklight.rb, line 52 def find_build_and_version_numbers if @file_contents.nil? read_file end iphone = @file_contents.at_css('application iphone') android = @file_contents.at_css('application android') iphone_version_num = iphone['version'] android_version_num = android['version'] parsed_iphone_num = Versionomy.parse(iphone_version_num, Versionomy::Format.get('rubygems')) parsed_android_num = Versionomy.parse(android_version_num, Versionomy::Format.get('rubygems')) parsed_version_num = parsed_android_num > parsed_iphone_num ? parsed_android_num : parsed_iphone_num @bumped_version_number = parsed_version_num.bump(parsed_version_num.parts.length - 1) obn = parsed_version_num.unparse ovn = parsed_version_num.unparse nbn = parsed_version_num.bump(parsed_version_num.parts.length - 1).unparse nvn = ovn [obn, ovn, nbn, nvn] end
read_file()
click to toggle source
# File lib/timewizard/versioner/worklight.rb, line 28 def read_file if @file.nil? raise 'file is nil and cannot be read' end @file_contents = Nokogiri.XML('') if File.exist?(@file) @file_contents = File.open(@file, 'r+') { |f| Nokogiri.XML(f) } end @file_contents end
write_file()
click to toggle source
# File lib/timewizard/versioner/worklight.rb, line 42 def write_file if @file.nil? raise 'file is nil and cannot be written' end if @file_contents.nil? raise 'file_contents is null and cannot be written' end File.open(@file, 'w') { |f| @file_contents.write_xml_to(f) } end