Module: Noumenon

Defined in:
lib/noumenon.rb,
lib/noumenon/version.rb,
lib/noumenon/spec/theme_helpers.rb

Defined Under Namespace

Modules: Spec, StringExtensions Classes: AssetRepository, Cli, ContentRepository, Core, Template, Theme

Constant Summary collapse

VERSION =

The current version of Noumenon.

"0.2.2"

Class Method Summary collapse

Class Method Details

.asset_repositoryNoumenon::Repository, ...

Returns the current asset repository. If one hasn’t been set then the content repository will be returned.

Returns:

  • (Noumenon::Repository, #get_asset, #save_asset)


56
57
58
# File 'lib/noumenon.rb', line 56

def self.asset_repository
  @asset_repository || content_repository
end

.asset_repository=(repository) ⇒ Object

Sets the current asset repository. If you want to return to using the default content repository set to nil.

Parameters:

  • repository (Noumenon::Repository, #get_asset, #save_asset)

    The repository to use for assets.



64
65
66
# File 'lib/noumenon.rb', line 64

def self.asset_repository=(repository)
  @asset_repository = repository
end

.content_repositoryNoumenon::Repository, ...

Returns the current content repository.

Returns:

  • (Noumenon::Repository, #get, #put)


40
41
42
# File 'lib/noumenon.rb', line 40

def self.content_repository
  @content_repository
end

.content_repository=(repository) ⇒ Object

Sets the repository to load site content from.

Parameters:

  • repository (Noumenon::Repository, #get, #put)

    the repository to use



48
49
50
# File 'lib/noumenon.rb', line 48

def self.content_repository=(repository)
  @content_repository = repository
end

.serverRack::Builder

Starts Noumenon serving, this will usually be called from a config.ru file something like this:

Noumenon.content_repository = Noumenon::Repository::FileSystem.new("/home/noumenon/content")
Noumenon.theme = Noumenon::Theme.load("/home/noumenon/theme")

run Noumenon.server

While you can also just use an instance Noumenon::Core, keep in mind that it won’t have the full Rack middleware stack, and so some functionality such as serving assets from themes won’t be available.

Returns:

  • (Rack::Builder)

    the Rack stack to serve a Noumenon site



29
30
31
32
33
34
# File 'lib/noumenon.rb', line 29

def self.server
  Rack::Builder.new do
    use Noumenon::Theme::AssetsMiddleware
    run Noumenon::Core
  end
end

.themeNoumenon::Theme

Returns the current theme

Returns:



72
73
74
# File 'lib/noumenon.rb', line 72

def self.theme
  @theme
end

.theme=(theme) ⇒ Noumenon::Theme?

Set the current theme.

If provided with a [ Noumenon::Theme ] object then it will set that, otherwise it will convert the argument to a string, and attempt to find a loaded theme with that name.

Parameters:

  • theme (Noumenon::Theme, #to_s)

    either a theme object, or the name of a loaded theme

Returns:

  • (Noumenon::Theme, nil)

    the specified theme, or nil if it could not be found



85
86
87
88
89
90
91
92
93
94
# File 'lib/noumenon.rb', line 85

def self.theme=(theme)
  if theme.is_a? Noumenon::Theme
    @theme = theme
  else
    raise ArgumentError.new("The theme '#{theme}' has not been loaded.") unless Noumenon::Theme.themes.key?(theme)
    self.theme = Noumenon::Theme.themes[theme]
  end
  
  @theme
end