Sha256: e6716ade7b650ea728254e59de2f0ec14b856f7f659a0551ab8775a6f8629902

Contents?: true

Size: 1.79 KB

Versions: 39

Compression:

Stored size: 1.79 KB

Contents

require 'copy_tuner_client/version'
require 'copy_tuner_client/configuration'

# Top-level interface to the CopyTuner client.
#
# Most applications should only need to use the {.configure}
# method, which will setup all the pieces and begin synchronization when
# appropriate.
module CopyTunerClient
  class << self
    # @return [Configuration] current client configuration
    # Must act like a hash and return sensible values for all CopyTuner
    # configuration options. Usually set when {.configure} is called.
    attr_accessor :configuration
  end

  # Issues a new deploy, marking all draft blurbs as published.
  # This is called when the copy_tuner:deploy rake task is invoked.
  def self.deploy
    client.deploy
  end

  # Issues a new export, returning yaml representation of blurb cache.
  # This is called when the copy_tuner:export rake task is invoked.
  def self.export
    cache.export
  end

  # Flush queued changed synchronously
  def self.flush
    cache.flush
  end

  def self.cache
    CopyTunerClient.configuration.cache
  end

  def self.client
    CopyTunerClient.configuration.client
  end

  def self.poller
    CopyTunerClient.configuration.poller
  end

  # Call this method to modify defaults in your initializers.
  #
  # @example
  #   CopyTunerClient.configure do |config|
  #     config.api_key = '1234567890abcdef'
  #     config.host = 'your-copy-tuner-server.herokuapp.com'
  #     config.secure = true
  #   end
  #
  # @param apply [Boolean] (internal) whether the configuration should be applied yet.
  #
  # @yield [Configuration] the configuration to be modified
  def self.configure(apply = true)
    self.configuration ||= Configuration.new
    yield configuration

    if apply
      configuration.apply
    end
  end
end

if defined? ::Rails
  require 'copy_tuner_client/rails'
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
copy_tuner_client-0.19.0 lib/copy_tuner_client.rb
copy_tuner_client-0.18.0 lib/copy_tuner_client.rb
copy_tuner_client-0.17.1 lib/copy_tuner_client.rb
copy_tuner_client-0.16.3 lib/copy_tuner_client.rb
copy_tuner_client-0.16.2 lib/copy_tuner_client.rb
copy_tuner_client-0.16.1 lib/copy_tuner_client.rb
copy_tuner_client-0.16.0 lib/copy_tuner_client.rb
copy_tuner_client-0.15.1 lib/copy_tuner_client.rb
copy_tuner_client-0.15.0 lib/copy_tuner_client.rb
copy_tuner_client-0.14.2 lib/copy_tuner_client.rb
copy_tuner_client-0.14.1 lib/copy_tuner_client.rb
copy_tuner_client-0.14.0 lib/copy_tuner_client.rb
copy_tuner_client-0.13.6 lib/copy_tuner_client.rb
copy_tuner_client-0.13.5 lib/copy_tuner_client.rb
copy_tuner_client-0.13.3 lib/copy_tuner_client.rb
copy_tuner_client-0.13.2 lib/copy_tuner_client.rb
copy_tuner_client-0.13.1 lib/copy_tuner_client.rb
copy_tuner_client-0.13.0 lib/copy_tuner_client.rb
copy_tuner_client-0.12.0 lib/copy_tuner_client.rb
copy_tuner_client-0.11.0 lib/copy_tuner_client.rb