Module: CopycopterClient

Defined in:
lib/copycopter_client.rb,
lib/copycopter_client/cache.rb,
lib/copycopter_client/rails.rb,
lib/copycopter_client/client.rb,
lib/copycopter_client/errors.rb,
lib/copycopter_client/poller.rb,
lib/copycopter_client/railtie.rb,
lib/copycopter_client/version.rb,
lib/copycopter_client/i18n_backend.rb,
lib/copycopter_client/request_sync.rb,
lib/copycopter_client/configuration.rb,
lib/copycopter_client/process_guard.rb,
lib/copycopter_client/prefixed_logger.rb

Overview

Top-level interface to the Copycopter client.

Most applications should only need to use the CopycopterClient.configure method, which will setup all the pieces and begin synchronization when appropriate.

Defined Under Namespace

Modules: Rails Classes: Cache, Client, Configuration, ConnectionError, I18nBackend, InvalidApiKey, Poller, PrefixedLogger, ProcessGuard, Railtie, RequestSync

Constant Summary collapse

VERSION =

Client version

'2.0.1'
API_VERSION =

API version being used to communicate with the server

'2.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationConfiguration

Must act like a hash and return sensible values for all Copycopter configuration options. Usually set when configure is called.

Returns:



14
15
16
# File 'lib/copycopter_client.rb', line 14

def configuration
  @configuration
end

.pollerPoller

This is set when configure is called.

Returns:

  • (Poller)

    instance used to poll for changes.



18
19
20
# File 'lib/copycopter_client.rb', line 18

def poller
  @poller
end

Class Method Details

.cacheObject



43
44
45
# File 'lib/copycopter_client.rb', line 43

def self.cache
  CopycopterClient.configuration.cache
end

.clientObject



47
48
49
# File 'lib/copycopter_client.rb', line 47

def self.client
  CopycopterClient.configuration.client
end

.configure(apply = true) {|Configuration| ... } ⇒ Object

Call this method to modify defaults in your initializers.

Examples:

CopycopterClient.configure do |config|
  config.api_key = '1234567890abcdef'
  config.host = 'your-copycopter-server.herokuapp.com'
  config.secure = true
end

Parameters:

  • apply (Boolean) (defaults to: true)

    (internal) whether the configuration should be applied yet.

Yields:



63
64
65
66
67
68
69
70
# File 'lib/copycopter_client.rb', line 63

def self.configure(apply = true)
  self.configuration ||= Configuration.new
  yield configuration

  if apply
    configuration.apply
  end
end

.deployObject

Issues a new deploy, marking all draft blurbs as published. This is called when the copycopter:deploy rake task is invoked.



23
24
25
# File 'lib/copycopter_client.rb', line 23

def self.deploy
  client.deploy
end

.exportObject

Issues a new export, returning yaml representation of blurb cache. This is called when the copycopter:export rake task is invoked.



29
30
31
# File 'lib/copycopter_client.rb', line 29

def self.export
  cache.export
end

.flushObject

Flush queued changed synchronously



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

def self.flush
  cache.flush
end

.start_pollerObject

Starts the polling process.



34
35
36
# File 'lib/copycopter_client.rb', line 34

def self.start_poller
  poller.start
end