checkoff 0.106.0 → 0.107.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/selector_classes/task.rb +2 -11
 - data/lib/checkoff/portfolios.rb +2 -2
 - data/lib/checkoff/tasks.rb +7 -1
 - data/lib/checkoff/timing.rb +26 -1
 - data/lib/checkoff/version.rb +1 -1
 - 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: 9a3f9bd1bb8698f7f5a318fefbf79cc09cf17998177dfbbae762fb3be82e33d7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 634e833fdb5f54c9f8a5e56411b4affb1a2d7384a1231a068bf77a8e37951088
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 950738387e7ecfe3652763452bca3dd79b39e3e8b8ca2618decacb77c04e6deb2d5b5680a272aacac5b46d97a75b53409a483bc339b13f8fd910c55d8ea0105a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 176ac1780573b9fe89f97a75c9bddf4cc74b69833ee31ec60e0f684ef88a7ca4dafa5e5661e5c5aec78ce8e5392dc23e7b9f3022e7ef77c2e94b1cc5efd45300
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -94,7 +94,7 @@ module Checkoff 
     | 
|
| 
       94 
94 
     | 
    
         
             
                    def evaluate(task, period = :now_or_before, ignore_dependencies = false)
         
     | 
| 
       95 
95 
     | 
    
         
             
                      @tasks.task_ready?(task, period: period, ignore_dependencies: ignore_dependencies)
         
     | 
| 
       96 
96 
     | 
    
         
             
                    end
         
     | 
| 
       97 
     | 
    
         
            -
                    # rubocop: 
     | 
| 
      
 97 
     | 
    
         
            +
                    # rubocop:enable Style/OptionalBooleanParameter
         
     | 
| 
       98 
98 
     | 
    
         
             
                  end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
100 
     | 
    
         
             
                  # :unassigned function
         
     | 
| 
         @@ -171,16 +171,7 @@ module Checkoff 
     | 
|
| 
       171 
171 
     | 
    
         
             
                    #
         
     | 
| 
       172 
172 
     | 
    
         
             
                    # @return [Boolean]
         
     | 
| 
       173 
173 
     | 
    
         
             
                    def evaluate(task, field_name, num_days)
         
     | 
| 
       174 
     | 
    
         
            -
                       
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
                      date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
                      return false if date.nil?
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
                      # @sg-ignore
         
     | 
| 
       181 
     | 
    
         
            -
                      n_days_ago = Date.today - num_days
         
     | 
| 
       182 
     | 
    
         
            -
                      # @sg-ignore
         
     | 
| 
       183 
     | 
    
         
            -
                      date < n_days_ago
         
     | 
| 
      
 174 
     | 
    
         
            +
                      @tasks.in_period?(task, field_name, [:less_than_n_days_ago, num_days])
         
     | 
| 
       184 
175 
     | 
    
         
             
                    end
         
     | 
| 
       185 
176 
     | 
    
         
             
                  end
         
     | 
| 
       186 
177 
     | 
    
         | 
    
        data/lib/checkoff/portfolios.rb
    CHANGED
    
    | 
         @@ -28,9 +28,9 @@ module Checkoff 
     | 
|
| 
       28 
28 
     | 
    
         
             
                # @param clients [Checkoff::Clients]
         
     | 
| 
       29 
29 
     | 
    
         
             
                # @param client [Asana::Client]
         
     | 
| 
       30 
30 
     | 
    
         
             
                def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
         
     | 
| 
       31 
     | 
    
         
            -
                               workspaces: Checkoff::Workspaces.new(config: config),
         
     | 
| 
       32 
31 
     | 
    
         
             
                               clients: Checkoff::Clients.new(config: config),
         
     | 
| 
       33 
     | 
    
         
            -
                               client: clients.client 
     | 
| 
      
 32 
     | 
    
         
            +
                               client: clients.client,
         
     | 
| 
      
 33 
     | 
    
         
            +
                               workspaces: Checkoff::Workspaces.new(config: config, client: client))
         
     | 
| 
       34 
34 
     | 
    
         
             
                  @workspaces = workspaces
         
     | 
| 
       35 
35 
     | 
    
         
             
                  @client = client
         
     | 
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
    
        data/lib/checkoff/tasks.rb
    CHANGED
    
    | 
         @@ -67,9 +67,15 @@ module Checkoff 
     | 
|
| 
       67 
67 
     | 
    
         
             
                # @param period [Symbol<:now_or_before,:this_week>]
         
     | 
| 
       68 
68 
     | 
    
         
             
                # @param ignore_dependencies [Boolean]
         
     | 
| 
       69 
69 
     | 
    
         
             
                def task_ready?(task, period: :now_or_before, ignore_dependencies: false)
         
     | 
| 
       70 
     | 
    
         
            -
                  field_name = :ready
         
     | 
| 
       71 
70 
     | 
    
         
             
                  return false if !ignore_dependencies && incomplete_dependencies?(task)
         
     | 
| 
       72 
71 
     | 
    
         | 
| 
      
 72 
     | 
    
         
            +
                  in_period?(task, :ready, period)
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                # @param task [Asana::Resources::Task]
         
     | 
| 
      
 76 
     | 
    
         
            +
                # @param field_name [Symbol]
         
     | 
| 
      
 77 
     | 
    
         
            +
                # @param period [Symbol<:now_or_before,:this_week>,Array] See Checkoff::Timing#in_period?_
         
     | 
| 
      
 78 
     | 
    
         
            +
                def in_period?(task, field_name, period)
         
     | 
| 
       73 
79 
     | 
    
         
             
                  # @type [Date,Time,nil]
         
     | 
| 
       74 
80 
     | 
    
         
             
                  task_date_or_time = task_timing.date_or_time_field_by_name(task, field_name)
         
     | 
| 
       75 
81 
     | 
    
         | 
    
        data/lib/checkoff/timing.rb
    CHANGED
    
    | 
         @@ -38,7 +38,9 @@ module Checkoff 
     | 
|
| 
       38 
38 
     | 
    
         
             
                end
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                # @param date_or_time [Date,Time,nil]
         
     | 
| 
       41 
     | 
    
         
            -
                # @param period [Symbol 
     | 
| 
      
 41 
     | 
    
         
            +
                # @param period [Symbol,Array<(Symbol,Integer)>]
         
     | 
| 
      
 42 
     | 
    
         
            +
                #
         
     | 
| 
      
 43 
     | 
    
         
            +
                #        Valid values: :this_week, :now_or_before, :indefinite, [:less_than_n_days_ago, Integer]
         
     | 
| 
       42 
44 
     | 
    
         
             
                def in_period?(date_or_time, period)
         
     | 
| 
       43 
45 
     | 
    
         
             
                  return this_week?(date_or_time) if period == :this_week
         
     | 
| 
       44 
46 
     | 
    
         | 
| 
         @@ -46,11 +48,34 @@ module Checkoff 
     | 
|
| 
       46 
48 
     | 
    
         | 
| 
       47 
49 
     | 
    
         
             
                  return now_or_before?(date_or_time) if period == :now_or_before
         
     | 
| 
       48 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
                  if period.is_a?(Array)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    # @sg-ignore
         
     | 
| 
      
 53 
     | 
    
         
            +
                    # @type [Symbol]
         
     | 
| 
      
 54 
     | 
    
         
            +
                    period_name = period.first
         
     | 
| 
      
 55 
     | 
    
         
            +
                    args = period[1..]
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    # @sg-ignore
         
     | 
| 
      
 58 
     | 
    
         
            +
                    return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       49 
61 
     | 
    
         
             
                  raise "Teach me how to handle period #{period.inspect}"
         
     | 
| 
       50 
62 
     | 
    
         
             
                end
         
     | 
| 
       51 
63 
     | 
    
         | 
| 
       52 
64 
     | 
    
         
             
                private
         
     | 
| 
       53 
65 
     | 
    
         | 
| 
      
 66 
     | 
    
         
            +
                # @param date_or_time [Date,Time,nil]
         
     | 
| 
      
 67 
     | 
    
         
            +
                # @param num_days [Integer]
         
     | 
| 
      
 68 
     | 
    
         
            +
                def less_than_n_days_ago?(date_or_time, num_days)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  return false if date_or_time.nil?
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                  date = date_or_time.to_date
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  # @sg-ignore
         
     | 
| 
      
 74 
     | 
    
         
            +
                  n_days_ago = @today_getter.today - num_days
         
     | 
| 
      
 75 
     | 
    
         
            +
                  # @sg-ignore
         
     | 
| 
      
 76 
     | 
    
         
            +
                  date < n_days_ago
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       54 
79 
     | 
    
         
             
                # @param date_or_time [Date,Time,nil]
         
     | 
| 
       55 
80 
     | 
    
         
             
                def this_week?(date_or_time)
         
     | 
| 
       56 
81 
     | 
    
         
             
                  return true if date_or_time.nil?
         
     | 
    
        data/lib/checkoff/version.rb
    CHANGED