Module: Compostr

Defined in:
lib/compostr.rb,
lib/compostr/syncer.rb,
lib/compostr/logging.rb,
lib/compostr/version.rb,
lib/compostr/wp_string.rb,
lib/compostr/entity_cache.rb,
lib/compostr/image_upload.rb,
lib/compostr/image_uploader.rb,
lib/compostr/custom_post_type.rb,
lib/compostr/custom_field_value.rb,
lib/compostr/media_library_cache.rb

Overview

Get the loggers, get the config, expose WP

Defined Under Namespace

Modules: Logging, WPString Classes: CustomFieldValue, CustomPostType, DeleteCustomFieldValue, EntityCache, ImageUpload, ImageUploader, MediaLibraryCache, NullCustomFieldValue, NullCustomPostType, Syncer

Constant Summary collapse

VERSION =
"0.1.6".freeze

Class Method Summary collapse

Class Method Details

.configObject

Access configuration hash.



30
31
32
# File 'lib/compostr.rb', line 30

def self.config
  @@config ||= load_conf
end

.delete_post(post_id) ⇒ Object

Delete a post with given wordpress post_id



55
56
57
58
59
60
61
# File 'lib/compostr.rb', line 55

def self.delete_post post_id
  begin
    Compostr::wp.deletePost(blog_id: 0, post_id: post_id)
  rescue XMLRPC::FaultException
    false
  end
end

.load_confObject

Load and memoize ‘compostr.conf’.



25
26
27
# File 'lib/compostr.rb', line 25

def self.load_conf
  @@config = OpenStruct.new YAML.load_file 'compostr.conf'
end

.loggerObject

Access the logger, initialize and memoize it on demand.



45
46
47
# File 'lib/compostr.rb', line 45

def self.logger
  @@logger ||= Logger.new(STDOUT)
end

.logger=(logger) ⇒ Object

Set the logger.



50
51
52
# File 'lib/compostr.rb', line 50

def self.logger= logger
  @@logger = logger
end

.wpObject

Access (and/or initialize) Rubypress client, settings initially pulled from the configuration.



36
37
38
39
40
41
42
# File 'lib/compostr.rb', line 36

def self.wp
  @wp ||= Rubypress::Client.new(host: config.host,
                                username: config.username,
                                password: config.password,
                                use_ssl:  config.use_ssl,
                                path:     config.path || "/xmlrpc.php")
end