Class: Flutter::Pub::Dependency
- Inherits:
-
Object
- Object
- Flutter::Pub::Dependency
- Defined in:
- lib/cocoapods-embed-flutter/flutter/dependency.rb
Overview
Provides a DSL to describe a flutter dependency. A dependency is defined in ‘pubspec.yaml` in `dependencies` or `dev_dependencies` sections.
Instance Attribute Summary collapse
-
#is_dev_dependency ⇒ Boolean
readonly
If this specification is an app specification.
-
#name ⇒ String
readonly
The name of the dependency.
-
#parent_spec ⇒ Spec
readonly
The parent specification where dependency declared.
-
#requirements ⇒ String, Hash
readonly
The requirements for dependency as declred in parent ‘pubspec`.
Class Method Summary collapse
-
.create_from_hash(hash, parent_spec, dev_dependency = false) ⇒ Array<Dependency>
Returns dependencies from hash declared in ‘dependencies` or `dev_dependencies` section in `pubspec.yaml` file.
Instance Method Summary collapse
-
#initialize(name, requirements, parent_spec, dev_dependency = false) ⇒ Dependency
constructor
A new instance of Dependency.
-
#install ⇒ Concurrent::Promises::Future, Nil
Concurrently install this dependency for the parent project.
-
#local? ⇒ Boolean
If this dependency is a local flutter project.
-
#method_missing(m, *args, &block) ⇒ Object
Allows accessing top level values in dependency requirements, if #requirements type is Hash, i.e.
-
#spec ⇒ Spec
For this dependency if this dependency is a local flutter project.
Constructor Details
#initialize(name, requirements, parent_spec, dev_dependency = false) ⇒ Dependency
Returns a new instance of Dependency.
36 37 38 39 40 41 42 43 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 36 def initialize(name, requirements, parent_spec, dev_dependency = false) raise StandardError, 'A flutter dependency requires a name.' unless name raise StandardError, 'A flutter dependency requires a parent pubspec.' unless parent_spec.is_a?(Flutter::Pub::Spec) @name = name @requirements = requirements @parent_spec = parent_spec @is_dev_dependency = dev_dependency end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
Allows accessing top level values in dependency requirements, if #requirements type is Hash, i.e. path, git etc.
100 101 102 103 104 105 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 100 def method_missing(m, *args, &block) if requirements.is_a?(Hash) && requirements.include?(m.to_s) return requirements[m.to_s] end super.method_missing(m, *args, &block) end |
Instance Attribute Details
#is_dev_dependency ⇒ Boolean (readonly)
Returns If this specification is an app specification.
22 23 24 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 22 def is_dev_dependency @is_dev_dependency end |
#name ⇒ String (readonly)
Returns the name of the dependency.
11 12 13 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 11 def name @name end |
#parent_spec ⇒ Spec (readonly)
Returns the parent specification where dependency declared.
19 20 21 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 19 def parent_spec @parent_spec end |
#requirements ⇒ String, Hash (readonly)
Returns the requirements for dependency as declred in parent ‘pubspec`.
15 16 17 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 15 def requirements @requirements end |
Class Method Details
.create_from_hash(hash, parent_spec, dev_dependency = false) ⇒ Array<Dependency>
Returns dependencies from hash declared in ‘dependencies` or `dev_dependencies` section in `pubspec.yaml` file.
60 61 62 63 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 60 def self.create_from_hash(hash, parent_spec, dev_dependency = false) raise StandardError, 'A flutter dependency requires a parent pubspec.' unless parent_spec.is_a?(Flutter::Pub::Spec) hash.keys.map { |key| Dependency.new(key, hash[key], parent_spec, dev_dependency) } end |
Instance Method Details
#install ⇒ Concurrent::Promises::Future, Nil
Concurrently install this dependency for the parent project.
83 84 85 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 83 def install spec.pub_get if local? end |
#local? ⇒ Boolean
Returns If this dependency is a local flutter project.
67 68 69 |
# File 'lib/cocoapods-embed-flutter/flutter/dependency.rb', line 67 def local? requirements.is_a?(Hash) && requirements.include?('path') end |