Skip to content

Commit 76009fd

Browse files
committed
Actually getting rabl to work
1 parent 5fe3d81 commit 76009fd

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

lib/split/api.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
require "split/api/version"
1+
require 'sinatra/base'
2+
require 'split'
3+
require 'rabl'
4+
require 'active_support/core_ext'
5+
require 'active_support/inflector'
6+
require 'builder'
27

38
module Split
4-
module Api
5-
# Your code goes here...
9+
class API < Sinatra::Base
10+
Rabl.register!
11+
dir = File.dirname(File.expand_path(__FILE__))
12+
13+
set :views, "#{dir}/api/views"
14+
15+
get '/experiments.json' do
16+
@experiments = Split::Experiment.all
17+
render :rabl, :index, :format => :json
18+
end
619
end
720
end

lib/split/api/views/index.rabl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
collection @experiments
2+
attributes :name

split-api.gemspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Gem::Specification.new do |gem|
1717
gem.add_dependency 'split'
1818
gem.add_dependency 'rabl'
1919
gem.add_dependency 'sinatra'
20+
gem.add_dependency 'activesupport'
21+
gem.add_dependency 'builder'
22+
gem.add_dependency 'i18n'
2023

2124
gem.add_development_dependency 'bundler', '~> 1.0'
2225
gem.add_development_dependency 'rspec', '~> 2.6'

0 commit comments

Comments
 (0)