Class: FlutterRb::FlutterRbConfigInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/flutter_rb/config/flutter_rb_config_initializer.rb

Overview

This class is responsible for initializing a FlutterRbConfig object.

Constant Summary collapse

FLUTTER_CHECKS =

An array of Flutter checks to be performed.

[
  PluginDirectoriesCheck.new,
  PluginPubspecNameCheck.new,
  PluginPubspecDescriptionCheck.new,
  PluginPubspecVersionCheck.new,
  PluginPubspecAuthorCheck.new,
  PluginPubspecHomepageCheck.new,
  PluginPubspecLintsCheck.new,
  PluginPubspecFlutterLintsCheck.new
].freeze
ANDROID_CHECKS =

An array of Android checks to be performed.

[
  PluginGradleAndroidPackageCheck.new,
  PluginGradleVersionCheck.new
].freeze
IOS_CHECKS =

An array of iOS checks to be performed.

[
  PluginPodspecNameCheck.new,
  PluginPodspecVersionCheck.new,
  PluginPodspecAuthorsCheck.new,
  PluginPodspecSourceCheck.new
].freeze

Instance Method Summary collapse

Instance Method Details

#defaultFlutterRbConfig

Initializes a FlutterRbConfig object with the default checks.

Returns:

  • (FlutterRbConfig)

    A FlutterRbConfig object initialized with the default checks.



74
75
76
77
78
79
80
# File 'lib/flutter_rb/config/flutter_rb_config_initializer.rb', line 74

def default
  FlutterRbConfig.new(
    FLUTTER_CHECKS,
    ANDROID_CHECKS,
    IOS_CHECKS
  )
end

#parse(path) ⇒ FlutterRbConfig

Parses a YAML configuration file and initializes a FlutterRbConfig object.

Parameters:

  • path (String)

    The path to the YAML configuration file.

Returns:

  • (FlutterRbConfig)

    A FlutterRbConfig object initialized with the parsed configuration.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/flutter_rb/config/flutter_rb_config_initializer.rb', line 41

def parse(path)
  config = YAML.load_file(path)

  exclude_flutter_checks = ::Set.new
  exclude_android_checks = ::Set.new
  exclude_ios_checks = ::Set.new

  unless config.nil?
    exclude_checks = YAML.load_file(path)['exclude']

    unless exclude_checks['flutter'].nil?
      exclude_flutter_checks += exclude_checks['flutter'].map { |check| "FlutterRb::#{check}" }
    end

    unless exclude_checks['android'].nil?
      exclude_android_checks += exclude_checks['android'].map { |check| "FlutterRb::#{check}" }
    end

    unless exclude_checks['ios'].nil?
      exclude_ios_checks += exclude_checks['ios'].map { |check| "FlutterRb::#{check}" }
    end
  end

  FlutterRbConfig.new(
    FLUTTER_CHECKS.reject { |check| exclude_flutter_checks&.include?(check.class.name) },
    ANDROID_CHECKS.reject { |check| exclude_android_checks&.include?(check.class.name) },
    IOS_CHECKS.reject { |check| exclude_ios_checks&.include?(check.class.name) }
  )
end