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.3"

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.



59
60
61
# File 'lib/noumenon.rb', line 59

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.



67
68
69
# File 'lib/noumenon.rb', line 67

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

.content_repositoryNoumenon::Repository, ...

Returns the current content repository.



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

def self.content_repository
  @content_repository
end

.content_repository=(repository) ⇒ Object

Sets the repository to load site content from.



51
52
53
# File 'lib/noumenon.rb', line 51

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

.mount(path, application, options = {}) ⇒ Object



105
106
107
108
109
110
# File 'lib/noumenon.rb', line 105

def self.mount(path, application, options = {})
  mounted_applications[path] = {
    application: application,
    options: options
  }
end

.mounted_applicationsObject



99
100
101
102
103
# File 'lib/noumenon.rb', line 99

def self.mounted_applications
  @mounted_applications ||= {
    "/" => { application: Noumenon::Core, options: {} }
  }
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.



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

def self.server
  Rack::Builder.new do
    use Noumenon::Theme::AssetsMiddleware
    
    Noumenon.mounted_applications.each do |path, app|
      map(path) { run app[:application].new(app[:options].merge(mount_point: path)) }
    end
  end
end

.themeNoumenon::Theme

Returns the current theme



75
76
77
# File 'lib/noumenon.rb', line 75

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.



88
89
90
91
92
93
94
95
96
97
# File 'lib/noumenon.rb', line 88

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