functional-light-service 6.1.0 → 6.3.0
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/functional-light-service.rb +6 -31
- metadata +15 -297
- data/.github/workflows/project-build.yml +0 -71
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.rubocop.yml +0 -101
- data/.solargraph.yml +0 -11
- data/AUDIT-functional-light-service.md +0 -352
- data/Appraisals +0 -7
- data/CHANGELOG.md +0 -273
- data/CODE_OF_CONDUCT.md +0 -22
- data/Gemfile +0 -4
- data/LICENSE +0 -22
- data/README.md +0 -1578
- data/Rakefile +0 -12
- data/VERSION +0 -1
- data/audit/bench.rb +0 -99
- data/audit/verify_findings.rb +0 -172
- data/functional-light-service.gemspec +0 -33
- data/gemfiles/dry_inflector_0_2_1.gemfile +0 -5
- data/gemfiles/i18n_1_8_11.gemfile +0 -5
- data/lib/functional-light-service/action.rb +0 -97
- data/lib/functional-light-service/configuration.rb +0 -26
- data/lib/functional-light-service/context/key_verifier.rb +0 -124
- data/lib/functional-light-service/context.rb +0 -195
- data/lib/functional-light-service/deprecations.rb +0 -26
- data/lib/functional-light-service/errors.rb +0 -8
- data/lib/functional-light-service/functional/enum.rb +0 -286
- data/lib/functional-light-service/functional/maybe.rb +0 -21
- data/lib/functional-light-service/functional/monad.rb +0 -77
- data/lib/functional-light-service/functional/null.rb +0 -88
- data/lib/functional-light-service/functional/option.rb +0 -100
- data/lib/functional-light-service/functional/result.rb +0 -129
- data/lib/functional-light-service/functional/sequencer.rb +0 -144
- data/lib/functional-light-service/localization_adapter.rb +0 -48
- data/lib/functional-light-service/organizer/execute.rb +0 -16
- data/lib/functional-light-service/organizer/iterate.rb +0 -30
- data/lib/functional-light-service/organizer/reduce_if.rb +0 -19
- data/lib/functional-light-service/organizer/reduce_until.rb +0 -22
- data/lib/functional-light-service/organizer/scoped_reducable.rb +0 -15
- data/lib/functional-light-service/organizer/with_callback.rb +0 -28
- data/lib/functional-light-service/organizer/with_reducer.rb +0 -81
- data/lib/functional-light-service/organizer/with_reducer_factory.rb +0 -20
- data/lib/functional-light-service/organizer/with_reducer_log_decorator.rb +0 -110
- data/lib/functional-light-service/organizer.rb +0 -114
- data/lib/functional-light-service/testing/context_factory.rb +0 -48
- data/lib/functional-light-service/testing.rb +0 -3
- data/lib/functional-light-service/version.rb +0 -5
- data/resources/fail_actions.png +0 -0
- data/resources/light-service.png +0 -0
- data/resources/organizer_and_actions.png +0 -0
- data/resources/skip_actions.png +0 -0
- data/spec/acceptance/add_numbers_spec.rb +0 -11
- data/spec/acceptance/after_actions_spec.rb +0 -87
- data/spec/acceptance/around_each_spec.rb +0 -19
- data/spec/acceptance/before_actions_spec.rb +0 -115
- data/spec/acceptance/custom_log_from_organizer_spec.rb +0 -61
- data/spec/acceptance/deprecation_warnings_spec.rb +0 -82
- data/spec/acceptance/fail_spec.rb +0 -52
- data/spec/acceptance/log_from_organizer_spec.rb +0 -154
- data/spec/acceptance/message_localization_spec.rb +0 -119
- data/spec/acceptance/organizer/add_aliases_spec.rb +0 -28
- data/spec/acceptance/organizer/add_to_context_spec.rb +0 -30
- data/spec/acceptance/organizer/around_each_with_reduce_if_spec.rb +0 -42
- data/spec/acceptance/organizer/context_failure_and_skipping_spec.rb +0 -68
- data/spec/acceptance/organizer/execute_spec.rb +0 -46
- data/spec/acceptance/organizer/iterate_spec.rb +0 -44
- data/spec/acceptance/organizer/reduce_if_spec.rb +0 -89
- data/spec/acceptance/organizer/reduce_until_spec.rb +0 -49
- data/spec/acceptance/organizer/with_callback_spec.rb +0 -113
- data/spec/acceptance/organizer_entry_point_spec.rb +0 -35
- data/spec/acceptance/rollback_spec.rb +0 -183
- data/spec/acceptance/testing/context_factory_spec.rb +0 -54
- data/spec/action_expected_keys_spec.rb +0 -63
- data/spec/action_expects_and_promises_spec.rb +0 -97
- data/spec/action_promised_keys_spec.rb +0 -126
- data/spec/action_spec.rb +0 -97
- data/spec/context/inspect_spec.rb +0 -42
- data/spec/context_spec.rb +0 -289
- data/spec/examples/amount_spec.rb +0 -77
- data/spec/examples/controller_spec.rb +0 -63
- data/spec/examples/validate_address_spec.rb +0 -38
- data/spec/lib/deterministic/class_mixin_spec.rb +0 -24
- data/spec/lib/deterministic/currify_spec.rb +0 -90
- data/spec/lib/deterministic/monad_axioms.rb +0 -46
- data/spec/lib/deterministic/monad_spec.rb +0 -47
- data/spec/lib/deterministic/null_spec.rb +0 -65
- data/spec/lib/deterministic/option_spec.rb +0 -140
- data/spec/lib/deterministic/result/failure_spec.rb +0 -65
- data/spec/lib/deterministic/result/result_map_spec.rb +0 -155
- data/spec/lib/deterministic/result/result_shared.rb +0 -25
- data/spec/lib/deterministic/result/success_spec.rb +0 -41
- data/spec/lib/deterministic/result_spec.rb +0 -63
- data/spec/lib/deterministic/sequencer_spec.rb +0 -506
- data/spec/lib/edge_cases_spec.rb +0 -156
- data/spec/lib/enum_spec.rb +0 -114
- data/spec/lib/native_pattern_matching_spec.rb +0 -74
- data/spec/localization_adapter_spec.rb +0 -83
- data/spec/organizer/with_reducer_spec.rb +0 -56
- data/spec/organizer_key_aliases_spec.rb +0 -29
- data/spec/organizer_spec.rb +0 -115
- data/spec/readme_spec.rb +0 -45
- data/spec/sample/calculates_order_tax_action_spec.rb +0 -16
- data/spec/sample/calculates_tax_spec.rb +0 -30
- data/spec/sample/looks_up_tax_percentage_action_spec.rb +0 -55
- data/spec/sample/provides_free_shipping_action_spec.rb +0 -25
- data/spec/sample/tax/calculates_order_tax_action.rb +0 -10
- data/spec/sample/tax/calculates_tax.rb +0 -11
- data/spec/sample/tax/looks_up_tax_percentage_action.rb +0 -28
- data/spec/sample/tax/provides_free_shipping_action.rb +0 -11
- data/spec/spec_helper.rb +0 -29
- data/spec/support.rb +0 -1
- data/spec/test_doubles.rb +0 -628
- data/spec/testing/context_factory/iterate_spec.rb +0 -39
- data/spec/testing/context_factory/reduce_if_spec.rb +0 -40
- data/spec/testing/context_factory/reduce_until_spec.rb +0 -40
- data/spec/testing/context_factory/with_callback_spec.rb +0 -38
- data/spec/testing/context_factory_spec.rb +0 -76
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require_relative 'tax/calculates_tax'
|
|
3
|
-
require_relative 'tax/looks_up_tax_percentage_action'
|
|
4
|
-
require_relative 'tax/calculates_order_tax_action'
|
|
5
|
-
require_relative 'tax/provides_free_shipping_action'
|
|
6
|
-
|
|
7
|
-
describe CalculatesTax do
|
|
8
|
-
let(:order) { double('order') }
|
|
9
|
-
let(:ctx) { FunctionalLightService::Context.make(:user => nil) }
|
|
10
|
-
|
|
11
|
-
it "calls the actions in order" do
|
|
12
|
-
allow(FunctionalLightService::Context).to receive(:make)
|
|
13
|
-
.with({ :order => order })
|
|
14
|
-
.and_return(ctx)
|
|
15
|
-
|
|
16
|
-
allow(LooksUpTaxPercentageAction).to receive(:execute)
|
|
17
|
-
.with(ctx)
|
|
18
|
-
.and_return(ctx)
|
|
19
|
-
allow(CalculatesOrderTaxAction).to receive(:execute)
|
|
20
|
-
.with(ctx)
|
|
21
|
-
.and_return(ctx)
|
|
22
|
-
allow(ProvidesFreeShippingAction).to receive(:execute)
|
|
23
|
-
.with(ctx)
|
|
24
|
-
.and_return(ctx)
|
|
25
|
-
|
|
26
|
-
result = CalculatesTax.call(order)
|
|
27
|
-
|
|
28
|
-
expect(result).to eq(ctx)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require_relative 'tax/looks_up_tax_percentage_action'
|
|
3
|
-
|
|
4
|
-
class TaxRange
|
|
5
|
-
extend FunctionalLightService::Action
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe LooksUpTaxPercentageAction do
|
|
9
|
-
let(:region) { double('region') }
|
|
10
|
-
let(:order) do
|
|
11
|
-
order = double('order')
|
|
12
|
-
allow(order).to receive_messages(:region => region)
|
|
13
|
-
allow(order).to receive_messages(:total => 200)
|
|
14
|
-
order
|
|
15
|
-
end
|
|
16
|
-
let(:context) do
|
|
17
|
-
FunctionalLightService::Context.make(:order => order)
|
|
18
|
-
end
|
|
19
|
-
let(:tax_percentage) { double('tax_percentage') }
|
|
20
|
-
let(:tax_ranges) { double('tax_ranges') }
|
|
21
|
-
|
|
22
|
-
context "when the tax_ranges were not found" do
|
|
23
|
-
it "sets the context to failure" do
|
|
24
|
-
allow(TaxRange).to receive(:for_region).with(region).and_return nil
|
|
25
|
-
LooksUpTaxPercentageAction.execute(context)
|
|
26
|
-
|
|
27
|
-
expect(context).to be_failure
|
|
28
|
-
expect(context.message).to eq "The tax ranges were not found"
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "when the tax_percentage is not found" do
|
|
33
|
-
it "sets the context to failure" do
|
|
34
|
-
allow(TaxRange).to receive(:for_region).with(region).and_return tax_ranges
|
|
35
|
-
allow(tax_ranges).to receive_messages(:for_total => nil)
|
|
36
|
-
|
|
37
|
-
LooksUpTaxPercentageAction.execute(context)
|
|
38
|
-
|
|
39
|
-
expect(context).to be_failure
|
|
40
|
-
expect(context.message).to eq "The tax percentage was not found"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "when the tax_percentage is found" do
|
|
45
|
-
it "sets the tax_percentage in context" do
|
|
46
|
-
allow(TaxRange).to receive(:for_region).with(region).and_return tax_ranges
|
|
47
|
-
allow(tax_ranges).to receive_messages(:for_total => 25)
|
|
48
|
-
|
|
49
|
-
LooksUpTaxPercentageAction.execute(context)
|
|
50
|
-
|
|
51
|
-
expect(context).to be_success
|
|
52
|
-
expect(context.fetch(:tax_percentage)).to eq 25
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require_relative 'tax/provides_free_shipping_action'
|
|
3
|
-
|
|
4
|
-
describe ProvidesFreeShippingAction do
|
|
5
|
-
let(:order) { double('order') }
|
|
6
|
-
let(:ctx) { { :order => order } }
|
|
7
|
-
|
|
8
|
-
context "when the order total with tax is > 200" do
|
|
9
|
-
specify "order gets free shipping" do
|
|
10
|
-
allow(order).to receive_messages(:total_with_tax => 201)
|
|
11
|
-
expect(order).to receive(:provide_free_shipping!)
|
|
12
|
-
|
|
13
|
-
ProvidesFreeShippingAction.execute(ctx)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "when the order total with tax is <= 200" do
|
|
18
|
-
specify "order does not get free shipping" do
|
|
19
|
-
allow(order).to receive_messages(:total_with_tax => 200)
|
|
20
|
-
expect(order).not_to receive(:provide_free_shipping!)
|
|
21
|
-
|
|
22
|
-
ProvidesFreeShippingAction.execute(ctx)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
class LooksUpTaxPercentageAction
|
|
2
|
-
extend FunctionalLightService::Action
|
|
3
|
-
|
|
4
|
-
expects :order
|
|
5
|
-
promises :tax_percentage
|
|
6
|
-
|
|
7
|
-
executed do |ctx|
|
|
8
|
-
tax_ranges = TaxRange.for_region(ctx.order.region)
|
|
9
|
-
ctx.tax_percentage = 0
|
|
10
|
-
|
|
11
|
-
next ctx if object_is_nil?(tax_ranges, ctx, 'The tax ranges were not found')
|
|
12
|
-
|
|
13
|
-
ctx.tax_percentage = tax_ranges.for_total(ctx.order.total)
|
|
14
|
-
|
|
15
|
-
error_message = 'The tax percentage was not found'
|
|
16
|
-
next ctx if object_is_nil?(ctx.tax_percentage, ctx, error_message)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.object_is_nil?(object, ctx, message)
|
|
20
|
-
if object.nil?
|
|
21
|
-
ctx.fail!(message)
|
|
22
|
-
return true
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
false
|
|
26
|
-
end
|
|
27
|
-
private_class_method :object_is_nil?
|
|
28
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
2
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
|
3
|
-
|
|
4
|
-
if ENV['RUN_COVERAGE_REPORT']
|
|
5
|
-
require 'simplecov'
|
|
6
|
-
|
|
7
|
-
SimpleCov.start do
|
|
8
|
-
add_filter 'vendor/'
|
|
9
|
-
add_filter %r{^/spec/}
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
SimpleCov.minimum_coverage 98
|
|
13
|
-
SimpleCov.minimum_coverage_by_file 90
|
|
14
|
-
|
|
15
|
-
require "simplecov-cobertura"
|
|
16
|
-
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
require "functional-light-service"
|
|
20
|
-
require "functional-light-service/testing"
|
|
21
|
-
require "functional-light-service/functional/null"
|
|
22
|
-
require "support"
|
|
23
|
-
require "test_doubles"
|
|
24
|
-
require "stringio"
|
|
25
|
-
|
|
26
|
-
# Le API deprecate (Maybe/Null, operatori esotici) restano testate:
|
|
27
|
-
# i warning vengono silenziati globalmente e riattivati solo nelle
|
|
28
|
-
# spec che li verificano
|
|
29
|
-
FunctionalLightService::Deprecations.silenced = true
|
data/spec/support.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|