marty 1.2.8 → 1.2.9
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/Gemfile.lock +1 -1
 - data/app/components/marty/base_rule_view.rb +29 -14
 - data/app/components/marty/extras/layout.rb +3 -2
 - data/app/models/marty/base_rule.rb +3 -3
 - data/lib/marty/version.rb +1 -1
 - data/spec/dummy/app/models/gemini/my_rule.rb +12 -1
 - data/spec/dummy/app/models/gemini/xyz_rule.rb +2 -1
 - data/spec/dummy/config/locales/en.yml +6 -1
 - data/spec/features/rule_spec.rb +34 -14
 - data/spec/fixtures/csv/rule/MyRule.csv +2 -1
 - data/spec/models/rule_spec.rb +24 -8
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6f9329ef429a6180b90811a7f0f438395a06a51f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 53eb8d02f9e32fb11f44f8a091a037d7758349b5
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cb21b47adbdc2a81981d9b1334e6e1e9ab93d989bcaa51c166ed20e99b2b9ead53d0725497fd5e43879d99029255ecfd189adadf0a69367061610a9e426fc675
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 738b139779f6d7a000b210b998a2c485fda2d47ffee0d9e463678fa41498290ccb8662d8af54b9c3b18c7c43ac52fef0e9464ff6de0819ac0c940b6466121629
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -103,13 +103,19 @@ class Marty::BaseRuleView < Marty::McflyGridPanel 
     | 
|
| 
       103 
103 
     | 
    
         
             
                }
         
     | 
| 
       104 
104 
     | 
    
         
             
              end
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
              def self.jsonb_field_getter(j, c)
         
     | 
| 
       107 
     | 
    
         
            -
                lambda  
     | 
| 
      
 106 
     | 
    
         
            +
              def self.jsonb_field_getter(j, c, nullbool=nil)
         
     | 
| 
      
 107 
     | 
    
         
            +
                lambda do |r|
         
     | 
| 
      
 108 
     | 
    
         
            +
                  rv = r.send(j)[c]
         
     | 
| 
      
 109 
     | 
    
         
            +
                  v = nullbool ? (rv == true ? 'True' :
         
     | 
| 
      
 110 
     | 
    
         
            +
                                    rv == false ? 'False' : rv) : rv
         
     | 
| 
      
 111 
     | 
    
         
            +
                  v || ""
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
       108 
113 
     | 
    
         
             
              end
         
     | 
| 
       109 
114 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
              def self.jsonb_field_setter(j, c)
         
     | 
| 
       111 
     | 
    
         
            -
                lambda do |r,  
     | 
| 
       112 
     | 
    
         
            -
                  v 
     | 
| 
      
 115 
     | 
    
         
            +
              def self.jsonb_field_setter(j, c, bool=nil)
         
     | 
| 
      
 116 
     | 
    
         
            +
                lambda do |r, rv|
         
     | 
| 
      
 117 
     | 
    
         
            +
                  v = bool ? rv.to_s.downcase == 'true' : rv
         
     | 
| 
      
 118 
     | 
    
         
            +
                  rv == '' || rv == '---' ? r.send(j).delete(c) : r.send(j)[c] = v
         
     | 
| 
       113 
119 
     | 
    
         
             
                end
         
     | 
| 
       114 
120 
     | 
    
         
             
              end
         
     | 
| 
       115 
121 
     | 
    
         | 
| 
         @@ -212,26 +218,35 @@ class Marty::BaseRuleView < Marty::McflyGridPanel 
     | 
|
| 
       212 
218 
     | 
    
         | 
| 
       213 
219 
     | 
    
         
             
              def self.field_maker(namestr, h, meth)
         
     | 
| 
       214 
220 
     | 
    
         
             
                name = namestr.to_sym
         
     | 
| 
      
 221 
     | 
    
         
            +
                nullbool = h[:type] == :boolean && (h[:null] == true || !h.include?(:null))
         
     | 
| 
       215 
222 
     | 
    
         
             
                attribute name do |c|
         
     | 
| 
       216 
223 
     | 
    
         
             
                  c.width = h[:width] || 150
         
     | 
| 
       217 
     | 
    
         
            -
                  case 
     | 
| 
       218 
     | 
    
         
            -
                  when : 
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
                   
     | 
| 
      
 224 
     | 
    
         
            +
                  case
         
     | 
| 
      
 225 
     | 
    
         
            +
                  when h[:type] == :datetime
         
     | 
| 
      
 226 
     | 
    
         
            +
                    c.format = 'Y-m-d H:i'
         
     | 
| 
      
 227 
     | 
    
         
            +
                  when h[:type] == :date
         
     | 
| 
      
 228 
     | 
    
         
            +
                    c.format = 'Y-m-d'
         
     | 
| 
      
 229 
     | 
    
         
            +
                  when nullbool
         
     | 
| 
      
 230 
     | 
    
         
            +
                      c.type = :string
         
     | 
| 
      
 231 
     | 
    
         
            +
                      enum_column(c, ['True', 'False'])
         
     | 
| 
      
 232 
     | 
    
         
            +
                  else
         
     | 
| 
      
 233 
     | 
    
         
            +
                    c.type = h[:type] || :string
         
     | 
| 
       221 
234 
     | 
    
         
             
                  end
         
     | 
| 
       222 
235 
     | 
    
         
             
                  c.label = h[:label] if h[:label]
         
     | 
| 
       223 
     | 
    
         
            -
                  if h[:enum]
         
     | 
| 
      
 236 
     | 
    
         
            +
                  if h[:enum] || (h[:type] == :string && h[:values].present?)
         
     | 
| 
      
 237 
     | 
    
         
            +
                    vals = h[:enum] || h[:values]
         
     | 
| 
       224 
238 
     | 
    
         
             
                    if h[:multi]
         
     | 
| 
       225 
     | 
    
         
            -
                      enum_array(c,  
     | 
| 
      
 239 
     | 
    
         
            +
                      enum_array(c, vals)
         
     | 
| 
       226 
240 
     | 
    
         
             
                    else
         
     | 
| 
       227 
     | 
    
         
            -
                      enum_column(c,  
     | 
| 
      
 241 
     | 
    
         
            +
                      enum_column(c, vals)
         
     | 
| 
       228 
242 
     | 
    
         
             
                    end
         
     | 
| 
       229 
243 
     | 
    
         
             
                  end
         
     | 
| 
       230 
244 
     | 
    
         
             
                  # for some unexplained reason the getter/setter need the full
         
     | 
| 
       231 
245 
     | 
    
         
             
                  # class qualification
         
     | 
| 
       232 
246 
     | 
    
         
             
                  if h[:type] != :range
         
     | 
| 
       233 
     | 
    
         
            -
                    c.getter = Marty:: 
     | 
| 
       234 
     | 
    
         
            -
                    c.setter = Marty:: 
     | 
| 
      
 247 
     | 
    
         
            +
                    c.getter = Marty::BaseRuleView.jsonb_field_getter(meth, namestr, nullbool)
         
     | 
| 
      
 248 
     | 
    
         
            +
                    c.setter = Marty::BaseRuleView.jsonb_field_setter(meth, namestr,
         
     | 
| 
      
 249 
     | 
    
         
            +
                                                                      h[:type]==:boolean)
         
     | 
| 
       235 
250 
     | 
    
         
             
                    c.filter_with = lambda do |rel, value, op|
         
     | 
| 
       236 
251 
     | 
    
         
             
                      v = ActiveRecord::Base.connection.quote(value)[1..-2]
         
     | 
| 
       237 
252 
     | 
    
         
             
                      rel.where("#{meth}->>'#{namestr}' like '%#{v}%'")
         
     | 
| 
         @@ -73,13 +73,14 @@ module Layout 
     | 
|
| 
       73 
73 
     | 
    
         
             
              ######################################################################
         
     | 
| 
       74 
74 
     | 
    
         
             
              # PG ENUM field handling
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
              def enum_column(c,  
     | 
| 
      
 76 
     | 
    
         
            +
              def enum_column(c, class_or_array)
         
     | 
| 
      
 77 
     | 
    
         
            +
                vals = class_or_array.is_a?(Array) ? class_or_array : class_or_array::VALUES
         
     | 
| 
       77 
78 
     | 
    
         
             
                editor_config = {
         
     | 
| 
       78 
79 
     | 
    
         
             
                  trigger_action: :all,
         
     | 
| 
       79 
80 
     | 
    
         
             
                  xtype:          :combo,
         
     | 
| 
       80 
81 
     | 
    
         | 
| 
       81 
82 
     | 
    
         
             
                  # hacky: extjs has issues with forceSelection true and clearing combos
         
     | 
| 
       82 
     | 
    
         
            -
                  store:           
     | 
| 
      
 83 
     | 
    
         
            +
                  store:          vals + ['---'],
         
     | 
| 
       83 
84 
     | 
    
         | 
| 
       84 
85 
     | 
    
         
             
                  # we can dynamically add enums (i.e. they're not in VALUES) --
         
     | 
| 
       85 
86 
     | 
    
         
             
                  # turn off forced selection.
         
     | 
| 
         @@ -17,7 +17,7 @@ class Marty::BaseRule < Marty::Base 
     | 
|
| 
       17 
17 
     | 
    
         
             
                types << :date if Date.parse(v) rescue nil
         
     | 
| 
       18 
18 
     | 
    
         
             
                types << :datetime if DateTime.parse(v) rescue nil
         
     | 
| 
       19 
19 
     | 
    
         
             
                types << :range if chkrange(v) rescue nil
         
     | 
| 
       20 
     | 
    
         
            -
                types << :boolean if [true, false].include?(v)
         
     | 
| 
      
 20 
     | 
    
         
            +
                types << :boolean if [true, false, 'True', 'False'].include?(v)
         
     | 
| 
       21 
21 
     | 
    
         
             
                types
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         
             
              def check(name, h)
         
     | 
| 
         @@ -72,7 +72,7 @@ class Marty::BaseRule < Marty::Base 
     | 
|
| 
       72 
72 
     | 
    
         | 
| 
       73 
73 
     | 
    
         
             
              before_create do
         
     | 
| 
       74 
74 
     | 
    
         
             
                self.class.guard_info.each do |k,v|
         
     | 
| 
       75 
     | 
    
         
            -
                  next if v 
     | 
| 
      
 75 
     | 
    
         
            +
                  next if !v.include?(:default) || self.simple_guards.include?(k)
         
     | 
| 
       76 
76 
     | 
    
         
             
                  self.simple_guards[k] = v[:default]
         
     | 
| 
       77 
77 
     | 
    
         
             
                end
         
     | 
| 
       78 
78 
     | 
    
         
             
              end
         
     | 
| 
         @@ -108,7 +108,7 @@ class Marty::BaseRule < Marty::Base 
     | 
|
| 
       108 
108 
     | 
    
         | 
| 
       109 
109 
     | 
    
         
             
                  q = q.where("(#{isn} #{filts})")
         
     | 
| 
       110 
110 
     | 
    
         
             
                end
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
                #print q.to_sql
         
     | 
| 
       112 
112 
     | 
    
         
             
                q.order(:name)
         
     | 
| 
       113 
113 
     | 
    
         
             
              end
         
     | 
| 
       114 
114 
     | 
    
         | 
    
        data/lib/marty/version.rb
    CHANGED
    
    
| 
         @@ -22,13 +22,24 @@ class Gemini::MyRule < Marty::DeloreanRule 
     | 
|
| 
       22 
22 
     | 
    
         
             
                                         values: ["Hi Mom", "abc", "def", "zzz"],
         
     | 
| 
       23 
23 
     | 
    
         
             
                                         width: 100},
         
     | 
| 
       24 
24 
     | 
    
         
             
                         "g_bool" => { type: :boolean,
         
     | 
| 
      
 25 
     | 
    
         
            +
                                       width: 100,
         
     | 
| 
      
 26 
     | 
    
         
            +
                                       null: false},
         
     | 
| 
      
 27 
     | 
    
         
            +
                         "g_nullbool" => { type: :boolean,
         
     | 
| 
       25 
28 
     | 
    
         
             
                                       width: 100},
         
     | 
| 
       26 
29 
     | 
    
         
             
                         "g_range" => { type: :range,
         
     | 
| 
       27 
30 
     | 
    
         
             
                                        width: 100},
         
     | 
| 
       28 
31 
     | 
    
         
             
                         "g_integer" => { type: :integer,
         
     | 
| 
       29 
32 
     | 
    
         
             
                                          width: 100},
         
     | 
| 
       30 
33 
     | 
    
         
             
                         "g_has_default" => { type:  :string,
         
     | 
| 
       31 
     | 
    
         
            -
                                              default: "string default"} 
     | 
| 
      
 34 
     | 
    
         
            +
                                              default: "string default"},
         
     | 
| 
      
 35 
     | 
    
         
            +
                         "g_bool_def" => { type: :boolean,
         
     | 
| 
      
 36 
     | 
    
         
            +
                                           width: 100,
         
     | 
| 
      
 37 
     | 
    
         
            +
                                           default: true,
         
     | 
| 
      
 38 
     | 
    
         
            +
                                           null: false},
         
     | 
| 
      
 39 
     | 
    
         
            +
                         "g_nbool_def" => { type: :boolean,
         
     | 
| 
      
 40 
     | 
    
         
            +
                                            default: false,
         
     | 
| 
      
 41 
     | 
    
         
            +
                                           width: 100},
         
     | 
| 
      
 42 
     | 
    
         
            +
                }
         
     | 
| 
       32 
43 
     | 
    
         
             
              end
         
     | 
| 
       33 
44 
     | 
    
         
             
              def self.results_cfg_var
         
     | 
| 
       34 
45 
     | 
    
         
             
                'RULEOPTS_MYRULE'
         
     | 
| 
         @@ -9,7 +9,12 @@ en: 
     | 
|
| 
       9 
9 
     | 
    
         
             
                g_array: "Array Guard"
         
     | 
| 
       10 
10 
     | 
    
         
             
                g_single: "Single Guard"
         
     | 
| 
       11 
11 
     | 
    
         
             
                g_bool: "Bool Guard"
         
     | 
| 
      
 12 
     | 
    
         
            +
                g_string: "String list Guard"
         
     | 
| 
      
 13 
     | 
    
         
            +
                g_has_default: "Defaulted String"
         
     | 
| 
      
 14 
     | 
    
         
            +
                g_nullbool: "NullBool Guard"
         
     | 
| 
       12 
15 
     | 
    
         
             
                g_range: "Range Guard"
         
     | 
| 
       13 
16 
     | 
    
         
             
                g_range1: "Range Guard 1"
         
     | 
| 
       14 
17 
     | 
    
         
             
                g_range2: "Range Guard 2"
         
     | 
| 
       15 
     | 
    
         
            -
                other_flag: "Other"
         
     | 
| 
      
 18 
     | 
    
         
            +
                other_flag: "Other"
         
     | 
| 
      
 19 
     | 
    
         
            +
                g_bool_def: "Bool def Guard"
         
     | 
| 
      
 20 
     | 
    
         
            +
                g_nbool_def: "NBool def Guard"
         
     | 
    
        data/spec/features/rule_spec.rb
    CHANGED
    
    | 
         @@ -94,7 +94,7 @@ feature 'rule view', js: true do 
     | 
|
| 
       94 
94 
     | 
    
         
             
                time_fill_in(1, '08:03:01')
         
     | 
| 
       95 
95 
     | 
    
         
             
                press("OK")
         
     | 
| 
       96 
96 
     | 
    
         
             
                wait_for_ajax
         
     | 
| 
       97 
     | 
    
         
            -
                expect(mrv.row_count()).to eq( 
     | 
| 
      
 97 
     | 
    
         
            +
                expect(mrv.row_count()).to eq(9)
         
     | 
| 
       98 
98 
     | 
    
         
             
                expect(mrv.get_row_vals(1)).to include({"name"=>"abc",
         
     | 
| 
       99 
99 
     | 
    
         
             
                                                        "rule_type"=>"SimpleRule",
         
     | 
| 
       100 
100 
     | 
    
         
             
                                                        "start_dt"=>"2013-01-01T19:03:01.000Z",
         
     | 
| 
         @@ -104,8 +104,12 @@ feature 'rule view', js: true do 
     | 
|
| 
       104 
104 
     | 
    
         
             
                                                        "g_single"=>"",
         
     | 
| 
       105 
105 
     | 
    
         
             
                                                        "g_string"=>"",
         
     | 
| 
       106 
106 
     | 
    
         
             
                                                        "g_bool"=>nil,
         
     | 
| 
      
 107 
     | 
    
         
            +
                                                        "g_nullbool"=>"",
         
     | 
| 
      
 108 
     | 
    
         
            +
                                                        "g_bool_def"=>nil,
         
     | 
| 
      
 109 
     | 
    
         
            +
                                                        "g_nbool_def"=>"False",
         
     | 
| 
       107 
110 
     | 
    
         
             
                                                        "g_range"=>nil,
         
     | 
| 
       108 
111 
     | 
    
         
             
                                                        "g_integer"=>nil,
         
     | 
| 
      
 112 
     | 
    
         
            +
                                                        "g_has_default"=>"string default",
         
     | 
| 
       109 
113 
     | 
    
         
             
                                                        "computed_guards"=>"",
         
     | 
| 
       110 
114 
     | 
    
         
             
                                                        "grids"=>"",
         
     | 
| 
       111 
115 
     | 
    
         
             
                                                        "results"=>"",
         
     | 
| 
         @@ -116,7 +120,10 @@ feature 'rule view', js: true do 
     | 
|
| 
       116 
120 
     | 
    
         
             
                                              "name"=>"abc",
         
     | 
| 
       117 
121 
     | 
    
         
             
                                              "engine"=>"Gemini::MyRuleScriptSet",
         
     | 
| 
       118 
122 
     | 
    
         
             
                                              "rule_type"=>"SimpleRule",
         
     | 
| 
       119 
     | 
    
         
            -
                                              "simple_guards"=>{" 
     | 
| 
      
 123 
     | 
    
         
            +
                                              "simple_guards"=>{"g_bool"=>false,
         
     | 
| 
      
 124 
     | 
    
         
            +
                                                                "g_bool_def"=>false,
         
     | 
| 
      
 125 
     | 
    
         
            +
                                                                "g_nbool_def"=>false,
         
     | 
| 
      
 126 
     | 
    
         
            +
                                                                "g_has_default"=>
         
     | 
| 
       120 
127 
     | 
    
         
             
                                                                "string default"},
         
     | 
| 
       121 
128 
     | 
    
         
             
                                              "computed_guards"=>{},
         
     | 
| 
       122 
129 
     | 
    
         
             
                                              "grids"=>{},
         
     | 
| 
         @@ -125,14 +132,11 @@ feature 'rule view', js: true do 
     | 
|
| 
       125 
132 
     | 
    
         
             
                # type validation (string with values list)
         
     | 
| 
       126 
133 
     | 
    
         
             
                mrv.select_row(1)
         
     | 
| 
       127 
134 
     | 
    
         
             
                press("Edit")
         
     | 
| 
       128 
     | 
    
         
            -
                fill_in(:g_string, with: "12345")
         
     | 
| 
       129 
     | 
    
         
            -
                press("OK")
         
     | 
| 
       130 
     | 
    
         
            -
                wait_for_ajax
         
     | 
| 
       131 
     | 
    
         
            -
                expect(page).to have_content("Bad value '12345' for 'g_string'")
         
     | 
| 
       132 
135 
     | 
    
         
             
                # type validation (range)
         
     | 
| 
       133 
     | 
    
         
            -
                 
     | 
| 
      
 136 
     | 
    
         
            +
                netzke_find("String list Guard", 'combobox').select_values("Hi Mom")
         
     | 
| 
       134 
137 
     | 
    
         
             
                click_checkbox("Bool Guard")
         
     | 
| 
       135 
138 
     | 
    
         
             
                click_checkbox("Other")
         
     | 
| 
      
 139 
     | 
    
         
            +
                netzke_find("NullBool Guard", 'combobox').select_values("False")
         
     | 
| 
       136 
140 
     | 
    
         
             
                netzke_find('Array Guard', 'combobox').select_values("G1V1,G1V3")
         
     | 
| 
       137 
141 
     | 
    
         
             
                netzke_find('Single Guard', 'combobox').select_values("G2V2")
         
     | 
| 
       138 
142 
     | 
    
         
             
                fill_in(:g_integer, with: 123)
         
     | 
| 
         @@ -144,6 +148,7 @@ feature 'rule view', js: true do 
     | 
|
| 
       144 
148 
     | 
    
         
             
                fill_in(:g_range, with: "<=100")
         
     | 
| 
       145 
149 
     | 
    
         
             
                netzke_find('Grid1', 'combobox').select_values("DataGrid1")
         
     | 
| 
       146 
150 
     | 
    
         
             
                netzke_find('Grid2', 'combobox').select_values("DataGrid2")
         
     | 
| 
      
 151 
     | 
    
         
            +
                fill_in("Defaulted String", with: "12345")
         
     | 
| 
       147 
152 
     | 
    
         
             
                press("OK")
         
     | 
| 
       148 
153 
     | 
    
         
             
                wait_for_ajax
         
     | 
| 
       149 
154 
     | 
    
         
             
                exp = {"name"=>"abc",
         
     | 
| 
         @@ -155,12 +160,16 @@ feature 'rule view', js: true do 
     | 
|
| 
       155 
160 
     | 
    
         
             
                       "g_single"=>"G2V2",
         
     | 
| 
       156 
161 
     | 
    
         
             
                       "g_string"=>"Hi Mom",
         
     | 
| 
       157 
162 
     | 
    
         
             
                       "g_bool"=>true,
         
     | 
| 
      
 163 
     | 
    
         
            +
                       "g_nullbool"=>"False",
         
     | 
| 
       158 
164 
     | 
    
         
             
                       "g_range"=>"<=100",
         
     | 
| 
       159 
165 
     | 
    
         
             
                       "g_integer"=>123,
         
     | 
| 
      
 166 
     | 
    
         
            +
                       "g_has_default"=>"12345",
         
     | 
| 
       160 
167 
     | 
    
         
             
                       "computed_guards"=>"",
         
     | 
| 
       161 
168 
     | 
    
         
             
                       "grids"=>"{\"grid1\":\"DataGrid1\",\"grid2\":\"DataGrid2\"}",
         
     | 
| 
       162 
169 
     | 
    
         
             
                       "results"=>"",
         
     | 
| 
       163 
170 
     | 
    
         
             
                      }
         
     | 
| 
      
 171 
     | 
    
         
            +
                r = Gemini::MyRule.lookup('infinity','abc')
         
     | 
| 
      
 172 
     | 
    
         
            +
                expect(r.as_json["simple_guards"]["g_nullbool"]).to eq(false)
         
     | 
| 
       164 
173 
     | 
    
         
             
                expect(mrv.get_row_vals(1)).to include(exp)
         
     | 
| 
       165 
174 
     | 
    
         
             
                # grid edits
         
     | 
| 
       166 
175 
     | 
    
         
             
                press("Edit")
         
     | 
| 
         @@ -169,6 +178,15 @@ feature 'rule view', js: true do 
     | 
|
| 
       169 
178 
     | 
    
         
             
                wait_for_ajax
         
     | 
| 
       170 
179 
     | 
    
         
             
                expect(mrv.get_row_vals(1)).to include(exp+{"grids"=>
         
     | 
| 
       171 
180 
     | 
    
         
             
                                                            "{\"grid1\":\"DataGrid1\"}"})
         
     | 
| 
      
 181 
     | 
    
         
            +
                press("Edit")
         
     | 
| 
      
 182 
     | 
    
         
            +
                netzke_find("NullBool Guard", 'combobox').select_values("---")
         
     | 
| 
      
 183 
     | 
    
         
            +
                press("OK")
         
     | 
| 
      
 184 
     | 
    
         
            +
                wait_for_ajax
         
     | 
| 
      
 185 
     | 
    
         
            +
                expect(mrv.get_row_vals(1)).to include(exp+{"g_nullbool"=>"",
         
     | 
| 
      
 186 
     | 
    
         
            +
                                                            "grids"=>
         
     | 
| 
      
 187 
     | 
    
         
            +
                                                            "{\"grid1\":\"DataGrid1\"}"})
         
     | 
| 
      
 188 
     | 
    
         
            +
                r = Gemini::MyRule.lookup('infinity','abc')
         
     | 
| 
      
 189 
     | 
    
         
            +
                expect(r.as_json["simple_guards"]).not_to include('g_nullbool')
         
     | 
| 
       172 
190 
     | 
    
         
             
                # computed fields
         
     | 
| 
       173 
191 
     | 
    
         
             
                press("Edit")
         
     | 
| 
       174 
192 
     | 
    
         
             
                fill_in(:computed_guards, with: 'sadf asdf ljsf')
         
     | 
| 
         @@ -220,6 +238,7 @@ feature 'rule view', js: true do 
     | 
|
| 
       220 
238 
     | 
    
         
             
                press("OK")
         
     | 
| 
       221 
239 
     | 
    
         
             
                r = Gemini::XyzRule.get_matches('infinity', {}, {"g_range1"=> 150,
         
     | 
| 
       222 
240 
     | 
    
         
             
                                                                 "g_range2"=> 35})
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
       223 
242 
     | 
    
         
             
                expect(r.to_a.count).to eq(1)
         
     | 
| 
       224 
243 
     | 
    
         
             
                exp = {"user_id"=>1,
         
     | 
| 
       225 
244 
     | 
    
         
             
                       "o_user_id"=>nil,
         
     | 
| 
         @@ -227,7 +246,8 @@ feature 'rule view', js: true do 
     | 
|
| 
       227 
246 
     | 
    
         
             
                       "engine"=>"Gemini::XyzRuleScriptSet",
         
     | 
| 
       228 
247 
     | 
    
         
             
                       "rule_type"=>"ZRule",
         
     | 
| 
       229 
248 
     | 
    
         
             
                       "start_dt"=>DateTime.parse("2017-1-1 08:01:00"),
         
     | 
| 
       230 
     | 
    
         
            -
                       "simple_guards"=>{" 
     | 
| 
      
 249 
     | 
    
         
            +
                       "simple_guards"=>{"g_bool"=>false,
         
     | 
| 
      
 250 
     | 
    
         
            +
                                         "g_date"=>"2017-1-1",
         
     | 
| 
       231 
251 
     | 
    
         
             
                                         "g_range1"=>"[100,200)",
         
     | 
| 
       232 
252 
     | 
    
         
             
                                         "g_range2"=>"[30,40)",
         
     | 
| 
       233 
253 
     | 
    
         
             
                                         "g_string"=>"aaa",
         
     | 
| 
         @@ -242,13 +262,13 @@ feature 'rule view', js: true do 
     | 
|
| 
       242 
262 
     | 
    
         
             
                expect(r.first.as_json).to include(exp)
         
     | 
| 
       243 
263 
     | 
    
         
             
                expect(xrv.col_values(:g_string, 5, 0)).to eq(["aaa", "bbb", "ccc",
         
     | 
| 
       244 
264 
     | 
    
         
             
                                                               "ddd", "eee"])
         
     | 
| 
       245 
     | 
    
         
            -
                click_column(xrv, " 
     | 
| 
      
 265 
     | 
    
         
            +
                click_column(xrv, "String list Guard")
         
     | 
| 
       246 
266 
     | 
    
         
             
                expect(xrv.col_values(:g_string, 5, 0)).to eq(["eee", "ddd", "ccc",
         
     | 
| 
       247 
267 
     | 
    
         
             
                                                               "bbb", "aaa"])
         
     | 
| 
       248 
     | 
    
         
            -
                column_filter(xrv, " 
     | 
| 
      
 268 
     | 
    
         
            +
                column_filter(xrv, "String list Guard", "eee")
         
     | 
| 
       249 
269 
     | 
    
         
             
                rc = xrv.row_count
         
     | 
| 
       250 
270 
     | 
    
         
             
                expect(xrv.col_values(:g_string,rc,0)).to eq(["eee"])
         
     | 
| 
       251 
     | 
    
         
            -
                column_filter_toggle(xrv, " 
     | 
| 
      
 271 
     | 
    
         
            +
                column_filter_toggle(xrv, "String list Guard")
         
     | 
| 
       252 
272 
     | 
    
         
             
                rc = xrv.row_count
         
     | 
| 
       253 
273 
     | 
    
         
             
                expect(xrv.col_values(:g_string,rc,0)).to eq(["eee", "ddd", "ccc",
         
     | 
| 
       254 
274 
     | 
    
         
             
                                                               "bbb", "aaa"])
         
     | 
| 
         @@ -293,9 +313,9 @@ feature 'rule view', js: true do 
     | 
|
| 
       293 
313 
     | 
    
         
             
                go_to_my_rules
         
     | 
| 
       294 
314 
     | 
    
         
             
                wait_for_ajax
         
     | 
| 
       295 
315 
     | 
    
         | 
| 
       296 
     | 
    
         
            -
                names = mrv.col_values(:name,  
     | 
| 
       297 
     | 
    
         
            -
                gvs = mrv.col_values(:grids,  
     | 
| 
       298 
     | 
    
         
            -
                rvs = mrv.col_values(:results,  
     | 
| 
      
 316 
     | 
    
         
            +
                names = mrv.col_values(:name, 9, 0)
         
     | 
| 
      
 317 
     | 
    
         
            +
                gvs = mrv.col_values(:grids, 9, 0)
         
     | 
| 
      
 318 
     | 
    
         
            +
                rvs = mrv.col_values(:results, 9, 0)
         
     | 
| 
       299 
319 
     | 
    
         
             
                expect(JSON.parse(gvs[names.index('abc')])).to eq(g1h)
         
     | 
| 
       300 
320 
     | 
    
         
             
                expect(JSON.parse(gvs[names.index('Rule2b')])).to eq(g1h +
         
     | 
| 
       301 
321 
     | 
    
         
             
                                                                     {"grid2"=>"DataGrid2"})
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            name,rule_type,start_dt,end_dt,other_flag,simple_guards,computed_guards,grids,results
         
     | 
| 
       2 
     | 
    
         
            -
            Rule1,SimpleRule,2017-1-1 12:00:00,2017-4-1,,"{""g_has_default"":""different"",""g_array"":[""G1V1"",""G1V3""],""g_single"":""G2V2"",""g_string"":""Hi Mom"",""g_bool"":true,""g_range"":""[50,)"",""g_integer"":10}",,,"{""simple_result"":""\""a value\""""}"
         
     | 
| 
      
 2 
     | 
    
         
            +
            Rule1,SimpleRule,2017-1-1 12:00:00,2017-4-1,,"{""g_has_default"":""different"",""g_array"":[""G1V1"",""G1V3""],""g_single"":""G2V2"",""g_string"":""Hi Mom"",""g_bool"":true,""g_bool_def"":false,""g_nbool_def"":true,""g_range"":""[50,)"",""g_integer"":10}",,,"{""simple_result"":""\""a value\""""}"
         
     | 
| 
       3 
3 
     | 
    
         
             
            Rule2,SimpleRule,2017-2-1 14:00:00,2017-4-1,true,"{""g_array"":[""G1V2""],""g_single"":""G2V3"",""g_string"":""abc"",""g_bool"":true,""g_range"":""(,50]"",""g_integer"":11}",,,"{
         
     | 
| 
       4 
4 
     | 
    
         
             
            ""simple_result"":""\""b value\"" # with comment "", 
         
     | 
| 
       5 
5 
     | 
    
         
             
            ""sr2"":""true # with comment"", 
         
     | 
| 
         @@ -9,6 +9,7 @@ Rule2,SimpleRule,2017-2-1 14:00:00,2017-4-1,true,"{""g_array"":[""G1V2""],""g_si 
     | 
|
| 
       9 
9 
     | 
    
         
             
            ""stringwithhash"": ""\"" string that contains a # character\""""}"
         
     | 
| 
       10 
10 
     | 
    
         
             
            Rule2a,SimpleRule,2017-2-1 14:00:00,2017-4-1,true,"{""g_array"":[""G1V2""],""g_single"":""G2V3"",""g_string"":""abc"",""g_bool"":true,""g_range"":""(,50]"",""g_integer"":99}",,,"{""simple_result"":""\""b value\"""", ""sr2"":""true"", ""sr3"": ""123""}"
         
     | 
| 
       11 
11 
     | 
    
         
             
            Rule2b,SimpleRule,2017-2-1 14:00:00,2017-4-1,true,"{""g_array"":[""G1V2""],""g_single"":""G2V3"",""g_string"":""abc"",""g_bool"":true,""g_range"":""(,50]"",""g_integer"":999}",,"{""grid1"":""DataGrid1"",""grid2"":""DataGrid2""}",
         
     | 
| 
      
 12 
     | 
    
         
            +
            Rule2c,SimpleRule,2017-2-1 14:00:00,2017-4-1,true,"{""g_array"":[""G1V2""],""g_single"":""G2V3"",""g_string"":""abc"",""g_bool"":false,""g_range"":""(,50]"",""g_integer"":10}",,"{""grid1"":""DataGrid1"",""grid2"":""DataGrid2""}",
         
     | 
| 
       12 
13 
     | 
    
         
             
            Rule3,ComplexRule,2017-3-1 00:00:00,2017-4-1,false,"{""g_array"":[""G1V2"",""G1V3""],""g_string"":""def"",""g_integer"":11}","{""cguard1"":""1==1"",""cguard2"":""param2 == 'abc'""}","{""grid1"":""DataGrid1"",""grid2"":""DataGrid2""}","{""simple_result"":""\""c value\"""",""computed_value"":""if paramb then param1 / (grid1_grid_result||1) else (grid2_grid_result||1) / param1""}"
         
     | 
| 
       13 
14 
     | 
    
         
             
            Rule4,ComplexRule,2017-4-1 15:00:01,2017-5-1,,"{""g_array"":[""G1V2"",""G1V3""],""g_string"":""Hi Mom"",""g_integer"":11}","{""cguard1"":""1==1"",""cguard2"":""param2 == \""abc\""""}","{""grid1"":""DataGrid1"",""grid2"":""DataGrid2""}","{""computed_name_grid"":""\""DataGrid\""+\""X\"""", ""simple_result"":""computed_name_grid"",""grid_sum"":""computed_name_grid_result + (grid1_grid_result||0)+(grid2_grid_result||0)""}"
         
     | 
| 
       14 
15 
     | 
    
         
             
            Rule5,ComplexRule,2017-4-2 15:00:01,2017-5-1,,"{""g_string"":""zzz"",""g_integer"":3757,""g_has_default"":""foo""}","{""cguard1"":""1==1""}",,"{""flavor"": ""[\""cherry\"",\""lemon\""][param2]"",""other_grid"": ""\""DataGrid4\"""",""final_value"": ""other_grid_result * 3""}"
         
     | 
    
        data/spec/models/rule_spec.rb
    CHANGED
    
    | 
         @@ -33,7 +33,8 @@ module Marty::RuleSpec 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    guards = (@g_array   ? {"g_array"   =>@g_array}   : {}) +
         
     | 
| 
       34 
34 
     | 
    
         
             
                             (@g_single  ? {"g_single"  =>@g_single}  : {}) +
         
     | 
| 
       35 
35 
     | 
    
         
             
                             (@g_string  ? {"g_string"  =>@g_string}  : {}) +
         
     | 
| 
       36 
     | 
    
         
            -
                             (@g_bool 
     | 
| 
      
 36 
     | 
    
         
            +
                             (@g_bool.nil?     ? {} : {"g_bool"     => @g_bool})     +
         
     | 
| 
      
 37 
     | 
    
         
            +
                             (@g_nullbool.nil? ? {} : {"g_nullbool" => @g_nullbool}) +
         
     | 
| 
       37 
38 
     | 
    
         
             
                             (@g_range   ? {"g_range"   =>@g_range}   : {}) +
         
     | 
| 
       38 
39 
     | 
    
         
             
                             (@g_integer ? {"g_integer" =>@g_integer} : {})
         
     | 
| 
       39 
40 
     | 
    
         
             
                    Gemini::MyRule.create!(name: "testrule",
         
     | 
| 
         @@ -116,6 +117,7 @@ module Marty::RuleSpec 
     | 
|
| 
       116 
117 
     | 
    
         
             
                                        ["Rule2", "string default"],
         
     | 
| 
       117 
118 
     | 
    
         
             
                                        ["Rule2a", "string default"],
         
     | 
| 
       118 
119 
     | 
    
         
             
                                        ["Rule2b", "string default"],
         
     | 
| 
      
 120 
     | 
    
         
            +
                                        ["Rule2c", "string default"],
         
     | 
| 
       119 
121 
     | 
    
         
             
                                        ["Rule3", "string default"],
         
     | 
| 
       120 
122 
     | 
    
         
             
                                        ["Rule4", "string default"],
         
     | 
| 
       121 
123 
     | 
    
         
             
                                        ["Rule5", "foo"]].sort)
         
     | 
| 
         @@ -177,14 +179,22 @@ module Marty::RuleSpec 
     | 
|
| 
       177 
179 
     | 
    
         
             
                                                        {'rule_type'=>'SimpleRule',
         
     | 
| 
       178 
180 
     | 
    
         
             
                                                        'other_flag'=>true},
         
     | 
| 
       179 
181 
     | 
    
         
             
                                                        {})
         
     | 
| 
       180 
     | 
    
         
            -
                    expect(lookup.to_a.count).to eq( 
     | 
| 
       181 
     | 
    
         
            -
                    expect(lookup.map{|l|l.name}.to_set).to eq(Set["Rule2","Rule2a", 
     | 
| 
      
 182 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(4)
         
     | 
| 
      
 183 
     | 
    
         
            +
                    expect(lookup.map{|l|l.name}.to_set).to eq(Set["Rule2","Rule2a",
         
     | 
| 
      
 184 
     | 
    
         
            +
                                                                   "Rule2b", "Rule2c"])
         
     | 
| 
       182 
185 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       183 
186 
     | 
    
         
             
                                                        {'rule_type'=>'ComplexRule',
         
     | 
| 
       184 
187 
     | 
    
         
             
                                                        'other_flag'=>false},
         
     | 
| 
       185 
188 
     | 
    
         
             
                                                        {})
         
     | 
| 
       186 
189 
     | 
    
         
             
                    expect(lookup.to_a.count).to eq(1)
         
     | 
| 
       187 
190 
     | 
    
         
             
                    expect(lookup.first.name).to eq("Rule3")
         
     | 
| 
      
 191 
     | 
    
         
            +
                    # bool false matches bool nil
         
     | 
| 
      
 192 
     | 
    
         
            +
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
      
 193 
     | 
    
         
            +
                                                        {'rule_type'=>'ComplexRule',
         
     | 
| 
      
 194 
     | 
    
         
            +
                                                        'other_flag'=>false},
         
     | 
| 
      
 195 
     | 
    
         
            +
                                                        {'g_bool'=>false})
         
     | 
| 
      
 196 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(1)
         
     | 
| 
      
 197 
     | 
    
         
            +
                    expect(lookup.first.name).to eq("Rule3")
         
     | 
| 
       188 
198 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       189 
199 
     | 
    
         
             
                                                        {'rule_type'=>'ComplexRule'},
         
     | 
| 
       190 
200 
     | 
    
         
             
                                                        {'g_string'=>'def'})
         
     | 
| 
         @@ -218,18 +228,19 @@ module Marty::RuleSpec 
     | 
|
| 
       218 
228 
     | 
    
         
             
                    expect(lookup.first.name).to eq("Rule1")
         
     | 
| 
       219 
229 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       220 
230 
     | 
    
         
             
                                                        {'rule_type'=>'SimpleRule'},
         
     | 
| 
       221 
     | 
    
         
            -
                                                        {'g_bool'=>false, "g_range"=> 
     | 
| 
      
 231 
     | 
    
         
            +
                                                        {'g_bool'=>false, "g_range"=>25,
         
     | 
| 
       222 
232 
     | 
    
         
             
                                                         'g_integer'=>10})
         
     | 
| 
       223 
     | 
    
         
            -
                    expect(lookup).to eq( 
     | 
| 
      
 233 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(1)
         
     | 
| 
      
 234 
     | 
    
         
            +
                    expect(lookup.first.name).to eq("Rule2c")
         
     | 
| 
       224 
235 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       225 
236 
     | 
    
         
             
                                                        {'rule_type'=>'SimpleRule'}, {})
         
     | 
| 
       226 
     | 
    
         
            -
                    expect(lookup.to_a.count).to eq( 
     | 
| 
      
 237 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(5)
         
     | 
| 
       227 
238 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       228 
239 
     | 
    
         
             
                                                        {'rule_dt'=>"2017-3-1 02:00:00"},
         
     | 
| 
       229 
240 
     | 
    
         
             
                                                        {})
         
     | 
| 
       230 
     | 
    
         
            -
                    expect(lookup.to_a.count).to eq( 
     | 
| 
      
 241 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(6)
         
     | 
| 
       231 
242 
     | 
    
         
             
                    expect(lookup.pluck(:name).to_set).to eq(Set["Rule1", "Rule2", "Rule2a",
         
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
      
 243 
     | 
    
         
            +
                                                               "Rule2b", "Rule2c", "Rule3"])
         
     | 
| 
       233 
244 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       234 
245 
     | 
    
         
             
                                                        {'rule_dt'=>"2017-4-1 16:00:00"},
         
     | 
| 
       235 
246 
     | 
    
         
             
                                                        {})
         
     | 
| 
         @@ -241,6 +252,11 @@ module Marty::RuleSpec 
     | 
|
| 
       241 
252 
     | 
    
         
             
                    lookup = Gemini::MyRule.get_matches('infinity',
         
     | 
| 
       242 
253 
     | 
    
         
             
                                                        {'rule_dt'=>"2017-5-1 00:00:01"}, {})
         
     | 
| 
       243 
254 
     | 
    
         
             
                    expect(lookup.to_a).to eq([])
         
     | 
| 
      
 255 
     | 
    
         
            +
                    lookup = Gemini::MyRule.get_matches('infinity', {},
         
     | 
| 
      
 256 
     | 
    
         
            +
                                                        {"g_bool_def"=>false,
         
     | 
| 
      
 257 
     | 
    
         
            +
                                                         "g_nbool_def"=>true})
         
     | 
| 
      
 258 
     | 
    
         
            +
                    expect(lookup.to_a.count).to eq(1)
         
     | 
| 
      
 259 
     | 
    
         
            +
                    expect(lookup.pluck(:name).first).to eq("Rule1")
         
     | 
| 
       244 
260 
     | 
    
         
             
                  end
         
     | 
| 
       245 
261 
     | 
    
         
             
                end
         
     | 
| 
       246 
262 
     | 
    
         
             
                context "rule compute" do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: marty
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Arman Bostani
         
     | 
| 
         @@ -14,7 +14,7 @@ authors: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
            date: 2018-03- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2018-03-09 00:00:00.000000000 Z
         
     | 
| 
       18 
18 
     | 
    
         
             
            dependencies:
         
     | 
| 
       19 
19 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       20 
20 
     | 
    
         
             
              name: pg
         
     |