marty 2.6.1 → 2.6.2
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 +4 -6
- data/app/models/marty/data_grid.rb +2 -1
- data/app/models/marty/script.rb +109 -101
- data/lib/marty/version.rb +1 -1
- data/lib/tasks/marty_tasks.rake +0 -14
- data/lib/tasks/scripts_tasks.rake +18 -0
- data/marty.gemspec +2 -1
- data/spec/dummy/delorean/test_namespace/nested_namespace/test.dl +1 -0
- data/spec/dummy/delorean/test_namespace/test.dl +1 -0
- data/spec/fixtures/scripts/load_tests/namespace/nested_namespace/script3.dl +2 -0
- data/spec/models/script_spec.rb +22 -8
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +1 -1
- data/spec/support/components/netzke_grid.rb +46 -4
- metadata +8 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d09559e9d5549c8ab9720fb91659a23af5eb2776cd4992d976a294573c2e7374
         | 
| 4 | 
            +
              data.tar.gz: d8a8cfbd3ddb0a74733f5e68046548dd33aab183e6bea5963e6f8774442ca3a6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c314f71f548391bfab763ab236d4f99dffe477c8dc90af831502caf36cd16439315df0906c454c3b7fb05d2967cac4481b46193c0f7aa461727c47186d4d1ff8
         | 
| 7 | 
            +
              data.tar.gz: 2e0c6f94fa4989ec13c37cce0b836c72d7f1e9153dea3b53d6e4037c3caf66a5883fae6411aeb2eaa89f4658dc2e7fd73111b3b539dc680bbb3063340cc5e0a1
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                marty (2.6. | 
| 4 | 
            +
                marty (2.6.2)
         | 
| 5 5 | 
             
                  aws-sigv4 (~> 1.0, >= 1.0.2)
         | 
| 6 6 | 
             
                  axlsx (= 3.0.0pre)
         | 
| 7 7 | 
             
                  coderay
         | 
| 8 8 | 
             
                  daemons (~> 1.3.1)
         | 
| 9 9 | 
             
                  delayed_job_active_record
         | 
| 10 | 
            -
                  delorean_lang (~> 0.5. | 
| 10 | 
            +
                  delorean_lang (~> 0.5.2)
         | 
| 11 11 | 
             
                  json-schema
         | 
| 12 12 | 
             
                  mcfly (~> 0.0.20)
         | 
| 13 13 | 
             
                  net-ldap (~> 0.16.1)
         | 
| @@ -62,9 +62,7 @@ GEM | |
| 62 62 | 
             
                  io-like (~> 0.3.0)
         | 
| 63 63 | 
             
                arel (8.0.0)
         | 
| 64 64 | 
             
                ast (2.4.0)
         | 
| 65 | 
            -
                aws- | 
| 66 | 
            -
                aws-sigv4 (1.1.0)
         | 
| 67 | 
            -
                  aws-eventstream (~> 1.0, >= 1.0.2)
         | 
| 65 | 
            +
                aws-sigv4 (1.0.3)
         | 
| 68 66 | 
             
                axlsx (3.0.0.pre)
         | 
| 69 67 | 
             
                  htmlentities (~> 4.3, >= 4.3.4)
         | 
| 70 68 | 
             
                  mimemagic (~> 0.3)
         | 
| @@ -99,7 +97,7 @@ GEM | |
| 99 97 | 
             
                delayed_job_active_record (4.1.3)
         | 
| 100 98 | 
             
                  activerecord (>= 3.0, < 5.3)
         | 
| 101 99 | 
             
                  delayed_job (>= 3.0, < 5)
         | 
| 102 | 
            -
                delorean_lang (0.5. | 
| 100 | 
            +
                delorean_lang (0.5.2)
         | 
| 103 101 | 
             
                  activerecord (>= 3.2)
         | 
| 104 102 | 
             
                  treetop (~> 1.5)
         | 
| 105 103 | 
             
                diff-lcs (1.3)
         | 
| @@ -238,7 +238,8 @@ class Marty::DataGrid < Marty::Base | |
| 238 238 |  | 
| 239 239 | 
             
              def self.lookup_grid_distinct_entry_h(
         | 
| 240 240 | 
             
                    pt, h, dgh, visited = nil, follow = true,
         | 
| 241 | 
            -
                    return_grid_data = false, distinct = true | 
| 241 | 
            +
                    return_grid_data = false, distinct = true
         | 
| 242 | 
            +
                  )
         | 
| 242 243 |  | 
| 243 244 | 
             
                # Perform grid lookup, if result is another data_grid, and follow is true,
         | 
| 244 245 | 
             
                # then perform lookup on the resulting grid.  Allows grids to be nested
         | 
    
        data/app/models/marty/script.rb
    CHANGED
    
    | @@ -4,7 +4,7 @@ class Marty::Script < Marty::Base | |
| 4 4 | 
             
              validates_presence_of :name, :body
         | 
| 5 5 | 
             
              mcfly_validates_uniqueness_of :name
         | 
| 6 6 | 
             
              validates_format_of :name,
         | 
| 7 | 
            -
                                  with: /\A[A-Z][a-zA-Z0-9]*\z/,
         | 
| 7 | 
            +
                                  with: /\A[A-Z][a-zA-Z0-9]*(::[A-Z][a-zA-Z0-9]*)*\z/,
         | 
| 8 8 | 
             
                                  message: I18n.t('script.save_error')
         | 
| 9 9 |  | 
| 10 10 | 
             
              belongs_to :user, class_name: 'Marty::User'
         | 
| @@ -12,112 +12,12 @@ class Marty::Script < Marty::Base | |
| 12 12 | 
             
              gen_mcfly_lookup :lookup, [:name], cache: true
         | 
| 13 13 |  | 
| 14 14 | 
             
              # find script by name/tag (not cached)
         | 
| 15 | 
            -
              def self.find_script(sname, tag = nil)
         | 
| 16 | 
            -
                tag = Marty::Tag.map_to_tag(tag)
         | 
| 17 | 
            -
                Marty::Script.mcfly_pt(tag.created_dt).find_by(name: sname)
         | 
| 18 | 
            -
              end
         | 
| 19 15 |  | 
| 20 16 | 
             
              def find_tag
         | 
| 21 17 | 
             
                # find the first tag created after this script.
         | 
| 22 18 | 
             
                Marty::Tag.where('created_dt >= ?', created_dt).order(:created_dt).first
         | 
| 23 19 | 
             
              end
         | 
| 24 20 |  | 
| 25 | 
            -
              def self.create_script(name, body)
         | 
| 26 | 
            -
                script      = new
         | 
| 27 | 
            -
                script.name = name
         | 
| 28 | 
            -
                script.body = body
         | 
| 29 | 
            -
                script.save
         | 
| 30 | 
            -
                script
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              def self.load_a_script(sname, body, dt = nil)
         | 
| 34 | 
            -
                s = Marty::Script.find_by(obsoleted_dt: 'infinity', name: sname)
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                if !s
         | 
| 37 | 
            -
                  s = Marty::Script.new
         | 
| 38 | 
            -
                  s.body = body
         | 
| 39 | 
            -
                  s.name = sname
         | 
| 40 | 
            -
                  s.created_dt = dt if dt
         | 
| 41 | 
            -
                  s.save!
         | 
| 42 | 
            -
                elsif s.body != body
         | 
| 43 | 
            -
                  s.body = body
         | 
| 44 | 
            -
                  s.created_dt = dt if dt
         | 
| 45 | 
            -
                  s.save!
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
              end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
              def self.load_script_bodies(bodies, dt = nil)
         | 
| 50 | 
            -
                bodies.each do |sname, body|
         | 
| 51 | 
            -
                  load_a_script(sname, body, dt)
         | 
| 52 | 
            -
                end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                # Create a new tag if scripts were modified after the last tag
         | 
| 55 | 
            -
                tag = Marty::Tag.get_latest1
         | 
| 56 | 
            -
                latest = Marty::Script.order('created_dt DESC').first
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                tag_time = (dt || [latest.try(:created_dt), Time.now].compact.max) +
         | 
| 59 | 
            -
                  1.second
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                # If no tag_time is provided, the tag created_dt will be the same
         | 
| 62 | 
            -
                # as the scripts.
         | 
| 63 | 
            -
                tag = Marty::Tag.do_create(tag_time, 'tagged from load scripts') if
         | 
| 64 | 
            -
                  !(tag && latest) || tag.created_dt <= latest.created_dt
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                tag
         | 
| 67 | 
            -
              end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
              def self.load_scripts(path = nil, dt = nil)
         | 
| 70 | 
            -
                files = get_script_filenames(path)
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                bodies = read_script_files(files)
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                load_script_bodies(bodies, dt)
         | 
| 75 | 
            -
              end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
              def self.read_script_files(files)
         | 
| 78 | 
            -
                files.collect do |fpath|
         | 
| 79 | 
            -
                  fname = File.basename(fpath)[0..-4].camelize
         | 
| 80 | 
            -
                  [fname, File.read(fpath)]
         | 
| 81 | 
            -
                end
         | 
| 82 | 
            -
              end
         | 
| 83 | 
            -
             | 
| 84 | 
            -
              def self.get_script_filenames(paths = nil)
         | 
| 85 | 
            -
                paths = get_script_paths(paths)
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                filenames = {}
         | 
| 88 | 
            -
                paths.each do |path|
         | 
| 89 | 
            -
                  Dir.glob("#{path}/*.dl").each do |filename|
         | 
| 90 | 
            -
                    basename = File.basename(filename)
         | 
| 91 | 
            -
                    filenames[basename] = filename unless filenames.key?(basename)
         | 
| 92 | 
            -
                  end
         | 
| 93 | 
            -
                end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                filenames.values
         | 
| 96 | 
            -
              end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
              def self.get_script_paths(paths)
         | 
| 99 | 
            -
                if paths
         | 
| 100 | 
            -
                  paths = Array(paths)
         | 
| 101 | 
            -
                elsif Rails.configuration.marty.delorean_scripts_path
         | 
| 102 | 
            -
                  paths = Rails.configuration.marty.delorean_scripts_path
         | 
| 103 | 
            -
                else
         | 
| 104 | 
            -
                  paths = [
         | 
| 105 | 
            -
                    "#{Rails.root}/delorean",
         | 
| 106 | 
            -
                    # FIXME: HACKY, wouldn't it be better to use
         | 
| 107 | 
            -
                    # Gem::Specification.find_by_name("marty").gem_dir??
         | 
| 108 | 
            -
                    File.expand_path('../../../../delorean', __FILE__),
         | 
| 109 | 
            -
                  ]
         | 
| 110 | 
            -
                end
         | 
| 111 | 
            -
              end
         | 
| 112 | 
            -
             | 
| 113 | 
            -
              def self.delete_scripts
         | 
| 114 | 
            -
                ActiveRecord::Base.connection.
         | 
| 115 | 
            -
                  execute('ALTER TABLE marty_scripts DISABLE TRIGGER USER;')
         | 
| 116 | 
            -
                Marty::Script.delete_all
         | 
| 117 | 
            -
                ActiveRecord::Base.connection.
         | 
| 118 | 
            -
                  execute('ALTER TABLE marty_scripts ENABLE TRIGGER USER;')
         | 
| 119 | 
            -
              end
         | 
| 120 | 
            -
             | 
| 121 21 | 
             
              delorean_fn :eval_to_hash, sig: 5 do |dt, script, node, attrs, params|
         | 
| 122 22 | 
             
                tag = Marty::Tag.find_match(dt) if dt.present?
         | 
| 123 23 | 
             
                raise("no tag for #{dt}") if tag.nil? && dt.present?
         | 
| @@ -156,4 +56,112 @@ class Marty::Script < Marty::Base | |
| 156 56 |  | 
| 157 57 | 
             
                CodeRay.scan(script.body, :ruby).div(line_numbers: :table)
         | 
| 158 58 | 
             
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              class << self
         | 
| 61 | 
            +
                def find_script(sname, tag = nil)
         | 
| 62 | 
            +
                  tag = Marty::Tag.map_to_tag(tag)
         | 
| 63 | 
            +
                  Marty::Script.mcfly_pt(tag.created_dt).find_by(name: sname)
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                def create_script(name, body)
         | 
| 67 | 
            +
                  script      = new
         | 
| 68 | 
            +
                  script.name = name
         | 
| 69 | 
            +
                  script.body = body
         | 
| 70 | 
            +
                  script.save
         | 
| 71 | 
            +
                  script
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def load_a_script(sname, body, dt = nil)
         | 
| 75 | 
            +
                  s = Marty::Script.find_by(obsoleted_dt: 'infinity', name: sname)
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  if !s
         | 
| 78 | 
            +
                    s = Marty::Script.new
         | 
| 79 | 
            +
                    s.body = body
         | 
| 80 | 
            +
                    s.name = sname
         | 
| 81 | 
            +
                    s.created_dt = dt if dt
         | 
| 82 | 
            +
                    s.save!
         | 
| 83 | 
            +
                  elsif s.body != body
         | 
| 84 | 
            +
                    s.body = body
         | 
| 85 | 
            +
                    s.created_dt = dt if dt
         | 
| 86 | 
            +
                    s.save!
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                def load_script_bodies(bodies, dt = nil)
         | 
| 91 | 
            +
                  bodies.each do |sname, body|
         | 
| 92 | 
            +
                    load_a_script(sname, body, dt)
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  # Create a new tag if scripts were modified after the last tag
         | 
| 96 | 
            +
                  tag = Marty::Tag.get_latest1
         | 
| 97 | 
            +
                  latest = Marty::Script.order('created_dt DESC').first
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  tag_time = (dt || [latest.try(:created_dt), Time.now].compact.max) +
         | 
| 100 | 
            +
                    1.second
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  # If no tag_time is provided, the tag created_dt will be the same
         | 
| 103 | 
            +
                  # as the scripts.
         | 
| 104 | 
            +
                  tag = Marty::Tag.do_create(tag_time, 'tagged from load scripts') if
         | 
| 105 | 
            +
                    !(tag && latest) || tag.created_dt <= latest.created_dt
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  tag
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                def load_scripts(path = nil, dt = nil)
         | 
| 111 | 
            +
                  files = get_script_file_paths(path)
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  bodies = read_script_files(files)
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  load_script_bodies(bodies, dt)
         | 
| 116 | 
            +
                end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                def read_script_files(files)
         | 
| 119 | 
            +
                  files.map do |fname, fpath|
         | 
| 120 | 
            +
                    script_name = fname.camelize
         | 
| 121 | 
            +
                    [script_name, File.read(fpath)]
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                def get_script_filenames(paths = nil)
         | 
| 126 | 
            +
                  get_script_file_paths(paths).values
         | 
| 127 | 
            +
                end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                def get_script_file_paths(paths = nil)
         | 
| 130 | 
            +
                  paths = get_script_paths(paths)
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  paths.each_with_object({}) do |path, filenames|
         | 
| 133 | 
            +
                    Dir.glob("#{path}/**/*.dl").each do |filename|
         | 
| 134 | 
            +
                      base_pathname = Pathname.new(path)
         | 
| 135 | 
            +
                      pathname = Pathname.new(filename).relative_path_from(base_pathname)
         | 
| 136 | 
            +
                      relative_file_name = pathname.sub_ext('').to_s
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                      next if filenames.key?(relative_file_name)
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                      filenames[relative_file_name] = filename
         | 
| 141 | 
            +
                    end
         | 
| 142 | 
            +
                  end
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                def get_script_paths(paths)
         | 
| 146 | 
            +
                  paths_from_config = Rails.configuration.marty.delorean_scripts_path
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                  return Array(paths) if paths
         | 
| 149 | 
            +
                  return paths_from_config if paths_from_config.present?
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                  [
         | 
| 152 | 
            +
                    "#{Rails.root}/delorean",
         | 
| 153 | 
            +
                    # FIXME: HACKY, wouldn't it be better to use
         | 
| 154 | 
            +
                    # Gem::Specification.find_by_name("marty").gem_dir??
         | 
| 155 | 
            +
                    File.expand_path('../../../../delorean', __FILE__),
         | 
| 156 | 
            +
                  ]
         | 
| 157 | 
            +
                end
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                def delete_scripts
         | 
| 160 | 
            +
                  ActiveRecord::Base.connection.
         | 
| 161 | 
            +
                    execute('ALTER TABLE marty_scripts DISABLE TRIGGER USER;')
         | 
| 162 | 
            +
                  Marty::Script.delete_all
         | 
| 163 | 
            +
                  ActiveRecord::Base.connection.
         | 
| 164 | 
            +
                    execute('ALTER TABLE marty_scripts ENABLE TRIGGER USER;')
         | 
| 165 | 
            +
                end
         | 
| 166 | 
            +
              end
         | 
| 159 167 | 
             
            end
         | 
    
        data/lib/marty/version.rb
    CHANGED
    
    
    
        data/lib/tasks/marty_tasks.rake
    CHANGED
    
    | @@ -9,20 +9,6 @@ namespace :marty do | |
| 9 9 | 
             
                end
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 | 
            -
              desc 'remove all loaded scripts from the database'
         | 
| 13 | 
            -
              task delete_scripts: :environment do
         | 
| 14 | 
            -
                Marty::Script.delete_scripts
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              desc 'load scripts from the LOAD_DIR directory'
         | 
| 18 | 
            -
              task load_scripts: :environment do
         | 
| 19 | 
            -
                Mcfly.whodunnit =
         | 
| 20 | 
            -
                  Marty::User.find_by_login(Rails.configuration.marty.system_account)
         | 
| 21 | 
            -
                raise 'must have system user account seeded' unless Mcfly.whodunnit
         | 
| 22 | 
            -
                load_dir = ENV['LOAD_DIR']
         | 
| 23 | 
            -
                Marty::Script.load_scripts(load_dir)
         | 
| 24 | 
            -
              end
         | 
| 25 | 
            -
             | 
| 26 12 | 
             
              # currently this is for delorean style rules only.  if other types were ever
         | 
| 27 13 | 
             
              # added (eg some sort of SQL rule like apollo has), that would probably be
         | 
| 28 14 | 
             
              # a new rake task
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            namespace :marty do
         | 
| 2 | 
            +
              desc 'remove all loaded scripts from the database'
         | 
| 3 | 
            +
              task delete_scripts: :environment do
         | 
| 4 | 
            +
                Marty::Script.delete_scripts
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              desc 'load scripts from the LOAD_DIR directory'
         | 
| 8 | 
            +
              task load_scripts: :environment do
         | 
| 9 | 
            +
                Mcfly.whodunnit = Marty::User.find_by_login(
         | 
| 10 | 
            +
                  Rails.configuration.marty.system_account
         | 
| 11 | 
            +
                )
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                raise 'must have system user account seeded' unless Mcfly.whodunnit
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                load_dir = ENV['LOAD_DIR']
         | 
| 16 | 
            +
                Marty::Script.load_scripts(load_dir)
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
    
        data/marty.gemspec
    CHANGED
    
    | @@ -5,6 +5,7 @@ require 'digest/md5' | |
| 5 5 | 
             
            require 'base64'
         | 
| 6 6 | 
             
            require 'zlib'
         | 
| 7 7 | 
             
            require 'csv'
         | 
| 8 | 
            +
            require 'pathname'
         | 
| 8 9 |  | 
| 9 10 | 
             
            Gem::Specification.new do |s|
         | 
| 10 11 | 
             
              s.name        = 'marty'
         | 
| @@ -32,7 +33,7 @@ Gem::Specification.new do |s| | |
| 32 33 |  | 
| 33 34 | 
             
              s.add_dependency 'axlsx', '3.0.0pre'
         | 
| 34 35 |  | 
| 35 | 
            -
              s.add_dependency 'delorean_lang', '~> 0.5. | 
| 36 | 
            +
              s.add_dependency 'delorean_lang', '~> 0.5.2'
         | 
| 36 37 | 
             
              s.add_dependency 'mcfly', '~> 0.0.20'
         | 
| 37 38 |  | 
| 38 39 | 
             
              s.add_dependency 'coderay'
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            # Empty script
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            # Empty script
         | 
    
        data/spec/models/script_spec.rb
    CHANGED
    
    | @@ -113,7 +113,7 @@ describe Marty::Script do | |
| 113 113 |  | 
| 114 114 | 
             
              describe '.load_scripts' do
         | 
| 115 115 | 
             
                before(:each) do
         | 
| 116 | 
            -
                  allow(Marty::Script).to receive(:load_script_bodies)
         | 
| 116 | 
            +
                  allow(Marty::Script).to receive(:load_script_bodies).and_call_original
         | 
| 117 117 | 
             
                end
         | 
| 118 118 |  | 
| 119 119 | 
             
                let(:scripts_path) do
         | 
| @@ -122,11 +122,25 @@ describe Marty::Script do | |
| 122 122 | 
             
                let(:now) { Time.zone.now - 1.minute }
         | 
| 123 123 | 
             
                let(:ls1) { File.read("#{scripts_path}/script1.dl") }
         | 
| 124 124 | 
             
                let(:ls2) { File.read("#{scripts_path}/script2.dl") }
         | 
| 125 | 
            +
                let(:ls3) { File.read("#{scripts_path}/namespace/nested_namespace/script3.dl") }
         | 
| 125 126 |  | 
| 126 127 | 
             
                it 'reads in the files and loads the script bodies' do
         | 
| 127 128 | 
             
                  Marty::Script.load_scripts(scripts_path, now)
         | 
| 129 | 
            +
                  expected_args = match_array([
         | 
| 130 | 
            +
                                                ['Script1', ls1],
         | 
| 131 | 
            +
                                                ['Script2', ls2],
         | 
| 132 | 
            +
                                                ['Namespace::NestedNamespace::Script3', ls3]
         | 
| 133 | 
            +
                                              ])
         | 
| 134 | 
            +
             | 
| 128 135 | 
             
                  expect(Marty::Script).to have_received(:load_script_bodies).
         | 
| 129 | 
            -
                    with( | 
| 136 | 
            +
                    with(expected_args, now)
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                  loaded_script_names = Marty::Script.pluck(:name).sort
         | 
| 139 | 
            +
                  expect(loaded_script_names).to eq [
         | 
| 140 | 
            +
                    'Namespace::NestedNamespace::Script3',
         | 
| 141 | 
            +
                    'Script1',
         | 
| 142 | 
            +
                    'Script2'
         | 
| 143 | 
            +
                  ]
         | 
| 130 144 | 
             
                end
         | 
| 131 145 | 
             
              end
         | 
| 132 146 |  | 
| @@ -140,7 +154,7 @@ describe Marty::Script do | |
| 140 154 |  | 
| 141 155 | 
             
                  it 'gets the files from the specified directory' do
         | 
| 142 156 | 
             
                    Marty::Script.get_script_filenames('/test')
         | 
| 143 | 
            -
                    expect(Dir).to have_received(:glob).with('/test | 
| 157 | 
            +
                    expect(Dir).to have_received(:glob).with('/test/**/*.dl')
         | 
| 144 158 | 
             
                  end
         | 
| 145 159 |  | 
| 146 160 | 
             
                  it 'returns the files in the given directory' do
         | 
| @@ -151,9 +165,9 @@ describe Marty::Script do | |
| 151 165 |  | 
| 152 166 | 
             
                context 'with duplicate script file names' do
         | 
| 153 167 | 
             
                  it 'returns only the unique file names' do
         | 
| 154 | 
            -
                    allow(Dir).to receive(:glob).with('/test1 | 
| 168 | 
            +
                    allow(Dir).to receive(:glob).with('/test1/**/*.dl').
         | 
| 155 169 | 
             
                      and_return(['/test1/sc1.dl', '/test1/sc2.dl'])
         | 
| 156 | 
            -
                    allow(Dir).to receive(:glob).with('/test2 | 
| 170 | 
            +
                    allow(Dir).to receive(:glob).with('/test2/**/*.dl').
         | 
| 157 171 | 
             
                      and_return(['/test2/sc2.dl', '/test2/sc3.dl'])
         | 
| 158 172 | 
             
                    expect(Marty::Script.get_script_filenames(['/test1', '/test2'])).
         | 
| 159 173 | 
             
                      to match_array(['/test1/sc1.dl', '/test1/sc2.dl', '/test2/sc3.dl'])
         | 
| @@ -164,9 +178,9 @@ describe Marty::Script do | |
| 164 178 | 
             
                  it 'gets the files from the default paths' do
         | 
| 165 179 | 
             
                    allow(Dir).to receive(:glob).and_return([])
         | 
| 166 180 | 
             
                    Marty::Script.get_script_filenames
         | 
| 167 | 
            -
                    expect(Dir).to have_received(:glob).with("#{Rails.root}/delorean | 
| 181 | 
            +
                    expect(Dir).to have_received(:glob).with("#{Rails.root}/delorean/**/*.dl")
         | 
| 168 182 | 
             
                    expect(Dir).to have_received(:glob).
         | 
| 169 | 
            -
                      with(File.expand_path('../../../delorean | 
| 183 | 
            +
                      with(File.expand_path('../../../delorean/**/*.dl', __FILE__))
         | 
| 170 184 | 
             
                    expect(Dir).to have_received(:glob).twice
         | 
| 171 185 | 
             
                  end
         | 
| 172 186 | 
             
                end
         | 
| @@ -180,7 +194,7 @@ describe Marty::Script do | |
| 180 194 | 
             
                  it 'gets the files from the specified path' do
         | 
| 181 195 | 
             
                    allow(Dir).to receive(:glob).and_return([])
         | 
| 182 196 | 
             
                    Marty::Script.get_script_filenames
         | 
| 183 | 
            -
                    expect(Dir).to have_received(:glob).with('/conf_test | 
| 197 | 
            +
                    expect(Dir).to have_received(:glob).with('/conf_test/**/*.dl')
         | 
| 184 198 | 
             
                  end
         | 
| 185 199 | 
             
                end
         | 
| 186 200 | 
             
              end
         | 
| @@ -68,15 +68,49 @@ module Marty; module RSpec; module Components | |
| 68 68 | 
             
                  find('#' + el).click
         | 
| 69 69 | 
             
                end
         | 
| 70 70 |  | 
| 71 | 
            -
                 | 
| 71 | 
            +
                # filter_col and filter_col_toggle expect sortable column
         | 
| 72 | 
            +
                #   might need to allow to specify the number of :down to send.
         | 
| 73 | 
            +
                #   for now, four :downs to get to the filter, :right opens it
         | 
| 74 | 
            +
                #    then enter value and press return
         | 
| 75 | 
            +
                def filter_col(col, value)
         | 
| 76 | 
            +
                  el = run_js <<-JS
         | 
| 77 | 
            +
                      #{ext_var(grid, 'grid')}
         | 
| 78 | 
            +
                      return #{ext_find(ext_arg('gridcolumn', text: col), 'grid')}.id
         | 
| 79 | 
            +
                    JS
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  c = find('#' + el)
         | 
| 82 | 
            +
                  c.send_keys([:down, :down, :down, :down, :right, value, :return])
         | 
| 83 | 
            +
                  sleep 1.0
         | 
| 84 | 
            +
                  c.click
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                def filter_col_toggle(col)
         | 
| 88 | 
            +
                  el = run_js <<-JS
         | 
| 89 | 
            +
                      #{ext_var(grid, 'grid')}
         | 
| 90 | 
            +
                      return #{ext_find(ext_arg('gridcolumn', text: col), 'grid')}.id
         | 
| 91 | 
            +
                    JS
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  c = find('#' + el)
         | 
| 94 | 
            +
                  c.send_keys([:down, :down, :down, :down, ' ', :escape])
         | 
| 95 | 
            +
                  sleep 1.0
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                def get_col_vals(col, cnt = row_count, init = 0, date_only = true)
         | 
| 72 99 | 
             
                  # NOTE: does not validate the # of rows
         | 
| 73 100 | 
             
                  run_js <<-JS
         | 
| 74 101 | 
             
                      var result = [];
         | 
| 75 102 | 
             
                      for (var i = #{init}; i < #{init.to_i + cnt.to_i}; i++) {
         | 
| 76 103 | 
             
                        #{ext_cell_val('i', col, grid)}
         | 
| 77 | 
            -
                        if(value instanceof Date){
         | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 104 | 
            +
                        if(value instanceof Date) {
         | 
| 105 | 
            +
                            if (#{date_only}){
         | 
| 106 | 
            +
                              result.push(value.toISOString().split('T')[0]);
         | 
| 107 | 
            +
                            }
         | 
| 108 | 
            +
                            else
         | 
| 109 | 
            +
                            {
         | 
| 110 | 
            +
                              result.push(value.toISOString());
         | 
| 111 | 
            +
                            }
         | 
| 112 | 
            +
                        }
         | 
| 113 | 
            +
                        else {
         | 
| 80 114 | 
             
                          result.push(value);
         | 
| 81 115 | 
             
                        };
         | 
| 82 116 | 
             
                      };
         | 
| @@ -113,6 +147,14 @@ module Marty; module RSpec; module Components | |
| 113 147 | 
             
                  el
         | 
| 114 148 | 
             
                end
         | 
| 115 149 |  | 
| 150 | 
            +
                def select_row_range(st, en)
         | 
| 151 | 
            +
                  resid = run_js(<<-JS, 10.0)
         | 
| 152 | 
            +
                      #{ext_var(grid, 'grid')}
         | 
| 153 | 
            +
                      grid.getSelectionModel().selectRange(#{st-1}, #{en-1});
         | 
| 154 | 
            +
                    JS
         | 
| 155 | 
            +
                  wait_for_ajax
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
             | 
| 116 158 | 
             
                def set_row_vals row, fields
         | 
| 117 159 | 
             
                  js_set_fields = fields.each_pair.map do |k, v|
         | 
| 118 160 | 
             
                    "r.set('#{k}', '#{v}');"
         | 
    
        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: 2.6. | 
| 4 | 
            +
              version: 2.6.2
         | 
| 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: 2019- | 
| 17 | 
            +
            date: 2019-04-09 00:00:00.000000000 Z
         | 
| 18 18 | 
             
            dependencies:
         | 
| 19 19 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 20 20 | 
             
              name: pg
         | 
| @@ -64,14 +64,14 @@ dependencies: | |
| 64 64 | 
             
                requirements:
         | 
| 65 65 | 
             
                - - "~>"
         | 
| 66 66 | 
             
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            -
                    version: 0.5. | 
| 67 | 
            +
                    version: 0.5.2
         | 
| 68 68 | 
             
              type: :runtime
         | 
| 69 69 | 
             
              prerelease: false
         | 
| 70 70 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 71 71 | 
             
                requirements:
         | 
| 72 72 | 
             
                - - "~>"
         | 
| 73 73 | 
             
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            -
                    version: 0.5. | 
| 74 | 
            +
                    version: 0.5.2
         | 
| 75 75 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 76 76 | 
             
              name: mcfly
         | 
| 77 77 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -424,6 +424,7 @@ files: | |
| 424 424 | 
             
            - lib/pyxll/pyxll.cfg
         | 
| 425 425 | 
             
            - lib/pyxll/sample.xlsx
         | 
| 426 426 | 
             
            - lib/tasks/marty_tasks.rake
         | 
| 427 | 
            +
            - lib/tasks/scripts_tasks.rake
         | 
| 427 428 | 
             
            - make-dummy.mk
         | 
| 428 429 | 
             
            - marty.gemspec
         | 
| 429 430 | 
             
            - other/marty/api/base.rb
         | 
| @@ -531,6 +532,8 @@ files: | |
| 531 532 | 
             
            - spec/dummy/delorean/marty_fields.dl
         | 
| 532 533 | 
             
            - spec/dummy/delorean/styles.dl
         | 
| 533 534 | 
             
            - spec/dummy/delorean/table_report.dl
         | 
| 535 | 
            +
            - spec/dummy/delorean/test_namespace/nested_namespace/test.dl
         | 
| 536 | 
            +
            - spec/dummy/delorean/test_namespace/test.dl
         | 
| 534 537 | 
             
            - spec/dummy/lib/assets/.gitkeep
         | 
| 535 538 | 
             
            - spec/dummy/lib/class_list.rb
         | 
| 536 539 | 
             
            - spec/dummy/lib/gemini/my_rule_script_set.rb
         | 
| @@ -1563,6 +1566,7 @@ files: | |
| 1563 1566 | 
             
            - spec/fixtures/csv/rule/XyzRule.csv
         | 
| 1564 1567 | 
             
            - spec/fixtures/json/rpc_controller.json
         | 
| 1565 1568 | 
             
            - spec/fixtures/misc/struct_compare_tests.txt
         | 
| 1569 | 
            +
            - spec/fixtures/scripts/load_tests/namespace/nested_namespace/script3.dl
         | 
| 1566 1570 | 
             
            - spec/fixtures/scripts/load_tests/script1.dl
         | 
| 1567 1571 | 
             
            - spec/fixtures/scripts/load_tests/script2.dl
         | 
| 1568 1572 | 
             
            - spec/job_helper.rb
         |