Class: FlutterRb::GradleParser
- Inherits:
-
Object
- Object
- FlutterRb::GradleParser
- Defined in:
- lib/flutter_rb/project/specs/android/gradle.rb
Overview
This class is responsible for parsing Gradle project information.
Instance Method Summary collapse
-
#initialize(path) ⇒ GradleParser
constructor
Initializes a new GradleParser instance.
-
#parse ⇒ Gradle
Parses the Gradle project information.
Constructor Details
#initialize(path) ⇒ GradleParser
Initializes a new GradleParser instance.
33 34 35 |
# File 'lib/flutter_rb/project/specs/android/gradle.rb', line 33 def initialize(path) @path = path end |
Instance Method Details
#parse ⇒ Gradle
Parses the Gradle project information.
Executes the ‘prepareInfo’ task in the Gradle project and reads the generated JSON file. If the JSON file does not exist, it raises an error.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/flutter_rb/project/specs/android/gradle.rb', line 43 def parse `gradle -p #{@path} -q prepareInfo` # Execute the 'prepareInfo' task in the Gradle project info_file_path = "#{@path}/flutter_rb_gradle_plugin_output.json" # Path to the JSON file unless File.exist?(info_file_path) # Check if the JSON file exists raise "Could not find Gradle info file at #{info_file_path}" # Raise an error if the JSON file does not exist end info_file = File.read info_file_path # Read the JSON file info = JSON.parse info_file # Parse the JSON content Gradle.new(@path, info['version']) # Create a new Gradle instance with the parsed information end |