Sha256: 499399a16e0510fb559e183ba835adffbc5d6b0d4a2be49e6681a3ce6d7ebbf9

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

$:.unshift(File.join(File.dirname(__FILE__)))
require 'sinatra'
require 'haml'
require 'rdiscount'

configure do
  set :haml, { :ugly=>true }
end

def features_path
  ARGV.first || "features"
end

def lists_features
  Wally::ListsFeatures.new(features_path)
end

before do
  @features = lists_features.features
end

get '/?' do
  haml :index
end

get '/features/:feature/?' do |feature|
  @features.each do |feature_hash|
   @feature = feature_hash if feature_hash["id"] == feature
  end
  haml :feature
end

get '/search/?' do
  if params[:q]
    @search_results = Wally::SearchFeatures.new(lists_features).find(:query => params[:q])
  end
  haml :search
end

get '/features/:feature/scenario/:scenario/?'  do  |feature_id, scenario_id|
  @features.each do |feature|
    if feature["id"] == feature_id
      feature["elements"].each do |element|
        if element["type"] == "background"
          @background = element
        end
        if element["type"] == "scenario" && element["id"] == "#{feature_id};#{scenario_id}"
          @scenario = element
        end
      end
    end
  end
  haml :scenario
end

def get_scenario_url(scenario)
  url = "/features/#{scenario["id"].gsub(";", "/scenario/")}"
end

def get_sorted_scenarios(feature)
  scenarios = []

  if feature["elements"]
    feature["elements"].each do |element|
      if element["type"] == "scenario"
        scenarios << element
      end
    end
  end
  scenarios.sort! { |a, b| a["name"] <=> b["name"] }
  scenarios
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wally-0.0.15 lib/wally/application.rb
wally-0.0.14 lib/wally/application.rb
wally-0.0.13 lib/wally/application.rb
wally-0.0.12 lib/wally/application.rb
wally-0.0.11 lib/wally/application.rb
wally-0.0.10 lib/wally/application.rb
wally-0.0.9 lib/wally/application.rb
wally-0.0.8 lib/wally/application.rb
wally-0.0.7 lib/wally/application.rb
wally-0.0.6 lib/wally/application.rb
wally-0.0.5 lib/wally/application.rb