foobara 0.0.63 → 0.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/projects/domain/src/domain_module_extension.rb +21 -9
- data/projects/domain_mapper/src/domain_mapper.rb +4 -0
- data/projects/domain_mapper/src/domain_mapper_lookups.rb +6 -0
- data/projects/enumerated/src/values.rb +1 -1
- data/projects/namespace/src/is_namespace.rb +4 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 57076f6987a22c895a9ce9b024b2a7e05ffcaa5d96719dedc168cb029404a185
         | 
| 4 | 
            +
              data.tar.gz: b1616575b7778d1ff2597a4c208fda89e544dbe77f3bf0a1ee724c6d5e753aae
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bfb5adcce767f972f766372d23a473ca5598eb281809b5ee64a62e4a08265326e8aae3c6a6698be9cb3a1dedf87f8e32e33bd75a416181fcca7c2cdce2c0d05a
         | 
| 7 | 
            +
              data.tar.gz: b2654dadfc19dda6fa4019715ede5b7ad0bc06e17232dff595cdeeff6ddfdd0da2bbf5e7df42b2f63d66a5ba56eed4d38d6c4e6dffcf2823ca001ac7ddd8a0dc
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,9 @@ | |
| 1 | 
            +
            ## [0.0.64] - 2025-02-25
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            - Fix bug where DomainMappers created after commands have ran wouldn't be detected
         | 
| 4 | 
            +
            - Expose Enumerated::Values#value?
         | 
| 5 | 
            +
            - Allow passing a hash to DomainMapper#new
         | 
| 6 | 
            +
             | 
| 1 7 | 
             
            ## [0.0.63] - 2025-02-25
         | 
| 2 8 |  | 
| 3 9 | 
             
            - Allow creating an Enumerated from a list of value strings that contain colons
         | 
| @@ -133,7 +133,25 @@ module Foobara | |
| 133 133 | 
             
                      super
         | 
| 134 134 | 
             
                    end
         | 
| 135 135 |  | 
| 136 | 
            -
                    def foobara_domain_map( | 
| 136 | 
            +
                    def foobara_domain_map(*args, to: nil, strict: false, criteria: nil, should_raise: false, **opts)
         | 
| 137 | 
            +
                      case args.size
         | 
| 138 | 
            +
                      when 1
         | 
| 139 | 
            +
                        value = args.first
         | 
| 140 | 
            +
                      when 0
         | 
| 141 | 
            +
                        if opts.empty?
         | 
| 142 | 
            +
                          # :nocov:
         | 
| 143 | 
            +
                          raise ArgumentError, "Expected at least one argument"
         | 
| 144 | 
            +
                          # :nocov:
         | 
| 145 | 
            +
                        else
         | 
| 146 | 
            +
                          value = opts
         | 
| 147 | 
            +
                          opts = {}
         | 
| 148 | 
            +
                        end
         | 
| 149 | 
            +
                      else
         | 
| 150 | 
            +
                        # :nocov:
         | 
| 151 | 
            +
                        raise ArgumentError, "Expected 1 argument but got #{args.size}"
         | 
| 152 | 
            +
                        # :nocov:
         | 
| 153 | 
            +
                      end
         | 
| 154 | 
            +
             | 
| 137 155 | 
             
                      invalid_keys = opts.keys - [:from]
         | 
| 138 156 |  | 
| 139 157 | 
             
                      if invalid_keys.any?
         | 
| @@ -145,17 +163,11 @@ module Foobara | |
| 145 163 | 
             
                      from = if opts.key?(:from)
         | 
| 146 164 | 
             
                               opts[:from]
         | 
| 147 165 | 
             
                             else
         | 
| 148 | 
            -
                               try_nil = true
         | 
| 149 166 | 
             
                               value
         | 
| 150 167 | 
             
                             end
         | 
| 151 168 |  | 
| 152 169 | 
             
                      mapper = lookup_matching_domain_mapper(from:, to:, criteria:, strict:)
         | 
| 153 170 |  | 
| 154 | 
            -
                      if try_nil
         | 
| 155 | 
            -
                        from = nil
         | 
| 156 | 
            -
                        mapper = lookup_matching_domain_mapper(from:, to:, criteria:, strict:)
         | 
| 157 | 
            -
                      end
         | 
| 158 | 
            -
             | 
| 159 171 | 
             
                      if mapper
         | 
| 160 172 | 
             
                        mapper.map!(value)
         | 
| 161 173 | 
             
                      elsif should_raise
         | 
| @@ -163,8 +175,8 @@ module Foobara | |
| 163 175 | 
             
                      end
         | 
| 164 176 | 
             
                    end
         | 
| 165 177 |  | 
| 166 | 
            -
                    def foobara_domain_map!( | 
| 167 | 
            -
                      foobara_domain_map( | 
| 178 | 
            +
                    def foobara_domain_map!(*, **, &)
         | 
| 179 | 
            +
                      foobara_domain_map(*, should_raise: true, **, &)
         | 
| 168 180 | 
             
                    end
         | 
| 169 181 |  | 
| 170 182 | 
             
                    def foobara_domain_name
         | 
| @@ -40,6 +40,12 @@ module Foobara | |
| 40 40 | 
             
                include Concern
         | 
| 41 41 |  | 
| 42 42 | 
             
                module ClassMethods
         | 
| 43 | 
            +
                  def new_mapper_registered!
         | 
| 44 | 
            +
                    if defined?(@mappers) && !@mappers.empty?
         | 
| 45 | 
            +
                      remove_instance_variable("@mappers")
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
             | 
| 43 49 | 
             
                  def lookup_matching_domain_mapper!(from: nil, to: nil, strict: false, criteria: nil)
         | 
| 44 50 | 
             
                    result = lookup_matching_domain_mapper(from:, to:, strict:, criteria:)
         | 
| 45 51 |  | 
| @@ -125,7 +125,7 @@ module Foobara | |
| 125 125 | 
             
                    mod = Module.new
         | 
| 126 126 | 
             
                    enumerated = self
         | 
| 127 127 |  | 
| 128 | 
            -
                    %i[all all_names all_values].each do |method_name|
         | 
| 128 | 
            +
                    %i[all all_names all_values value?].each do |method_name|
         | 
| 129 129 | 
             
                      mod.singleton_class.define_method method_name do |*args, **opts, &block|
         | 
| 130 130 | 
             
                        enumerated.send(method_name, *args, **opts, &block)
         | 
| 131 131 | 
             
                      end
         | 
| @@ -78,6 +78,10 @@ module Foobara | |
| 78 78 | 
             
                    foobara_registry.register(scoped)
         | 
| 79 79 | 
             
                    # awkward??
         | 
| 80 80 | 
             
                    scoped.scoped_namespace = self
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    if scoped.respond_to?(:foobara_on_register)
         | 
| 83 | 
            +
                      scoped.foobara_on_register
         | 
| 84 | 
            +
                    end
         | 
| 81 85 | 
             
                  rescue PrefixlessRegistry::RegisteringScopedWithPrefixError,
         | 
| 82 86 | 
             
                         BaseRegistry::WouldMakeRegistryAmbiguousError => e
         | 
| 83 87 | 
             
                    _upgrade_registry(e)
         |