Class: Remi::BusinessRules::Filestore

Inherits:
Object
  • Object
show all
Defined in:
lib/remi/cucumber/business_rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFilestore

Returns a new instance of Filestore.



456
457
458
459
# File 'lib/remi/cucumber/business_rules.rb', line 456

def initialize
  @files = []
  @delivered = {}
end

Instance Attribute Details

#sftp_entriesObject (readonly)

Returns the value of attribute sftp_entries.



461
462
463
# File 'lib/remi/cucumber/business_rules.rb', line 461

def sftp_entries
  @sftp_entries
end

Instance Method Details

#anti_pattern(pattern) ⇒ Object



467
468
469
# File 'lib/remi/cucumber/business_rules.rb', line 467

def anti_pattern(pattern)
  @pattern = /^ThisBetterNeverMatchAnythingOrIWillShootYou\d{8}Times$/
end

#delivered_before(date_time) ⇒ Object



475
476
477
# File 'lib/remi/cucumber/business_rules.rb', line 475

def delivered_before(date_time)
  @delivered = { :before => date_time }
end

#delivered_since(date_time) ⇒ Object



471
472
473
# File 'lib/remi/cucumber/business_rules.rb', line 471

def delivered_since(date_time)
  @delivered = { :since => date_time }
end

#generateObject



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/remi/cucumber/business_rules.rb', line 483

def generate
  psuedorand = Random.new(4985674985672348954987589429)

  generate_files_with_pattern
  @files.map! do |file|
    date_method = @delivered.keys.first
    if date_method == :since
      file[:attributes][:createdtime] = @delivered[:since] + 10 + psuedorand.rand * 100
    elsif date_method == :before
      file[:attributes][:createdtime] = @delivered[:since] - 10 - psuedorand.rand * 100
    else
      file[:attributes][:createdtime] = Time.now - 10 - psuedorand.rand * 100
    end
    file
  end
end

#latestObject



479
480
481
# File 'lib/remi/cucumber/business_rules.rb', line 479

def latest
  @files.max_by { |f| f[:attributes][:createdtime] }[:name]
end

#pattern(pattern) ⇒ Object



463
464
465
# File 'lib/remi/cucumber/business_rules.rb', line 463

def pattern(pattern)
  @pattern = pattern
end