[Groonga-commit] ranguba/chupa-text-decomposer-pdf at 1948d6d [master] Support ChupaText::Attributes

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Feb 17 23:40:56 JST 2014


Kouhei Sutou	2014-02-17 23:40:56 +0900 (Mon, 17 Feb 2014)

  New Revision: 1948d6d286868e87896ab52b418ffcba51f2bcb2
  https://github.com/ranguba/chupa-text-decomposer-pdf/commit/1948d6d286868e87896ab52b418ffcba51f2bcb2

  Message:
    Support ChupaText::Attributes

  Modified files:
    lib/chupa-text/decomposers/pdf.rb
    test/test-pdf.rb

  Modified: lib/chupa-text/decomposers/pdf.rb (+6 -5)
===================================================================
--- lib/chupa-text/decomposers/pdf.rb    2014-02-17 22:14:31 +0900 (9e55e87)
+++ lib/chupa-text/decomposers/pdf.rb    2014-02-17 23:40:56 +0900 (e2f7337)
@@ -45,7 +45,7 @@ module ChupaText
         add_attribute(text_data, document, :keywords)
         add_attribute(text_data, document, :creator)
         add_attribute(text_data, document, :producer)
-        add_attribute(text_data, document, :creation_date)
+        add_attribute(text_data, document, :creation_date, :created_time)
         yield(text_data)
       end
 
@@ -71,12 +71,13 @@ module ChupaText
         password
       end
 
-      def add_attribute(text_data, document, name)
-        value = document.send(name)
+      def add_attribute(text_data, document,
+                        pdf_attribute_name, data_attribute_name=nil)
+        value = document.send(pdf_attribute_name)
         return if value.nil?
-        attribute_name = name.to_s.gsub(/_/, "-")
         value = Time.at(value).utc.iso8601 if value.is_a?(Integer)
-        text_data[attribute_name] = value
+        data_attribute_name ||= pdf_attribute_name.to_s.gsub(/_/, "-")
+        text_data[data_attribute_name] = value
       end
     end
   end

  Modified: test/test-pdf.rb (+3 -2)
===================================================================
--- test/test-pdf.rb    2014-02-17 22:14:31 +0900 (8a50651)
+++ test/test-pdf.rb    2014-02-17 23:40:56 +0900 (c5bb2f9)
@@ -104,8 +104,9 @@ class TestPDF < Test::Unit::TestCase
         assert_equal(["LibreOffice 4.1"], decompose("producer"))
       end
 
-      def test_creation_date
-        assert_equal([nil], decompose("creation_date"))
+      def test_created_time
+        assert_equal([Time.parse("2014-01-05T06:52:45Z")],
+                     decompose("created_time"))
       end
 
       private
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index