Sha256: cdb2238a0676e3e76e154da35769e81c5e8b96c298cc10079d4dac594bf1ab60

Contents?: true

Size: 729 Bytes

Versions: 6

Compression:

Stored size: 729 Bytes

Contents

module Xcode
  class Project
    class Version < PlistChanger
      attr_reader :major, :minor, :patch

      KEY = 'CFBundleShortVersionString'

      def to_s
        "#{major}.#{minor}.#{patch}".sub(/\.0/, '')
      end

      def set(string)
        if /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/ =~ string
          @major, @minor, @patch = $1.to_i, $2.to_i, $3.to_i
          self
        else
          raise "Can't parse version #{string.inspect}"
        end
      end

      def bump_major
        @major += 1
        @minor, @patch = 0, 0
        self
      end

      def bump_minor
        @minor += 1
        @patch = 0
        self
      end

      def bump_patch
        @patch += 1
        self
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xcode-0.1.6 lib/xcode/project/version.rb
xcode-0.1.5 lib/xcode/project/version.rb
xcode-0.1.4 lib/xcode/project/version.rb
xcode-0.1.3 lib/xcode/project/version.rb
xcode-0.1.2 lib/xcode/project/version.rb
xcode-0.1.1 lib/xcode/project/version.rb