ncs_mdes_warehouse 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG.md +23 -0
  2. data/lib/ncs_navigator/warehouse.rb +2 -0
  3. data/lib/ncs_navigator/warehouse/cli.rb +10 -2
  4. data/lib/ncs_navigator/warehouse/configuration.rb +80 -0
  5. data/lib/ncs_navigator/warehouse/configuration/file_evaluator.rb +1 -1
  6. data/lib/ncs_navigator/warehouse/contents.rb +77 -0
  7. data/lib/ncs_navigator/warehouse/filters.rb +19 -0
  8. data/lib/ncs_navigator/warehouse/filters/add_id_prefix_filter.rb +32 -0
  9. data/lib/ncs_navigator/warehouse/{transformers → filters}/apply_global_values_filter.rb +1 -1
  10. data/lib/ncs_navigator/warehouse/{transformers → filters}/coded_as_missing_filter.rb +1 -1
  11. data/lib/ncs_navigator/warehouse/filters/composite_filter.rb +77 -0
  12. data/lib/ncs_navigator/warehouse/{transformers → filters}/no_blank_foreign_keys_filter.rb +1 -1
  13. data/lib/ncs_navigator/warehouse/{transformers → filters}/no_ssu_outreach_all_ssus_filter.rb +1 -1
  14. data/lib/ncs_navigator/warehouse/{transformers → filters}/no_ssu_outreach_placeholder_filter.rb +1 -1
  15. data/lib/ncs_navigator/warehouse/filters/record_id_changing_filter_support.rb +71 -0
  16. data/lib/ncs_navigator/warehouse/filters/remove_id_prefix_filter.rb +32 -0
  17. data/lib/ncs_navigator/warehouse/transformers.rb +0 -6
  18. data/lib/ncs_navigator/warehouse/transformers/database.rb +14 -8
  19. data/lib/ncs_navigator/warehouse/transformers/enum_transformer.rb +5 -3
  20. data/lib/ncs_navigator/warehouse/version.rb +1 -1
  21. data/lib/ncs_navigator/warehouse/xml_emitter.rb +101 -50
  22. data/sample_configuration.rb +12 -0
  23. data/spec/ncs_navigator/warehouse/configuration_spec.rb +102 -0
  24. data/spec/ncs_navigator/warehouse/contents_spec.rb +166 -0
  25. data/spec/ncs_navigator/warehouse/filters/add_id_prefix_filter_spec.rb +82 -0
  26. data/spec/ncs_navigator/warehouse/{transformers → filters}/apply_global_values_filter_spec.rb +1 -1
  27. data/spec/ncs_navigator/warehouse/{transformers → filters}/coded_as_missing_filter_spec.rb +1 -1
  28. data/spec/ncs_navigator/warehouse/{transformers/filters_spec.rb → filters/composite_filter_spec.rb} +8 -8
  29. data/spec/ncs_navigator/warehouse/{transformers → filters}/no_blank_foreign_keys_filter_spec.rb +1 -1
  30. data/spec/ncs_navigator/warehouse/{transformers → filters}/no_ssu_outreach_all_ssus_filter_spec.rb +1 -1
  31. data/spec/ncs_navigator/warehouse/{transformers → filters}/no_ssu_outreach_placeholder_filter_spec.rb +1 -1
  32. data/spec/ncs_navigator/warehouse/filters/remove_id_prefix_filter_spec.rb +95 -0
  33. data/spec/ncs_navigator/warehouse/xml_emitter_spec.rb +94 -0
  34. metadata +33 -22
  35. data/lib/ncs_navigator/warehouse/transformers/filters.rb +0 -66
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncs_mdes_warehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ncs_mdes
@@ -2890,9 +2890,20 @@ files:
2890
2890
  - lib/ncs_navigator/warehouse/comparator.rb
2891
2891
  - lib/ncs_navigator/warehouse/configuration.rb
2892
2892
  - lib/ncs_navigator/warehouse/configuration/file_evaluator.rb
2893
+ - lib/ncs_navigator/warehouse/contents.rb
2893
2894
  - lib/ncs_navigator/warehouse/data_mapper.rb
2894
2895
  - lib/ncs_navigator/warehouse/data_mapper_patches.rb
2895
2896
  - lib/ncs_navigator/warehouse/database_initializer.rb
2897
+ - lib/ncs_navigator/warehouse/filters.rb
2898
+ - lib/ncs_navigator/warehouse/filters/add_id_prefix_filter.rb
2899
+ - lib/ncs_navigator/warehouse/filters/apply_global_values_filter.rb
2900
+ - lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb
2901
+ - lib/ncs_navigator/warehouse/filters/composite_filter.rb
2902
+ - lib/ncs_navigator/warehouse/filters/no_blank_foreign_keys_filter.rb
2903
+ - lib/ncs_navigator/warehouse/filters/no_ssu_outreach_all_ssus_filter.rb
2904
+ - lib/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter.rb
2905
+ - lib/ncs_navigator/warehouse/filters/record_id_changing_filter_support.rb
2906
+ - lib/ncs_navigator/warehouse/filters/remove_id_prefix_filter.rb
2896
2907
  - lib/ncs_navigator/warehouse/hooks.rb
2897
2908
  - lib/ncs_navigator/warehouse/hooks/etl_status_email.rb
2898
2909
  - lib/ncs_navigator/warehouse/mailer_templates/etl_status_email/failure_message.text.erb
@@ -2909,21 +2920,15 @@ files:
2909
2920
  - lib/ncs_navigator/warehouse/transform_load.rb
2910
2921
  - lib/ncs_navigator/warehouse/transform_status.rb
2911
2922
  - lib/ncs_navigator/warehouse/transformers.rb
2912
- - lib/ncs_navigator/warehouse/transformers/apply_global_values_filter.rb
2913
- - lib/ncs_navigator/warehouse/transformers/coded_as_missing_filter.rb
2914
2923
  - lib/ncs_navigator/warehouse/transformers/database.rb
2915
2924
  - lib/ncs_navigator/warehouse/transformers/enum_transformer.rb
2916
2925
  - lib/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer.rb
2917
- - lib/ncs_navigator/warehouse/transformers/filters.rb
2918
2926
  - lib/ncs_navigator/warehouse/transformers/foreign_key_index.rb
2919
2927
  - lib/ncs_navigator/warehouse/transformers/foreign_key_index/database_key_provider.rb
2920
2928
  - lib/ncs_navigator/warehouse/transformers/foreign_key_index/static_key_provider.rb
2921
2929
  - lib/ncs_navigator/warehouse/transformers/mdes_csv.rb
2922
2930
  - lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb
2923
2931
  - lib/ncs_navigator/warehouse/transformers/mdes_csv/table_reader.rb
2924
- - lib/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter.rb
2925
- - lib/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter.rb
2926
- - lib/ncs_navigator/warehouse/transformers/no_ssu_outreach_placeholder_filter.rb
2927
2932
  - lib/ncs_navigator/warehouse/transformers/sampling_units.rb
2928
2933
  - lib/ncs_navigator/warehouse/transformers/sql/sql_statements.treetop
2929
2934
  - lib/ncs_navigator/warehouse/transformers/sql_transformer.rb
@@ -2941,8 +2946,17 @@ files:
2941
2946
  - spec/global_state_helper.rb
2942
2947
  - spec/navigator.ini
2943
2948
  - spec/ncs_navigator/warehouse/configuration_spec.rb
2949
+ - spec/ncs_navigator/warehouse/contents_spec.rb
2944
2950
  - spec/ncs_navigator/warehouse/data_mapper_spec.rb
2945
2951
  - spec/ncs_navigator/warehouse/database_initializer_spec.rb
2952
+ - spec/ncs_navigator/warehouse/filters/add_id_prefix_filter_spec.rb
2953
+ - spec/ncs_navigator/warehouse/filters/apply_global_values_filter_spec.rb
2954
+ - spec/ncs_navigator/warehouse/filters/coded_as_missing_filter_spec.rb
2955
+ - spec/ncs_navigator/warehouse/filters/composite_filter_spec.rb
2956
+ - spec/ncs_navigator/warehouse/filters/no_blank_foreign_keys_filter_spec.rb
2957
+ - spec/ncs_navigator/warehouse/filters/no_ssu_outreach_all_ssus_filter_spec.rb
2958
+ - spec/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter_spec.rb
2959
+ - spec/ncs_navigator/warehouse/filters/remove_id_prefix_filter_spec.rb
2946
2960
  - spec/ncs_navigator/warehouse/hooks/etl_status_email_spec.rb
2947
2961
  - spec/ncs_navigator/warehouse/models/mdes_model_spec.rb
2948
2962
  - spec/ncs_navigator/warehouse/models_spec.rb
@@ -2951,20 +2965,14 @@ files:
2951
2965
  - spec/ncs_navigator/warehouse/table_modeler_spec.rb
2952
2966
  - spec/ncs_navigator/warehouse/transform_load_spec.rb
2953
2967
  - spec/ncs_navigator/warehouse/transform_status_spec.rb
2954
- - spec/ncs_navigator/warehouse/transformers/apply_global_values_filter_spec.rb
2955
- - spec/ncs_navigator/warehouse/transformers/coded_as_missing_filter_spec.rb
2956
2968
  - spec/ncs_navigator/warehouse/transformers/database_spec.rb
2957
2969
  - spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
2958
2970
  - spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
2959
- - spec/ncs_navigator/warehouse/transformers/filters_spec.rb
2960
2971
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index/database_key_provider_spec.rb
2961
2972
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index_spec.rb
2962
2973
  - spec/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader_spec.rb
2963
2974
  - spec/ncs_navigator/warehouse/transformers/mdes_csv/table_reader_spec.rb
2964
2975
  - spec/ncs_navigator/warehouse/transformers/mdes_csv_spec.rb
2965
- - spec/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter_spec.rb
2966
- - spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter_spec.rb
2967
- - spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_placeholder_filter_spec.rb
2968
2976
  - spec/ncs_navigator/warehouse/transformers/sampling_units_spec.rb
2969
2977
  - spec/ncs_navigator/warehouse/transformers/sql_transformer_spec.rb
2970
2978
  - spec/ncs_navigator/warehouse/transformers/subprocess_transformer_spec.rb
@@ -2992,7 +3000,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
2992
3000
  version: '0'
2993
3001
  segments:
2994
3002
  - 0
2995
- hash: 3977651589906325525
3003
+ hash: 2914256523883206240
2996
3004
  required_rubygems_version: !ruby/object:Gem::Requirement
2997
3005
  none: false
2998
3006
  requirements:
@@ -3001,7 +3009,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
3001
3009
  version: '0'
3002
3010
  segments:
3003
3011
  - 0
3004
- hash: 3977651589906325525
3012
+ hash: 2914256523883206240
3005
3013
  requirements: []
3006
3014
  rubyforge_project:
3007
3015
  rubygems_version: 1.8.25
@@ -3016,8 +3024,17 @@ test_files:
3016
3024
  - spec/global_state_helper.rb
3017
3025
  - spec/navigator.ini
3018
3026
  - spec/ncs_navigator/warehouse/configuration_spec.rb
3027
+ - spec/ncs_navigator/warehouse/contents_spec.rb
3019
3028
  - spec/ncs_navigator/warehouse/data_mapper_spec.rb
3020
3029
  - spec/ncs_navigator/warehouse/database_initializer_spec.rb
3030
+ - spec/ncs_navigator/warehouse/filters/add_id_prefix_filter_spec.rb
3031
+ - spec/ncs_navigator/warehouse/filters/apply_global_values_filter_spec.rb
3032
+ - spec/ncs_navigator/warehouse/filters/coded_as_missing_filter_spec.rb
3033
+ - spec/ncs_navigator/warehouse/filters/composite_filter_spec.rb
3034
+ - spec/ncs_navigator/warehouse/filters/no_blank_foreign_keys_filter_spec.rb
3035
+ - spec/ncs_navigator/warehouse/filters/no_ssu_outreach_all_ssus_filter_spec.rb
3036
+ - spec/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter_spec.rb
3037
+ - spec/ncs_navigator/warehouse/filters/remove_id_prefix_filter_spec.rb
3021
3038
  - spec/ncs_navigator/warehouse/hooks/etl_status_email_spec.rb
3022
3039
  - spec/ncs_navigator/warehouse/models/mdes_model_spec.rb
3023
3040
  - spec/ncs_navigator/warehouse/models_spec.rb
@@ -3026,20 +3043,14 @@ test_files:
3026
3043
  - spec/ncs_navigator/warehouse/table_modeler_spec.rb
3027
3044
  - spec/ncs_navigator/warehouse/transform_load_spec.rb
3028
3045
  - spec/ncs_navigator/warehouse/transform_status_spec.rb
3029
- - spec/ncs_navigator/warehouse/transformers/apply_global_values_filter_spec.rb
3030
- - spec/ncs_navigator/warehouse/transformers/coded_as_missing_filter_spec.rb
3031
3046
  - spec/ncs_navigator/warehouse/transformers/database_spec.rb
3032
3047
  - spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
3033
3048
  - spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
3034
- - spec/ncs_navigator/warehouse/transformers/filters_spec.rb
3035
3049
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index/database_key_provider_spec.rb
3036
3050
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index_spec.rb
3037
3051
  - spec/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader_spec.rb
3038
3052
  - spec/ncs_navigator/warehouse/transformers/mdes_csv/table_reader_spec.rb
3039
3053
  - spec/ncs_navigator/warehouse/transformers/mdes_csv_spec.rb
3040
- - spec/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter_spec.rb
3041
- - spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter_spec.rb
3042
- - spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_placeholder_filter_spec.rb
3043
3054
  - spec/ncs_navigator/warehouse/transformers/sampling_units_spec.rb
3044
3055
  - spec/ncs_navigator/warehouse/transformers/sql_transformer_spec.rb
3045
3056
  - spec/ncs_navigator/warehouse/transformers/subprocess_transformer_spec.rb
@@ -1,66 +0,0 @@
1
- require 'forwardable'
2
-
3
- module NcsNavigator::Warehouse::Transformers
4
- ##
5
- # Encapsulates an ordered list of filters that can be applied to a
6
- # record coming out of an enumeration in {EnumTransformer}.
7
- #
8
- # Each filter is an object with an `call` method. The `call`
9
- # method takes an array of zero or more records as input and returns
10
- # an array of zero or more records. The input and output arrays may
11
- # be the same or different. A filter may add, remove, or mutate
12
- # records (or all three).
13
- #
14
- # A filter will be called multiple times for a single transform run,
15
- # but it will never see the same record twice. To put it another
16
- # way, the first filter will be invoked exactly once per record
17
- # yielded from an {EnumTransformer}'s enumeration. Subsequent
18
- # filters are invoked on return value from the previous filter.
19
- #
20
- # Depending on the filter order, a particular filter may never see
21
- # some of the eventually transformed records. This will happen if
22
- # records are created by a filter lower in the filter chain.
23
- class Filters
24
- include Enumerable
25
- extend Forwardable
26
-
27
- def_delegators :@filters, :each
28
-
29
- attr_accessor :filters
30
-
31
- def initialize(filter_objects)
32
- check_filters(filter_objects)
33
-
34
- @filters = filter_objects
35
- end
36
-
37
- ##
38
- # @param records [Array] zero or more records to filter.
39
- # @return [Array] the filtered records.
40
- def call(records)
41
- filters.inject(ensure_array(records)) { |result, filter| ensure_array(filter.call(result)) }
42
- end
43
-
44
- private
45
-
46
- def check_filters(candidates)
47
- candidates.each_with_index do |f, i|
48
- unless f.respond_to?(:call)
49
- fail "Filter #{i} (#{f.class}) does not have a call method"
50
- end
51
- end
52
- end
53
-
54
- def ensure_array(records)
55
- case records
56
- when nil
57
- []
58
- when Enumerable
59
- records.to_a
60
- else
61
- [records]
62
- end
63
- end
64
- end
65
- end
66
-