activejob-status 0.3.0 → 0.4.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 +4 -4
 - data/lib/activejob-status/status.rb +15 -3
 - data/lib/activejob-status/version.rb +1 -1
 - data/lib/activejob-status.rb +2 -0
 - 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: a8a41508ce07744c1b0372a313f3d47a981986145423b5ded100bd1f39b3b37d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6dea6ede3e4f251a637ecf5ff7dc1c824145fb7bd2a55edb4f38bfed409f74fe
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4eab47f16733e16c9006ce3dff76d239ffdf2932e47bcd8eafe30c953d1131292f9fee1f4298f5f642461394f4cb7f1f41407fa8d922a4b1486a34a71f7e32f1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9fb5a5f0fc42f5c90b1a8839b856317a7f7544555dfda2e94798ad08fefeb223491b15743af8dcb3df0659351f072f27aaabfc04f7ee82a8ed5b60d56ed2b6fc
         
     | 
| 
         @@ -23,8 +23,10 @@ module ActiveJob 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  alias_method :to_h, :read
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                  def update(payload, options = {})
         
     | 
| 
       26 
     | 
    
         
            -
                    @job. 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                    if @job.respond_to?(:progress)
         
     | 
| 
      
 27 
     | 
    
         
            +
                      @job.progress.instance_variable_set(:@progress, payload[:progress]) if payload.include?(:progress)
         
     | 
| 
      
 28 
     | 
    
         
            +
                      @job.progress.instance_variable_set(:@total, payload[:total]) if payload.include?(:total)
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
                    @storage.update(@job, payload, **options)
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -56,6 +58,8 @@ module ActiveJob 
     | 
|
| 
       56 
58 
     | 
    
         
             
                  # Update default data
         
     | 
| 
       57 
59 
     | 
    
         | 
| 
       58 
60 
     | 
    
         
             
                  def update_defaults(status_key)
         
     | 
| 
      
 61 
     | 
    
         
            +
                    raise "cannot call #update_defaults when status is accessed from outside the job" if @job.is_a?(String)
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
       59 
63 
     | 
    
         
             
                    payload = {}
         
     | 
| 
       60 
64 
     | 
    
         
             
                    payload[:status] = status_key if @defaults.include?(:status)
         
     | 
| 
       61 
65 
     | 
    
         
             
                    payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
         
     | 
| 
         @@ -63,10 +67,18 @@ module ActiveJob 
     | 
|
| 
       63 
67 
     | 
    
         
             
                  end
         
     | 
| 
       64 
68 
     | 
    
         | 
| 
       65 
69 
     | 
    
         
             
                  def catch_exception(e)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    raise "cannot call #catch_exception when status is accessed from outside the job" if @job.is_a?(String)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       66 
72 
     | 
    
         
             
                    payload = {}
         
     | 
| 
       67 
73 
     | 
    
         
             
                    payload[:status] = :failed if @defaults.include?(:status)
         
     | 
| 
       68 
74 
     | 
    
         
             
                    payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                    if @defaults.include?(:exception)
         
     | 
| 
      
 77 
     | 
    
         
            +
                      message = e.message
         
     | 
| 
      
 78 
     | 
    
         
            +
                      message = e.original_message if e.respond_to?(:original_message)
         
     | 
| 
      
 79 
     | 
    
         
            +
                      payload[:exception] = {class: e.class.name, message: message}
         
     | 
| 
      
 80 
     | 
    
         
            +
                    end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
       70 
82 
     | 
    
         
             
                    update(payload, force: true)
         
     | 
| 
       71 
83 
     | 
    
         
             
                  end
         
     | 
| 
       72 
84 
     | 
    
         
             
                end
         
     | 
    
        data/lib/activejob-status.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: activejob-status
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Savater Sebastien
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-01-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activejob
         
     |