Class: ServerlessRedirector::Controller
- Inherits:
-
Object
- Object
- ServerlessRedirector::Controller
- Defined in:
- lib/serverless_redirector/controller.rb
Instance Attribute Summary collapse
-
#destination_uri ⇒ Object
Configuration has some options:.
-
#dry_run ⇒ Object
Configuration has some options:.
-
#log_path ⇒ Object
Configuration has some options:.
-
#manifest_path ⇒ Object
Configuration has some options:.
-
#skip_deletes ⇒ Object
Configuration has some options:.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Controller
constructor
A new instance of Controller.
- #invoke! ⇒ Object
- #unpack_options(options) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Controller
Returns a new instance of Controller.
18 19 20 21 22 23 24 25 |
# File 'lib/serverless_redirector/controller.rb', line 18 def initialize( = {}) @dry_run = false @log_path = nil @destination_uri = nil @manifest_path = nil @skip_deletes = false end |
Instance Attribute Details
#destination_uri ⇒ Object
Configuration has some options:
12 13 14 |
# File 'lib/serverless_redirector/controller.rb', line 12 def destination_uri @destination_uri end |
#dry_run ⇒ Object
Configuration has some options:
12 13 14 |
# File 'lib/serverless_redirector/controller.rb', line 12 def dry_run @dry_run end |
#log_path ⇒ Object
Configuration has some options:
12 13 14 |
# File 'lib/serverless_redirector/controller.rb', line 12 def log_path @log_path end |
#manifest_path ⇒ Object
Configuration has some options:
12 13 14 |
# File 'lib/serverless_redirector/controller.rb', line 12 def manifest_path @manifest_path end |
#skip_deletes ⇒ Object
Configuration has some options:
12 13 14 |
# File 'lib/serverless_redirector/controller.rb', line 12 def skip_deletes @skip_deletes end |
Instance Method Details
#invoke! ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/serverless_redirector/controller.rb', line 42 def invoke! logger = create_logger manifest = create_manifest destination = create_destination syncer = ServerlessRedirector::Syncer.new(manifest, destination, logger, skip_deletes) syncer.run dry_run end |
#unpack_options(options) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/serverless_redirector/controller.rb', line 27 def () @dry_run = !![:dry_run] if .key?(:dry_run) @skip_deletes = !![:skip_deletes] if .key?(:skip_deletes) @manifest_path = .fetch(:manifest_path) if .key?(:manifest_path) @log_path = .fetch(:log_path) if .key?(:log_path) @destination_uri = .fetch(:destination_uri) if .key?(:destination_uri) end |
#validate ⇒ Object
36 37 38 39 40 |
# File 'lib/serverless_redirector/controller.rb', line 36 def validate raise ArgumentError.new("Manifest path does not exist") unless manifest_path && ::File.exist?(manifest_path) raise ArgumentError.new("Destination URI Invalid") unless destination_uri && ::URI.parse(destination_uri).present? # Otherwise fine here... end |