lib/grit_ext.rb in grit_ext-0.0.1 vs lib/grit_ext.rb in grit_ext-0.1.0
- old
+ new
@@ -1,34 +1,18 @@
require "rubygems"
require "charlock_holmes"
require "language_sniffer"
+require "grit_ext/blob"
require "grit_ext/version"
+require "grit_ext/raw_object"
-Grit::GitRuby::Internal::RawObject.class_eval do
- def content
- transcoding(@content)
- end
-
+module GritExt
private
- def transcoding(content)
+ def transcode(content)
detection = CharlockHolmes::EncodingDetector.detect(content)
if hash = detection
content = CharlockHolmes::Converter.convert(content, hash[:encoding], 'UTF-8') if hash[:encoding]
end
content
end
end
-Grit::Blob.class_eval do
-
- def encoding
- if detection = CharlockHolmes::EncodingDetector.detect(data)
- detection[:encoding]
- end
- end
-
- def language
- if lang = LanguageSniffer.detect(basename, :content => data).language
- lang.name
- end
- end
-end