lib/multi_sync.rb in multi_sync-0.0.2 vs lib/multi_sync.rb in multi_sync-0.0.3

- old
+ new

@@ -10,12 +10,13 @@ extend MultiSync::Logging extend MultiSync::Environment # a list of libraries, extension file and class name REQUIREMENT_MAP = [ - ['rails', 'multi_sync/extensions/rails'].freeze, - ['middleman-core', 'multi_sync/extensions/middleman'].freeze + ['rails', 'multi_sync/extensions/rails'], + ['middleman-core', 'multi_sync/extensions/middleman'], + ['jekyll', 'multi_sync/extensions/jekyll'] ] # delegate all MultiSync::Configuration's attribute accessors to the configuration def_delegators :configuration, *MultiSync::Configuration.attribute_set.map(&:name) @@ -23,13 +24,27 @@ def_delegators :configuration, *(MultiSync::Configuration.attribute_set.map(&:name).map { |key| "#{key}=".to_sym }) # delegate all MultiSync::Client's attribute accessors to the configuration def_delegators :client, *MultiSync::Client.attribute_set.map(&:name) - # include some public methods - def_delegators :client, :target, :source, :synchronize + # include sync method + def_delegator :client, :sync + # create methods for each source (local_source(options), manifest_source(options)) + MultiSync::Client::SUPPORTED_SOURCE_TYPES.each do |type, clazz| + define_singleton_method "#{type}_source" do |options = {}| + client.add_source(clazz, options) + end + end + + # create methods for each target (aws_target(options)) + MultiSync::Client::SUPPORTED_TARGET_TYPES.each do |type, clazz| + define_singleton_method "#{type}_target" do |options = {}| + client.add_target(clazz, options) + end + end + # Configure # # @return [MultiSync] def self.configure(&block) instance_eval(&block) if block_given? @@ -38,11 +53,11 @@ # Run # # @return [MultiSync] def self.run(&block) - configure(&block).synchronize + configure(&block).sync end # Prepare # # @return [MultiSync] @@ -60,9 +75,16 @@ # Fetch the MultiSync::Configuration # # @return [MultiSync::Configuration] def self.configuration(options = {}) @configuration ||= MultiSync::Configuration.new(options) + end + + # Return the MultiSync::VERSION + # + # @return [String] + def self.version + MultiSync::VERSION end # Reset the MultiSync::Client def self.reset_client! remove_instance_variable :@client if defined?(@client)