Sha256: 88f42b6a2e063c445178f0762678d5d0191023ae511ee6489af35db9e2c6c3a5

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Screengrab
  # In order to share the tool version info between Java and Ruby from one canonical file, we're
  # including version.properties in the bundled Gem, and deriving the version info from it here
  def self.determine_version
    version_props_file = File.join(File.dirname(__FILE__), '../../version.properties')

    # Java tends to write files as UTF-8, so we need to be resilent to the UTF-8 Byte Order Mark
    # being present
    File.open(version_props_file, 'r:bom|utf-8') do |f|
      v = {}

      # This file gets evaluated _before_ the gemspec gets built, we don't have access to loaded
      # 3rd party gems here! Thus, we'll do it simply, by hand.
      f.read.split("\n").each do |line|
        key, val = line.chomp.split('=')
        next if key.nil? || val.nil? || key.empty? || val.empty?
        v[key.strip] = val.strip
      end

      # The value of the block is returned from File.open
      [v['major'], v['minor'], v['patch']].join('.')
    end
  end

  VERSION = determine_version.freeze
  DESCRIPTION = "Automate taking localized screenshots of your Android app on real devices or emulators".freeze
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
screengrab-0.2.0 lib/screengrab/version.rb