Class: Upload

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_path, actual_path) ⇒ Upload

Returns a new instance of Upload.



12
13
14
15
# File 'lib/upload.rb', line 12

def initialize(expected_path, actual_path)
	@expected_path = expected_path
	@actual_path = actual_path
end

Instance Attribute Details

#actual_pathObject (readonly)

Returns the value of attribute actual_path.



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

def actual_path
  @actual_path
end

#expected_pathObject (readonly)

Returns the value of attribute expected_path.



7
8
9
# File 'lib/upload.rb', line 7

def expected_path
  @expected_path
end

#uploaded_actual_urlObject

Returns the value of attribute uploaded_actual_url.



10
11
12
# File 'lib/upload.rb', line 10

def uploaded_actual_url
  @uploaded_actual_url
end

#uploaded_expected_urlObject

Returns the value of attribute uploaded_expected_url.



9
10
11
# File 'lib/upload.rb', line 9

def uploaded_expected_url
  @uploaded_expected_url
end

Instance Method Details

#to_htmlObject



32
33
34
# File 'lib/upload.rb', line 32

def to_html
	"<li><a href='#{ @uploaded_expected_url.to_s }'>Expected</a>, <a href='#{ @uploaded_actual_url.to_s }'>Actual</li>"
end

#upload(bucket, path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/upload.rb', line 17

def upload(bucket, path)
	abort unless bucket
	abort unless path

	expected_filename = Pathname.new(@expected_path).basename.to_s
	expected_object = bucket.objects[path + "/" + expected_filename]
	expected_object.write(:file => @expected_path)
	@uploaded_expected_url = expected_object.url_for(:read)

	actual_filename = Pathname.new(@actual_path).basename.to_s
	actual_object = bucket.objects[path + "/" + actual_filename]
	actual_object.write(:file => @actual_path)
	@uploaded_actual_url = actual_object.url_for(:read)
end