Class: FlossFunding::Inclusion
- Inherits:
-
Object
- Object
- FlossFunding::Inclusion
- Includes:
- FileFinder
- Defined in:
- lib/floss_funding/inclusion.rb
Overview
Represents the runtime inclusion context for a given inclusion of FlossFunding.
Encapsulates discovery (Namespace, Library), activation state, and the
ActivationEvent generated from an include site.
Instance Attribute Summary collapse
-
#activation_key ⇒ String
readonly
-
#base ⇒ Module
readonly
-
#config_data ⇒ Hash
readonly
-
#config_path ⇒ String?
readonly
-
#configuration ⇒ FlossFunding::Configuration
readonly
-
#custom_namespace ⇒ String?
readonly
-
#event ⇒ FlossFunding::ActivationEvent
readonly
-
#including_path ⇒ String
readonly
-
#library ⇒ FlossFunding::Library
readonly
-
#library_name ⇒ String
readonly
-
#library_root_path ⇒ String
readonly
-
#name ⇒ String
readonly
-
#namespace ⇒ FlossFunding::Namespace
readonly
-
#options ⇒ Hash
readonly
-
#silent ⇒ #call?
readonly
-
#state ⇒ String
readonly
Instance Method Summary collapse
-
#initialize(base, custom_namespace, including_path, options = {}) ⇒ Inclusion
constructor
Build an Inclusion and register its activation event.
Methods included from FileFinder
#find_file_upwards, #find_last_file_upwards, root_level=, root_level?
Constructor Details
#initialize(base, custom_namespace, including_path, options = {}) ⇒ Inclusion
Build an Inclusion and register its activation event.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/floss_funding/inclusion.rb', line 50 def initialize(base, custom_namespace, including_path, = {}) @options = .dup @base = base @including_path = including_path @silent = @options.delete(:silent) @config_path = @options.delete(:config_path) # Assign early so validation sees the actual provided value @custom_namespace = custom_namespace validate_inputs! @name = if custom_namespace.is_a?(String) && !custom_namespace.empty? @custom_namespace = custom_namespace else @base_name = base.name end ### NAMESPACE (not frozen!) ### @namespace = FlossFunding::Namespace.new(@name, base) @activation_key = @namespace.activation_key @state = @namespace.state reason = discover_library_root_path raise ::FlossFunding::Error, "Missing library root path due to: #{reason}" unless @library_root_path if @config_path discover_config_path else discover_config_path_from_library_root end # Derive config data from @config_path by parsing .floss_funding.yml. data_from_config_file validate_config_data @library_name = @config_data["library_name"].first ### CONFIGURATION (frozen object!) ### @configuration = FlossFunding::Configuration.new(@config_data) ### LIBRARY (frozen object!) ### @library = ::FlossFunding::Library.new( @library_name, @namespace, @custom_namespace, @base_name, @including_path, @library_root_path, @config_path, @namespace.env_var_name, @configuration, @silent, ) ### ACTIVATION EVENT (frozen object!) ### @event = ::FlossFunding::ActivationEvent.new( @library, @activation_key, @state, @silent, ) FlossFunding.add_or_update_namespace_with_event(@namespace, @event) FlossFunding.initiate_begging(@event) end |
Instance Attribute Details
#activation_key ⇒ String (readonly)
29 30 31 |
# File 'lib/floss_funding/inclusion.rb', line 29 def activation_key @activation_key end |
#base ⇒ Module (readonly)
11 12 13 |
# File 'lib/floss_funding/inclusion.rb', line 11 def base @base end |
#config_data ⇒ Hash (readonly)
39 40 41 |
# File 'lib/floss_funding/inclusion.rb', line 39 def config_data @config_data end |
#config_path ⇒ String? (readonly)
37 38 39 |
# File 'lib/floss_funding/inclusion.rb', line 37 def config_path @config_path end |
#configuration ⇒ FlossFunding::Configuration (readonly)
41 42 43 |
# File 'lib/floss_funding/inclusion.rb', line 41 def configuration @configuration end |
#custom_namespace ⇒ String? (readonly)
19 20 21 |
# File 'lib/floss_funding/inclusion.rb', line 19 def custom_namespace @custom_namespace end |
#event ⇒ FlossFunding::ActivationEvent (readonly)
33 34 35 |
# File 'lib/floss_funding/inclusion.rb', line 33 def event @event end |
#including_path ⇒ String (readonly)
13 14 15 |
# File 'lib/floss_funding/inclusion.rb', line 13 def including_path @including_path end |
#library ⇒ FlossFunding::Library (readonly)
27 28 29 |
# File 'lib/floss_funding/inclusion.rb', line 27 def library @library end |
#library_name ⇒ String (readonly)
17 18 19 |
# File 'lib/floss_funding/inclusion.rb', line 17 def library_name @library_name end |
#library_root_path ⇒ String (readonly)
15 16 17 |
# File 'lib/floss_funding/inclusion.rb', line 15 def library_root_path @library_root_path end |
#name ⇒ String (readonly)
23 24 25 |
# File 'lib/floss_funding/inclusion.rb', line 23 def name @name end |
#namespace ⇒ FlossFunding::Namespace (readonly)
25 26 27 |
# File 'lib/floss_funding/inclusion.rb', line 25 def namespace @namespace end |
#options ⇒ Hash (readonly)
35 36 37 |
# File 'lib/floss_funding/inclusion.rb', line 35 def @options end |
#silent ⇒ #call? (readonly)
21 22 23 |
# File 'lib/floss_funding/inclusion.rb', line 21 def silent @silent end |
#state ⇒ String (readonly)
31 32 33 |
# File 'lib/floss_funding/inclusion.rb', line 31 def state @state end |