parse_decision 0.0.5
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/bin/parse_decision +126 -0
- data/lib/parse_decision/config.rb +90 -0
- data/lib/parse_decision/controller.rb +142 -0
- data/lib/parse_decision/parsedecisiontask.rb +31 -0
- data/lib/parse_decision/parser.rb +194 -0
- data/lib/parse_decision/pd_context.rb +148 -0
- data/lib/parse_decision/plugin/application.rb +48 -0
- data/lib/parse_decision/plugin/plugin.rb +56 -0
- data/lib/parse_decision/plugin/ppm_xpath.rb +70 -0
- data/lib/parse_decision/plugin/pre_decision_guideline.rb +177 -0
- data/lib/parse_decision/plugin/product.rb +176 -0
- data/lib/parse_decision/plugin/product_xpath.rb +52 -0
- data/lib/parse_decision/plugin/web_product.rb +179 -0
- data/lib/parse_decision/plugin.rb +50 -0
- data/lib/parse_decision/version.rb +5 -0
- data/lib/parse_decision.rb +59 -0
- data/parse_decision.gemspec +27 -0
- data/rakefile.rb +58 -0
- data/spec/context_spec.rb +21 -0
- data/spec/data/multiproduct.decision.txt +1481 -0
- data/spec/data/prod.decision.txt +3957 -0
- data/spec/data/reference/multiproduct/001-APP.xml +1 -0
- data/spec/data/reference/multiproduct/001-Mod-Forbear-PRODUCT.xml +357 -0
- data/spec/data/reference/multiproduct/001-Mod-Forgive-PRODUCT.xml +361 -0
- data/spec/data/reference/multiproduct/001-Mod-RateTerm-PRODUCT.xml +353 -0
- data/spec/data/reference/multiproduct/001-Mod-SAM-PRODUCT.xml +365 -0
- data/spec/data/reference/product/001-APP.xml +1 -0
- data/spec/data/reference/product/001-Validation-Rules.xml +536 -0
- data/spec/data/reference/product/002-APP.xml +1 -0
- data/spec/data/reference/product/002-FAPIILoanModification-PRODUCT.xml +1770 -0
- data/spec/data/reference/web/001-APP.xml +1 -0
- data/spec/data/reference/web/001-Product01-PRODUCT.xml +1088 -0
- data/spec/data/reference/web/002-APP.xml +1 -0
- data/spec/data/reference/web/002-Product01-PRODUCT.xml +15 -0
- data/spec/data/reference/workflow/001-APP.xml +1 -0
- data/spec/data/reference/workflow/001-WF-DataClearing-Pre-Rules.xml +37 -0
- data/spec/data/reference/workflow-2/001-APP.xml +1 -0
- data/spec/data/reference/workflow-2/001-WF-ProdSel-Post-Rules.xml +699 -0
- data/spec/data/test.rb +13 -0
- data/spec/data/validation.decision.txt +1199 -0
- data/spec/data/web.decision.txt +1128 -0
- data/spec/data/wf.decision.txt +43 -0
- data/spec/data/wf2.decision.txt +705 -0
- data/spec/parser_spec.rb +308 -0
- data/spec/plugin_app_spec.rb +40 -0
- data/spec/plugin_ppmxpath_spec.rb +74 -0
- data/spec/plugin_predecision_spec.rb +81 -0
- data/spec/plugin_product_spec.rb +117 -0
- data/spec/plugin_productxpath_spec.rb +76 -0
- data/spec/plugin_spec.rb +54 -0
- data/spec/spec_helper.rb +81 -0
- data/test/data/2.2.decision-multiple.txt +1391 -0
- data/test/data/2.2.decision.txt +1128 -0
- data/test/data/2.decision.txt +1481 -0
- data/test/plugins/test_plugin_predecisionguideline.rb +120 -0
- data/test/plugins/test_plugin_product.rb +120 -0
- data/test/test_config.rb +90 -0
- data/test/test_context.rb +103 -0
- data/test/test_parse_webdecision.rb +121 -0
- data/test/test_parser.rb +69 -0
- data/test/test_parser_parse.rb +110 -0
- metadata +225 -0
data/spec/plugin_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ParseDecision::Plugin::Plugin do
|
4
|
+
|
5
|
+
let(:plugin) { ParseDecision::Plugin::Plugin.new }
|
6
|
+
let(:context) { ParseDecision::PDContext.new }
|
7
|
+
|
8
|
+
let(:outdir) { 'tmp/spec/plugin' }
|
9
|
+
before :each do
|
10
|
+
out = Pathname.new outdir
|
11
|
+
out.rmtree if out.exist? && out.directory?
|
12
|
+
out.mkdir
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can be created" do
|
16
|
+
plugin.should_not be nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#execute returns false by default" do
|
20
|
+
plugin.execute(context, "").should be_falsy
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#apply_template replaces substrings in a template" do
|
24
|
+
template = "Hello <<one>> <<one>> <<two>>"
|
25
|
+
pattern = "<<one>>"
|
26
|
+
replacement = "cruel"
|
27
|
+
output = plugin.apply_template( template, pattern, replacement )
|
28
|
+
output.should eq "Hello cruel cruel <<two>>"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "#apply_templates replaces substrings provided in a hash" do
|
32
|
+
template = "Hello <<one>> <<one>> <<two>>"
|
33
|
+
pat1 = "<<one>>"
|
34
|
+
pat2 = "<<two>>"
|
35
|
+
rep1 = "cruel"
|
36
|
+
rep2 = "world"
|
37
|
+
output = plugin.apply_templates( template, { pat1 => rep1, pat2 => rep2 } )
|
38
|
+
output.should eq "Hello cruel cruel world"
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:test_txt) { outdir+'/test.txt' }
|
42
|
+
let(:test_result) { file_to_array( test_txt ) }
|
43
|
+
|
44
|
+
it "#write_to_file will write an array to a file" do
|
45
|
+
array = ["one", 'two', "three"]
|
46
|
+
|
47
|
+
File.open(test_txt,'w') do |f|
|
48
|
+
plugin.write_to_file f, array
|
49
|
+
end
|
50
|
+
|
51
|
+
test_result.should eq array.join
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
#config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
|
18
|
+
# Allow the use of (old) should syntax, AND expect:
|
19
|
+
config.expect_with :rspec do |c|
|
20
|
+
# Disable the `expect` sytax...
|
21
|
+
#c.syntax = :should
|
22
|
+
|
23
|
+
# ...or disable the `should` syntax...
|
24
|
+
#c.syntax = :expect
|
25
|
+
|
26
|
+
# ...or explicitly enable both
|
27
|
+
c.syntax = [:should, :expect]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
require 'rspec/given'
|
34
|
+
require_relative '../lib/parse_decision'
|
35
|
+
require 'pathname'
|
36
|
+
|
37
|
+
# To activate tracing, use the following example command line:
|
38
|
+
#
|
39
|
+
# TRACE=on rspec spec
|
40
|
+
#
|
41
|
+
if ENV["TRACE"] == '1' || ENV["TRACE"] == 'on'
|
42
|
+
puts '##'*20
|
43
|
+
puts
|
44
|
+
puts "ENV[TRACE] = on. Tracing activated"
|
45
|
+
puts
|
46
|
+
puts '##'*20
|
47
|
+
|
48
|
+
# See http://www.blackbytes.info/2012/06/ruby-tracing/ for further details.
|
49
|
+
set_trace_func proc { |event, file, line, id, binding, classname|
|
50
|
+
# Limit output to plugin method calls.
|
51
|
+
if event == 'call' && file.include?('parse_decision/plugin')
|
52
|
+
#printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
53
|
+
|
54
|
+
# Shorten the class name and filename strings by stripping of the prefixes.
|
55
|
+
clsname = classname.to_s.sub!("ParseDecision::Plugin::", "")
|
56
|
+
file.sub!("c:/Users/Jeff/ams/tools/ruby/parse_decision/lib/parse_decision/", "")
|
57
|
+
|
58
|
+
printf "%28s %30s %s:%-2d\n", clsname, id, file, line
|
59
|
+
end
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def file_to_array(filepath)
|
65
|
+
dump = String.new
|
66
|
+
File.open(filepath) do |f|
|
67
|
+
f.each_line {|line| dump << line}
|
68
|
+
end
|
69
|
+
dump
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_context( _state=nil, _index=0 )
|
73
|
+
ctx = ParseDecision::PDContext.new
|
74
|
+
ctx.outdir = 'tmp/spec'
|
75
|
+
ctx.state = _state
|
76
|
+
_index.times { ctx.nextIndex() }
|
77
|
+
ctx.verbose = true
|
78
|
+
ctx
|
79
|
+
end
|
80
|
+
|
81
|
+
|