checkoff 0.29.3 → 0.30.0
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/Gemfile.lock +1 -1
- data/lib/checkoff/internal/search_url/custom_field_param_converter.rb +1 -0
- data/lib/checkoff/internal/search_url/custom_field_variant.rb +14 -0
- data/lib/checkoff/internal/task_selector_evaluator.rb +42 -24
- data/lib/checkoff/projects.rb +3 -3
- data/lib/checkoff/sections.rb +5 -4
- data/lib/checkoff/tasks.rb +3 -3
- data/lib/checkoff/version.rb +1 -1
- data/lib/checkoff/workspaces.rb +1 -2
- 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: 56b8922e030c6770a830b116c1b436f31621670e1a80617e01bf35c5756688fd
         | 
| 4 | 
            +
              data.tar.gz: efa9bbbf45f71ef73df1ec5e1ebc0501915ae6c92b43d6246e48d9866b76da57
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9b09f82050f2a5b15fc15c8b34ef70093cc7502e64cc5a59d90bc475fce7cdd957dfe4e00d5223ab7c185c2b7f5ddaddc27f1830264c70b3b2279389032c114a
         | 
| 7 | 
            +
              data.tar.gz: 05627d4fc018a5eae0bf06a226dccf0819ac836a297f56c221b69b5b255f74e2e3501ab8f3e99bfffd4c65984d712e667c9c2e0332fba407fb00f95f7c27a582
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -55,6 +55,7 @@ module Checkoff | |
| 55 55 | 
             
                      'greater_than' => CustomFieldVariant::GreaterThan,
         | 
| 56 56 | 
             
                      'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
         | 
| 57 57 | 
             
                      'contains_any' => CustomFieldVariant::ContainsAny,
         | 
| 58 | 
            +
                      'contains_all' => CustomFieldVariant::ContainsAll,
         | 
| 58 59 | 
             
                    }.freeze
         | 
| 59 60 |  | 
| 60 61 | 
             
                    def convert_single_custom_field_params(gid, single_custom_field_params)
         | 
| @@ -99,6 +99,20 @@ module Checkoff | |
| 99 99 | 
             
                      end
         | 
| 100 100 | 
             
                    end
         | 
| 101 101 |  | 
| 102 | 
            +
                    # This is used in the UI for multi-select fields
         | 
| 103 | 
            +
                    #
         | 
| 104 | 
            +
                    # custom_field_#{gid}.variant = 'contains_all'
         | 
| 105 | 
            +
                    class ContainsAll < CustomFieldVariant
         | 
| 106 | 
            +
                      def convert
         | 
| 107 | 
            +
                        selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                        [{ "custom_fields.#{gid}.is_set" => 'true' },
         | 
| 110 | 
            +
                         ['custom_field_gid_value_contains_all_gids',
         | 
| 111 | 
            +
                          gid,
         | 
| 112 | 
            +
                          selected_options]]
         | 
| 113 | 
            +
                      end
         | 
| 114 | 
            +
                    end
         | 
| 115 | 
            +
             | 
| 102 116 | 
             
                    # custom_field_#{gid}.variant = 'no_value'
         | 
| 103 117 | 
             
                    class NoValue < CustomFieldVariant
         | 
| 104 118 | 
             
                      def convert
         | 
| @@ -35,6 +35,35 @@ module Checkoff | |
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                attr_reader :task_selector
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def pull_enum_values(custom_field)
         | 
| 40 | 
            +
                  resource_subtype = custom_field.fetch('resource_subtype')
         | 
| 41 | 
            +
                  case resource_subtype
         | 
| 42 | 
            +
                  when 'enum'
         | 
| 43 | 
            +
                    [custom_field.fetch('enum_value')]
         | 
| 44 | 
            +
                  when 'multi_enum'
         | 
| 45 | 
            +
                    custom_field.fetch('multi_enum_values')
         | 
| 46 | 
            +
                  else
         | 
| 47 | 
            +
                    raise "Teach me how to handle resource_subtype #{resource_subtype}"
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def find_gids(custom_field, enum_value)
         | 
| 52 | 
            +
                  if enum_value.nil?
         | 
| 53 | 
            +
                    []
         | 
| 54 | 
            +
                  else
         | 
| 55 | 
            +
                    raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                    [enum_value.fetch('gid')]
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                def pull_custom_field_values_gids(task, custom_field_gid)
         | 
| 62 | 
            +
                  custom_field = pull_custom_field_or_raise(task, custom_field_gid)
         | 
| 63 | 
            +
                  pull_enum_values(custom_field).flat_map do |enum_value|
         | 
| 64 | 
            +
                    find_gids(custom_field, enum_value)
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 38 67 | 
             
              end
         | 
| 39 68 |  | 
| 40 69 | 
             
              # :and function
         | 
| @@ -152,35 +181,23 @@ module Checkoff | |
| 152 181 | 
             
                    custom_field_values_gids.include?(custom_field_value)
         | 
| 153 182 | 
             
                  end
         | 
| 154 183 | 
             
                end
         | 
| 184 | 
            +
              end
         | 
| 155 185 |  | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
                def  | 
| 159 | 
            -
                   | 
| 160 | 
            -
                  case resource_subtype
         | 
| 161 | 
            -
                  when 'enum'
         | 
| 162 | 
            -
                    [custom_field.fetch('enum_value')]
         | 
| 163 | 
            -
                  when 'multi_enum'
         | 
| 164 | 
            -
                    custom_field.fetch('multi_enum_values')
         | 
| 165 | 
            -
                  else
         | 
| 166 | 
            -
                    raise "Teach me how to handle resource_subtype #{resource_subtype}"
         | 
| 167 | 
            -
                  end
         | 
| 186 | 
            +
              # :custom_field_gid_value_contains_all_gids function
         | 
| 187 | 
            +
              class CustomFieldGidValueContainsAllGidsFunctionEvaluator < FunctionEvaluator
         | 
| 188 | 
            +
                def matches?
         | 
| 189 | 
            +
                  fn?(task_selector, :custom_field_gid_value_contains_all_gids)
         | 
| 168 190 | 
             
                end
         | 
| 169 191 |  | 
| 170 | 
            -
                def  | 
| 171 | 
            -
                   | 
| 172 | 
            -
                    []
         | 
| 173 | 
            -
                  else
         | 
| 174 | 
            -
                    raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                    [enum_value.fetch('gid')]
         | 
| 177 | 
            -
                  end
         | 
| 192 | 
            +
                def evaluate_arg?(_index)
         | 
| 193 | 
            +
                  false
         | 
| 178 194 | 
             
                end
         | 
| 179 195 |  | 
| 180 | 
            -
                def  | 
| 181 | 
            -
                   | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 196 | 
            +
                def evaluate(task, custom_field_gid, custom_field_values_gids)
         | 
| 197 | 
            +
                  actual_custom_field_values_gids = pull_custom_field_values_gids(task, custom_field_gid)
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                  custom_field_values_gids.all? do |custom_field_value|
         | 
| 200 | 
            +
                    actual_custom_field_values_gids.include?(custom_field_value)
         | 
| 184 201 | 
             
                  end
         | 
| 185 202 | 
             
                end
         | 
| 186 203 | 
             
              end
         | 
| @@ -200,6 +217,7 @@ module Checkoff | |
| 200 217 | 
             
                  CustomFieldValueFunctionEvaluator,
         | 
| 201 218 | 
             
                  CustomFieldGidValueFunctionEvaluator,
         | 
| 202 219 | 
             
                  CustomFieldGidValueContainsAnyGidFunctionEvaluator,
         | 
| 220 | 
            +
                  CustomFieldGidValueContainsAllGidsFunctionEvaluator,
         | 
| 203 221 | 
             
                  AndFunctionEvaluator,
         | 
| 204 222 | 
             
                  DuePFunctionEvaluator,
         | 
| 205 223 | 
             
                ].freeze
         | 
    
        data/lib/checkoff/projects.rb
    CHANGED
    
    | @@ -24,9 +24,9 @@ module Checkoff | |
| 24 24 | 
             
                SHORT_CACHE_TIME = MINUTE
         | 
| 25 25 |  | 
| 26 26 | 
             
                def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
         | 
| 27 | 
            -
                                | 
| 28 | 
            -
                                | 
| 29 | 
            -
             | 
| 27 | 
            +
                               client: Checkoff::Clients.new(config: config).client,
         | 
| 28 | 
            +
                               workspaces: Checkoff::Workspaces.new(config: config,
         | 
| 29 | 
            +
                                                                    client: client))
         | 
| 30 30 | 
             
                  @config = config
         | 
| 31 31 | 
             
                  @workspaces = workspaces
         | 
| 32 32 | 
             
                  @client = client
         | 
    
        data/lib/checkoff/sections.rb
    CHANGED
    
    | @@ -18,10 +18,11 @@ module Checkoff | |
| 18 18 | 
             
                attr_reader :projects, :workspaces, :time, :my_tasks
         | 
| 19 19 |  | 
| 20 20 | 
             
                def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
         | 
| 21 | 
            -
                                | 
| 22 | 
            -
                                | 
| 23 | 
            -
             | 
| 24 | 
            -
                                | 
| 21 | 
            +
                               client: Checkoff::Clients.new(config: config).client,
         | 
| 22 | 
            +
                               projects: Checkoff::Projects.new(config: config,
         | 
| 23 | 
            +
                                                                client: client),
         | 
| 24 | 
            +
                               workspaces: Checkoff::Workspaces.new(config: config,
         | 
| 25 | 
            +
                                                                    client: client),
         | 
| 25 26 | 
             
                               time: Time)
         | 
| 26 27 | 
             
                  @projects = projects
         | 
| 27 28 | 
             
                  @workspaces = workspaces
         | 
    
        data/lib/checkoff/tasks.rb
    CHANGED
    
    | @@ -15,9 +15,9 @@ module Checkoff | |
| 15 15 | 
             
                SHORT_CACHE_TIME = MINUTE * 5
         | 
| 16 16 |  | 
| 17 17 | 
             
                def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
         | 
| 18 | 
            -
                                | 
| 19 | 
            -
                                | 
| 20 | 
            -
             | 
| 18 | 
            +
                               client: Checkoff::Clients.new(config: config).client,
         | 
| 19 | 
            +
                               sections: Checkoff::Sections.new(config: config,
         | 
| 20 | 
            +
                                                                client: client),
         | 
| 21 21 | 
             
                               time_class: Time,
         | 
| 22 22 | 
             
                               asana_task: Asana::Resources::Task)
         | 
| 23 23 | 
             
                  @config = config
         | 
    
        data/lib/checkoff/version.rb
    CHANGED
    
    
    
        data/lib/checkoff/workspaces.rb
    CHANGED
    
    | @@ -18,8 +18,7 @@ module Checkoff | |
| 18 18 | 
             
                SHORT_CACHE_TIME = MINUTE
         | 
| 19 19 |  | 
| 20 20 | 
             
                def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
         | 
| 21 | 
            -
                                | 
| 22 | 
            -
                               client: clients.client)
         | 
| 21 | 
            +
                               client: Checkoff::Clients.new(config: config).client)
         | 
| 23 22 | 
             
                  @config = config
         | 
| 24 23 | 
             
                  @client = client
         | 
| 25 24 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: checkoff
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.30.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Vince Broz
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-02- | 
| 11 | 
            +
            date: 2023-02-26 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |