Class: Alephant::Preview::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Alephant::Preview::Server
- Defined in:
- lib/alephant/preview/server.rb
Constant Summary collapse
- BASE_LOCATION =
"#{(ENV['BASE_LOCATION'] || Dir.pwd)}/components"
Instance Method Summary collapse
- #find_id_from_template(template) ⇒ Object
- #render_batch_component ⇒ Object
- #render_component ⇒ Object
- #render_preview ⇒ Object
Instance Method Details
#find_id_from_template(template) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/alephant/preview/server.rb', line 66 def find_id_from_template(template) files = Dir.glob(BASE_LOCATION + '/**/models/*') file = files.select! { |file| file.include? "/#{template}.rb" }.pop result = /#{BASE_LOCATION}\/(\w+)/.match(file) result[1] end |
#render_batch_component ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/alephant/preview/server.rb', line 84 def render_batch_component { :component => template, :options => {}, :status => 200, :body => render_component } end |
#render_component ⇒ Object
80 81 82 |
# File 'lib/alephant/preview/server.rb', line 80 def render_component view_mapper.generate(fixture_data)[template].render end |