Sha256: 9b4384098b4abda5885582f73dcbb7e1d9f705cd1d27064299cd652fe41cef63

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

require 'coffee-script'

class Netzke::TestingController < ApplicationController
  def components
    component_name = params[:class].gsub("::", "_").underscore
    render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:class]}', :height => #{params[:height] || 400} %>",
           :layout => true
  end

  def specs
    coffee = spec_file(params[:name])
    render text: CoffeeScript.compile(coffee)
  end

  private

  def spec_file(name)
    spec_root = Pathname.new(Netzke::Testing.spec_root || Rails.root)

    path = spec_root.join "spec/javascripts/#{name}_spec.js.coffee"

    if !File.exists?(File.expand_path(path, __FILE__))
      path = spec_root.join "spec/javascripts/#{name}.js.coffee"
    end

    File.read(File.expand_path(path, __FILE__))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-testing-0.9.1 app/controllers/netzke/testing_controller.rb
netzke-testing-0.9.0 app/controllers/netzke/netzke/testing_controller.rb