Class: Fastlane::FirebaseDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, version:, orientation:, locale: 'en') ⇒ FirebaseDevice

Returns a new instance of FirebaseDevice.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 5

def initialize(model:, version:, orientation:, locale: 'en')
  raise 'Invalid Model' unless FirebaseDevice.valid_model_names.include? model
  raise 'Invalid Version' unless FirebaseDevice.valid_version_numbers.include? version
  raise 'Invalid Locale' unless FirebaseDevice.valid_locales.include? locale
  raise 'Invalid Orientation' unless FirebaseDevice.valid_orientations.include? orientation

  @model = model
  @version = version
  @locale = locale
  @orientation = orientation
end

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale.



3
4
5
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 3

def locale
  @locale
end

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 3

def model
  @model
end

#orientationObject (readonly)

Returns the value of attribute orientation.



3
4
5
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 3

def orientation
  @orientation
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 3

def version
  @version
end

Class Method Details

.locale_dataObject



42
43
44
45
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 42

def locale_data
  FirebaseDevice.verify_logged_in!
  @locale_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'locales', 'list', '--format="json"', log: false)
end

.model_dataObject



47
48
49
50
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 47

def model_data
  FirebaseDevice.verify_logged_in!
  @model_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'models', 'list', '--format="json"', log: false)
end

.valid_localesObject



34
35
36
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 34

def valid_locales
  JSON.parse(locale_data).map { |locale| locale['id'] }
end

.valid_model_namesObject



26
27
28
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 26

def valid_model_names
  JSON.parse(model_data).map { |device| device['codename'] }
end

.valid_orientationsObject



38
39
40
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 38

def valid_orientations
  %w[portrait landscape]
end

.valid_version_numbersObject



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 30

def valid_version_numbers
  JSON.parse(version_data).map { |version| version['apiLevel'].to_i }
end

.verify_logged_in!Object



57
58
59
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 57

def verify_logged_in!
  UI.user_error!('You must call `firebase_login` before creating a FirebaseDevice object') unless FirebaseAccount.authenticated?
end

.version_dataObject



52
53
54
55
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 52

def version_data
  FirebaseDevice.verify_logged_in!
  @version_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'versions', 'list', '--format="json"', log: false)
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb', line 17

def to_s
  "model=#{@model},version=#{@version},locale=#{@locale},orientation=#{@orientation}"
end