Class: Timewizard::Versioner::Apple
- Inherits:
-
Object
- Object
- Timewizard::Versioner::Apple
- Defined in:
- lib/timewizard/versioner/apple.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#new_build_number ⇒ Object
Returns the value of attribute new_build_number.
-
#new_bundle_version ⇒ Object
Returns the value of attribute new_bundle_version.
-
#old_build_number ⇒ Object
readonly
Returns the value of attribute old_build_number.
-
#old_bundle_version ⇒ Object
readonly
Returns the value of attribute old_bundle_version.
-
#plists ⇒ Object
readonly
Returns the value of attribute plists.
-
#proj ⇒ Object
readonly
Returns the value of attribute proj.
Instance Method Summary collapse
- #change_build_number(versions, change_to = '-1') ⇒ Object
- #change_bundle_version(versions, change_to = '-1') ⇒ Object
- #find_build_number(lists) ⇒ Object
- #find_bundle_and_build_version(lists) ⇒ Object
- #find_bundle_version(lists) ⇒ Object
- #find_plists ⇒ Object
- #find_xcode_project ⇒ Object
-
#initialize(dir) ⇒ Apple
constructor
A new instance of Apple.
- #write_plists(versions) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Apple
Returns a new instance of Apple.
17 18 19 20 21 |
# File 'lib/timewizard/versioner/apple.rb', line 17 def initialize(dir) @dir = dir @proj = nil @plists = [] end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
9 10 11 |
# File 'lib/timewizard/versioner/apple.rb', line 9 def dir @dir end |
#new_build_number ⇒ Object
Returns the value of attribute new_build_number.
15 16 17 |
# File 'lib/timewizard/versioner/apple.rb', line 15 def new_build_number @new_build_number end |
#new_bundle_version ⇒ Object
Returns the value of attribute new_bundle_version.
14 15 16 |
# File 'lib/timewizard/versioner/apple.rb', line 14 def new_bundle_version @new_bundle_version end |
#old_build_number ⇒ Object (readonly)
Returns the value of attribute old_build_number.
13 14 15 |
# File 'lib/timewizard/versioner/apple.rb', line 13 def old_build_number @old_build_number end |
#old_bundle_version ⇒ Object (readonly)
Returns the value of attribute old_bundle_version.
12 13 14 |
# File 'lib/timewizard/versioner/apple.rb', line 12 def old_bundle_version @old_bundle_version end |
#plists ⇒ Object (readonly)
Returns the value of attribute plists.
11 12 13 |
# File 'lib/timewizard/versioner/apple.rb', line 11 def plists @plists end |
#proj ⇒ Object (readonly)
Returns the value of attribute proj.
10 11 12 |
# File 'lib/timewizard/versioner/apple.rb', line 10 def proj @proj end |
Instance Method Details
#change_build_number(versions, change_to = '-1') ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/timewizard/versioner/apple.rb', line 77 def change_build_number(versions, change_to = '-1') if change_to == '-1' ver = Timewizard::Utils::Wizardry.only_version @old_build_number.to_s parsed = Versionomy.parse(ver, Versionomy::Format.get('rubygems')) parsed = parsed.bump(parsed.parts.length - 1) versions[1] = parsed.unparse @new_build_number = versions[1] else ver = Timewizard::Utils::Wizardry.only_version change_to parsed = Versionomy.parse ver versions[1] = parsed.unparse @new_build_number = versions[1] end versions end |
#change_bundle_version(versions, change_to = '-1') ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/timewizard/versioner/apple.rb', line 65 def change_bundle_version(versions, change_to = '-1') unless change_to != '-1' @new_bundle_version = versions[0] versions end ver = Timewizard::Utils::Wizardry.only_version change_to parsed = Versionomy.parse(ver, Versionomy::Format.get('rubygems')) versions[0] = parsed.unparse @new_bundle_version = versions[0] versions end |
#find_build_number(lists) ⇒ Object
61 62 63 |
# File 'lib/timewizard/versioner/apple.rb', line 61 def find_build_number(lists) find_bundle_and_build_version(lists)[1] end |
#find_bundle_and_build_version(lists) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/timewizard/versioner/apple.rb', line 93 def find_bundle_and_build_version(lists) versions = [] for list in lists do list_hash = Xcodeproj::PlistHelper.read list versions[0] ||= list_hash["CFBundleShortVersionString"] versions[1] ||= list_hash["CFBundleVersion"] @old_bundle_version = versions[0] @old_build_number = versions[1] end versions end |
#find_bundle_version(lists) ⇒ Object
57 58 59 |
# File 'lib/timewizard/versioner/apple.rb', line 57 def find_bundle_version(lists) find_bundle_and_build_version(lists)[0] end |
#find_plists ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/timewizard/versioner/apple.rb', line 40 def find_plists() if @proj.nil? raise "there is no .xcodeproj" end directory = File.dirname(@proj.to_s) unless Dir.exist?(directory) raise "proj is not in a directory" end @plists = [] Find.find(directory) do |p| if /^.*Info\.plist$/ =~ p @plists << p end end @plists end |
#find_xcode_project ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/timewizard/versioner/apple.rb', line 23 def find_xcode_project() if @dir.nil? raise "directory cannot be nil" end if @dir.end_with? ".xcodeproj" @proj = File.absolute_path(@dir) else Find.find(@dir) do |path| unless path.to_s.end_with? ".xcodeproj" next end @proj = path end end @proj end |
#write_plists(versions) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/timewizard/versioner/apple.rb', line 106 def write_plists(versions) for list in @plists do list_hash = Xcodeproj::PlistHelper.read list list_hash["CFBundleShortVersionString"] = versions[0] || list_hash["CFBundleShortVersionString"] list_hash["CFBundleVersion"] = versions[0] || list_hash["CFBundleVersion"] Xcodeproj::PlistHelper.write(list_hash, list) end end |