deploy_pin 1.7.0 → 1.7.2
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/MIT-LICENSE +1 -1
 - data/README.md +5 -5
 - data/lib/deploy_pin/task.rb +6 -0
 - data/lib/deploy_pin/version.rb +1 -1
 - data/lib/generators/deploy_pin/upgrade/templates/upgrade_deploy_pins.rb +3 -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: 92739dddf68cb804a3d4e76873afcaa11bcf5481ebcf8dd45d277ae992616eb7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 729e8e6401392109892d868613e996517a56e476a01f74ed968a6fd79d5c9f0f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4655ced6a71eec2d98aa92e30cd5a16584c50b02b7d3757b8bd7a5c6898d6b93a904944d8e9ce478a80889e62f76ac78c6808b533ff004546cab4e33965a4e02
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 105bef59cd93ba4a9c2fe88e8c60c75ce000439810c346359fcb9f823cdb025cf989137216a5f74c8aa5f212672ebc06df42feac1c2247dee745ea40b36e8d4a
         
     | 
    
        data/MIT-LICENSE
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -178,7 +178,7 @@ To use a different formatting value than the default, you need to specify it exp 
     | 
|
| 
       178 
178 
     | 
    
         | 
| 
       179 
179 
     | 
    
         
             
            ## Resumable Tasks
         
     | 
| 
       180 
180 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
            When working with long-running code that processes a large dataset, it makes sense to store progress in the database to allow resuming the task later. You can do this by using the `DeployPin::Task` instance methods: `#progress` and `#increment_progress(num)`.
         
     | 
| 
      
 181 
     | 
    
         
            +
            When working with long-running code that processes a large dataset, it makes sense to store progress in the database to allow resuming the task later. You can do this by using the `DeployPin::Task` instance methods: `#progress`, `#save_progress!(num)` and `#increment_progress!(num)`.
         
     | 
| 
       182 
182 
     | 
    
         | 
| 
       183 
183 
     | 
    
         
             
            Here is an example of how to use these methods:
         
     | 
| 
       184 
184 
     | 
    
         | 
| 
         @@ -190,16 +190,14 @@ Here is an example of how to use these methods: 
     | 
|
| 
       190 
190 
     | 
    
         
             
            # The progress is 0 by default
         
     | 
| 
       191 
191 
     | 
    
         
             
            Users.where(id: progress..).find_each do |user|
         
     | 
| 
       192 
192 
     | 
    
         
             
              # Do some work
         
     | 
| 
       193 
     | 
    
         
            -
              increment_progress(1) # Increment progress by 1 and store it in the database so you can resume the task from this point
         
     | 
| 
      
 193 
     | 
    
         
            +
              increment_progress!(1) # Increment progress by 1 and store it in the database so you can resume the task from this point
         
     | 
| 
      
 194 
     | 
    
         
            +
              # or save_progress!(user.id) # Save the progress as the user id
         
     | 
| 
       194 
195 
     | 
    
         
             
            end
         
     | 
| 
       195 
196 
     | 
    
         
             
            ```
         
     | 
| 
       196 
197 
     | 
    
         | 
| 
       197 
198 
     | 
    
         
             
            This allows your task to resume from where it left off, minimizing the risk of repeating work.
         
     | 
| 
       198 
199 
     | 
    
         | 
| 
       199 
200 
     | 
    
         | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
            ```bash
         
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
201 
     | 
    
         
             
            ## Recurring Tasks
         
     | 
| 
       204 
202 
     | 
    
         
             
            If you want to generate a recurring task, you can use the `--recurring` option. Make sure to set a correct `--identifier`, which should be a numeric value. Positive and negative numbers are possible here. The identifier affects the order of task execution, allowing you to customize the sequence as desired.
         
     | 
| 
       205 
203 
     | 
    
         | 
| 
         @@ -236,6 +234,8 @@ bundle exec rake deploy_pin:run[I, II, III] - # enters to ongoing state before " 
     | 
|
| 
       236 
234 
     | 
    
         
             
            bundle exec rake deploy_pin:run[rollback] - # enters "pending state"
         
     | 
| 
       237 
235 
     | 
    
         
             
            ```
         
     | 
| 
       238 
236 
     | 
    
         
             
            ## Similar Gems
         
     | 
| 
      
 237 
     | 
    
         
            +
            - https://github.com/ilyakatz/data-migrate
         
     | 
| 
      
 238 
     | 
    
         
            +
            - https://github.com/Shopify/maintenance_tasks
         
     | 
| 
       239 
239 
     | 
    
         
             
            - https://github.com/theSteveMitchell/after_party
         
     | 
| 
       240 
240 
     | 
    
         | 
| 
       241 
241 
     | 
    
         
             
            ## Contributing
         
     | 
    
        data/lib/deploy_pin/task.rb
    CHANGED
    
    | 
         @@ -54,6 +54,12 @@ module DeployPin 
     | 
|
| 
       54 
54 
     | 
    
         
             
                  record.increment!(:progress, incrementor)
         
     | 
| 
       55 
55 
     | 
    
         
             
                end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
      
 57 
     | 
    
         
            +
                def save_progress!(value)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  raise NotImplementedError, 'Recurring tasks do not support progress yet.' if recurring
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  record.update(progress: value)
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
       57 
63 
     | 
    
         
             
                def done?
         
     | 
| 
       58 
64 
     | 
    
         
             
                  return if recurring
         
     | 
| 
       59 
65 
     | 
    
         
             
                  return unless record
         
     | 
    
        data/lib/deploy_pin/version.rb
    CHANGED
    
    
| 
         @@ -4,5 +4,8 @@ class UpgradeDeployPins < ActiveRecord::Migration[7.0] 
     | 
|
| 
       4 
4 
     | 
    
         
             
              def change
         
     | 
| 
       5 
5 
     | 
    
         
             
                add_column :deploy_pins, :progress, :integer, default: 0, if_not_exists: true
         
     | 
| 
       6 
6 
     | 
    
         
             
                add_column :deploy_pins, :completed_at, :datetime, default: nil, if_not_exists: true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                # set completed_at to created_at for all completed deploy_pins
         
     | 
| 
      
 9 
     | 
    
         
            +
                DeployPin::Record.update_all('completed_at = created_at')
         
     | 
| 
       7 
10 
     | 
    
         
             
              end
         
     | 
| 
       8 
11 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: deploy_pin
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.7. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.7.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Viktor Sych
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024-10- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-10-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: colorize
         
     |