module SycLink::Infrastructure
Helper methods to setup the infrastructure for syclink
Public Instance Methods
copy_file_if_missing(file, to_directory)
click to toggle source
Copies a file to a target directory
# File lib/syclink/infrastructure.rb, line 15 def copy_file_if_missing(file, to_directory) unless File.exists? File.join(to_directory, File.basename(file)) FileUtils.cp(file, to_directory) end end
create_directory_if_missing(directory)
click to toggle source
Creates a directory if it does not exist
# File lib/syclink/infrastructure.rb, line 8 def create_directory_if_missing(directory) unless File.exists? directory Dir.mkdir directory end end
html_file(directory = '.', website)
click to toggle source
Creates an html filename to save the html representation of the website to
# File lib/syclink/infrastructure.rb, line 38 def html_file(directory = '.', website) File.join(directory, "#{website.downcase.gsub(/\s/, '-')}.html") end
load_config(file)
click to toggle source
Loads the configuration from a file
# File lib/syclink/infrastructure.rb, line 22 def load_config(file) unless File.exists? file File.open(file, 'w') do |f| YAML.dump({ default_website: 'default' }, f) end end YAML.load_file(file) end
yaml_file(directory = '.', website)
click to toggle source
Creates the filename of the website for saving, loading and deleting
# File lib/syclink/infrastructure.rb, line 32 def yaml_file(directory = '.', website) File.join(directory, "#{website.downcase.gsub(/\s/, '-')}.website") end