Kouhei Sutou
null+****@clear*****
Mon Jul 10 13:48:51 JST 2017
Kouhei Sutou 2017-07-10 13:48:51 +0900 (Mon, 10 Jul 2017) New Revision: c59b657f7883e96fbb7bff2dacd8776f6beff003 https://github.com/ranguba/chupa-text/commit/c59b657f7883e96fbb7bff2dacd8776f6beff003 Message: Use Pathname for path data Modified files: lib/chupa-text/virtual-content.rb Modified: lib/chupa-text/virtual-content.rb (+9 -1) =================================================================== --- lib/chupa-text/virtual-content.rb 2017-07-10 10:24:47 +0900 (3229a71) +++ lib/chupa-text/virtual-content.rb 2017-07-10 13:48:51 +0900 (89518fe) @@ -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 "pathname" require "stringio" require "tempfile" @@ -25,6 +26,13 @@ module ChupaText attr_reader :size def initialize(input, original_path=nil) @file = nil + if original_path.is_a?(String) + if original_path.empty? + original_path = nil + else + original_path = Pathname.new(original_path) + end + end @base_name = compute_base_name(original_path) @body = nil setup_file do |file| @@ -47,7 +55,7 @@ module ChupaText private def compute_base_name(original_path) if original_path - prefix, suffix = File.basename(original_path).split(/(\.[^.]+\z)/) + prefix, suffix = original_path.basename.to_s.split(/(\.[^.]+\z)/) if suffix [prefix, suffix] else -------------- next part -------------- HTML����������������������������... Descargar