Class: FlutterRb::PubspecParser
- Inherits:
-
Object
- Object
- FlutterRb::PubspecParser
- Defined in:
- lib/flutter_rb/project/specs/flutter/pubspec.rb
Overview
This class is responsible for parsing a pubspec.yaml file and creating a Pubspec object.
Instance Method Summary collapse
-
#dev_dependencies(pubspec) ⇒ Array<DevDependency>
Parses the pubspec.yaml file and extracts the dev dependencies.
-
#initialize(path, pubspec) ⇒ PubspecParser
constructor
Initializes a new instance of PubspecParser.
-
#parse ⇒ Pubspec
Parses the pubspec.yaml file and creates a Pubspec object.
-
#platform_plugins(pubspec) ⇒ Array<PlatformPlugin>
Parses the pubspec.yaml file and extracts the platform plugins.
-
#pubspec_info(pubspec) ⇒ PubspecInfo
Parses the pubspec.yaml file and extracts the general information.
Constructor Details
#initialize(path, pubspec) ⇒ PubspecParser
Initializes a new instance of PubspecParser.
50 51 52 53 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 50 def initialize(path, pubspec) @path = path @pubspec = pubspec end |
Instance Method Details
#dev_dependencies(pubspec) ⇒ Array<DevDependency>
Parses the pubspec.yaml file and extracts the dev dependencies.
85 86 87 88 89 90 91 92 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 85 def dev_dependencies(pubspec) pubspec['dev_dependencies']&.map do |dev_dependency| DevDependency.new( dev_dependency.first, dev_dependency.last ) end end |
#parse ⇒ Pubspec
Parses the pubspec.yaml file and creates a Pubspec object.
58 59 60 61 62 63 64 65 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 58 def parse Pubspec.new( @path, pubspec_info(@pubspec), dev_dependencies(@pubspec), platform_plugins(@pubspec) ) end |
#platform_plugins(pubspec) ⇒ Array<PlatformPlugin>
Parses the pubspec.yaml file and extracts the platform plugins.
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 98 def platform_plugins(pubspec) pubspec.dig('flutter', 'plugin', 'platforms')&.map do |platform_plugin| plugin_info = platform_plugin.last PlatformPlugin.new( plugin_info['package'], plugin_info['pluginClass'], platform_plugin.first == Platform::ANDROID ? Platform::ANDROID : Platform::IOS ) end end |
#pubspec_info(pubspec) ⇒ PubspecInfo
Parses the pubspec.yaml file and extracts the general information.
71 72 73 74 75 76 77 78 79 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 71 def pubspec_info(pubspec) PubspecInfo.new( pubspec['name'], pubspec['description'], pubspec['version'], pubspec['author'], pubspec['homepage'] ) end |