Module: TrustyCms

Defined in:
lib/trusty_cms/pagination/link_renderer.rb,
lib/trusty_cms.rb,
lib/trusty_cms/setup.rb,
lib/trusty_cms/engine.rb,
lib/trusty_cms/admin_ui.rb,
lib/trusty_cms/extension.rb,
lib/trusty_cms/initializer.rb,
lib/trusty_cms/task_support.rb,
app/models/trusty_cms/config.rb,
lib/trusty_cms/extension_path.rb,
lib/trusty_cms/extension_loader.rb,
lib/trusty_cms/config/definition.rb,
lib/trusty_cms/extension_migrator.rb,
lib/trusty_cms/resource_responses.rb,
lib/trusty_cms/pagination/controller.rb,
app/models/trusty_cms/page_response_cache_director.rb,
lib/configuration_extensions/configuration_extensions.rb

Overview

This handy simplification is adapted from SphinxSearch (thanks) and originally came from Ultrasphinx it saves us a lot of including and bodging to make will_paginate’s template calls work in the Page model

Defined Under Namespace

Modules: AvailableLocales, Initializer, Pagination, ResourceResponses, Taggable Classes: AdminUI, Config, Engine, Extension, ExtensionLoader, ExtensionMigrator, ExtensionPath, PageResponseCacheDirector, Setup, TaskSupport

Constant Summary collapse

VERSION =
'4.1.3'.freeze

Class Method Summary collapse

Class Method Details

.app?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/configuration_extensions/configuration_extensions.rb', line 62

def app?
  File.exist?("#{Rails.root}/lib/trusty_cms.rb")
end

.boot!Object



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

def boot!
  unless booted?
    preinitialize
    pick_boot.run
  end
end

.booted?Boolean

Returns:

  • (Boolean)


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

def booted?
  defined? TrustyCms::Initializer
end

.config {|TrustyCms::Config| ... } ⇒ Object

Returns the TrustyCms::Config eigenclass object, so it can be used wherever you would use TrustyCms::Config.

TrustyCms.config['site.title']
TrustyCms.config['site.url'] = 'example.com'

but it will also yield itself to a block:

TrustyCms.config do |config|
  config.define 'something', default => 'something'
  config['other.thing'] = 'nothing'
end

Yields:



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

def config  # method must be defined before any initializers run
  yield TrustyCms::Config if block_given?
  TrustyCms::Config
end

.config_definitionsObject



3
4
5
# File 'app/models/trusty_cms/config.rb', line 3

def config_definitions
  @config_definitions ||= {}
end

.config_definitions=(definitions) ⇒ Object



7
8
9
# File 'app/models/trusty_cms/config.rb', line 7

def config_definitions=(definitions)
  @config_definitions = definitions
end

.configuration {|Rails.configuration| ... } ⇒ Object

Returns the configuration object with which this application was initialized. For now it’s exactly the same as calling Rails.configuration except that it will also yield itself to a block.

Yields:



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

def configuration
  yield Rails.configuration if block_given?
  Rails.configuration
end

.loaded_via_gem?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/configuration_extensions/configuration_extensions.rb', line 70

def loaded_via_gem?
  pick_boot.is_a? GemBoot
end

.pick_bootObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/configuration_extensions/configuration_extensions.rb', line 47

def pick_boot
  case
    when app?
      AppBoot.new
    when vendor?
      VendorBoot.new
    else
      GemBoot.new
  end
end

.preinitializeObject



66
67
68
# File 'lib/configuration_extensions/configuration_extensions.rb', line 66

def preinitialize
  load(preinitializer_path) if File.exist?(preinitializer_path)
end

.preinitializer_pathObject



74
75
76
# File 'lib/configuration_extensions/configuration_extensions.rb', line 74

def preinitializer_path
  "#{Rails.root}/config/preinitializer.rb"
end

.rootObject

Returns the root directory of this installation (which is usually the gem directory). This is not the same as Rails.root, which is the instance directory and tends to contain only site-delivery material.



33
34
35
# File 'lib/configuration_extensions/configuration_extensions.rb', line 33

def root
  Pathname.new(TRUSTY_CMS_ROOT) if defined?(TRUSTY_CMS_ROOT)
end

.vendor?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/configuration_extensions/configuration_extensions.rb', line 58

def vendor?
  File.exist?("#{Rails.root}/vendor/trusty")
end