Skip to content

Commit

Permalink
Correct special characters before upload
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanroock committed Jan 28, 2012
1 parent ed4273d commit 839d3e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions codersdojo.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.version = "1.5.13"
s.date = %q{2012-01-16}
s.version = "1.5.15"
s.date = %q{2012-01-28}
s.name = %q{codersdojo}
s.authors = ["CodersDojo-Team"]
s.email = %q{codersdojo@it-agile.de}
Expand Down
13 changes: 13 additions & 0 deletions lib/upload/encoding_adjuster.rb
@@ -0,0 +1,13 @@
# coding: utf-8

class EncodingAdjuster

def adjust string
{"‘" => "'", "’" => "'"}.each_pair do |key, value|
string = string.gsub(key, value)
end
string
end


end
5 changes: 4 additions & 1 deletion lib/upload/uploader.rb
Expand Up @@ -2,6 +2,7 @@
require 'state'
require 'state_reader'
require 'upload/xml_element_extractor'
require 'upload/encoding_adjuster'
require 'shellutils/progress'
require 'filename_formatter'
require 'rest_client'
Expand Down Expand Up @@ -46,9 +47,11 @@ def read_states
end

def upload_kata
adjuster = EncodingAdjuster.new
kata_data = {:framework => @framework}
states_data = states.each_with_index do |state,index|
kata_data["states[#{index}]"] = {:code => state.file_contents, :result => state.result, :green => state.green?,
kata_data["states[#{index}]"] = {:code => state.file_contents.collect{|content| adjuster.adjust(content)},
:result => adjuster.adjust(state.result), :green => state.green?,
:created_at => state.time}
end
RestClient.post "#{@hostname}#{@@kata_path}", kata_data
Expand Down

0 comments on commit 839d3e1

Please sign in to comment.