diff options
author | Vít Ondruch <vondruch@redhat.com> | 2016-07-04 13:11:44 +0200 |
---|---|---|
committer | Vít Ondruch <vondruch@redhat.com> | 2016-07-04 13:11:44 +0200 |
commit | 7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca (patch) | |
tree | 88f5c06236a1588ec1366f11be569c22584a48d4 /activesupport/test/multibyte_test_helpers.rb | |
parent | 9bdf08c5a57d0411db866124eca4deba5097c30a (diff) | |
download | rails-7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca.tar.gz rails-7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca.tar.bz2 rails-7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca.zip |
DRY Downloader.
Diffstat (limited to 'activesupport/test/multibyte_test_helpers.rb')
-rw-r--r-- | activesupport/test/multibyte_test_helpers.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/multibyte_test_helpers.rb b/activesupport/test/multibyte_test_helpers.rb index 58cf5488cd..709586e9c1 100644 --- a/activesupport/test/multibyte_test_helpers.rb +++ b/activesupport/test/multibyte_test_helpers.rb @@ -1,4 +1,22 @@ module MultibyteTestHelpers + class Downloader + def self.download(from, to) + unless File.exist?(to) + unless File.exist?(File.dirname(to)) + system "mkdir -p #{File.dirname(to)}" + end + open(from) do |source| + File.open(to, 'w') do |target| + source.each_line do |l| + target.write l + end + end + end + end + true + end + end + UNICODE_STRING = 'こにちわ'.freeze ASCII_STRING = 'ohayo'.freeze BYTE_STRING = "\270\236\010\210\245".force_encoding("ASCII-8BIT").freeze |