From 00a33320133cfebe87ec3ffc15d68d2fe13d346e Mon Sep 17 00:00:00 2001 From: Braulio Martinez Date: Wed, 1 May 2013 20:13:31 -0300 Subject: [PATCH] Remove unnecessary ruby187 hacks --- Changelog.md | 1 + app/controllers/photos_controller.rb | 11 ++--------- app/models/acts_as_taggable_on/tag.rb | 4 ++-- config/application.rb | 6 ------ config/initializers/monkey_patch_to_xs.rb | 12 ------------ spec/models/photo_spec.rb | 11 ++++------- 6 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 config/initializers/monkey_patch_to_xs.rb diff --git a/Changelog.md b/Changelog.md index dbfa4a9cb0e..b056425f6be 100644 --- a/Changelog.md +++ b/Changelog.md @@ -107,6 +107,7 @@ everything is set up. * Cleanup of script/server * Attempt to stabilize federation of attached photos (fix [#3033](https://github.com/diaspora/diaspora/issues/3033) [#3940](https://github.com/diaspora/diaspora/pull/3940) * Refactor develop install script [#4111](https://github.com/diaspora/diaspora/pull/4111) +* Remove special hacks for supporting Ruby 1.8 [#4113] (https://github.com/diaspora/diaspora/pull/4139) ## Bug fixes diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 186b9643501..f28b8cc9aaa 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -141,16 +141,9 @@ def file_handler(params) # get file content type att_content_type = (request.content_type.to_s == "") ? "application/octet-stream" : request.content_type.to_s # create tempora##l file - begin - file = Tempfile.new(file_name, {:encoding => 'BINARY'}) - file.print request.raw_post.force_encoding('BINARY') - rescue RuntimeError => e - raise e unless e.message.include?('cannot generate tempfile') - file = Tempfile.new(file_name) # Ruby 1.8 compatibility - file.binmode - file.print request.raw_post - end + file = Tempfile.new(file_name, {:encoding => 'BINARY'}) # put data into this file from raw post request + file.print request.raw_post.force_encoding('BINARY') # create several required methods for this temporal file Tempfile.send(:define_method, "content_type") {return att_content_type} diff --git a/app/models/acts_as_taggable_on/tag.rb b/app/models/acts_as_taggable_on/tag.rb index 70b77f69b4a..4e652ee4de4 100644 --- a/app/models/acts_as_taggable_on/tag.rb +++ b/app/models/acts_as_taggable_on/tag.rb @@ -1,13 +1,13 @@ class ActsAsTaggableOn::Tag self.include_root_in_json = false - + def followed_count @followed_count ||= TagFollowing.where(:tag_id => self.id).count end def self.tag_text_regexp - @@tag_text_regexp ||= (RUBY_VERSION.include?('1.9') ? "[[:alnum:]]_-" : "\\w-") + @@tag_text_regexp ||= "[[:alnum:]]_-" end def self.autocomplete(name) diff --git a/config/application.rb b/config/application.rb index 8e1d13759ce..2f14c8c419e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,13 +5,7 @@ require 'pathname' require Pathname.new(__FILE__).expand_path.dirname.join('boot') -# Needed for versions of ruby 1.9.2 that were compiled with libyaml. -# They use psych by default which doesn't handle having a default set of parameters. -# See bug #1120. require 'yaml' -if RUBY_VERSION.include? '1.9' - YAML::ENGINE.yamler= 'syck' -end require 'rails/all' diff --git a/config/initializers/monkey_patch_to_xs.rb b/config/initializers/monkey_patch_to_xs.rb deleted file mode 100644 index cae9570f84a..00000000000 --- a/config/initializers/monkey_patch_to_xs.rb +++ /dev/null @@ -1,12 +0,0 @@ -#see https://github.com/hpricot/hpricot/issues/53 -if RUBY_VERSION < "1.9" - module Builder - class XmlBase - unless ::String.method_defined?(:encode) - def _escape(text) - text.to_xs - end - end - end - end -end \ No newline at end of file diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index b168e10c0eb..f9e8d2036a9 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -120,13 +120,10 @@ def with_carrierwave_processing(&block) it 'should save a photo' do @photo.unprocessed_image.store! File.open(@fixture_name) @photo.save.should == true - begin - binary = @photo.unprocessed_image.read.force_encoding('BINARY') - fixture_binary = File.open(@fixture_name).read.force_encoding('BINARY') - rescue NoMethodError # Ruby 1.8 doesn't have force_encoding - binary = @photo.unprocessed_image.read - fixture_binary = File.open(@fixture_name).read - end + + binary = @photo.unprocessed_image.read.force_encoding('BINARY') + fixture_binary = File.read(@fixture_name).force_encoding('BINARY') + binary.should == fixture_binary end