Kouhei Sutou
null+****@clear*****
Fri Jan 3 21:18:58 JST 2014
Kouhei Sutou 2014-01-03 21:18:58 +0900 (Fri, 03 Jan 2014) New Revision: 632c0baba7452f6676c36dfe8cd86074729ea912 https://github.com/ranguba/chupa-text/commit/632c0baba7452f6676c36dfe8cd86074729ea912 Message: Make mime_type instance variable instead of one of attributes Modified files: README.md lib/chupa-text/data.rb Modified: README.md (+26 -0) =================================================================== --- README.md 2014-01-03 21:02:17 +0900 (23a7638) +++ README.md 2014-01-03 21:18:58 +0900 (0094975) @@ -9,6 +9,32 @@ ChupaText ChupaText is an extensible text extractor. You can plug your custom text extractor in ChupaText. You can write your plugin by Ruby. +## Install + +Install `chupa-text` gem: + +``` +% gem install chupa-text +``` + +Now, you can use `chupa-text` command: + +``` +% chupa-text --version +chupa-text 1.0.0 +``` + +## How to use + +You can use ChupaText as command line tool or Ruby library. + +### How to use as command line tool + + + +### How to use as Ruby library + + ## Author * Kouhei Sutou `<kou �� clear-code.com>` Modified: lib/chupa-text/data.rb (+11 -3) =================================================================== --- lib/chupa-text/data.rb 2014-01-03 21:02:17 +0900 (1b1a880) +++ lib/chupa-text/data.rb 2014-01-03 21:18:58 +0900 (10a3f28) @@ -36,6 +36,7 @@ module ChupaText def initialize @body = nil + @mime_type = nil @attributes = {} @uri = nil @source = nil @@ -74,12 +75,19 @@ module ChupaText @attributes[name] = value end + # @return [String] The MIME type of the data. If MIME type + # isn't set, guesses MIME type from path and body. + # @return [nil] If MIME type isn't set and it can't guess MIME type + # from path and body. def mime_type - self["mime-type"] || guess_mime_type + @mime_type || guess_mime_type end + # @param [String, nil] type The MIME type of the data. You can + # unset MIME type by `nil`. If you unset MIME type, MIME type + # is guessed from path and body of the data. def mime_type=(type) - self["mime-type"] = type + @mime_type = type end # @return [String, nil] Normalized extension as String if {#uri} @@ -90,7 +98,7 @@ module ChupaText File.extname(@uri.path).downcase.gsub(/\A\./, "") end - # @return [Bool] true if MIME type is "text/plain", false + # @return [Bool] true if MIME type is "text/XXX", false # otherwise. def text? (mime_type || "").start_with?("text/") -------------- next part -------------- HTML����������������������������...Download