reactor 0.4.6 → 0.4.7
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/.gitignore +2 -1
 - data/lib/reactor/event.rb +1 -1
 - data/lib/reactor/models/concerns/publishable.rb +10 -17
 - data/lib/reactor/version.rb +1 -1
 - data/reactor.gemspec +2 -2
 - data/spec/models/concerns/publishable_spec.rb +4 -3
 - metadata +6 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5ace8ce445f2aebac77523482a0a16112cda5143
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1844c28133029e8b9ed6d1eac32793efd2a58ede
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d268ec515c2b5e26577ebac12299a4969de3a17721e8dd02d9509b0b10cc8010115331d55ca3a8b133e7e51de619b30a1e4ccea9cc3f915c3ed7237ee60f998d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d0c4f6f3d2b99293034ffb76f06b48a34ed7a4b23a917801706478d390ea115a9a6f827ef843f3cbc8dd8ea1ea1b2ab0a9ab4984d9f81b08c5f13c341a656f38
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/lib/reactor/event.rb
    CHANGED
    
    | 
         @@ -70,7 +70,7 @@ class Reactor::Event 
     | 
|
| 
       70 
70 
     | 
    
         
             
                def reschedule(name, data = {})
         
     | 
| 
       71 
71 
     | 
    
         
             
                  scheduled_jobs = Sidekiq::ScheduledSet.new
         
     | 
| 
       72 
72 
     | 
    
         
             
                  job = scheduled_jobs.detect do |job|
         
     | 
| 
       73 
     | 
    
         
            -
                    job['class'] == self. 
     | 
| 
      
 73 
     | 
    
         
            +
                    job['class'] == self.name.to_s &&
         
     | 
| 
       74 
74 
     | 
    
         
             
                    job['args'].first == name.to_s &&
         
     | 
| 
       75 
75 
     | 
    
         
             
                    job.score.to_i == data[:was].to_i
         
     | 
| 
       76 
76 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -2,7 +2,7 @@ module Reactor::Publishable 
     | 
|
| 
       2 
2 
     | 
    
         
             
              extend ActiveSupport::Concern
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              included do
         
     | 
| 
       5 
     | 
    
         
            -
                after_commit :schedule_events, if: :persisted 
     | 
| 
      
 5 
     | 
    
         
            +
                after_commit :schedule_events, if: :persisted?
         
     | 
| 
       6 
6 
     | 
    
         
             
                after_commit :reschedule_events, if: :persisted?, on: :update
         
     | 
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -31,11 +31,11 @@ module Reactor::Publishable 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  ).except(:watch, :if)
         
     | 
| 
       32 
32 
     | 
    
         
             
                  need_to_fire = case (ifarg = data[:if])
         
     | 
| 
       33 
33 
     | 
    
         
             
                                   when Proc
         
     | 
| 
       34 
     | 
    
         
            -
                                     instance_exec 
     | 
| 
      
 34 
     | 
    
         
            +
                                     instance_exec(&ifarg)
         
     | 
| 
       35 
35 
     | 
    
         
             
                                   when Symbol
         
     | 
| 
       36 
36 
     | 
    
         
             
                                     send(ifarg)
         
     | 
| 
       37 
37 
     | 
    
         
             
                                   else
         
     | 
| 
       38 
     | 
    
         
            -
                                      
     | 
| 
      
 38 
     | 
    
         
            +
                                     transaction_include_action?(:create)
         
     | 
| 
       39 
39 
     | 
    
         
             
                                 end
         
     | 
| 
       40 
40 
     | 
    
         
             
                  Reactor::Event.publish name, event if need_to_fire
         
     | 
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
         @@ -46,20 +46,13 @@ module Reactor::Publishable 
     | 
|
| 
       46 
46 
     | 
    
         
             
                  attr_changed_method = data[:watch] || data[:at]
         
     | 
| 
       47 
47 
     | 
    
         
             
                  if data[:at] && previous_changes[attr_changed_method]
         
     | 
| 
       48 
48 
     | 
    
         
             
                    Reactor::Event.reschedule name,
         
     | 
| 
       49 
     | 
    
         
            -
                       
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                  if data[:if]
         
     | 
| 
       55 
     | 
    
         
            -
                    need_to_fire = case (ifarg = data[:if])
         
     | 
| 
       56 
     | 
    
         
            -
                                     when Proc
         
     | 
| 
       57 
     | 
    
         
            -
                                       instance_exec &ifarg
         
     | 
| 
       58 
     | 
    
         
            -
                                     when Symbol
         
     | 
| 
       59 
     | 
    
         
            -
                                       send(ifarg)
         
     | 
| 
       60 
     | 
    
         
            -
                                   end
         
     | 
| 
       61 
     | 
    
         
            -
                    Reactor::Event.publish name, actor: self if need_to_fire
         
     | 
| 
      
 49 
     | 
    
         
            +
                      data.merge(
         
     | 
| 
      
 50 
     | 
    
         
            +
                        at: send(data[:at]),
         
     | 
| 
      
 51 
     | 
    
         
            +
                        actor: ( data[:actor] ? send(data[:actor]) : self ),
         
     | 
| 
      
 52 
     | 
    
         
            +
                        target: ( data[:target] ? self : nil),
         
     | 
| 
      
 53 
     | 
    
         
            +
                        was: previous_changes[data[:at]].try(:first) || send("#{data[:at]}_was"))
         
     | 
| 
       62 
54 
     | 
    
         
             
                  end
         
     | 
| 
       63 
55 
     | 
    
         
             
                end
         
     | 
| 
       64 
56 
     | 
    
         
             
              end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/reactor/version.rb
    CHANGED
    
    
    
        data/reactor.gemspec
    CHANGED
    
    | 
         @@ -6,8 +6,8 @@ require 'reactor/version' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.name          = "reactor"
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.version       = Reactor::VERSION
         
     | 
| 
       9 
     | 
    
         
            -
              spec.authors       = ["winfred", "walt"]
         
     | 
| 
       10 
     | 
    
         
            -
              spec.email         = ["winfred@developerauction.com", "walt@developerauction.com", "curtis@developerauction.com", "nate@developerauction.com"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["winfred", "walt", "nate", "cgag", "petermin"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["winfred@developerauction.com", "walt@developerauction.com", "curtis@developerauction.com", "nate@developerauction.com", "kengteh.min@gmail.com"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.description   = %q{ rails chrono reactor }
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.summary       = %q{ Sidekiq/ActiveRecord pubsub lib }
         
     | 
| 
       13 
13 
     | 
    
         
             
              spec.homepage      = ""
         
     | 
| 
         @@ -17,7 +17,7 @@ class Auction < ActiveRecord::Base 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              publishes :bell
         
     | 
| 
       19 
19 
     | 
    
         
             
              publishes :ring, at: :ring_timeout, watch: :start_at
         
     | 
| 
       20 
     | 
    
         
            -
              publishes :begin, at: :start_at
         
     | 
| 
      
 20 
     | 
    
         
            +
              publishes :begin, at: :start_at, additional_info: 'curtis was here'
         
     | 
| 
       21 
21 
     | 
    
         
             
              publishes :conditional_event_on_save, if: -> { we_want_it }
         
     | 
| 
       22 
22 
     | 
    
         
             
              publishes :woof, actor: :pet, target: :self
         
     | 
| 
       23 
23 
     | 
    
         
             
            end
         
     | 
| 
         @@ -62,7 +62,8 @@ describe Reactor::Publishable do 
     | 
|
| 
       62 
62 
     | 
    
         
             
                    hash_including(
         
     | 
| 
       63 
63 
     | 
    
         
             
                      at: new_start_at,
         
     | 
| 
       64 
64 
     | 
    
         
             
                      actor: auction,
         
     | 
| 
       65 
     | 
    
         
            -
                      was: start_at
         
     | 
| 
      
 65 
     | 
    
         
            +
                      was: start_at,
         
     | 
| 
      
 66 
     | 
    
         
            +
                      additional_info: 'curtis was here'
         
     | 
| 
       66 
67 
     | 
    
         
             
                    )
         
     | 
| 
       67 
68 
     | 
    
         
             
                  auction.start_at = new_start_at
         
     | 
| 
       68 
69 
     | 
    
         
             
                  auction.save!
         
     | 
| 
         @@ -118,4 +119,4 @@ describe Reactor::Publishable do 
     | 
|
| 
       118 
119 
     | 
    
         
             
                  TestSubscriber.class_variable_get(:@@called).should be_true
         
     | 
| 
       119 
120 
     | 
    
         
             
                end
         
     | 
| 
       120 
121 
     | 
    
         
             
              end
         
     | 
| 
       121 
     | 
    
         
            -
            end
         
     | 
| 
      
 122 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: reactor
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - winfred
         
     | 
| 
       8 
8 
     | 
    
         
             
            - walt
         
     | 
| 
      
 9 
     | 
    
         
            +
            - nate
         
     | 
| 
      
 10 
     | 
    
         
            +
            - cgag
         
     | 
| 
      
 11 
     | 
    
         
            +
            - petermin
         
     | 
| 
       9 
12 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
13 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
14 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-07 
     | 
| 
      
 15 
     | 
    
         
            +
            date: 2013-08-07 00:00:00.000000000 Z
         
     | 
| 
       13 
16 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
17 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
18 
     | 
    
         
             
              name: sidekiq
         
     | 
| 
         @@ -87,6 +90,7 @@ email: 
     | 
|
| 
       87 
90 
     | 
    
         
             
            - walt@developerauction.com
         
     | 
| 
       88 
91 
     | 
    
         
             
            - curtis@developerauction.com
         
     | 
| 
       89 
92 
     | 
    
         
             
            - nate@developerauction.com
         
     | 
| 
      
 93 
     | 
    
         
            +
            - kengteh.min@gmail.com
         
     | 
| 
       90 
94 
     | 
    
         
             
            executables: []
         
     | 
| 
       91 
95 
     | 
    
         
             
            extensions: []
         
     | 
| 
       92 
96 
     | 
    
         
             
            extra_rdoc_files: []
         
     |