friendly_format 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +11 -0
 - data/LICENSE +201 -0
 - data/NOTICE +10 -0
 - data/README +45 -0
 - data/Rakefile +58 -0
 - data/TODO +6 -0
 - data/friendly_format.gemspec +42 -0
 - data/lib/friendly_format/set_common.rb +16 -0
 - data/lib/friendly_format/set_strict.rb +12 -0
 - data/lib/friendly_format/version.rb +3 -0
 - data/lib/friendly_format.rb +171 -0
 - data/tasks/ann.rake +80 -0
 - data/tasks/bones.rake +20 -0
 - data/tasks/gem.rake +192 -0
 - data/tasks/git.rake +40 -0
 - data/tasks/manifest.rake +48 -0
 - data/tasks/notes.rake +27 -0
 - data/tasks/post_load.rake +39 -0
 - data/tasks/rdoc.rake +50 -0
 - data/tasks/rubyforge.rake +55 -0
 - data/tasks/setup.rb +279 -0
 - data/tasks/spec.rake +54 -0
 - data/tasks/svn.rake +47 -0
 - data/tasks/test.rake +40 -0
 - data/test/sample/complex_article.txt +111 -0
 - data/test/sample/complex_article_result.txt +108 -0
 - data/test/test_friendly_format.rb +168 -0
 - metadata +119 -0
 
    
        data/tasks/test.rake
    ADDED
    
    | 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            namespace :test do
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              Rake::TestTask.new(:run) do |t|
         
     | 
| 
      
 8 
     | 
    
         
            +
                t.libs = PROJ.libs
         
     | 
| 
      
 9 
     | 
    
         
            +
                t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
         
     | 
| 
      
 10 
     | 
    
         
            +
                               else PROJ.test.files end
         
     | 
| 
      
 11 
     | 
    
         
            +
                t.ruby_opts += PROJ.ruby_opts
         
     | 
| 
      
 12 
     | 
    
         
            +
                t.ruby_opts += PROJ.test.opts
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              if HAVE_RCOV
         
     | 
| 
      
 16 
     | 
    
         
            +
                desc 'Run rcov on the unit tests'
         
     | 
| 
      
 17 
     | 
    
         
            +
                task :rcov => :clobber_rcov do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
         
     | 
| 
      
 19 
     | 
    
         
            +
                  opts = opts.join(' ')
         
     | 
| 
      
 20 
     | 
    
         
            +
                  files = if test(?f, PROJ.test.file) then [PROJ.test.file]
         
     | 
| 
      
 21 
     | 
    
         
            +
                          else PROJ.test.files end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  files = files.join(' ')
         
     | 
| 
      
 23 
     | 
    
         
            +
                  sh "#{RCOV} #{files} #{opts}"
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                task :clobber_rcov do
         
     | 
| 
      
 27 
     | 
    
         
            +
                  rm_r 'coverage' rescue nil
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            end  # namespace :test
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            desc 'Alias to test:run'
         
     | 
| 
      
 34 
     | 
    
         
            +
            task :test => 'test:run'
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            task :clobber => 'test:clobber_rcov' if HAVE_RCOV
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            # EOF
         
     | 
| 
         @@ -0,0 +1,111 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            http://phpbb.godfat.org/viewtopic.php?t=873
         
     | 
| 
      
 2 
     | 
    
         
            +
            <pre> 作者  godfat (godfat 真常)                                 站內  ProjectX
         
     | 
| 
      
 3 
     | 
    
         
            +
             標題  Re: [PSC] variants timer
         
     | 
| 
      
 4 
     | 
    
         
            +
             時間  2008/03/04 Tue 00:34:54
         
     | 
| 
      
 5 
     | 
    
         
            +
            http://phpbb.godfat.org/viewtopic.php?t=873
         
     | 
| 
      
 6 
     | 
    
         
            +
            <a href="http://phpbb.godfat.org/viewtopic.php?t=873">
         
     | 
| 
      
 7 
     | 
    
         
            +
            測試</a>
         
     | 
| 
      
 8 
     | 
    
         
            +
            <a href="http://phpbb.godfat.org/viewtopic.php?t=873">
         
     | 
| 
      
 9 
     | 
    
         
            +
            <img src="http://phpbb.godfat.org/templates/subSilver/images/logo_phpBB.gif"/></a>
         
     | 
| 
      
 10 
     | 
    
         
            +
            ※ 引述《godfat (godfat 真常)》之銘言:
         
     | 
| 
      
 11 
     | 
    
         
            +
            > 3. tuple + traits, 也就是一堆 template 技巧了
         
     | 
| 
      
 12 
     | 
    
         
            +
            > class Dispatcher{
         
     | 
| 
      
 13 
     | 
    
         
            +
            >     template <class T>
         
     | 
| 
      
 14 
     | 
    
         
            +
            >     void sub(shared_ptr<T> p){
         
     | 
| 
      
 15 
     | 
    
         
            +
            >         get_tuple_data_field_by_type<T>(data).push_back(p);
         
     | 
| 
      
 16 
     | 
    
         
            +
            >     }
         
     | 
| 
      
 17 
     | 
    
         
            +
            >     tuple<A, B, C> data;
         
     | 
| 
      
 18 
     | 
    
         
            +
            > };
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            以上 A, B, C 是指 timer_subscriber_list<A>, etc.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            這個東西會需要從 T => tuple index 的 mapping
         
     | 
| 
      
 23 
     | 
    
         
            +
            現在這部份做完了...........(template 沒忘太多啊哈哈)
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            #include <tr1/tuple>
         
     | 
| 
      
 26 
     | 
    
         
            +
            #include <tr1/type_traits>
         
     | 
| 
      
 27 
     | 
    
         
            +
            #include <iostream>
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            using namespace std::tr1;
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            // 拿來判斷兩個整數是否相同,這是為了檢查有沒有爆表
         
     | 
| 
      
 32 
     | 
    
         
            +
            // 像是 tuple_element<3, tuple<int,int,int> >::type
         
     | 
| 
      
 33 
     | 
    
         
            +
            // 這樣就是爆表,因為這 tuple 沒這麼大
         
     | 
| 
      
 34 
     | 
    
         
            +
            template <bool> struct is_equal_type       { typedef true_type type; };
         
     | 
| 
      
 35 
     | 
    
         
            +
            template <>     struct is_equal_type<false>{ typedef false_type type; };
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            // 定義相等的話,is_equal<1,1>::value 會是 1
         
     | 
| 
      
 38 
     | 
    
         
            +
            //               is_equal<1,2>::value 會是 0
         
     | 
| 
      
 39 
     | 
    
         
            +
            //                            ::type 會是 true_type/false_type (from tr1)
         
     | 
| 
      
 40 
     | 
    
         
            +
            template <int Lhs, int Rhs> struct is_equal{
         
     | 
| 
      
 41 
     | 
    
         
            +
                enum{ value = Lhs == Rhs };
         
     | 
| 
      
 42 
     | 
    
         
            +
                typedef typename is_equal_type<value>::type type;
         
     | 
| 
      
 43 
     | 
    
         
            +
            };
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            template <class T, class Tuple, int Index> struct type_index_imp;
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            // 如果跑到這裡,表示爆表了,在我的 g++4.3 上會顯示:
         
     | 
| 
      
 48 
     | 
    
         
            +
            // tuple.cpp:20: error: ‘type_not_found’ is not a member of "T"
         
     | 
| 
      
 49 
     | 
    
         
            +
            template <class T, class Tuple, int Index, class Bool>
         
     | 
| 
      
 50 
     | 
    
         
            +
            struct type_index_check{
         
     | 
| 
      
 51 
     | 
    
         
            +
                enum{ value = T::type_not_found };
         
     | 
| 
      
 52 
     | 
    
         
            +
            };
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            // 沒有爆表就繼續找吧
         
     | 
| 
      
 55 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 56 
     | 
    
         
            +
            struct type_index_check<T, Tuple, Index, false_type>{
         
     | 
| 
      
 57 
     | 
    
         
            +
                    enum{ value = type_index_imp<T, Tuple, Index+1>::value };
         
     | 
| 
      
 58 
     | 
    
         
            +
            };
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            // 找到了!
         
     | 
| 
      
 61 
     | 
    
         
            +
            template <class T, class Tuple, int Index, class Bool>
         
     | 
| 
      
 62 
     | 
    
         
            +
            struct type_index_if{
         
     | 
| 
      
 63 
     | 
    
         
            +
                enum{ value = Index }; // found, stop recursion
         
     | 
| 
      
 64 
     | 
    
         
            +
            };
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            // 不直接呼叫 imp, 呼叫 check 檢查是否爆表
         
     | 
| 
      
 67 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 68 
     | 
    
         
            +
            struct type_index_if<T, Tuple, Index, false_type>{
         
     | 
| 
      
 69 
     | 
    
         
            +
                enum{ value = type_index_check<T, Tuple, Index,
         
     | 
| 
      
 70 
     | 
    
         
            +
                        typename is_equal<Index+1, tuple_size<Tuple>::value>::type>::value };
         
     | 
| 
      
 71 
     | 
    
         
            +
            };
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            // 檢查兩個型別是否相同
         
     | 
| 
      
 74 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 75 
     | 
    
         
            +
            struct type_index_imp{
         
     | 
| 
      
 76 
     | 
    
         
            +
                enum{ value = type_index_if<T, Tuple, Index,
         
     | 
| 
      
 77 
     | 
    
         
            +
                        typename is_same<T, typename tuple_element<Index, Tuple>::type>::type>::value };
         
     | 
| 
      
 78 
     | 
    
         
            +
            };
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            // simple wrapper
         
     | 
| 
      
 81 
     | 
    
         
            +
            template <class T, class Tuple>
         
     | 
| 
      
 82 
     | 
    
         
            +
            struct type_index{
         
     | 
| 
      
 83 
     | 
    
         
            +
                enum{ value = type_index_imp<T, Tuple, 0>::value };
         
     | 
| 
      
 84 
     | 
    
         
            +
            };
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            int main(){
         
     | 
| 
      
 87 
     | 
    
         
            +
                typedef tuple<int, char, void> test_t;
         
     | 
| 
      
 88 
     | 
    
         
            +
                std::cout << type_index<int, test_t>::value << std::endl;
         
     | 
| 
      
 89 
     | 
    
         
            +
                std::cout << type_index<char, test_t>::value << std::endl;
         
     | 
| 
      
 90 
     | 
    
         
            +
                std::cout << type_index<void, test_t>::value << std::endl;
         
     | 
| 
      
 91 
     | 
    
         
            +
                std::cout << tuple_size<test_t>::value << std::endl;
         
     | 
| 
      
 92 
     | 
    
         
            +
                // std::cout << type_index<int*, test_t>::value << std::endl;
         
     | 
| 
      
 93 
     | 
    
         
            +
            }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            輸出:
         
     | 
| 
      
 96 
     | 
    
         
            +
            0
         
     | 
| 
      
 97 
     | 
    
         
            +
            1
         
     | 
| 
      
 98 
     | 
    
         
            +
            2
         
     | 
| 
      
 99 
     | 
    
         
            +
            3
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            最後一行註解拿掉,則顯示:
         
     | 
| 
      
 102 
     | 
    
         
            +
            tuple.cpp:20: error:  "type_not_found" is not a member of "T"
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            這樣應該是蠻完整的了。有了這個之後.... 後面還有得做 XD
         
     | 
| 
      
 105 
     | 
    
         
            +
            至少還需要一個 tuple for_each, 這也會用 template 遞迴展開
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            --
         
     | 
| 
      
 108 
     | 
    
         
            +
             ※ Orign:  群星的眷屬  chance.twbbs.org
         
     | 
| 
      
 109 
     | 
    
         
            +
             ◆ Author: godfat From 220-135-28-18.HINET-IP.hinet.net</pre>
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            end of article...
         
     | 
| 
         @@ -0,0 +1,108 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <a href="http://phpbb.godfat.org/viewtopic.php?t=873" title="http://phpbb.godfat.org/viewtopic.php?t=873">http://phpbb.godfat.org/viewtopic.php?t=873</a><br /><pre> 作者  godfat (godfat 真常)                                 站內  ProjectX
         
     | 
| 
      
 2 
     | 
    
         
            +
             標題  Re: [PSC] variants timer
         
     | 
| 
      
 3 
     | 
    
         
            +
             時間  2008/03/04 Tue 00:34:54
         
     | 
| 
      
 4 
     | 
    
         
            +
            <a href="http://phpbb.godfat.org/viewtopic.php?t=873" title="http://phpbb.godfat.org/viewtopic.php?t=873">http://phpbb.godfat.org/viewtopic.php?t=873</a>
         
     | 
| 
      
 5 
     | 
    
         
            +
            <a href="<a href="http://phpbb.godfat.org/viewtopic.php?t=873" title="http://phpbb.godfat.org/viewtopic.php?t=873">http://phpbb.godfat.org/viewtopic.php?t=873</a>">
         
     | 
| 
      
 6 
     | 
    
         
            +
            測試</a>
         
     | 
| 
      
 7 
     | 
    
         
            +
            <a href="<a href="http://phpbb.godfat.org/viewtopic.php?t=873" title="http://phpbb.godfat.org/viewtopic.php?t=873">http://phpbb.godfat.org/viewtopic.php?t=873</a>">
         
     | 
| 
      
 8 
     | 
    
         
            +
            <img src="<a href="http://phpbb.godfat.org/templates/subSilver/images/logo_phpBB.gif" title="http://phpbb.godfat.org/templates/subSilver/images/logo_phpBB.gif">http://phpbb.godfat.org/templates/subSilver/images/logo_phpBB.gif</a>"/></a>
         
     | 
| 
      
 9 
     | 
    
         
            +
            ※ 引述《godfat (godfat 真常)》之銘言:
         
     | 
| 
      
 10 
     | 
    
         
            +
            > 3. tuple + traits, 也就是一堆 template 技巧了
         
     | 
| 
      
 11 
     | 
    
         
            +
            > class Dispatcher{
         
     | 
| 
      
 12 
     | 
    
         
            +
            >     template <class T>
         
     | 
| 
      
 13 
     | 
    
         
            +
            >     void sub(shared_ptr<T> p){
         
     | 
| 
      
 14 
     | 
    
         
            +
            >         get_tuple_data_field_by_type<T>(data).push_back(p);
         
     | 
| 
      
 15 
     | 
    
         
            +
            >     }
         
     | 
| 
      
 16 
     | 
    
         
            +
            >     tuple<A, B, C> data;
         
     | 
| 
      
 17 
     | 
    
         
            +
            > };
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            以上 A, B, C 是指 timer_subscriber_list<A>, etc.
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            這個東西會需要從 T => tuple index 的 mapping
         
     | 
| 
      
 22 
     | 
    
         
            +
            現在這部份做完了...........(template 沒忘太多啊哈哈)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            #include <tr1/tuple>
         
     | 
| 
      
 25 
     | 
    
         
            +
            #include <tr1/type_traits>
         
     | 
| 
      
 26 
     | 
    
         
            +
            #include <iostream>
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            using namespace std::tr1;
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            // 拿來判斷兩個整數是否相同,這是為了檢查有沒有爆表
         
     | 
| 
      
 31 
     | 
    
         
            +
            // 像是 tuple_element<3, tuple<int,int,int> >::type
         
     | 
| 
      
 32 
     | 
    
         
            +
            // 這樣就是爆表,因為這 tuple 沒這麼大
         
     | 
| 
      
 33 
     | 
    
         
            +
            template <bool> struct is_equal_type       { typedef true_type type; };
         
     | 
| 
      
 34 
     | 
    
         
            +
            template <>     struct is_equal_type<false>{ typedef false_type type; };
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            // 定義相等的話,is_equal<1,1>::value 會是 1
         
     | 
| 
      
 37 
     | 
    
         
            +
            //               is_equal<1,2>::value 會是 0
         
     | 
| 
      
 38 
     | 
    
         
            +
            //                            ::type 會是 true_type/false_type (from tr1)
         
     | 
| 
      
 39 
     | 
    
         
            +
            template <int Lhs, int Rhs> struct is_equal{
         
     | 
| 
      
 40 
     | 
    
         
            +
                enum{ value = Lhs == Rhs };
         
     | 
| 
      
 41 
     | 
    
         
            +
                typedef typename is_equal_type<value>::type type;
         
     | 
| 
      
 42 
     | 
    
         
            +
            };
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            template <class T, class Tuple, int Index> struct type_index_imp;
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            // 如果跑到這裡,表示爆表了,在我的 g++4.3 上會顯示:
         
     | 
| 
      
 47 
     | 
    
         
            +
            // tuple.cpp:20: error: ‘type_not_found’ is not a member of "T"
         
     | 
| 
      
 48 
     | 
    
         
            +
            template <class T, class Tuple, int Index, class Bool>
         
     | 
| 
      
 49 
     | 
    
         
            +
            struct type_index_check{
         
     | 
| 
      
 50 
     | 
    
         
            +
                enum{ value = T::type_not_found };
         
     | 
| 
      
 51 
     | 
    
         
            +
            };
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            // 沒有爆表就繼續找吧
         
     | 
| 
      
 54 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 55 
     | 
    
         
            +
            struct type_index_check<T, Tuple, Index, false_type>{
         
     | 
| 
      
 56 
     | 
    
         
            +
                    enum{ value = type_index_imp<T, Tuple, Index+1>::value };
         
     | 
| 
      
 57 
     | 
    
         
            +
            };
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            // 找到了!
         
     | 
| 
      
 60 
     | 
    
         
            +
            template <class T, class Tuple, int Index, class Bool>
         
     | 
| 
      
 61 
     | 
    
         
            +
            struct type_index_if{
         
     | 
| 
      
 62 
     | 
    
         
            +
                enum{ value = Index }; // found, stop recursion
         
     | 
| 
      
 63 
     | 
    
         
            +
            };
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            // 不直接呼叫 imp, 呼叫 check 檢查是否爆表
         
     | 
| 
      
 66 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 67 
     | 
    
         
            +
            struct type_index_if<T, Tuple, Index, false_type>{
         
     | 
| 
      
 68 
     | 
    
         
            +
                enum{ value = type_index_check<T, Tuple, Index,
         
     | 
| 
      
 69 
     | 
    
         
            +
                        typename is_equal<Index+1, tuple_size<Tuple>::value>::type>::value };
         
     | 
| 
      
 70 
     | 
    
         
            +
            };
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            // 檢查兩個型別是否相同
         
     | 
| 
      
 73 
     | 
    
         
            +
            template <class T, class Tuple, int Index>
         
     | 
| 
      
 74 
     | 
    
         
            +
            struct type_index_imp{
         
     | 
| 
      
 75 
     | 
    
         
            +
                enum{ value = type_index_if<T, Tuple, Index,
         
     | 
| 
      
 76 
     | 
    
         
            +
                        typename is_same<T, typename tuple_element<Index, Tuple>::type>::type>::value };
         
     | 
| 
      
 77 
     | 
    
         
            +
            };
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            // simple wrapper
         
     | 
| 
      
 80 
     | 
    
         
            +
            template <class T, class Tuple>
         
     | 
| 
      
 81 
     | 
    
         
            +
            struct type_index{
         
     | 
| 
      
 82 
     | 
    
         
            +
                enum{ value = type_index_imp<T, Tuple, 0>::value };
         
     | 
| 
      
 83 
     | 
    
         
            +
            };
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            int main(){
         
     | 
| 
      
 86 
     | 
    
         
            +
                typedef tuple<int, char, void> test_t;
         
     | 
| 
      
 87 
     | 
    
         
            +
                std::cout << type_index<int, test_t>::value << std::endl;
         
     | 
| 
      
 88 
     | 
    
         
            +
                std::cout << type_index<char, test_t>::value << std::endl;
         
     | 
| 
      
 89 
     | 
    
         
            +
                std::cout << type_index<void, test_t>::value << std::endl;
         
     | 
| 
      
 90 
     | 
    
         
            +
                std::cout << tuple_size<test_t>::value << std::endl;
         
     | 
| 
      
 91 
     | 
    
         
            +
                // std::cout << type_index<int*, test_t>::value << std::endl;
         
     | 
| 
      
 92 
     | 
    
         
            +
            }
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            輸出:
         
     | 
| 
      
 95 
     | 
    
         
            +
            0
         
     | 
| 
      
 96 
     | 
    
         
            +
            1
         
     | 
| 
      
 97 
     | 
    
         
            +
            2
         
     | 
| 
      
 98 
     | 
    
         
            +
            3
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            最後一行註解拿掉,則顯示:
         
     | 
| 
      
 101 
     | 
    
         
            +
            tuple.cpp:20: error:  "type_not_found" is not a member of "T"
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            這樣應該是蠻完整的了。有了這個之後.... 後面還有得做 XD
         
     | 
| 
      
 104 
     | 
    
         
            +
            至少還需要一個 tuple for_each, 這也會用 template 遞迴展開
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            --
         
     | 
| 
      
 107 
     | 
    
         
            +
             ※ Orign:  群星的眷屬  chance.twbbs.org
         
     | 
| 
      
 108 
     | 
    
         
            +
             ◆ Author: godfat From 220-135-28-18.HINET-IP.hinet.net</pre><br /><br />end of article...<br />
         
     | 
| 
         @@ -0,0 +1,168 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'minitest/unit'
         
     | 
| 
      
 5 
     | 
    
         
            +
            MiniTest::Unit.autorun
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require 'friendly_format'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # 2008-05-09 godfat
         
     | 
| 
      
 10 
     | 
    
         
            +
            class TestFriendlyFormat < MiniTest::Unit::TestCase
         
     | 
| 
      
 11 
     | 
    
         
            +
              include FriendlyFormat
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def test_article
         
     | 
| 
      
 14 
     | 
    
         
            +
                str = 
         
     | 
| 
      
 15 
     | 
    
         
            +
            ' http://friends.roodo.com/forum/viewTopic/10170
         
     | 
| 
      
 16 
     | 
    
         
            +
            用 Haskell 寫成的名軟體?
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            主題發起人 : godfat 真常
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            2008年04月02日 01:24
         
     | 
| 
      
 21 
     | 
    
         
            +
            第一個當然是首推唐鳳寫的 Pugs!
         
     | 
| 
      
 22 
     | 
    
         
            +
            是基於 Perl 6 一直實作困難,所以才決定寫 Pugs 當中繼者。
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Pugs 無論對 Haskell 社群和 Perl 6 社群都有很大的影響。
         
     | 
| 
      
 25 
     | 
    
         
            +
            唐大師:
         
     | 
| 
      
 26 
     | 
    
         
            +
            http://zh.wikipedia.org/wiki/唐鳳
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            另一個就是 Darcs 了,非常強大的 revision control system,
         
     | 
| 
      
 29 
     | 
    
         
            +
            蠻多人在用的。理所當然,比 svn 先進多了。
         
     | 
| 
      
 30 
     | 
    
         
            +
            svn 其實也差不多是要慢慢式微了...
         
     | 
| 
      
 31 
     | 
    
         
            +
            取而代之的大概會是 SVK, git, 和 Darcs 吧
         
     | 
| 
      
 32 
     | 
    
         
            +
            目前看到是這三個最多,都很先進。不過我對 git 沒好感。
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            另一方面還有非常多,Haskell 正在成長中啊 ~~~
         
     | 
| 
      
 35 
     | 
    
         
            +
            很多知名 library 都有 haskell binding 了,wxWidgets,
         
     | 
| 
      
 36 
     | 
    
         
            +
            OpenGL, 還有一些 web cgi 之類的東西也有。
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            現在切入正是時機啊... XD'
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                assert_equal \
         
     | 
| 
      
 41 
     | 
    
         
            +
            ' <a href="http://friends.roodo.com/forum/viewTopic/10170" title="http://friends.roodo.com/forum/viewTopic/10170">http://friends.roodo.com/forum/viewTopic/10170</a>
         
     | 
| 
      
 42 
     | 
    
         
            +
            用 Haskell 寫成的名軟體?
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            主題發起人 : godfat 真常
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            2008年04月02日 01:24
         
     | 
| 
      
 47 
     | 
    
         
            +
            第一個當然是首推唐鳳寫的 Pugs!
         
     | 
| 
      
 48 
     | 
    
         
            +
            是基於 Perl 6 一直實作困難,所以才決定寫 Pugs 當中繼者。
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            Pugs 無論對 Haskell 社群和 Perl 6 社群都有很大的影響。
         
     | 
| 
      
 51 
     | 
    
         
            +
            唐大師:
         
     | 
| 
      
 52 
     | 
    
         
            +
            <a href="http://zh.wikipedia.org/wiki/" title="http://zh.wikipedia.org/wiki/">http://zh.wikipedia.org/wiki/</a>唐鳳
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            另一個就是 Darcs 了,非常強大的 revision control system,
         
     | 
| 
      
 55 
     | 
    
         
            +
            蠻多人在用的。理所當然,比 svn 先進多了。
         
     | 
| 
      
 56 
     | 
    
         
            +
            svn 其實也差不多是要慢慢式微了...
         
     | 
| 
      
 57 
     | 
    
         
            +
            取而代之的大概會是 SVK, git, 和 Darcs 吧
         
     | 
| 
      
 58 
     | 
    
         
            +
            目前看到是這三個最多,都很先進。不過我對 git 沒好感。
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            另一方面還有非常多,Haskell 正在成長中啊 ~~~
         
     | 
| 
      
 61 
     | 
    
         
            +
            很多知名 library 都有 haskell binding 了,wxWidgets,
         
     | 
| 
      
 62 
     | 
    
         
            +
            OpenGL, 還有一些 web cgi 之類的東西也有。
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            現在切入正是時機啊... XD', s = format_autolink(str)
         
     | 
| 
      
 65 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
              def test_persent
         
     | 
| 
      
 68 
     | 
    
         
            +
                str =
         
     | 
| 
      
 69 
     | 
    
         
            +
            'XDDDD
         
     | 
| 
      
 70 
     | 
    
         
            +
            http://www.amazon.co.jp/%E3%80%8C%E7%84%94~%E3%83%9B%E3%83%A0%E3%83%A9%E3%80%8D~Ar-tonelico2-hymmnos-concert-Side-%E7%B4%85~/dp/B000VKZL30/ref=pd_sbs_sw_img_2 orz'
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                assert_equal \
         
     | 
| 
      
 73 
     | 
    
         
            +
            'XDDDD
         
     | 
| 
      
 74 
     | 
    
         
            +
            <a href="http://www.amazon.co.jp/%E3%80%8C%E7%84%94~%E3%83%9B%E3%83%A0%E3%83%A9%E3%80%8D~Ar-tonelico2-hymmnos-concert-Side-%E7%B4%85~/dp/B000VKZL30/ref=pd_sbs_sw_img_2" title="http://www.amazon.co.jp/%E3%80%8C%E7%84%94~%E3%83%9B%E3%83%A0%E3%83%A9%E3%80%8D~Ar-tonelico2-hymmnos-concert-Side-%E7%B4%85~/dp/B000VKZL30/ref=pd_sbs_sw_img_2">http://www.amazon.co.jp/%E3%80%8C%E7%84%94~%E3%83%9B%E3%83%A0%E3%83%A9%E...</a> orz', s = format_autolink(str)
         
     | 
| 
      
 75 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
              def test_img_src
         
     | 
| 
      
 78 
     | 
    
         
            +
                str = 
         
     | 
| 
      
 79 
     | 
    
         
            +
            'Thirst for Knowledge
         
     | 
| 
      
 80 
     | 
    
         
            +
            <img src="http://friends.roodo.com/images/diary_photos_large/15386/MjMyNjYtdGhpcnN0X2Zvcl9rbm93bGVkZ2U=.jpg" />
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            2007年12月14日
         
     | 
| 
      
 83 
     | 
    
         
            +
            '
         
     | 
| 
      
 84 
     | 
    
         
            +
                assert_equal str, s = format_autolink(str)
         
     | 
| 
      
 85 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
              def test_wikipedia_persent
         
     | 
| 
      
 88 
     | 
    
         
            +
                str = 'http://en.wikipedia.org/wiki/Haskell_%28programming_language%29'
         
     | 
| 
      
 89 
     | 
    
         
            +
                assert_equal \
         
     | 
| 
      
 90 
     | 
    
         
            +
            '<a href="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29" title="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29">http://en.wikipedia.org/wiki/Haskell_%28programming_language%29</a>', s = format_autolink(str)
         
     | 
| 
      
 91 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
              def test_wikipedia_parentheses
         
     | 
| 
      
 94 
     | 
    
         
            +
                str = 'http://en.wikipedia.org/wiki/Haskell_(programming_language)'
         
     | 
| 
      
 95 
     | 
    
         
            +
                assert_equal \
         
     | 
| 
      
 96 
     | 
    
         
            +
            '<a href="http://en.wikipedia.org/wiki/Haskell_" title="http://en.wikipedia.org/wiki/Haskell_" class="XD">http://en.wikipedia.org/wiki/Haskell_</a>(programming_language)', s = format_autolink(str, :class => 'XD')
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str, :class => 'XD')
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
              def test_fixing_html
         
     | 
| 
      
 100 
     | 
    
         
            +
                str = 'test<p>if missing end of p'
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert_equal 'test<p>if missing end of p</p>', format_autolink(str)
         
     | 
| 
      
 102 
     | 
    
         
            +
                str = 'test<p>if missing<a> end of p'
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert_equal 'test<p>if missing<a> end of p</a></p>', format_autolink(str)
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
              def test_www_url
         
     | 
| 
      
 106 
     | 
    
         
            +
                str = 'go to www.google.com to see if you can see'
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_equal 'go to <a href="http://www.google.com" title="http://www.google.com">www.google.com</a> to see if you can see',
         
     | 
| 
      
 108 
     | 
    
         
            +
                  s = format_autolink(str)
         
     | 
| 
      
 109 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
              def test_escape_html_and_correct_html
         
     | 
| 
      
 112 
     | 
    
         
            +
                str = 'test<p>if missing end of p'
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert_equal 'test<p>if missing end of p</p>', format_article(str, :p)
         
     | 
| 
      
 114 
     | 
    
         
            +
                assert_equal 'test<p>if missing end of p</p>', format_article(str, :a)
         
     | 
| 
      
 115 
     | 
    
         
            +
                str = '<pre>asdasd<a>orz'
         
     | 
| 
      
 116 
     | 
    
         
            +
                assert_equal '<pre>asdasd<a>orz</pre>', format_article(str, :a, :pre)
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_equal '<pre>asdasd<a>orz</a></pre>', format_article(str, :a)
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_equal '<pre>asdasd<a>orz</pre>', format_article(str, :pre)
         
     | 
| 
      
 119 
     | 
    
         
            +
                str = 'orz<img>asd'
         
     | 
| 
      
 120 
     | 
    
         
            +
                assert_equal 'orz<img />asd', format_article(str, :img)
         
     | 
| 
      
 121 
     | 
    
         
            +
                assert_equal 'orz<img>asd', format_article(str)
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
      
 123 
     | 
    
         
            +
              def test_trim_url
         
     | 
| 
      
 124 
     | 
    
         
            +
                str = 'test with http://890123456789012345678901234567890123456789012345678901234567890123456789.com'
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                assert_equal 'test with <a href="http://890123456789012345678901234567890123456789012345678901234567890123456789.com" title="http://890123456789012345678901234567890123456789012345678901234567890123456789.com">http://89012345678901234567890123456789012345678901234567890123456789012...</a>', s = format_article(str)
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(str)
         
     | 
| 
      
 128 
     | 
    
         
            +
              end
         
     | 
| 
      
 129 
     | 
    
         
            +
              def test_escape_html
         
     | 
| 
      
 130 
     | 
    
         
            +
                str = 'a lambda expression is λ x. x+1'
         
     | 
| 
      
 131 
     | 
    
         
            +
                assert_equal str, format_article(str)
         
     | 
| 
      
 132 
     | 
    
         
            +
                str = 'as you can see, use <img src="asd"/> to use'
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert_equal str, format_article(str)
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
              def test_html_with_pre_and_newline2br
         
     | 
| 
      
 136 
     | 
    
         
            +
                result = File.read('test/sample/complex_article_result.txt')
         
     | 
| 
      
 137 
     | 
    
         
            +
                input  = File.read('test/sample/complex_article.txt')
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                assert_equal result, format_article(input, :pre)
         
     | 
| 
      
 140 
     | 
    
         
            +
                assert_equal result, format_article(input, SetCommon.new)
         
     | 
| 
      
 141 
     | 
    
         
            +
              end
         
     | 
| 
      
 142 
     | 
    
         
            +
              def test_simple_link
         
     | 
| 
      
 143 
     | 
    
         
            +
                s = '今天是我一歲生日 <a href="http://godfat.org/" title="http://godfat.org/">http://godfat.org/</a> 真的嗎?'
         
     | 
| 
      
 144 
     | 
    
         
            +
                assert_equal s, format_article(s, :a)
         
     | 
| 
      
 145 
     | 
    
         
            +
                assert_equal s, format_autolink_regexp(s)
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
              def test_extra_xd_at_tail
         
     | 
| 
      
 148 
     | 
    
         
            +
                input = '<img style="float: right;" src="http://flolac.iis.sinica.edu.tw/lambdawan/sites/default/files/ruby.png.thumb.jpg"/>
         
     | 
| 
      
 149 
     | 
    
         
            +
            <a href="http://www.ruby-forum.com/topic/169911">JRuby 1.1.5 Released</a>
         
     | 
| 
      
 150 
     | 
    
         
            +
            <a href="http://jruby.codehaus.org/">JRuby</a> 是用 Java 寫成的 Ruby interpreter/compiler.
         
     | 
| 
      
 151 
     | 
    
         
            +
            原本 JRuby 只是普通的 open source project, 後來因為 <a href="http://www.sun.com/">Sun Microsystem</a>,
         
     | 
| 
      
 152 
     | 
    
         
            +
            也就是 Java 的開發公司,看好 JRuby, 於是僱用 JRuby team,
         
     | 
| 
      
 153 
     | 
    
         
            +
            full time 開發 JRuby. 後來 JRuby 在各方面都快速大幅成長,
         
     | 
| 
      
 154 
     | 
    
         
            +
            尤其效能有了不可思議的大幅提昇,可能是 Sun 有一些撇步沒有公開吧。
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            效能大幅提昇之後,JRuby 開發沒有停緩,接下來是非常大量的相容性提昇。
         
     | 
| 
      
 157 
     | 
    
         
            +
            也從原本僅支援 interpret mode 到後來也支援 just in time 與 ahead of time 的
         
     | 
| 
      
 158 
     | 
    
         
            +
            compilation mode. 非常驚人的開發速度。
         
     | 
| 
      
 159 
     | 
    
         
            +
            <zzz><xd>
         
     | 
| 
      
 160 
     | 
    
         
            +
            此外,其中一位開發者,<a href="http://blog.headius.com/">Charles Nutter</a> 也經常參與 <a href="http://www.ruby-forum.com/forum/14">ruby-core</a> 的討論,
         
     | 
| 
      
 161 
     | 
    
         
            +
            對於 Ruby 的開發頗有貢獻。'
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                expected = '<img src="http://flolac.iis.sinica.edu.tw/lambdawan/sites/default/files/ruby.png.thumb.jpg" style="float: right;" /><br /><a href="http://www.ruby-forum.com/topic/169911">JRuby 1.1.5 Released</a><br /><a href="http://jruby.codehaus.org/">JRuby</a> 是用 Java 寫成的 Ruby interpreter/compiler.<br />原本 JRuby 只是普通的 open source project, 後來因為 <a href="http://www.sun.com/">Sun Microsystem</a>,<br />也就是 Java 的開發公司,看好 JRuby, 於是僱用 JRuby team,<br />full time 開發 JRuby. 後來 JRuby 在各方面都快速大幅成長,<br />尤其效能有了不可思議的大幅提昇,可能是 Sun 有一些撇步沒有公開吧。<br /><br />效能大幅提昇之後,JRuby 開發沒有停緩,接下來是非常大量的相容性提昇。<br />也從原本僅支援 interpret mode 到後來也支援 just in time 與 ahead of time 的<br />compilation mode. 非常驚人的開發速度。<br /><zzz><xd><br />此外,其中一位開發者,<a href="http://blog.headius.com/">Charles Nutter</a> 也經常參與 <a href="http://www.ruby-forum.com/forum/14">ruby-core</a> 的討論,<br />對於 Ruby 的開發頗有貢獻。</xd></zzz>'
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                assert_equal expected, format_article(input, SetCommon.new, :zzz)
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
              end
         
     | 
| 
      
 168 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,119 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: friendly_format
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 7 
     | 
    
         
            +
            - "Lin Jen-Shin (a.k.a. godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-12-12 00:00:00 +08:00
         
     | 
| 
      
 13 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: hpricot
         
     | 
| 
      
 17 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 18 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 19 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 0.6.0
         
     | 
| 
      
 24 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: bones
         
     | 
| 
      
 27 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 28 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 29 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 2.1.0
         
     | 
| 
      
 34 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 35 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 36 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 37 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 39 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: 1.3.0
         
     | 
| 
      
 44 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            description: make user input be valid xhtml and format it with gsub("\n", "<br/>") etc. you can partially allow some tags and don't escape them.
         
     | 
| 
      
 46 
     | 
    
         
            +
            email: godfat (XD) godfat.org
         
     | 
| 
      
 47 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 52 
     | 
    
         
            +
            - CHANGES
         
     | 
| 
      
 53 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 54 
     | 
    
         
            +
            - NOTICE
         
     | 
| 
      
 55 
     | 
    
         
            +
            - README
         
     | 
| 
      
 56 
     | 
    
         
            +
            - TODO
         
     | 
| 
      
 57 
     | 
    
         
            +
            - friendly_format.gemspec
         
     | 
| 
      
 58 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            - CHANGES
         
     | 
| 
      
 60 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 61 
     | 
    
         
            +
            - NOTICE
         
     | 
| 
      
 62 
     | 
    
         
            +
            - README
         
     | 
| 
      
 63 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 64 
     | 
    
         
            +
            - TODO
         
     | 
| 
      
 65 
     | 
    
         
            +
            - friendly_format.gemspec
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib/friendly_format.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - lib/friendly_format/set_common.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - lib/friendly_format/set_strict.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
            - lib/friendly_format/version.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - tasks/ann.rake
         
     | 
| 
      
 71 
     | 
    
         
            +
            - tasks/bones.rake
         
     | 
| 
      
 72 
     | 
    
         
            +
            - tasks/gem.rake
         
     | 
| 
      
 73 
     | 
    
         
            +
            - tasks/git.rake
         
     | 
| 
      
 74 
     | 
    
         
            +
            - tasks/manifest.rake
         
     | 
| 
      
 75 
     | 
    
         
            +
            - tasks/notes.rake
         
     | 
| 
      
 76 
     | 
    
         
            +
            - tasks/post_load.rake
         
     | 
| 
      
 77 
     | 
    
         
            +
            - tasks/rdoc.rake
         
     | 
| 
      
 78 
     | 
    
         
            +
            - tasks/rubyforge.rake
         
     | 
| 
      
 79 
     | 
    
         
            +
            - tasks/setup.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - tasks/spec.rake
         
     | 
| 
      
 81 
     | 
    
         
            +
            - tasks/svn.rake
         
     | 
| 
      
 82 
     | 
    
         
            +
            - tasks/test.rake
         
     | 
| 
      
 83 
     | 
    
         
            +
            - test/sample/complex_article.txt
         
     | 
| 
      
 84 
     | 
    
         
            +
            - test/sample/complex_article_result.txt
         
     | 
| 
      
 85 
     | 
    
         
            +
            - test/test_friendly_format.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 87 
     | 
    
         
            +
            homepage: http://github.com/godfat/friendly_format
         
     | 
| 
      
 88 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 89 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 90 
     | 
    
         
            +
            - --diagram
         
     | 
| 
      
 91 
     | 
    
         
            +
            - --charset=utf-8
         
     | 
| 
      
 92 
     | 
    
         
            +
            - --inline-source
         
     | 
| 
      
 93 
     | 
    
         
            +
            - --line-numbers
         
     | 
| 
      
 94 
     | 
    
         
            +
            - --promiscuous
         
     | 
| 
      
 95 
     | 
    
         
            +
            - --main
         
     | 
| 
      
 96 
     | 
    
         
            +
            - README
         
     | 
| 
      
 97 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 98 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 99 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 100 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 101 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 102 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 103 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 104 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 105 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 106 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 107 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 108 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 109 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 110 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 111 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            rubyforge_project: ludy
         
     | 
| 
      
 114 
     | 
    
         
            +
            rubygems_version: 1.3.1
         
     | 
| 
      
 115 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 116 
     | 
    
         
            +
            specification_version: 2
         
     | 
| 
      
 117 
     | 
    
         
            +
            summary: make user input be valid xhtml and format it with gsub("\n", "<br/>") etc. you can partially allow some tags and don't escape them.
         
     | 
| 
      
 118 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 119 
     | 
    
         
            +
            - test/test_friendly_format.rb
         
     |