Class: Staticpress::Site
- Inherits:
-
Object
- Object
- Staticpress::Site
- Includes:
- Enumerable, Helpers
- Defined in:
- lib/staticpress/site.rb
Constant Summary collapse
- CONTENT_TYPES =
ordered by priority
[ Staticpress::Content::Page, Staticpress::Content::Post, Staticpress::Content::Index, Staticpress::Content::Category, Staticpress::Content::Tag, Staticpress::Content::Theme ]
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #find_content_by_env(env) ⇒ Object
-
#initialize ⇒ Site
constructor
A new instance of Site.
- #meta ⇒ Object
- #save ⇒ Object
Methods included from Helpers
#config, #extensionless_basename, #extensionless_path, #hash_from_array, #hash_from_match_data, #paginate, #settings, #spider_map, #titleize
Constructor Details
#initialize ⇒ Site
Returns a new instance of Site.
20 21 22 |
# File 'lib/staticpress/site.rb', line 20 def initialize @directory = Staticpress.blog_path + config.source_path end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
18 19 20 |
# File 'lib/staticpress/site.rb', line 18 def directory @directory end |
Instance Method Details
#each(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/staticpress/site.rb', line 24 def each(&block) semaphore = Mutex.new CONTENT_TYPES.map do |content_type| Thread.new do content_type.published.each do |content| semaphore.synchronize do block.call content end end end end.each(&:join) end |
#find_content_by_env(env) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/staticpress/site.rb', line 38 def find_content_by_env(env) catch :content do CONTENT_TYPES.detect do |content_type| content = content_type.find_by_url_path env['REQUEST_PATH'] throw :content, content if content && content.exist? end nil end end |
#meta ⇒ Object
49 50 51 52 |
# File 'lib/staticpress/site.rb', line 49 def # or something... inject(Staticpress::Metadata.new) { |, content| << content. } end |
#save ⇒ Object
54 55 56 57 58 |
# File 'lib/staticpress/site.rb', line 54 def save destination = Staticpress.blog_path + config.destination_path FileUtils.rm_r destination if destination.directory? each &:save end |