Skip to content

Commit

Permalink
Merge 23b2106 into 01d236d
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Pikesley committed Sep 7, 2016
2 parents 01d236d + 23b2106 commit fa30e75
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ GEM
phantomjs
rack (>= 1.2.1)
rake
jasmine-core (2.5.0)
jasmine-core (2.5.1)
json (1.8.3)
kramdown (1.12.0)
listen (3.1.5)
Expand All @@ -108,7 +108,7 @@ GEM
minitest (5.9.0)
multi_json (1.12.1)
nenv (0.3.0)
nineteen-eighty-two (0.1.2)
nineteen-eighty-two (0.1.3)
erubis
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
Expand Down
9 changes: 9 additions & 0 deletions lib/uncle_clive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ class App < Sinatra::Base
end
end

post '/' do
respond_to do |wants|
wants.svg do
j = JSON.parse request.body.read
Nineteen::Eighty::Two::Formats::SVG.format j['text'], {colour: "##{params.fetch('colour', '000000')}"}
end
end
end

# start the server if ruby file executed directly
run! if app_file == $0
end
Expand Down
16 changes: 16 additions & 0 deletions spec/uncle_clive/uncle_clive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ module UncleClive
expect(last_response).to be_ok
expect(last_response.body.split("\n")[4]).to eq " fill: #fa8100;"
end

it 'serves multi-line SVG' do
body = {
'text' => [
'more',
'than',
'one',
'line'
]
}.to_json

post '/', body, SVG_HEADERS
expect(last_response).to be_ok
lines = last_response.body.split("\n")
expect(lines[0]).to eq"<svg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'>"
end
end
end
end
Expand Down

0 comments on commit fa30e75

Please sign in to comment.