Kouhei Sutou
null+****@clear*****
Wed Jul 5 12:14:21 JST 2017
Kouhei Sutou 2017-07-05 12:14:21 +0900 (Wed, 05 Jul 2017) New Revision: 9c8d603fa3108201ab492ba7b0cd4badee31cb68 https://github.com/ranguba/chupa-text/commit/9c8d603fa3108201ab492ba7b0cd4badee31cb68 Message: Support file name in Japanese Modified files: lib/chupa-text/command/chupa-text.rb lib/chupa-text/data.rb lib/chupa-text/input-data.rb Modified: lib/chupa-text/command/chupa-text.rb (+2 -2) =================================================================== --- lib/chupa-text/command/chupa-text.rb 2017-07-05 11:57:33 +0900 (f9007db) +++ lib/chupa-text/command/chupa-text.rb 2017-07-05 12:14:21 +0900 (015f17b) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -154,7 +154,7 @@ module ChupaText if****@input*****? VirtualFileData.new(nil, $stdin) else - InputData.new(@input) + InputData.new(Pathname(@input)) end end Modified: lib/chupa-text/data.rb (+14 -2) =================================================================== --- lib/chupa-text/data.rb 2017-07-05 11:57:33 +0900 (1d65601) +++ lib/chupa-text/data.rb 2017-07-05 12:14:21 +0900 (6e80d0f) @@ -14,6 +14,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +require "cgi/util" require "uri" require "open-uri" @@ -91,8 +92,19 @@ module ChupaText # `nil`, it means that the data isn't associated with any URIs. def uri=(uri) case uri - when String, Pathname - uri = URI.parse(uri.to_s) + when String + uri = URI.parse(uri) + when Pathname + file_uri = "" + target = uri.expand_path + loop do + target, base = target.split + file_uri = "/#{CGI.escape(base.to_s)}#{file_uri}" + break if target.root? + end + file_uri = "file://#{file_uri}" + uri = URI.parse(file_uri) + p uri end @uri = uri end Modified: lib/chupa-text/input-data.rb (+5 -1) =================================================================== --- lib/chupa-text/input-data.rb 2017-07-05 11:57:33 +0900 (0967ab6) +++ lib/chupa-text/input-data.rb 2017-07-05 12:14:21 +0900 (2f32cb9) @@ -14,6 +14,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +require "cgi/util" require "uri" require "open-uri" @@ -23,7 +24,10 @@ module ChupaText super(options) self.uri = uri if****@uri***** == URI::Generic - @content = FileContent.new(@uri.path) + unescaped_components =****@uri*****("/").collect do |component| + CGI.unescape(component) + end + @content = FileContent.new(unescaped_components.join("/")) else @content = download end -------------- next part -------------- HTML����������������������������...Download