Class: Suite::Project
- Inherits:
-
Object
- Object
- Suite::Project
- Defined in:
- lib/suite/project.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#content ⇒ Object
Retrieves the content hash for the current view.
-
#path ⇒ Object
Returns the value of attribute path.
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #asset(path) ⇒ Object
- #asset_path ⇒ Object
- #asset_registry ⇒ Object
- #file_types ⇒ Object
- #include?(slugs) ⇒ Boolean
-
#initialize(path, config, content, view) ⇒ Project
constructor
A new instance of Project.
- #page_at_slugs(slugs) ⇒ Object
- #pages ⇒ Object
-
#renderers ⇒ Object
TODO: Puts a renderers config in the yaml to add new renderers.
- #source_asset_path ⇒ Object
- #sprocket_environment ⇒ Object
Constructor Details
#initialize(path, config, content, view) ⇒ Project
Returns a new instance of Project.
6 7 8 |
# File 'lib/suite/project.rb', line 6 def initialize path, config, content, view @path, @config, @content, @view = path, config, content, view end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/suite/project.rb', line 5 def config @config end |
#content ⇒ Object
Retrieves the content hash for the current view
15 16 17 |
# File 'lib/suite/project.rb', line 15 def content @content end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/suite/project.rb', line 5 def path @path end |
#view ⇒ Object
Returns the value of attribute view.
5 6 7 |
# File 'lib/suite/project.rb', line 5 def view @view end |
Instance Method Details
#asset(path) ⇒ Object
42 43 44 |
# File 'lib/suite/project.rb', line 42 def asset path sprocket_environment[path.sub(/javascripts\/|stylesheets\/|images\/|icons\//,'')] end |
#asset_path ⇒ Object
50 51 52 |
# File 'lib/suite/project.rb', line 50 def asset_path Suite.env.build? && config["asset_host"] ? config["asset_host"].gsub(/\/$/,'') : "/assets" end |
#asset_registry ⇒ Object
54 55 56 |
# File 'lib/suite/project.rb', line 54 def asset_registry @_memoized_asset_registry ||= Suite::AssetRegistry.new end |
#file_types ⇒ Object
38 39 40 |
# File 'lib/suite/project.rb', line 38 def file_types config["file_types"] || [:html] end |
#include?(slugs) ⇒ Boolean
23 24 25 |
# File 'lib/suite/project.rb', line 23 def include? slugs return !!content_at_slugs(slugs) end |
#page_at_slugs(slugs) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/suite/project.rb', line 27 def page_at_slugs slugs content_level = pages slugs.each do |slug| return false unless content_level = content_level[slug.to_s] end return { layout: content_level["layout"] ? content_level["layout"] : content["layout"], content: content_level["content"] } end |
#pages ⇒ Object
19 20 21 |
# File 'lib/suite/project.rb', line 19 def pages content["pages"] end |
#renderers ⇒ Object
TODO: Puts a renderers config in the yaml to add new renderers
70 71 72 73 74 |
# File 'lib/suite/project.rb', line 70 def renderers @_memoized_render_types ||= begin Suite::Renderers.default_renderers end end |
#source_asset_path ⇒ Object
46 47 48 |
# File 'lib/suite/project.rb', line 46 def source_asset_path path + "/assets" end |
#sprocket_environment ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/suite/project.rb', line 58 def sprocket_environment @_memorized_sprocket_environment ||= begin environment = Sprockets::Environment.new environment.append_path source_asset_path + '/icons' environment.append_path source_asset_path + '/images' environment.append_path source_asset_path + '/javascripts' environment.append_path source_asset_path + '/stylesheets' environment end end |