Sha256: 1f40fd24247dd457e016c3af74502de88315e04d39f792da45ceb6d119e7b8a7

Contents?: true

Size: 1.59 KB

Versions: 54

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/ruby
require 'plist' # gem install plist
require 'big_stash/stash_operator'
require 'pathname'

module BigKeeper
  # Operator for Info.plist
  class InfoPlistOperator
    def change_version_build(path, version)
      if find_infoPlist_filePath(path) == ''
        raise %(Not find be Info.plist at #{path})
      end
      info_plist_path = find_infoPlist_filePath(path)
      result = Plist.parse_xml(info_plist_path)
      result['CFBundleVersion'] = getBuildVersion(version, result['CFBundleShortVersionString'], result['CFBundleVersion']).to_s
      result['CFBundleShortVersionString'] = version.to_s
      Plist::Emit.save_plist(result, info_plist_path)
      puts %Q('Version has changed to #{version}')
    end

    # Find Info.plist file path
    # @return [String] pathName of info.plist
    def find_infoPlist_filePath(path)
      paths = Pathname.new(path).children.select { |pn| pn.extname == '.xcodeproj' }
      xcodePath = paths[0].to_s.split('/')[-1]
      projectName = xcodePath.split('.')[0]
      projectPath = ''
      Pathname.new("#{path}/#{projectName}").children.select { |pn|
        if pn.to_s == "#{path}/#{projectName}/Info.plist"
          projectPath = "#{path}/#{projectName}/Info.plist"
        end
      }
      projectPath
    end

    private
    def getBuildVersion(build_string, old_build_string, old_build_version)
      if build_string == old_build_string
        return old_build_version.to_i + 1
      else
        version_arr = build_string.split('.')
        return version_arr[0].to_i * 1000 + version_arr[1].to_i * 100 + version_arr[2].to_i * 10
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 4 rubygems

Version Path
shkeeper-1.0.0 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.1.2 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.1.0 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.9 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.8 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.7 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.6 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.5 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.4 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.3 lib/big_keeper/util/info_plist_operator.rb
kookeeper-3.0.0 lib/big_keeper/util/info_plist_operator.rb
kookeeper-2.0.0 lib/big_keeper/util/info_plist_operator.rb
kookeeper-1.0.0 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.21 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.20 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.19 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.18 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.17 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.16 lib/big_keeper/util/info_plist_operator.rb
bigkeeper-0.9.15 lib/big_keeper/util/info_plist_operator.rb