Sha256: 49b06acf34fb4261f6d11a4ac05524bb4c41ac485ff54a23b968f9b34669c6e5
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Hopskip class HopscotchParser require 'yaml' attr_reader :yaml_source attr_writer :controller def initialize(controller) @controller = controller filename = Rails.root.join('app', 'tours', "#{ @controller.controller_name }_tour.yml") puts filename if File.exists?(filename) @yaml_source = YAML::load(File.open("#{ Rails.root }/app/tours/#{ @controller.controller_name }_tour.yml")) else puts 'cannot find file!' end end def show if @yaml_source.present? && @yaml_source[@controller.action_name].present? steps = @yaml_source[@controller.action_name]['steps'] steps.each do |step| step['onNext'] = "eval(#{step['onNext']})" end locals = { id: "#{ @controller.controller_name }_#{ @controller.action_name }_tour", steps: steps.to_json } Erubis::Eruby.new("<script>var tour = {id: \"<%= id %>\",steps: <%= steps %>};hopscotch.startTour(tour);</script>").result(locals).html_safe end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hopskip-0.1.1 | lib/hopskip/hopscotch_parser.rb |