Sha256: f1002804ba07a7b2b7143b85ca6f37dd818089eb50e350abbe24f46f5f801aa7

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

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

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

before do
  features_path = ARGV.first || "features"
  @lists_features = Wally::ListsFeatures.new(features_path)
  @features = @lists_features.features
  @tag_count = Wally::CountsTags.new(@lists_features).count_tags
  @excessive_wip_tags = @tag_count["@wip"] >= 10
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

1 entries across 1 versions & 1 rubygems

Version Path
wally-0.0.17 lib/wally/application.rb