Class: FeduxOrgStdlib::Rake::WebserverTask

Inherits:
Task
  • Object
show all
Defined in:
lib/fedux_org_stdlib/rake/webserver_task.rb

Overview

Webserver Task

See Also:

  • Rakefile

Instance Attribute Summary collapse

Attributes inherited from Task

#description, #name, #verbose, #verbose (true)

Instance Method Summary collapse

Methods inherited from Task

#include, #instance_binding

Constructor Details

#initialize(directory: File.expand_path('utils/server'), site: 'http://fedux-org.github.io/data/downloads/local_webserver', checksums_file: 'CHECKSUMS', index_file_content: nil, files: %w( server.darwin.amd64 server.linux.amd64 server.windows.amd64.exe ), redirect_to: nil, **args) ⇒ WebserverTask

Create a new webserver task

Examples:

Create new task

FeduxOrgStdlib::Rake::WebserverTask.new

Parameters:

  • directory (String) (defaults to: File.expand_path('utils/server'))

    The directory where the generated server should be stored

  • url (String)

    The url which should be used to fetch the remote repository



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 26

def initialize(
  directory: File.expand_path('utils/server'),
  site: 'http://fedux-org.github.io/data/downloads/local_webserver',
  checksums_file: 'CHECKSUMS',
  index_file_content: nil,
  files: %w(
    server.darwin.amd64
    server.linux.amd64
    server.windows.amd64.exe
  ),
  redirect_to: nil,
  **args
)
  super(**args)

  @site               = Addressable::URI.heuristic_parse(site)
  @files              = Array(files)
  @checksums_file     = checksums_file
  @directory          = File.expand_path(directory)
  @index_file_content = if index_file_content
                          index_file_content
                        elsif redirect_to
                          redirect_to_destination(redirect_to)
                        else
                          nil
                        end
end

Instance Attribute Details

#checksumsObject (readonly)

Returns the value of attribute checksums.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def checksums
  @checksums
end

#checksums_fileObject (readonly)

Returns the value of attribute checksums_file.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def checksums_file
  @checksums_file
end

#directoryObject (readonly)

Returns the value of attribute directory.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def directory
  @directory
end

#filesObject (readonly)

Returns the value of attribute files.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def files
  @files
end

#index_file_contentObject (readonly)

Returns the value of attribute index_file_content.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def index_file_content
  @index_file_content
end

#reportObject (readonly)

The report to be generated



16
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

attr_reader :site, :directory, :index_file_content, :files, :checksums_file, :checksums

#siteObject (readonly)

Returns the value of attribute site.



16
17
18
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 16

def site
  @site
end

Instance Method Details

#run_task(_verbose) ⇒ Object



55
56
57
58
59
# File 'lib/fedux_org_stdlib/rake/webserver_task.rb', line 55

def run_task(_verbose)
  fetch_checksums
  fetch_files
  create_index_file unless index_file_content.blank?
end