class Precheck::Rule
Public Class Methods
default_value()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 86 def self.default_value CredentialsManager::AppfileConfig.try_fetch_value(self.key) end
description()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 78 def self.description not_implemented(__method__) end
env_name()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 70 def self.env_name not_implemented(__method__) end
friendly_name()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 82 def self.friendly_name not_implemented(__method__) end
key()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 74 def self.key not_implemented(__method__) end
new(short_option: nil, verify_block: nil, is_string: nil, type: nil, conflicting_options: nil, conflict_block: nil, deprecated: nil, sensitive: nil, display_in_shell: nil)
click to toggle source
Calls superclass method
FastlaneCore::ConfigItem::new
# File precheck/lib/precheck/rule.rb, line 40 def initialize(short_option: nil, verify_block: nil, is_string: nil, type: nil, conflicting_options: nil, conflict_block: nil, deprecated: nil, sensitive: nil, display_in_shell: nil) super(key: self.class.key, env_name: self.class.env_name, description: self.class.description, short_option: short_option, default_value: self.class.default_value, verify_block: verify_block, is_string: is_string, type: type, optional: true, conflicting_options: conflicting_options, conflict_block: conflict_block, deprecated: deprecated, sensitive: sensitive, display_in_shell: display_in_shell) end
Public Instance Methods
check_item(item)
click to toggle source
# File precheck/lib/precheck/rule.rb, line 118 def check_item(item) # validate the item we have was properly matched to this rule: TextItem -> TextRule, URLItem -> URLRule return skip_item_not_meant_for_this_rule(item) unless handle_item?(item) return skip_item_not_meant_for_this_rule(item) unless item_field_supported?(item_name: item.item_name) # do the actual checking now return perform_check(item: item) end
customize_with_data(data: nil)
click to toggle source
some rules can be customized with extra data at runtime, see CustomTextRule
as an example
# File precheck/lib/precheck/rule.rb, line 104 def customize_with_data(data: nil) not_implemented(__method__) end
friendly_name()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 90 def friendly_name return self.class.friendly_name end
handle_item?(item)
click to toggle source
each rule can define what type of ItemToCheck
subclass they support override this method and return true or false
# File precheck/lib/precheck/rule.rb, line 134 def handle_item?(item) not_implemented(__method__) end
inspect()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 94 def inspect "#{self.class}(description: #{@description}, key: #{@key})" end
item_field_supported?(item_name: nil)
click to toggle source
# File precheck/lib/precheck/rule.rb, line 138 def item_field_supported?(item_name: nil) return true if supported_fields_symbol_set.nil? return true if supported_fields_symbol_set.include?(item_name) return false end
needs_customization?()
click to toggle source
some rules can be customized with extra data at runtime, see CustomTextRule
as an example
# File precheck/lib/precheck/rule.rb, line 99 def needs_customization? return false end
perform_check(item: nil)
click to toggle source
# File precheck/lib/precheck/rule.rb, line 144 def perform_check(item: nil) if item.item_data.to_s == "" && item.is_optional # item is optional, and empty, so that's totally fine check_result = RuleReturn.new(validation_state: VALIDATION_STATES[:passed]) return RuleCheckResult.new(item, check_result, self) end check_result = self.rule_block.call(item.item_data) return RuleCheckResult.new(item, check_result, self) end
rule_block()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 114 def rule_block not_implemented(__method__) end
skip_item_not_meant_for_this_rule(item)
click to toggle source
# File precheck/lib/precheck/rule.rb, line 127 def skip_item_not_meant_for_this_rule(item) # item isn't mean for this rule, which is fine, we can just keep passing it along return nil end
supported_fields_symbol_set()
click to toggle source
some rules only support specific fields, by default, all fields are supported unless restricted by providing a list of symbols matching the item_name as defined as the ItemToCheck
is generated
# File precheck/lib/precheck/rule.rb, line 110 def supported_fields_symbol_set return nil end
to_s()
click to toggle source
# File precheck/lib/precheck/rule.rb, line 66 def to_s @key end