rggen-core 0.23.0 → 0.23.1
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
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d508be683e4b6306f85c0fa2c793e98ba33dc2710dab29c07ae0fb720c0b1e20
         | 
| 4 | 
            +
              data.tar.gz: a19ac7cea3493c7128672f343dee9833199d9e2c3769fdf0cd4679c3cc464c6d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f173621ce29ca6664d0201b4af80d9851151ab71dbd01f3027793d48402533ee9b8941d7149e5df0039370b4701975c9e926af2b36c94d8253bb6921ef3710b9
         | 
| 7 | 
            +
              data.tar.gz: 0a7bdf33b0708f3e493b79f932fb4daf1400ea68fef957d040ef6ff5b6e1881b783b06d78d7d43a857034bc98addb3c10bb0238b01e0d7d93921c49a7ec3901b
         | 
| @@ -11,22 +11,19 @@ module RgGen | |
| 11 11 | 
             
                      @enabled_features = {}
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 |  | 
| 14 | 
            -
                    def define_simple_feature( | 
| 15 | 
            -
                       | 
| 16 | 
            -
                        .each { |name| create_new_entry(:simple, name, context, body) }
         | 
| 14 | 
            +
                    def define_simple_feature(name, context = nil, &body)
         | 
| 15 | 
            +
                      create_new_entry(:simple, name, context, body)
         | 
| 17 16 | 
             
                    end
         | 
| 18 17 |  | 
| 19 | 
            -
                    def define_list_feature( | 
| 20 | 
            -
                       | 
| 21 | 
            -
                        .each { |name| create_new_entry(:list, name, context, body) }
         | 
| 18 | 
            +
                    def define_list_feature(list_name, context = nil, &body)
         | 
| 19 | 
            +
                      create_new_entry(:list, list_name, context, body)
         | 
| 22 20 | 
             
                    end
         | 
| 23 21 |  | 
| 24 | 
            -
                    def define_list_item_feature(list_name,  | 
| 22 | 
            +
                    def define_list_item_feature(list_name, feature_name, context = nil, &body)
         | 
| 25 23 | 
             
                      entry = @feature_entries[list_name]
         | 
| 26 24 | 
             
                      entry&.match_entry_type?(:list) ||
         | 
| 27 25 | 
             
                        (raise BuilderError.new("unknown list feature: #{list_name}"))
         | 
| 28 | 
            -
                       | 
| 29 | 
            -
                        .each { |name| entry.define_feature(name, context, &body) }
         | 
| 26 | 
            +
                      entry.define_feature(feature_name, context, &body)
         | 
| 30 27 | 
             
                    end
         | 
| 31 28 |  | 
| 32 29 | 
             
                    def enable(feature_or_list_names, feature_names = nil)
         | 
| @@ -11,16 +11,8 @@ module RgGen | |
| 11 11 |  | 
| 12 12 | 
             
                      attr_setter :body
         | 
| 13 13 | 
             
                      attr_setter :method_name
         | 
| 14 | 
            -
                      attr_setter : | 
| 15 | 
            -
                      attr_setter : | 
| 16 | 
            -
             | 
| 17 | 
            -
                      def shared_context(&body)
         | 
| 18 | 
            -
                        if block_given?
         | 
| 19 | 
            -
                          @shared_context ||= Object.new
         | 
| 20 | 
            -
                          @shared_context.instance_eval(&body)
         | 
| 21 | 
            -
                        end
         | 
| 22 | 
            -
                        @shared_context
         | 
| 23 | 
            -
                      end
         | 
| 14 | 
            +
                      attr_setter :list_name
         | 
| 15 | 
            +
                      attr_setter :feature_name
         | 
| 24 16 |  | 
| 25 17 | 
             
                      def register_execution(registry, &body)
         | 
| 26 18 | 
             
                        @executions ||= []
         | 
| @@ -29,15 +21,14 @@ module RgGen | |
| 29 21 |  | 
| 30 22 | 
             
                      def execute(layer)
         | 
| 31 23 | 
             
                        Docile.dsl_eval(layer, &body)
         | 
| 32 | 
            -
                        @executions&.each( | 
| 24 | 
            +
                        @executions&.each { |execution| call_execution(layer, execution) }
         | 
| 33 25 | 
             
                      end
         | 
| 34 26 |  | 
| 35 27 | 
             
                      private
         | 
| 36 28 |  | 
| 37 | 
            -
                      def call_execution(execution)
         | 
| 38 | 
            -
                        args = [ | 
| 39 | 
            -
                        execution[:registry]
         | 
| 40 | 
            -
                          .__send__(method_name, *args, &execution[:body])
         | 
| 29 | 
            +
                      def call_execution(layer, execution)
         | 
| 30 | 
            +
                        args = [list_name, feature_name, layer.shared_context].compact
         | 
| 31 | 
            +
                        execution[:registry].__send__(method_name, *args, &execution[:body])
         | 
| 41 32 | 
             
                      end
         | 
| 42 33 | 
             
                    end
         | 
| 43 34 |  | 
| @@ -52,31 +43,44 @@ module RgGen | |
| 52 43 | 
             
                    end
         | 
| 53 44 |  | 
| 54 45 | 
             
                    def shared_context(&body)
         | 
| 55 | 
            -
                       | 
| 46 | 
            +
                      return unless @proxy
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                      if block_given?
         | 
| 49 | 
            +
                        context = current_shared_context(true)
         | 
| 50 | 
            +
                        context.singleton_exec(&body)
         | 
| 51 | 
            +
                      end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                      current_shared_context(false)
         | 
| 56 54 | 
             
                    end
         | 
| 57 55 |  | 
| 58 56 | 
             
                    def define_simple_feature(feature_names, &body)
         | 
| 59 | 
            -
                       | 
| 60 | 
            -
                        proxy | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 57 | 
            +
                      Array(feature_names).each do |feature_name|
         | 
| 58 | 
            +
                        do_proxy_call do |proxy|
         | 
| 59 | 
            +
                          proxy.body(body)
         | 
| 60 | 
            +
                          proxy.method_name(__method__)
         | 
| 61 | 
            +
                          proxy.feature_name(feature_name)
         | 
| 62 | 
            +
                        end
         | 
| 63 63 | 
             
                      end
         | 
| 64 64 | 
             
                    end
         | 
| 65 65 |  | 
| 66 66 | 
             
                    def define_list_feature(list_names, &body)
         | 
| 67 | 
            -
                       | 
| 68 | 
            -
                        proxy | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 67 | 
            +
                      Array(list_names).each do |list_name|
         | 
| 68 | 
            +
                        do_proxy_call do |proxy|
         | 
| 69 | 
            +
                          proxy.body(body)
         | 
| 70 | 
            +
                          proxy.method_name(__method__)
         | 
| 71 | 
            +
                          proxy.list_name(list_name)
         | 
| 72 | 
            +
                        end
         | 
| 71 73 | 
             
                      end
         | 
| 72 74 | 
             
                    end
         | 
| 73 75 |  | 
| 74 76 | 
             
                    def define_list_item_feature(list_name, feature_names, &body)
         | 
| 75 | 
            -
                       | 
| 76 | 
            -
                        proxy | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 77 | 
            +
                      Array(feature_names).each do |feature_name|
         | 
| 78 | 
            +
                        do_proxy_call do |proxy|
         | 
| 79 | 
            +
                          proxy.body(body)
         | 
| 80 | 
            +
                          proxy.method_name(__method__)
         | 
| 81 | 
            +
                          proxy.list_name(list_name)
         | 
| 82 | 
            +
                          proxy.feature_name(feature_name)
         | 
| 83 | 
            +
                        end
         | 
| 80 84 | 
             
                      end
         | 
| 81 85 | 
             
                    end
         | 
| 82 86 |  | 
| @@ -111,6 +115,17 @@ module RgGen | |
| 111 115 | 
             
                      @proxy.execute(self)
         | 
| 112 116 | 
             
                      remove_instance_variable(:@proxy)
         | 
| 113 117 | 
             
                    end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    def current_shared_context(allocate)
         | 
| 120 | 
            +
                      list_name = @proxy.list_name || @proxy.feature_name
         | 
| 121 | 
            +
                      feature_name = @proxy.feature_name
         | 
| 122 | 
            +
                      allocate && (shared_contexts[list_name][feature_name] ||= Object.new)
         | 
| 123 | 
            +
                      shared_contexts[list_name][feature_name]
         | 
| 124 | 
            +
                    end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    def shared_contexts
         | 
| 127 | 
            +
                      @shared_contexts ||= Hash.new { |h, k| h[k] = {} }
         | 
| 128 | 
            +
                    end
         | 
| 114 129 | 
             
                  end
         | 
| 115 130 | 
             
                end
         | 
| 116 131 | 
             
              end
         | 
    
        data/lib/rggen/core/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rggen-core
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.23. | 
| 4 | 
            +
              version: 0.23.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Taichi Ishitani
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-10-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: docile
         | 
| @@ -189,5 +189,5 @@ requirements: [] | |
| 189 189 | 
             
            rubygems_version: 3.1.2
         | 
| 190 190 | 
             
            signing_key: 
         | 
| 191 191 | 
             
            specification_version: 4
         | 
| 192 | 
            -
            summary: rggen-core-0.23. | 
| 192 | 
            +
            summary: rggen-core-0.23.1
         | 
| 193 193 | 
             
            test_files: []
         |