Class: FlutterRb::PubspecParser
- Inherits:
-
Object
- Object
- FlutterRb::PubspecParser
- Defined in:
- lib/flutter_rb/project/specs/flutter/pubspec.rb
Overview
pubspec.yaml parser
Instance Method Summary collapse
- #dev_dependencies(pubspec) ⇒ Object
-
#initialize(path, pubspec) ⇒ PubspecParser
constructor
A new instance of PubspecParser.
- #parse ⇒ Object
- #platform_plugins(pubspec) ⇒ Object
- #pubspec_info(pubspec) ⇒ Object
Constructor Details
#initialize(path, pubspec) ⇒ PubspecParser
Returns a new instance of PubspecParser.
25 26 27 28 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 25 def initialize(path, pubspec) @path = path @pubspec = pubspec end |
Instance Method Details
#dev_dependencies(pubspec) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 49 def dev_dependencies(pubspec) pubspec['dev_dependencies']&.map do |dev_dependency| DevDependency.new( dev_dependency.first, dev_dependency.last ) end end |
#parse ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 30 def parse Pubspec.new( @path, pubspec_info(@pubspec), dev_dependencies(@pubspec), platform_plugins(@pubspec) ) end |
#platform_plugins(pubspec) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 58 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) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/flutter_rb/project/specs/flutter/pubspec.rb', line 39 def pubspec_info(pubspec) PubspecInfo.new( pubspec['name'], pubspec['description'], pubspec['version'], pubspec['author'], pubspec['homepage'] ) end |