flutter_rb 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -8
- data/bin/frb +1 -16
- data/lib/checkstyle_report/checkstyle_report.rb +78 -36
- data/lib/flutter_rb/checks/check.rb +16 -16
- data/lib/flutter_rb/checks/plugin_directories_check.rb +16 -12
- data/lib/flutter_rb/checks/plugin_gradle_check.rb +37 -22
- data/lib/flutter_rb/checks/plugin_podspec_check.rb +78 -47
- data/lib/flutter_rb/checks/plugin_pubspec_check.rb +110 -70
- data/lib/flutter_rb/config/flutter_rb_config.rb +15 -5
- data/lib/flutter_rb/config/flutter_rb_config_initializer.rb +11 -7
- data/lib/flutter_rb/project/project.rb +37 -10
- data/lib/flutter_rb/project/specs/android/android_folder.rb +14 -3
- data/lib/flutter_rb/project/specs/android/gradle.rb +35 -11
- data/lib/flutter_rb/project/specs/flutter/dev_dependency.rb +14 -4
- data/lib/flutter_rb/project/specs/flutter/platform_plugin.rb +24 -6
- data/lib/flutter_rb/project/specs/flutter/pubspec.rb +47 -16
- data/lib/flutter_rb/project/specs/flutter/pubspec_info.rb +27 -7
- data/lib/flutter_rb/project/specs/ios/ios_folder.rb +18 -4
- data/lib/flutter_rb/project/specs/ios/podspec.rb +44 -10
- data/lib/flutter_rb/report/check_report.rb +32 -10
- data/lib/flutter_rb.rb +42 -40
- metadata +16 -2
@@ -10,12 +10,14 @@ require_relative './specs/ios/ios_folder'
|
|
10
10
|
require 'yaml'
|
11
11
|
|
12
12
|
module FlutterRb
|
13
|
-
#
|
13
|
+
# Represents a Flutter project.
|
14
14
|
class Project
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# @param
|
18
|
-
# @param
|
15
|
+
# Initializes a new instance of Project.
|
16
|
+
#
|
17
|
+
# @param path [String] The path to the Flutter project.
|
18
|
+
# @param pubspec [Pubspec] The parsed pubspec of the project.
|
19
|
+
# @param android_folder [AndroidFolder, nil] The parsed Android folder of the project.
|
20
|
+
# @param ios_folder [IOSFolder, nil] The parsed iOS folder of the project.
|
19
21
|
def initialize(path, pubspec, android_folder, ios_folder)
|
20
22
|
@path = path
|
21
23
|
@pubspec = pubspec
|
@@ -23,29 +25,54 @@ module FlutterRb
|
|
23
25
|
@ios_folder = ios_folder
|
24
26
|
end
|
25
27
|
|
26
|
-
|
28
|
+
# Accessor for the path of the project.
|
29
|
+
#
|
30
|
+
# @return [String] The path of the project.
|
31
|
+
attr_accessor :path
|
32
|
+
|
33
|
+
# Accessor for the pubspec of the project.
|
34
|
+
#
|
35
|
+
# @return [Pubspec] The pubspec of the project.
|
36
|
+
attr_accessor :pubspec
|
37
|
+
|
38
|
+
# Accessor for the Android folder of the project.
|
39
|
+
#
|
40
|
+
# @return [AndroidFolder] The Android folder of the project.
|
41
|
+
attr_accessor :android_folder
|
42
|
+
|
43
|
+
# Accessor for the iOS folder of the project.
|
44
|
+
#
|
45
|
+
# @return [IOSFolder] The iOS folder of the project.
|
46
|
+
attr_accessor :ios_folder
|
27
47
|
end
|
28
48
|
|
29
|
-
# Flutter
|
49
|
+
# Class to parse and represent a Flutter project.
|
30
50
|
class ProjectParser
|
31
|
-
#
|
51
|
+
# Initializes a new instance of ProjectParser.
|
52
|
+
#
|
53
|
+
# @param path [String] The path to the Flutter project.
|
32
54
|
def initialize(path)
|
33
55
|
@path = path
|
34
56
|
end
|
35
57
|
|
36
|
-
#
|
58
|
+
# Parses the Flutter project at the given path and returns a Project object.
|
59
|
+
#
|
60
|
+
# @return [Project, nil] A Project object if the project exists and can be parsed, otherwise nil.
|
37
61
|
def project
|
38
62
|
File.exist?("#{@path}/pubspec.yaml") ? parse_project : nil
|
39
63
|
end
|
40
64
|
|
41
65
|
private
|
42
66
|
|
43
|
-
#
|
67
|
+
# Parses the project at the given path and returns a Project object.
|
68
|
+
#
|
69
|
+
# @return [Project] A Project object representing the parsed project.
|
44
70
|
def parse_project
|
45
71
|
pubspec_path = "#{@path}/pubspec.yaml"
|
46
72
|
android_path = "#{@path}/android"
|
47
73
|
ios_path = "#{@path}/ios"
|
48
74
|
pubspec = PubspecParser.new(pubspec_path, YAML.load_file(pubspec_path)).parse
|
75
|
+
|
49
76
|
Project.new(
|
50
77
|
@path,
|
51
78
|
pubspec,
|
@@ -3,14 +3,25 @@
|
|
3
3
|
require_relative './gradle'
|
4
4
|
|
5
5
|
module FlutterRb
|
6
|
-
# Android project
|
6
|
+
# Represents an Android project folder.
|
7
7
|
class AndroidFolder
|
8
|
-
#
|
8
|
+
# Initializes a new instance of AndroidFolder.
|
9
|
+
#
|
10
|
+
# @param path [String] The path to the Android project folder.
|
9
11
|
def initialize(path)
|
10
12
|
@path = path
|
13
|
+
# Parse the Gradle build file and store the parsed data.
|
11
14
|
@gradle = GradleParser.new(@path).parse
|
12
15
|
end
|
13
16
|
|
14
|
-
|
17
|
+
# Returns the path to the Android project folder.
|
18
|
+
#
|
19
|
+
# @return [String] The path to the Android project folder.
|
20
|
+
attr_reader :path
|
21
|
+
|
22
|
+
# Returns the parsed Gradle build file data.
|
23
|
+
#
|
24
|
+
# @return [GradleParser] The parsed Gradle build file data.
|
25
|
+
attr_reader :gradle
|
15
26
|
end
|
16
27
|
end
|
@@ -3,31 +3,55 @@
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module FlutterRb
|
6
|
-
# Gradle
|
6
|
+
# Represents a Gradle project.
|
7
7
|
class Gradle
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Initializes a new Gradle instance.
|
9
|
+
#
|
10
|
+
# @param path [String] The path to the Gradle project.
|
11
|
+
# @param version [String] The version of Gradle being used.
|
10
12
|
def initialize(path, version)
|
11
13
|
@path = path
|
12
14
|
@version = version
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
# Returns the path to the Gradle project.
|
18
|
+
#
|
19
|
+
# @return [String] The path to the Gradle project.
|
20
|
+
attr_reader :path
|
21
|
+
|
22
|
+
# Returns the version of Gradle being used.
|
23
|
+
#
|
24
|
+
# @return [String] The version of Gradle being used.
|
25
|
+
attr_reader :version
|
16
26
|
end
|
17
27
|
|
18
|
-
# Gradle
|
28
|
+
# This class is responsible for parsing Gradle project information.
|
19
29
|
class GradleParser
|
20
|
-
#
|
30
|
+
# Initializes a new GradleParser instance.
|
31
|
+
#
|
32
|
+
# @param path [String] The path to the Gradle project.
|
21
33
|
def initialize(path)
|
22
34
|
@path = path
|
23
35
|
end
|
24
36
|
|
25
|
-
#
|
37
|
+
# Parses the Gradle project information.
|
38
|
+
#
|
39
|
+
# Executes the 'prepareInfo' task in the Gradle project and reads the generated JSON file.
|
40
|
+
# If the JSON file does not exist, it raises an error.
|
41
|
+
#
|
42
|
+
# @return [Gradle] An instance of Gradle with the parsed information.
|
26
43
|
def parse
|
27
|
-
`gradle -p #{@path} -q prepareInfo`
|
28
|
-
|
29
|
-
|
30
|
-
|
44
|
+
`gradle -p #{@path} -q prepareInfo` # Execute the 'prepareInfo' task in the Gradle project
|
45
|
+
info_file_path = "#{@path}/flutter_rb_gradle_plugin_output.json" # Path to the JSON file
|
46
|
+
|
47
|
+
unless File.exist?(info_file_path) # Check if the JSON file exists
|
48
|
+
raise "Could not find Gradle info file at #{info_file_path}" # Raise an error if the JSON file does not exist
|
49
|
+
end
|
50
|
+
|
51
|
+
info_file = File.read info_file_path # Read the JSON file
|
52
|
+
info = JSON.parse info_file # Parse the JSON content
|
53
|
+
|
54
|
+
Gradle.new(@path, info['version']) # Create a new Gradle instance with the parsed information
|
31
55
|
end
|
32
56
|
end
|
33
57
|
end
|
@@ -1,15 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FlutterRb
|
4
|
-
#
|
4
|
+
# Represents a development dependency in a Flutter project.
|
5
5
|
class DevDependency
|
6
|
-
#
|
7
|
-
#
|
6
|
+
# Initializes a new instance of DevDependency.
|
7
|
+
#
|
8
|
+
# @param name [String] The name of the development dependency.
|
9
|
+
# @param version [String] The version of the development dependency.
|
8
10
|
def initialize(name, version)
|
9
11
|
@name = name
|
10
12
|
@version = version
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
# Returns the name of the development dependency.
|
16
|
+
#
|
17
|
+
# @return [String] The name of the development dependency.
|
18
|
+
attr_reader :name
|
19
|
+
|
20
|
+
# Returns the version of the development dependency.
|
21
|
+
#
|
22
|
+
# @return [String] The version of the development dependency.
|
23
|
+
attr_reader :version
|
14
24
|
end
|
15
25
|
end
|
@@ -1,23 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FlutterRb
|
4
|
-
#
|
4
|
+
# Represents a Flutter platform plugin.
|
5
5
|
class PlatformPlugin
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# @param
|
6
|
+
# Initializes a new instance of PlatformPlugin.
|
7
|
+
#
|
8
|
+
# @param platform [String] The platform this plugin is for.
|
9
|
+
# @param package [String] The package name of the plugin.
|
10
|
+
# @param plugin_class [String] The class name of the plugin.
|
9
11
|
def initialize(platform, package, plugin_class)
|
10
12
|
@platform = platform
|
11
13
|
@package = package
|
12
14
|
@plugin_class = plugin_class
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
# Returns the platform this plugin is for.
|
18
|
+
#
|
19
|
+
# @return [String] The platform.
|
20
|
+
attr_reader :platform
|
21
|
+
|
22
|
+
# Returns the package name of the plugin.
|
23
|
+
#
|
24
|
+
# @return [String] The package name.
|
25
|
+
attr_reader :package
|
26
|
+
|
27
|
+
# Returns the class name of the plugin.
|
28
|
+
#
|
29
|
+
# @return [String] The class name.
|
30
|
+
attr_reader :plugin_class
|
16
31
|
end
|
17
32
|
|
18
|
-
#
|
33
|
+
# Represents a platform in Flutter.
|
19
34
|
class Platform
|
35
|
+
# The Android platform constant.
|
20
36
|
ANDROID = 'android'
|
37
|
+
|
38
|
+
# The iOS platform constant.
|
21
39
|
IOS = 'ios'
|
22
40
|
end
|
23
41
|
end
|
@@ -5,12 +5,14 @@ require_relative './dev_dependency'
|
|
5
5
|
require_relative './platform_plugin'
|
6
6
|
|
7
7
|
module FlutterRb
|
8
|
-
# pubspec.yaml
|
8
|
+
# Represents a parsed pubspec.yaml file.
|
9
9
|
class Pubspec
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# @param
|
13
|
-
# @param
|
10
|
+
# Initializes a new instance of Pubspec.
|
11
|
+
#
|
12
|
+
# @param path [String] The path to the pubspec.yaml file.
|
13
|
+
# @param pubspec_info [PubspecInfo] The parsed information from the pubspec.yaml file.
|
14
|
+
# @param dev_dependencies [Array<DevDependency>] An array of parsed dev dependencies.
|
15
|
+
# @param platform_plugins [Array<PlatformPlugin>] An array of parsed platform plugins.
|
14
16
|
def initialize(path, pubspec_info, dev_dependencies, platform_plugins)
|
15
17
|
@path = path
|
16
18
|
@pubspec_info = pubspec_info
|
@@ -18,19 +20,41 @@ module FlutterRb
|
|
18
20
|
@platform_plugins = platform_plugins
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
# Returns the path to the pubspec.yaml file.
|
24
|
+
#
|
25
|
+
# @return [String] The path to the pubspec.yaml file.
|
26
|
+
attr_reader :path
|
27
|
+
|
28
|
+
# Returns the parsed information from the pubspec.yaml file.
|
29
|
+
#
|
30
|
+
# @return [PubspecInfo] The parsed information from the pubspec.yaml file.
|
31
|
+
attr_reader :pubspec_info
|
32
|
+
|
33
|
+
# Returns an array of parsed dev dependencies.
|
34
|
+
#
|
35
|
+
# @return [Array<DevDependency>] An array of parsed dev dependencies.
|
36
|
+
attr_reader :dev_dependencies
|
37
|
+
|
38
|
+
# Returns an array of parsed platform plugins.
|
39
|
+
#
|
40
|
+
# @return [Array<PlatformPlugin>] An array of parsed platform plugins.
|
41
|
+
attr_reader :platform_plugins
|
22
42
|
end
|
23
43
|
|
24
|
-
# pubspec.yaml
|
44
|
+
# This class is responsible for parsing a pubspec.yaml file and creating a Pubspec object.
|
25
45
|
class PubspecParser
|
26
|
-
#
|
27
|
-
#
|
46
|
+
# Initializes a new instance of PubspecParser.
|
47
|
+
#
|
48
|
+
# @param path [String] The path to the pubspec.yaml file.
|
49
|
+
# @param pubspec [Hash] The parsed pubspec.yaml file as a Hash.
|
28
50
|
def initialize(path, pubspec)
|
29
51
|
@path = path
|
30
52
|
@pubspec = pubspec
|
31
53
|
end
|
32
54
|
|
33
|
-
#
|
55
|
+
# Parses the pubspec.yaml file and creates a Pubspec object.
|
56
|
+
#
|
57
|
+
# @return [Pubspec] The parsed Pubspec object.
|
34
58
|
def parse
|
35
59
|
Pubspec.new(
|
36
60
|
@path,
|
@@ -40,8 +64,10 @@ module FlutterRb
|
|
40
64
|
)
|
41
65
|
end
|
42
66
|
|
43
|
-
#
|
44
|
-
#
|
67
|
+
# Parses the pubspec.yaml file and extracts the general information.
|
68
|
+
#
|
69
|
+
# @param pubspec [Hash] The parsed pubspec.yaml file as a Hash.
|
70
|
+
# @return [PubspecInfo] The parsed PubspecInfo object.
|
45
71
|
def pubspec_info(pubspec)
|
46
72
|
PubspecInfo.new(
|
47
73
|
pubspec['name'],
|
@@ -52,8 +78,10 @@ module FlutterRb
|
|
52
78
|
)
|
53
79
|
end
|
54
80
|
|
55
|
-
#
|
56
|
-
#
|
81
|
+
# Parses the pubspec.yaml file and extracts the dev dependencies.
|
82
|
+
#
|
83
|
+
# @param pubspec [Hash] The parsed pubspec.yaml file as a Hash.
|
84
|
+
# @return [Array<DevDependency>] An array of parsed DevDependency objects.
|
57
85
|
def dev_dependencies(pubspec)
|
58
86
|
pubspec['dev_dependencies']&.map do |dev_dependency|
|
59
87
|
DevDependency.new(
|
@@ -63,11 +91,14 @@ module FlutterRb
|
|
63
91
|
end
|
64
92
|
end
|
65
93
|
|
66
|
-
#
|
67
|
-
#
|
94
|
+
# Parses the pubspec.yaml file and extracts the platform plugins.
|
95
|
+
#
|
96
|
+
# @param pubspec [Hash] The parsed pubspec.yaml file as a Hash.
|
97
|
+
# @return [Array<PlatformPlugin>] An array of parsed PlatformPlugin objects.
|
68
98
|
def platform_plugins(pubspec)
|
69
99
|
pubspec.dig('flutter', 'plugin', 'platforms')&.map do |platform_plugin|
|
70
100
|
plugin_info = platform_plugin.last
|
101
|
+
|
71
102
|
PlatformPlugin.new(
|
72
103
|
plugin_info['package'],
|
73
104
|
plugin_info['pluginClass'],
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FlutterRb
|
4
|
-
#
|
4
|
+
# Represents the information contained in a Flutter project's pubspec.yaml file.
|
5
5
|
class PubspecInfo
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# @param
|
9
|
-
# @param
|
10
|
-
# @param
|
6
|
+
# Initializes a new instance of PubspecInfo.
|
7
|
+
#
|
8
|
+
# @param name [String] The name of the Flutter project.
|
9
|
+
# @param description [String] A brief description of the Flutter project.
|
10
|
+
# @param version [String] The version number of the Flutter project.
|
11
|
+
# @param author [String] The author of the Flutter project.
|
12
|
+
# @param homepage [String] The homepage URL of the Flutter project.
|
11
13
|
def initialize(name, description, version, author, homepage)
|
12
14
|
@name = name
|
13
15
|
@description = description
|
@@ -16,6 +18,24 @@ module FlutterRb
|
|
16
18
|
@homepage = homepage
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
# Returns the name of the Flutter project.
|
22
|
+
# @return [String] The name of the Flutter project.
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
# Returns the brief description of the Flutter project.
|
26
|
+
# @return [String] The brief description of the Flutter project.
|
27
|
+
attr_reader :description
|
28
|
+
|
29
|
+
# Returns the version number of the Flutter project.
|
30
|
+
# @return [String] The version number of the Flutter project.
|
31
|
+
attr_reader :version
|
32
|
+
|
33
|
+
# Returns the author of the Flutter project.
|
34
|
+
# @return [String] The author of the Flutter project.
|
35
|
+
attr_reader :author
|
36
|
+
|
37
|
+
# Returns the homepage URL of the Flutter project.
|
38
|
+
# @return [String] The homepage URL of the Flutter project.
|
39
|
+
attr_reader :homepage
|
20
40
|
end
|
21
41
|
end
|
@@ -3,16 +3,30 @@
|
|
3
3
|
require_relative './podspec'
|
4
4
|
|
5
5
|
module FlutterRb
|
6
|
-
# iOS
|
6
|
+
# Represents the iOS folder structure and its associated podspec file.
|
7
7
|
class IOSFolder
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Initializes a new instance of IOSFolder.
|
9
|
+
#
|
10
|
+
# @param path [String] The path to the iOS folder.
|
11
|
+
# @param pubspec [Pubspec] The parsed pubspec information.
|
12
|
+
#
|
13
|
+
# @return [IOSFolder] A new instance of IOSFolder.
|
10
14
|
def initialize(path, pubspec)
|
11
15
|
@path = path
|
16
|
+
# Construct the path to the podspec file.
|
12
17
|
podspec_path = "#{path}/#{pubspec.pubspec_info.name}.podspec"
|
18
|
+
# If the podspec file exists, parse it; otherwise, set @podspec to nil.
|
13
19
|
@podspec = File.exist?(podspec_path) ? PodspecParser.new(podspec_path).parse : nil
|
14
20
|
end
|
15
21
|
|
16
|
-
|
22
|
+
# Returns the path to the iOS folder.
|
23
|
+
#
|
24
|
+
# @return [String] The path to the iOS folder.
|
25
|
+
attr_reader :path
|
26
|
+
|
27
|
+
# Returns the parsed podspec information.
|
28
|
+
#
|
29
|
+
# @return [Podspec, nil] The parsed podspec information, or nil if the podspec file does not exist.
|
30
|
+
attr_reader :podspec
|
17
31
|
end
|
18
32
|
end
|
@@ -3,13 +3,15 @@
|
|
3
3
|
require 'cocoapods'
|
4
4
|
|
5
5
|
module FlutterRb
|
6
|
-
# Podspec
|
6
|
+
# Represents a parsed Podspec file.
|
7
7
|
class Podspec
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# @param
|
11
|
-
# @param
|
12
|
-
# @param
|
8
|
+
# Initializes a new instance of Podspec.
|
9
|
+
#
|
10
|
+
# @param path [String] The path to the Podspec file.
|
11
|
+
# @param name [String] The name of the Podspec.
|
12
|
+
# @param version [String] The version of the Podspec.
|
13
|
+
# @param authors [Array<String>] The authors of the Podspec.
|
14
|
+
# @param source [String] The source of the Podspec.
|
13
15
|
def initialize(path, name, version, authors, source)
|
14
16
|
@path = path
|
15
17
|
@name = name
|
@@ -18,19 +20,51 @@ module FlutterRb
|
|
18
20
|
@source = source
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
# Returns the path to the Podspec file.
|
24
|
+
#
|
25
|
+
# @return [String] The path to the Podspec file.
|
26
|
+
attr_reader :path
|
27
|
+
|
28
|
+
# Returns the name of the Podspec.
|
29
|
+
#
|
30
|
+
# @return [String] The name of the Podspec.
|
31
|
+
attr_reader :name
|
32
|
+
|
33
|
+
# Returns the version of the Podspec.
|
34
|
+
#
|
35
|
+
# @return [String] The version of the Podspec.
|
36
|
+
attr_reader :version
|
37
|
+
|
38
|
+
# Returns the authors of the Podspec.
|
39
|
+
#
|
40
|
+
# @return [Array<String>] The authors of the Podspec.
|
41
|
+
attr_reader :authors
|
42
|
+
|
43
|
+
# Returns the source of the Podspec.
|
44
|
+
#
|
45
|
+
# @return [String] The source of the Podspec.
|
46
|
+
attr_reader :source
|
22
47
|
end
|
23
48
|
|
24
|
-
# Podspec
|
49
|
+
# Represents a parser for Podspec files.
|
25
50
|
class PodspecParser
|
26
|
-
#
|
51
|
+
# Initializes a new instance of PodspecParser.
|
52
|
+
#
|
53
|
+
# @param path [String] The path to the Podspec file to be parsed.
|
27
54
|
def initialize(path)
|
28
55
|
@path = path
|
29
56
|
end
|
30
57
|
|
31
|
-
#
|
58
|
+
# Parses the Podspec file at the given path and returns a Podspec object.
|
59
|
+
#
|
60
|
+
# @return [Podspec] A Podspec object representing the parsed Podspec file.
|
61
|
+
#
|
62
|
+
# @raise [Pod::DSLError] If there is an error parsing the Podspec file.
|
32
63
|
def parse
|
64
|
+
# Parse the Podspec file using CocoaPods' Pod::Specification.
|
33
65
|
podspec = Pod::Specification.from_file(@path)
|
66
|
+
|
67
|
+
# Create a new Podspec object with the parsed data.
|
34
68
|
@podspec = Podspec.new(
|
35
69
|
@path,
|
36
70
|
podspec.name,
|
@@ -4,11 +4,14 @@ require 'colorize'
|
|
4
4
|
|
5
5
|
module FlutterRb
|
6
6
|
# Check report
|
7
|
+
# Represents a report for a specific check.
|
7
8
|
class CheckReport
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# @param
|
11
|
-
# @param
|
9
|
+
# Initializes a new instance of CheckReport.
|
10
|
+
#
|
11
|
+
# @param check_name [String] The name of the check.
|
12
|
+
# @param check_report_status [String] The status of the check report.
|
13
|
+
# @param message [String] The message associated with the check report.
|
14
|
+
# @param path [String] The path associated with the check report.
|
12
15
|
def initialize(check_name, check_report_status, message, path)
|
13
16
|
@check_name = check_name
|
14
17
|
@check_report_status = check_report_status
|
@@ -16,8 +19,10 @@ module FlutterRb
|
|
16
19
|
@path = path
|
17
20
|
end
|
18
21
|
|
19
|
-
#
|
20
|
-
#
|
22
|
+
# Prints the check report.
|
23
|
+
#
|
24
|
+
# @param colorize [Bool] Whether to colorize the output or not. Default is true.
|
25
|
+
# @return [String] The formatted check report.
|
21
26
|
def print(colorize: true)
|
22
27
|
if colorize
|
23
28
|
status_color = color_for_report_status(@check_report_status)
|
@@ -27,8 +32,10 @@ module FlutterRb
|
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
#
|
31
|
-
#
|
35
|
+
# Determines the color for the check report status.
|
36
|
+
#
|
37
|
+
# @param check_report_status [CheckReportStatus] The status of the check report.
|
38
|
+
# @return [Symbol] The color associated with the check report status.
|
32
39
|
def color_for_report_status(check_report_status)
|
33
40
|
case check_report_status
|
34
41
|
when CheckReportStatus::NORMAL
|
@@ -42,13 +49,28 @@ module FlutterRb
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
|
-
|
52
|
+
# Reader for check_name attribute.
|
53
|
+
attr_reader :check_name
|
54
|
+
|
55
|
+
# Reader for check_report_status attribute.
|
56
|
+
attr_reader :check_report_status
|
57
|
+
|
58
|
+
# Reader for message attribute.
|
59
|
+
attr_reader :message
|
60
|
+
|
61
|
+
# Reader for path attribute.
|
62
|
+
attr_reader :path
|
46
63
|
end
|
47
64
|
|
48
|
-
#
|
65
|
+
# Represents the status of a check report.
|
49
66
|
class CheckReportStatus
|
67
|
+
# Constant representing a normal status.
|
50
68
|
NORMAL = 'normal'
|
69
|
+
|
70
|
+
# Constant representing a warning status.
|
51
71
|
WARNING = 'warning'
|
72
|
+
|
73
|
+
# Constant representing an error status.
|
52
74
|
ERROR = 'error'
|
53
75
|
end
|
54
76
|
end
|