Class: Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/multistockphoto/sender.rb

Overview

Die Klasse Sender dient als Ausgangspunkt fuer die Applikation. Hier sind zentrale Festlegungen gespeichert bzw. werden Methoden zur Verfuegung gestellt, die nicht einzelne Sites sondern das Senden als ganzes betreffen.

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Sender

Returns a new instance of Sender.



8
9
10
# File 'lib/multistockphoto/sender.rb', line 8

def initialize(name)
  @name = name
end

Instance Method Details

#active_sitesObject

gibt ein Array in Form [:fotolia,:zoonar,:photocase] zurueck



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/multistockphoto/sender.rb', line 13

def active_sites
  if ENV['MSP_CONFIG']
    if File.exist? ENV['MSP_CONFIG']
    @config = YAML.load_file(ENV['MSP_CONFIG'])
    else
      @config = YAML.load_file("config.yaml")
    end
  else
    @config = YAML.load_file("config.yaml")
  end
  @config[:active_sites]
end

#done_dirObject



30
31
32
# File 'lib/multistockphoto/sender.rb', line 30

def done_dir
  'done'
end

#sent_to?(p_filename, p_site) ⇒ Boolean

wurde dieses File schon an diese Site gesendet?

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/multistockphoto/sender.rb', line 35

def sent_to?(p_filename,p_site) #TODO:
  sendeliste = 'sendeliste.dat' #TODO:
  result = false
  File.open(sendeliste) {|f|
    f.each_line {|line|
      site,photo_file,time = line.chomp.split("\t")
      if site == p_site.to_s and photo_file == p_filename
        result = true
        break
      end
    }
  }
  result
end

#upload_dirObject



26
27
28
# File 'lib/multistockphoto/sender.rb', line 26

def upload_dir
  'upload'
end