Class: JsFixtures::HTMLS3

Inherits:
HTML show all
Includes:
S3Upload
Defined in:
lib/js_fixtures/html_s3.rb

Constant Summary

Constants included from S3Upload

S3Upload::AWS_KEY, S3Upload::AWS_SECRET_KEY, S3Upload::HTML_HEADERS

Class Attribute Summary collapse

Attributes inherited from HTML

#post_scripts, #pre_scripts, #scripts

Attributes inherited from Base

#location, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from S3Upload

#upload_html_file

Methods inherited from HTML

#clone, inherited

Methods inherited from Base

config, create, generate_all, get

Constructor Details

#initialize(name, config) ⇒ HTMLS3

Returns a new instance of HTMLS3.



18
19
20
21
22
23
24
25
26
# File 'lib/js_fixtures/html_s3.rb', line 18

def initialize(name, config)
  super

  # Number of seconds since 1970-01-01 00:00:00 UTC
  # to avoid test collisions from multiple machines
  suffix = Time.now.strftime("%s")
  @filename = "#{@name}-#{suffix}.html"
  @location = "#{self.class.s3_access_url}/#{@filename}"
end

Class Attribute Details

.s3_access_urlObject (readonly)

Returns the value of attribute s3_access_url.



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

def s3_access_url
  @s3_access_url
end

.s3_upload_urlObject (readonly)

Returns the value of attribute s3_upload_url.



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

def s3_upload_url
  @s3_upload_url
end

Class Method Details

.s3_path=(s3_path) ⇒ Object



11
12
13
14
# File 'lib/js_fixtures/html_s3.rb', line 11

def s3_path=(s3_path)
  @s3_upload_url = s3_path
  @s3_access_url = "http://#{s3_path.gsub(':', '/')}"
end

Instance Method Details

#generateObject



28
29
30
31
32
# File 'lib/js_fixtures/html_s3.rb', line 28

def generate
  puts "Generating Fixture: #{@name}"
  super
  upload_html_file(@local_file, "#{self.class.s3_upload_url}/#{@filename}") 
end