11require 'cocoapods-embed-flutter/gem_version'
22require 'cocoapods-embed-flutter/flutter/pubspec'
33
4- module CocoapodsEmbedFlutter
5- module FlutterModule
6- def flutter_module ( name = nil , *requirements )
7- raise StandardError , 'A flutter module requires a name.' unless name
4+ module Pod
5+ class Podfile
6+ module DSL
7+ def flutter_module ( name = nil , *requirements )
8+ raise StandardError , 'A flutter module requires a name.' unless name
89
9- options = requirements . last
10- raise StandardError , "No options for flutter module: '#{ name } '." unless options . is_a? ( Hash )
10+ options = requirements . last
11+ raise StandardError , "No options for flutter module: '#{ name } '." unless options . is_a? ( Hash )
1112
12- path = options [ :path ]
13- raise StandardError , "No path for flutter module: '#{ name } '." unless path
13+ path = options [ :path ]
14+ raise StandardError , "No path for flutter module: '#{ name } '." unless path
1415
15- path = File . expand_path ( path , Dir . pwd )
16- if File . basename ( path ) == Flutter ::PUBSPEC_FILENAME
17- pubspec = Flutter ::PubSpec . new ( path )
18- raise StandardError , "Invalid pubspec path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
19- path = File . dirname ( path )
20- elsif Dir . exists? ( File . expand_path ( name , path ) ) && File . exists? ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , File . expand_path ( name , path ) ) )
21- module_path = File . expand_path ( name , path )
22- pubspec = Flutter ::PubSpec . new ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , module_path ) )
23- raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
24- path = module_path
25- elsif File . exists? ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , path ) )
26- pubspec = Flutter ::PubSpec . new ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , path ) )
27- raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
28- else
29- raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '."
30- end
16+ path = File . expand_path ( path , Dir . pwd )
17+ if File . basename ( path ) == Flutter ::PUBSPEC_FILENAME
18+ pubspec = Flutter ::PubSpec . new ( path )
19+ raise StandardError , "Invalid pubspec path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
20+ path = File . dirname ( path )
21+ elsif Dir . exists? ( File . expand_path ( name , path ) ) && File . exists? ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , File . expand_path ( name , path ) ) )
22+ module_path = File . expand_path ( name , path )
23+ pubspec = Flutter ::PubSpec . new ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , module_path ) )
24+ raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
25+ path = module_path
26+ elsif File . exists? ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , path ) )
27+ pubspec = Flutter ::PubSpec . new ( File . expand_path ( Flutter ::PUBSPEC_FILENAME , path ) )
28+ raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '." unless pubspec . name == name
29+ else
30+ raise StandardError , "Invalid path: '#{ path } ' for flutter module: '#{ name } '."
31+ end
3132
32- pubspec . setup
33- raise StandardError , "Invalid flutter module: '#{ name } '." unless File . exists? ( pubspec . pod_helper_path )
33+ pubspec . setup
34+ raise StandardError , "Invalid flutter module: '#{ name } '." unless File . exists? ( pubspec . pod_helper_path )
3435
35- load pubspec . pod_helper_path
36- install_all_flutter_pods ( path )
37- end
38- end
39-
40- # Registers for CocoaPods plugin hooks
41- module Hooks
42- Pod ::HooksManager . register ( CocoapodsEmbedFlutter ::NAME , :post_install ) do |installer , options |
43- # Do nothing
36+ load pubspec . pod_helper_path
37+ install_all_flutter_pods ( path )
38+ end
4439 end
4540 end
4641end
0 commit comments