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.



502
503
504
505
# File 'lib/remi/cucumber/business_rules.rb', line 502

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

Instance Attribute Details

#sftp_entriesObject (readonly)

Returns the value of attribute sftp_entries.



507
508
509
# File 'lib/remi/cucumber/business_rules.rb', line 507

def sftp_entries
  @sftp_entries
end

Instance Method Details

#anti_pattern(pattern) ⇒ Object



513
514
515
# File 'lib/remi/cucumber/business_rules.rb', line 513

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

#delivered_before(date_time) ⇒ Object



521
522
523
# File 'lib/remi/cucumber/business_rules.rb', line 521

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

#delivered_since(date_time) ⇒ Object



517
518
519
# File 'lib/remi/cucumber/business_rules.rb', line 517

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

#generateObject



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/remi/cucumber/business_rules.rb', line 529

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



525
526
527
# File 'lib/remi/cucumber/business_rules.rb', line 525

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

#pattern(pattern) ⇒ Object



509
510
511
# File 'lib/remi/cucumber/business_rules.rb', line 509

def pattern(pattern)
  @pattern = pattern
end