ecoportal-api-v2 0.9.5 → 0.9.7
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 +24 -1
 - data/lib/ecoportal/api/common/content/collection_model.rb +1 -1
 - data/lib/ecoportal/api/v2/page/component/reference_field.rb +24 -7
 - data/lib/ecoportal/api/v2/page/component.rb +16 -1
 - data/lib/ecoportal/api/v2/page/force/binding.rb +6 -0
 - data/lib/ecoportal/api/v2/page/stage.rb +4 -0
 - data/lib/ecoportal/api/v2_version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cd61279f012c243d8ac7dc7168273fb76ad2555871f464c17c38a2a54147aea8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a7837403a1df3d5e386d9fd71a24cb29eb98c43ea12637c9a4dd19301ac13bec
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bb9cdb7833b7eae455274cd89348e395c01bd423d8d9591c62b1f66a129b8e3ef9a13f6301870cf75b4707be6306e4ee83299b6bcc9ce05d3224741d44141019
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9009e8341f147df8610777d99026f6a2107b2fe64d5e0e0c5fa0b7623d632982899e00728a02c6a737395a6755a40f19a54e805b86ab6648cef51e46e3c3c9a4
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,12 +1,35 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Change Log
         
     | 
| 
       2 
2 
     | 
    
         
             
            All notable changes to this project will be documented in this file.
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            ## [0.9. 
     | 
| 
      
 4 
     | 
    
         
            +
            ## [0.9.8] - 2022-11-xx
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            ### Added
         
     | 
| 
       7 
7 
     | 
    
         
             
            ### Changed
         
     | 
| 
       8 
8 
     | 
    
         
             
            ### Fixed
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
      
 10 
     | 
    
         
            +
            ## [0.9.7] - 2022-11-29
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ### Added
         
     | 
| 
      
 13 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Component::ReferenceField` added methods `#delete` and `#clear`
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ### Changed
         
     | 
| 
      
 16 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Component::ReferenceField#add`
         
     | 
| 
      
 17 
     | 
    
         
            +
                - be able to add multiple references
         
     | 
| 
      
 18 
     | 
    
         
            +
                - prevent double-ups, just in case the server doesn't handle this
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            ### Fixed
         
     | 
| 
      
 21 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Component#bindings`
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## [0.9.6] - 2022-11-18
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ### Added
         
     | 
| 
      
 26 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Stage#components`
         
     | 
| 
      
 27 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Component#replace`
         
     | 
| 
      
 28 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Force::Binding#replace`
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ### Fixed
         
     | 
| 
      
 31 
     | 
    
         
            +
              - `Ecoportal::API::V2::Page::Component#bindings`
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       10 
33 
     | 
    
         
             
            ## [0.9.5] - 2022-11-17
         
     | 
| 
       11 
34 
     | 
    
         | 
| 
       12 
35 
     | 
    
         
             
            ### Fixed
         
     | 
| 
         @@ -175,7 +175,7 @@ module Ecoportal 
     | 
|
| 
       175 
175 
     | 
    
         
             
                      # @return [Object] the `items_class` element object
         
     | 
| 
       176 
176 
     | 
    
         
             
                      def upsert!(value, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
         
     | 
| 
       177 
177 
     | 
    
         
             
                        unless value.is_a?(Hash) || value.is_a?(Content::DoubleModel)
         
     | 
| 
       178 
     | 
    
         
            -
                          raise "'Content::DoubleModel' or 'Hash' doc required"
         
     | 
| 
      
 178 
     | 
    
         
            +
                          raise "'Content::DoubleModel' or 'Hash' doc required. Given #{value.class}"
         
     | 
| 
       179 
179 
     | 
    
         
             
                        end
         
     | 
| 
       180 
180 
     | 
    
         
             
                        item_doc = value.is_a?(Content::DoubleModel)? value.doc : value
         
     | 
| 
       181 
181 
     | 
    
         
             
                        item_doc = JSON.parse(item_doc.to_json)
         
     | 
| 
         @@ -13,19 +13,36 @@ module Ecoportal 
     | 
|
| 
       13 
13 
     | 
    
         
             
                        def empty?
         
     | 
| 
       14 
14 
     | 
    
         
             
                          reference_ids.empty?
         
     | 
| 
       15 
15 
     | 
    
         
             
                        end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       17 
17 
     | 
    
         
             
                        def reference_ids
         
     | 
| 
       18 
18 
     | 
    
         
             
                          references.map do |ref|
         
     | 
| 
       19 
19 
     | 
    
         
             
                            ref["id"]
         
     | 
| 
       20 
20 
     | 
    
         
             
                          end
         
     | 
| 
       21 
21 
     | 
    
         
             
                        end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
                        def add( 
     | 
| 
       24 
     | 
    
         
            -
                          doc["references"]. 
     | 
| 
       25 
     | 
    
         
            -
                             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
                        def add(*ref_ids)
         
     | 
| 
      
 24 
     | 
    
         
            +
                          doc["references"].tap do |refs|
         
     | 
| 
      
 25 
     | 
    
         
            +
                            ref_ids.each do |ref_id|
         
     | 
| 
      
 26 
     | 
    
         
            +
                              next if reference_ids.include?(ref_id)
         
     | 
| 
      
 27 
     | 
    
         
            +
                              refs.push({
         
     | 
| 
      
 28 
     | 
    
         
            +
                                "id" => ref_id,
         
     | 
| 
      
 29 
     | 
    
         
            +
                                "weight" => 0,
         
     | 
| 
      
 30 
     | 
    
         
            +
                                "patch_ver" => 0
         
     | 
| 
      
 31 
     | 
    
         
            +
                              })
         
     | 
| 
      
 32 
     | 
    
         
            +
                            end
         
     | 
| 
      
 33 
     | 
    
         
            +
                          end
         
     | 
| 
      
 34 
     | 
    
         
            +
                        end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                        def clear
         
     | 
| 
      
 37 
     | 
    
         
            +
                          delete(*reference_ids)
         
     | 
| 
      
 38 
     | 
    
         
            +
                        end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                        def delete(*ref_ids)
         
     | 
| 
      
 41 
     | 
    
         
            +
                          ref_ids.each do |ref_id|
         
     | 
| 
      
 42 
     | 
    
         
            +
                            if doc_ref = doc["references"].find {|doc_ref| doc_ref["id"] == ref_id}
         
     | 
| 
      
 43 
     | 
    
         
            +
                              doc["references"].delete(doc_ref)
         
     | 
| 
      
 44 
     | 
    
         
            +
                            end
         
     | 
| 
      
 45 
     | 
    
         
            +
                          end
         
     | 
| 
       29 
46 
     | 
    
         
             
                        end
         
     | 
| 
       30 
47 
     | 
    
         | 
| 
       31 
48 
     | 
    
         
             
                        def to_s(delimiter: "\n")
         
     | 
| 
         @@ -139,7 +139,6 @@ module Ecoportal 
     | 
|
| 
       139 
139 
     | 
    
         
             
                        ooze.forces.each_with_object([]) do |force, out|
         
     | 
| 
       140 
140 
     | 
    
         
             
                          out.push(*force.bindings.get_by_reference(self))
         
     | 
| 
       141 
141 
     | 
    
         
             
                        end
         
     | 
| 
       142 
     | 
    
         
            -
                        out
         
     | 
| 
       143 
142 
     | 
    
         
             
                      end
         
     | 
| 
       144 
143 
     | 
    
         | 
| 
       145 
144 
     | 
    
         
             
                      # @return [Array<Ecoportal::API::V2::Page::Force] the forces this component is bound to if any.
         
     | 
| 
         @@ -154,6 +153,22 @@ module Ecoportal 
     | 
|
| 
       154 
153 
     | 
    
         
             
                        forces.count > 0
         
     | 
| 
       155 
154 
     | 
    
         
             
                      end
         
     | 
| 
       156 
155 
     | 
    
         | 
| 
      
 156 
     | 
    
         
            +
                      # If the field has bindings they are replaced by this new field
         
     | 
| 
      
 157 
     | 
    
         
            +
                      # @note careful with this, depending what's done in the force, this may brake the force.
         
     | 
| 
      
 158 
     | 
    
         
            +
                      def replace(fld)
         
     | 
| 
      
 159 
     | 
    
         
            +
                        if fld.section
         
     | 
| 
      
 160 
     | 
    
         
            +
                          fld.move(section: self.section, before: self)
         
     | 
| 
      
 161 
     | 
    
         
            +
                        else
         
     | 
| 
      
 162 
     | 
    
         
            +
                          self.section.add(fld, before: self)
         
     | 
| 
      
 163 
     | 
    
         
            +
                        end
         
     | 
| 
      
 164 
     | 
    
         
            +
                        replace_bindings(fld)
         
     | 
| 
      
 165 
     | 
    
         
            +
                        self.delete!
         
     | 
| 
      
 166 
     | 
    
         
            +
                      end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                      def replace_bindings(fld)
         
     | 
| 
      
 169 
     | 
    
         
            +
                        bindings.map {|b| b.replace(fld)}
         
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
       157 
172 
     | 
    
         
             
                      def delete!
         
     | 
| 
       158 
173 
     | 
    
         
             
                        bindings.each {|b| b.delete!}
         
     | 
| 
       159 
174 
     | 
    
         
             
                        self.unattach!
         
     | 
| 
         @@ -53,6 +53,12 @@ module Ecoportal 
     | 
|
| 
       53 
53 
     | 
    
         
             
                          self.component? ? component : section
         
     | 
| 
       54 
54 
     | 
    
         
             
                        end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
      
 56 
     | 
    
         
            +
                        def replace(mem_sec)
         
     | 
| 
      
 57 
     | 
    
         
            +
                          self._parent.add(mem_sec, name: self.name, before: self) do |bind|
         
     | 
| 
      
 58 
     | 
    
         
            +
                            self.delete! if bind
         
     | 
| 
      
 59 
     | 
    
         
            +
                          end
         
     | 
| 
      
 60 
     | 
    
         
            +
                        end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       56 
62 
     | 
    
         
             
                        def delete!
         
     | 
| 
       57 
63 
     | 
    
         
             
                          self._parent.delete!(self)
         
     | 
| 
       58 
64 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -21,6 +21,10 @@ module Ecoportal 
     | 
|
| 
       21 
21 
     | 
    
         
             
                        self._parent.ooze
         
     | 
| 
       22 
22 
     | 
    
         
             
                      end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
                      def components
         
     | 
| 
      
 25 
     | 
    
         
            +
                        sections.map(&:components).flatten(1).uniq
         
     | 
| 
      
 26 
     | 
    
         
            +
                      end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       24 
28 
     | 
    
         
             
                      # @yield [section] do some stuff with section.
         
     | 
| 
       25 
29 
     | 
    
         
             
                      # @yieldparam section [Ecoportal::API::V2::Page::Section] one of the sections of this stage
         
     | 
| 
       26 
30 
     | 
    
         
             
                      # @return [Array<Ecoportal::API::V2::Page::Section>] sections attached to this stage.
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ecoportal-api-v2
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.9. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.9.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Oscar Segura
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-11-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |