taskinator 0.4.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/CHANGELOG.md +5 -0
- data/Gemfile.lock +2 -2
- data/lib/taskinator/definition/builder.rb +16 -7
- data/lib/taskinator/version.rb +1 -1
- data/spec/taskinator/definition/builder_spec.rb +48 -0
- data/spec/taskinator/task_spec.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: 4a5f5f63478b9c1b1419e33baf6039f8e92153638ba2c08dc60cadd1a968d117
         | 
| 4 | 
            +
              data.tar.gz: e222c79a85490ec2cbced43833b05b40e97dc6863782586505b19b178e44f664
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ffd5ee0e0b9bfc78e9f44086d2b60986483c4668acf9b9a282ed3110d15d59477fec68b1042876d52899fe2531648ccd793efa9ba92415231ad4e637922b8049
         | 
| 7 | 
            +
              data.tar.gz: 99fb91f000e510dd98eda1d843e644c563ca71288759e7d23493a605b7f7b342a116cff2d2bd530250fb552cd88d728a67171fafb49419461baa7200355d9e47
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -24,7 +24,10 @@ module Taskinator | |
| 24 24 | 
             
                    raise ArgumentError, 'block' unless block_given?
         | 
| 25 25 |  | 
| 26 26 | 
             
                    sub_process = Process.define_sequential_process_for(@definition, options)
         | 
| 27 | 
            -
                     | 
| 27 | 
            +
                    task = define_sub_process_task(@process, sub_process, options)
         | 
| 28 | 
            +
                    Builder.new(sub_process, @definition, *@args).instance_eval(&block)
         | 
| 29 | 
            +
                    @process.tasks << task if sub_process.tasks.any?
         | 
| 30 | 
            +
                    nil
         | 
| 28 31 | 
             
                  end
         | 
| 29 32 |  | 
| 30 33 | 
             
                  # defines a sub process of tasks which are executed concurrently
         | 
| @@ -32,7 +35,10 @@ module Taskinator | |
| 32 35 | 
             
                    raise ArgumentError, 'block' unless block_given?
         | 
| 33 36 |  | 
| 34 37 | 
             
                    sub_process = Process.define_concurrent_process_for(@definition, complete_on, options)
         | 
| 35 | 
            -
                     | 
| 38 | 
            +
                    task = define_sub_process_task(@process, sub_process, options)
         | 
| 39 | 
            +
                    Builder.new(sub_process, @definition, *@args).instance_eval(&block)
         | 
| 40 | 
            +
                    @process.tasks << task if sub_process.tasks.any?
         | 
| 41 | 
            +
                    nil
         | 
| 36 42 | 
             
                  end
         | 
| 37 43 |  | 
| 38 44 | 
             
                  # dynamically defines tasks, using the given @iterator method
         | 
| @@ -51,6 +57,7 @@ module Taskinator | |
| 51 57 | 
             
                    @executor.send(method, *method_args) do |*args|
         | 
| 52 58 | 
             
                      Builder.new(@process, @definition, *args).instance_eval(&block)
         | 
| 53 59 | 
             
                    end
         | 
| 60 | 
            +
                    nil
         | 
| 54 61 | 
             
                  end
         | 
| 55 62 |  | 
| 56 63 | 
             
                  alias_method :transform, :for_each
         | 
| @@ -61,6 +68,7 @@ module Taskinator | |
| 61 68 | 
             
                    raise NoMethodError, method unless @executor.respond_to?(method)
         | 
| 62 69 |  | 
| 63 70 | 
             
                    define_step_task(@process, method, @args, options)
         | 
| 71 | 
            +
                    nil
         | 
| 64 72 | 
             
                  end
         | 
| 65 73 |  | 
| 66 74 | 
             
                  # defines a task which executes the given @job
         | 
| @@ -70,6 +78,7 @@ module Taskinator | |
| 70 78 | 
             
                    raise ArgumentError, 'job' unless job.methods.include?(:perform) || job.instance_methods.include?(:perform)
         | 
| 71 79 |  | 
| 72 80 | 
             
                    define_job_task(@process, job, @args, options)
         | 
| 81 | 
            +
                    nil
         | 
| 73 82 | 
             
                  end
         | 
| 74 83 |  | 
| 75 84 | 
             
                  # defines a sub process task, for the given @definition
         | 
| @@ -82,7 +91,10 @@ module Taskinator | |
| 82 91 | 
             
                    # TODO: decide whether the sub process to dynamically receive arguments
         | 
| 83 92 |  | 
| 84 93 | 
             
                    sub_process = definition.create_sub_process(*@args, combine_options(options))
         | 
| 85 | 
            -
                     | 
| 94 | 
            +
                    task = define_sub_process_task(@process, sub_process, options)
         | 
| 95 | 
            +
                    Builder.new(sub_process, definition, *@args)
         | 
| 96 | 
            +
                    @process.tasks << task if sub_process.tasks.any?
         | 
| 97 | 
            +
                    nil
         | 
| 86 98 | 
             
                  end
         | 
| 87 99 |  | 
| 88 100 | 
             
                private
         | 
| @@ -100,10 +112,7 @@ module Taskinator | |
| 100 112 | 
             
                  end
         | 
| 101 113 |  | 
| 102 114 | 
             
                  def define_sub_process_task(process, sub_process, options={})
         | 
| 103 | 
            -
                     | 
| 104 | 
            -
                      Task.define_sub_process_task(process, sub_process, combine_options(options))
         | 
| 105 | 
            -
                    }
         | 
| 106 | 
            -
                    sub_process
         | 
| 115 | 
            +
                    Task.define_sub_process_task(process, sub_process, combine_options(options))
         | 
| 107 116 | 
             
                  end
         | 
| 108 117 |  | 
| 109 118 | 
             
                  def define_task(process)
         | 
    
        data/lib/taskinator/version.rb
    CHANGED
    
    
| @@ -75,6 +75,22 @@ describe Taskinator::Definition::Builder do | |
| 75 75 | 
             
                  expect(Taskinator::Process).to receive(:define_sequential_process_for).with(definition, options).and_call_original
         | 
| 76 76 | 
             
                  subject.sequential(options, &define_block)
         | 
| 77 77 | 
             
                end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                it "adds sub-process task" do
         | 
| 80 | 
            +
                  block = Proc.new {|p|
         | 
| 81 | 
            +
                    p.task :task_method
         | 
| 82 | 
            +
                  }
         | 
| 83 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 84 | 
            +
                  subject.sequential(options, &block)
         | 
| 85 | 
            +
                  expect(process.tasks).to_not be_empty
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                it "ignores sub-processes without tasks" do
         | 
| 89 | 
            +
                  allow(block).to receive(:call)
         | 
| 90 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 91 | 
            +
                  subject.sequential(options, &define_block)
         | 
| 92 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 93 | 
            +
                end
         | 
| 78 94 | 
             
              end
         | 
| 79 95 |  | 
| 80 96 | 
             
              describe "#concurrent" do
         | 
| @@ -100,6 +116,22 @@ describe Taskinator::Definition::Builder do | |
| 100 116 | 
             
                  expect(Taskinator::Process).to receive(:define_concurrent_process_for).with(definition, Taskinator::CompleteOn::First, options).and_call_original
         | 
| 101 117 | 
             
                  subject.concurrent(Taskinator::CompleteOn::First, options, &define_block)
         | 
| 102 118 | 
             
                end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                it "adds sub-process task" do
         | 
| 121 | 
            +
                  block = Proc.new {|p|
         | 
| 122 | 
            +
                    p.task :task_method
         | 
| 123 | 
            +
                  }
         | 
| 124 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 125 | 
            +
                  subject.sequential(options, &block)
         | 
| 126 | 
            +
                  expect(process.tasks).to_not be_empty
         | 
| 127 | 
            +
                end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                it "ignores sub-processes without tasks" do
         | 
| 130 | 
            +
                  allow(block).to receive(:call)
         | 
| 131 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 132 | 
            +
                  subject.sequential(options, &define_block)
         | 
| 133 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 134 | 
            +
                end
         | 
| 103 135 | 
             
              end
         | 
| 104 136 |  | 
| 105 137 | 
             
              describe "#for_each" do
         | 
| @@ -235,6 +267,22 @@ describe Taskinator::Definition::Builder do | |
| 235 267 | 
             
                  expect(sub_definition).to receive(:create_sub_process).with(*args, builder_options.merge(options)).and_call_original
         | 
| 236 268 | 
             
                  subject.sub_process(sub_definition, options)
         | 
| 237 269 | 
             
                end
         | 
| 270 | 
            +
             | 
| 271 | 
            +
                it "adds sub-process task" do
         | 
| 272 | 
            +
                  block = Proc.new {|p|
         | 
| 273 | 
            +
                    p.task :task_method
         | 
| 274 | 
            +
                  }
         | 
| 275 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 276 | 
            +
                  subject.sequential(options, &block)
         | 
| 277 | 
            +
                  expect(process.tasks).to_not be_empty
         | 
| 278 | 
            +
                end
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                it "ignores sub-processes without tasks" do
         | 
| 281 | 
            +
                  allow(block).to receive(:call)
         | 
| 282 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 283 | 
            +
                  subject.sequential(options, &define_block)
         | 
| 284 | 
            +
                  expect(process.tasks).to be_empty
         | 
| 285 | 
            +
                end
         | 
| 238 286 | 
             
              end
         | 
| 239 287 |  | 
| 240 288 | 
             
            end
         | 
| @@ -227,7 +227,7 @@ describe Taskinator::Task do | |
| 227 227 |  | 
| 228 228 | 
             
                    method = subject.method
         | 
| 229 229 |  | 
| 230 | 
            -
                    executor.class_eval do
         | 
| 230 | 
            +
                    executor.singleton_class.class_eval do
         | 
| 231 231 | 
             
                      define_method method do |*args|
         | 
| 232 232 | 
             
                        # this method executes in the scope of the executor
         | 
| 233 233 | 
             
                        # store the context in an instance variable
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: taskinator
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4. | 
| 4 | 
            +
              version: 0.4.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Stefano
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021-03- | 
| 11 | 
            +
            date: 2021-03-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: redis
         |