Class: Bones

Inherits:
Object show all
Defined in:
lib/bones/bones.rb,
lib/bones/cache.rb,
lib/bones/proxy.rb,
lib/bones/server.rb,
lib/bones/static.rb,
lib/bones/release.rb,
lib/bones/template.rb,
lib/bones/initializer.rb,
lib/bones/versioned_release.rb

Overview

BonesProxy is simply a proxy class handler to the actual Bones class - the reason for this is to allow live changes to Bones and helpers, etc. The proxy reloads on every request

Defined Under Namespace

Classes: Cache, Initializer, Proxy, Release, Server, Static, Template, VersionedRelease

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.baseObject

Returns the value of attribute base.



6
7
8
# File 'lib/bones/bones.rb', line 6

def base
  @base
end

.bootedObject

Returns the value of attribute booted.



8
9
10
# File 'lib/bones/bones.rb', line 8

def booted
  @booted
end

.layouts_pathObject

Path to the directory containing the layout templates

[root]/layouts


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

def layouts_path
  @layouts_path
end

.pages_pathObject

Path to the directory containing the page templates

[root]/pages


27
28
29
# File 'lib/bones/bones.rb', line 27

def pages_path
  @pages_path
end

.rootObject

Path to the root of the bones project



15
16
17
# File 'lib/bones/bones.rb', line 15

def root
  @root
end

.system_pathObject

Path to the bones system files Defaults to the lib



21
22
23
# File 'lib/bones/bones.rb', line 21

def system_path
  @system_path
end

Class Method Details

.booted?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/bones/bones.rb', line 37

def booted?
  @booted
end

.directories(base) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/bones/bones.rb', line 41

def directories(base)
  Dir.chdir(base) do
    Dir.entries(base).map do |e|
      next if e =~ /^\.+$/ 
      File.directory?(base / e) ? '/' + e : nil
    end.compact
  end
end

.page_directoriesObject



50
51
52
# File 'lib/bones/bones.rb', line 50

def page_directories
  directories(Bones.root / 'pages')
end

.pagesObject

Returns array of all pages (excluding partials)



88
89
90
91
92
93
94
# File 'lib/bones/bones.rb', line 88

def self.pages
  Dir.chdir(Bones.pages_path) do
    Dir.glob('**/*.html.erb').map do |f|
      File.basename(f).starts_with?('_') ? nil : f.gsub('.html.erb', '')
    end.compact
  end
end

.public_directoriesObject



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

def public_directories
  directories(Bones.root / 'public') - page_directories - versioned_directories
end

.resetObject

Resets root, pages, and layouts paths and the base setting



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

def self.reset
  @pages_path = @layouts_path = @root = @base = nil
end

.versioned_directoriesObject



54
55
56
# File 'lib/bones/bones.rb', line 54

def versioned_directories
  Bones::VersionedRelease.directories
end

Instance Method Details

#call(env) ⇒ Object

Process incoming request (for real this time!)



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bones/bones.rb', line 69

def call(env)
  # Grab the request
  request  = Rack::Request.new(env) 
  
  # Create a new template for the given path
  # and compile it
  
  template = Template.new(Template.template_for_request(request))
  template.request = request
  output   = template.compile

  # Build a rack response
  # Rack::Response.new.finish do |response|
  #   response.write output
  # end    
  [200, { 'Content-Type' => 'text/html'}, output]
end