Module: Kinksync

Defined in:
lib/kinksync.rb,
lib/kinksync/version.rb,
lib/kinksync/file_2_sync.rb,
lib/kinksync/path_2_sync.rb,
lib/kinksync/configuration.rb

Overview

Kynsync parent module for all classes. Provides methods for configuration and synchronization of a group of files and/or directories

Defined Under Namespace

Classes: Configuration, File2Sync, Path2Sync

Constant Summary collapse

VERSION =

Current gem version

'0.1.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns current configuration or initializes an empty one and returns it

Returns:

  • Configuration object



39
40
41
# File 'lib/kinksync.rb', line 39

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Configures a Kynksync module with the values provided through the block it recieves

Examples:

Kinksync.configure do |config|
  config.remote_path = '/home/pablo/MEGA/kinksync/'
  config.log_file = config.remote_path + 'kinksync.log'
end

Parameters:

  • Values: (block)
    • remote_path: path to mounting cloud storage location

Yields:



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

def self.configure
  yield(configuration)
end

.resetObject

Resets configuration: all attributes are set to nil

Returns:

  • Empty Configuration object



46
47
48
# File 'lib/kinksync.rb', line 46

def self.reset
  @configuration = nil
end

.sync(paths_to_sync = []) ⇒ Object

Syncs lists of files and paths recieved as arguments. If no arg is provided syncs all files in remote path

Examples:

Kinksync.sync([
  'a_file.mp3',
  '/an/absolute/path/',
  'another_file.avi',
  'a/relative/path'
])

Parameters:

  • paths_to_sync (Array) (defaults to: [])

    List of files and paths to sync



63
64
65
66
67
68
# File 'lib/kinksync.rb', line 63

def self.sync(paths_to_sync = [])
  synced = []
  paths_to_sync = [Kinksync.configuration.remote_path] if paths_to_sync.empty?
  paths_to_sync.each { |p| synced += Path2Sync.new(p).sync }
  synced
end