Skip to content

Commit

Permalink
Merge pull request #9 from abak-press/master
Browse files Browse the repository at this point in the history
Merge branch 'master' into 'orders/release/20160303'
  • Loading branch information
dsalahutdinov committed Mar 2, 2016
2 parents 60a2ac6 + b4ebc8c commit 8f460c1
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ mkmf.log
/.rvmrc
/.idea/
gemfiles/
internal/
internal/log
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

#### [Current]
* 2016-03-01 [8375263](../../commit/8375263) - __(Semyon Pupkov)__ feature: add base field and translators

#### v0.0.4
* 2016-02-17 [d16dde0](../../commit/d16dde0) - __(Salahutdinov Dmitry)__ Release 0.0.4
* 2016-02-16 [791f5d1](../../commit/791f5d1) - __(Salahutdinov Dmitry)__ feature: базовый счетчик денормализации

#### v0.0.3
Expand Down
6 changes: 6 additions & 0 deletions lib/treasury/fields/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Treasury
module Fields
class Base < ::CoreDenormalization::Fields::Base
end
end
end
7 changes: 7 additions & 0 deletions lib/treasury/processors/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
module Treasury
module Processors
class Base < ::CoreDenormalization::Processors::Base
def form_value(value)
value
end

def result_row(value)
{@object => form_value(value)}
end
end
end
end
6 changes: 3 additions & 3 deletions lib/treasury/processors/counters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def process_insert
fields = counters_list.each_with_object({}) do |counter, hash|
hash[counter] = incremented_current_value(counter) if send "#{counter}_satisfied?"
end
result_row fields
result_row(fields) if fields.present?
end

def process_update
Expand All @@ -79,14 +79,14 @@ def process_update
hash[counter] = decremented_current_value(counter) if send "#{counter}_was_counted?"
end
end
result_row fields
result_row(fields) if fields.present?
end

def process_delete
fields = counters_list.each_with_object({}) do |counter, hash|
hash[counter] = decremented_current_value(counter) if send "#{counter}_was_counted?"
end
result_row fields
result_row(fields) if fields.present?
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/treasury/processors/optimized_translator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Treasury
module Processors
module OptimizedTranslator
include ::CoreDenormalization::Processors::OptimizedTranslator
end
end
end
7 changes: 7 additions & 0 deletions lib/treasury/processors/translator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Treasury
module Processors
module Translator
include ::CoreDenormalization::Processors::Translator
end
end
end
2 changes: 1 addition & 1 deletion lib/treasury/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Treasury
VERSION = '0.0.4'
VERSION = '0.0.5'
end
6 changes: 6 additions & 0 deletions spec/internal/lib/core_denormalization/processors/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module CoreDenormalization
module Processors
class Base
end
end
end
Empty file added spec/internal/log/test.log
Empty file.
10 changes: 8 additions & 2 deletions spec/lib/treasury/processors/counters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:processor) { processor_class.new }

let(:processor_class) do
Class.new do
Class.new(::Treasury::Processors::Base) do
include ::Treasury::Processors::Counters
counters :count

Expand Down Expand Up @@ -34,13 +34,13 @@ def count?(data)
it do
expect(processor).not_to receive(:incremented_current_value)
expect(processor).not_to receive(:decremented_current_value)
expect(result).to be_nil
end
end

before do
allow(processor).to receive(:incremented_current_value)
allow(processor).to receive(:decremented_current_value)
allow(processor).to receive(:result_row)

processor.instance_variable_set :@event, event
end
Expand Down Expand Up @@ -107,6 +107,8 @@ def count?(data)
end

describe "#process_insert" do
let(:result) { processor.process_insert }

context "when event is satisfied" do
let(:event) { double satisfied }
it { expect(processor).to receive(:incremented_current_value).with(:count) }
Expand All @@ -121,6 +123,8 @@ def count?(data)
end

describe "#process_update" do
let(:result) { processor.process_update }

context "when event is satisfied and wasn't counted" do
let(:event) { double satisfied.merge(not_counted) }
it { expect(processor).to receive(:incremented_current_value).with(:count) }
Expand All @@ -145,6 +149,8 @@ def count?(data)
end

describe "#process_delete" do
let(:result) { processor.process_delete }

context "when event was counted" do
let(:event) { double counted }
it { expect(processor).to receive(:decremented_current_value).with(:count) }
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@

require 'combustion'
Combustion.initialize!

require_relative 'internal/lib/core_denormalization/processors/base'

0 comments on commit 8f460c1

Please sign in to comment.