flextures 3.1.3 → 4.0.0
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.
- checksums.yaml +4 -4
 - data/Gemfile +6 -1
 - data/Gemfile.lock +17 -13
 - data/README.ja.md +15 -13
 - data/README.md +9 -8
 - data/Rakefile +5 -0
 - data/flextures.gemspec +3 -1
 - data/lib/flextures.rb +0 -3
 - data/lib/flextures/flextures.rake +1 -42
 - data/lib/flextures/flextures.rb +4 -7
 - data/lib/flextures/flextures_base_config.rb +17 -28
 - data/lib/flextures/flextures_command.rb +3 -5
 - data/lib/flextures/flextures_dumper.rb +27 -29
 - data/lib/flextures/flextures_extension_modules.rb +1 -14
 - data/lib/flextures/flextures_factory.rb +3 -5
 - data/lib/flextures/flextures_loader.rb +49 -51
 - data/lib/flextures/flextures_railtie.rb +0 -2
 - data/lib/flextures/rspec_flextures_support.rb +125 -71
 - data/lib/flextures/version.rb +1 -1
 - data/test/models/flextures_test.rb +8 -0
 - data/test/test_helper.rb +4 -3
 - data/test/unit/flextures_args_test.rb +178 -0
 - data/test/unit/flextures_dumper_test.rb +232 -0
 - data/test/unit/{test_flextures_extention_modules.rb → flextures_extention_modules_test.rb} +18 -13
 - data/test/unit/flextures_hooks_test.rb +111 -0
 - data/test/unit/flextures_loader_test.rb +313 -0
 - metadata +9 -18
 - data/lib/flextures/testunit_flextures_support.rb +0 -43
 - data/test/unit/test_flextures.rb +0 -8
 - data/test/unit/test_flextures_args.rb +0 -147
 - data/test/unit/test_flextures_dumper.rb +0 -187
 - data/test/unit/test_flextures_hooks.rb +0 -90
 - data/test/unit/test_flextures_loader.rb +0 -271
 - data/test/unit/test_simple.rb +0 -8
 
    
        data/lib/flextures/version.rb
    CHANGED
    
    
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -1,12 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'stringio'
         
     | 
| 
       4 
     | 
    
         
            -
            require ' 
     | 
| 
      
 4 
     | 
    
         
            +
            require 'minitest'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "minitest/autorun"
         
     | 
| 
       5 
6 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'drb/drb'
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       8 
9 
     | 
    
         
             
            require File.dirname(__FILE__) + '/../lib/flextures'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
            ## under 'lib' directories your library write below
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
            require "flextures"
         
     | 
| 
         @@ -0,0 +1,178 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.push( File.join(File.dirname(File.expand_path(__FILE__)), '../') )
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Flextures::ARGS do
         
     | 
| 
      
 6 
     | 
    
         
            +
              describe "if set TABLE='table_name' option " do
         
     | 
| 
      
 7 
     | 
    
         
            +
                before do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  ENV["TABLE"] = "users"
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @format = Flextures::ARGS.parse
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                it "return table_name" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  assert_equal "users", @format.first[:table]
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                it "filename is same table_name" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  assert_equal "users", @format.first[:file]
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                after do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  ENV.delete("TABLE")
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              describe "if set T=table_name option " do
         
     | 
| 
      
 26 
     | 
    
         
            +
                before do
         
     | 
| 
      
 27 
     | 
    
         
            +
                  ENV["T"] = "s_user"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @format = Flextures::ARGS.parse
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                it "retrun table_name" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  assert_equal "s_user", @format.first[:table]
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                it "filename is same table_name" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  assert_equal "s_user", @format.first[:file]
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                after do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              describe " DIR=option " do
         
     | 
| 
      
 45 
     | 
    
         
            +
                before do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ENV["T"] = "users"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  ENV["DIR"] = "test/fixtures/"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @format = Flextures::ARGS.parse
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                it "directory name is exist" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  assert_equal "test/fixtures/", @format.first[:dir]
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                it "set table name" do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  assert_equal "users", @format.first[:table]
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                it "file name is equal table name" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  assert_equal "users", @format.first[:file]
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                after do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 65 
     | 
    
         
            +
                  ENV.delete("DIR")
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              describe " D=option " do
         
     | 
| 
      
 70 
     | 
    
         
            +
                before do
         
     | 
| 
      
 71 
     | 
    
         
            +
                  ENV["T"] = "users"
         
     | 
| 
      
 72 
     | 
    
         
            +
                  ENV["D"] = "test/fixtures/"
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @format = Flextures::ARGS.parse
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                it "directory name" do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  assert_equal "test/fixtures/", @format.first[:dir]
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                it "table name is exist" do
         
     | 
| 
      
 81 
     | 
    
         
            +
                  assert_equal "users", @format.first[:table]
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                it "file name is equal table name" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                  assert_equal "users", @format.first[:file]
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                after do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 90 
     | 
    
         
            +
                  ENV.delete("D")
         
     | 
| 
      
 91 
     | 
    
         
            +
                end
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              describe " FIXTURES=option " do
         
     | 
| 
      
 95 
     | 
    
         
            +
                before do
         
     | 
| 
      
 96 
     | 
    
         
            +
                  ENV["T"] = "users"
         
     | 
| 
      
 97 
     | 
    
         
            +
                  ENV["FIXTURES"] = "user_another"
         
     | 
| 
      
 98 
     | 
    
         
            +
                  @format = Flextures::ARGS.parse
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                it "table name is exist" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  assert_equal "users", @format.first[:table]
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                it " file name is changed by option's name " do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  assert_equal "user_another", @format.first[:file]
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                after do
         
     | 
| 
      
 110 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 111 
     | 
    
         
            +
                  ENV.delete("FIXTURES")
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
              end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
              describe " MINUS option " do
         
     | 
| 
      
 116 
     | 
    
         
            +
                describe "only one columns" do
         
     | 
| 
      
 117 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 118 
     | 
    
         
            +
                    ENV["T"]="users"
         
     | 
| 
      
 119 
     | 
    
         
            +
                    ENV["MINUS"]="id"
         
     | 
| 
      
 120 
     | 
    
         
            +
                    @format = Flextures::ARGS.parse
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                  it " option contain 'minus' parameters" do
         
     | 
| 
      
 124 
     | 
    
         
            +
                    assert_equal ["id"], @format.first[:minus]
         
     | 
| 
      
 125 
     | 
    
         
            +
                  end
         
     | 
| 
      
 126 
     | 
    
         
            +
                end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                describe "many columns" do
         
     | 
| 
      
 129 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 130 
     | 
    
         
            +
                    ENV["T"]="users"
         
     | 
| 
      
 131 
     | 
    
         
            +
                    ENV["MINUS"]="id,created_at,updated_at"
         
     | 
| 
      
 132 
     | 
    
         
            +
                    @format = Flextures::ARGS.parse
         
     | 
| 
      
 133 
     | 
    
         
            +
                  end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                  it " option contain 'minus' parameters" do
         
     | 
| 
      
 136 
     | 
    
         
            +
                    assert_equal ["id","created_at","updated_at"], @format.first[:minus]
         
     | 
| 
      
 137 
     | 
    
         
            +
                  end
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                after do
         
     | 
| 
      
 141 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 142 
     | 
    
         
            +
                  ENV.delete("MINUS")
         
     | 
| 
      
 143 
     | 
    
         
            +
                end
         
     | 
| 
      
 144 
     | 
    
         
            +
              end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              describe " PLUS options " do
         
     | 
| 
      
 147 
     | 
    
         
            +
                before do
         
     | 
| 
      
 148 
     | 
    
         
            +
                  ENV["T"]="users"
         
     | 
| 
      
 149 
     | 
    
         
            +
                end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                describe "only one columns" do
         
     | 
| 
      
 152 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 153 
     | 
    
         
            +
                    ENV["PLUS"]="hoge"
         
     | 
| 
      
 154 
     | 
    
         
            +
                    @format = Flextures::ARGS.parse
         
     | 
| 
      
 155 
     | 
    
         
            +
                  end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                  it " option contain 'plus' parameters" do
         
     | 
| 
      
 158 
     | 
    
         
            +
                    assert_equal ["hoge"], @format.first[:plus]
         
     | 
| 
      
 159 
     | 
    
         
            +
                  end
         
     | 
| 
      
 160 
     | 
    
         
            +
                end
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                describe "many columns" do
         
     | 
| 
      
 163 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 164 
     | 
    
         
            +
                    ENV["PLUS"]="hoge,mage"
         
     | 
| 
      
 165 
     | 
    
         
            +
                    @format = Flextures::ARGS.parse
         
     | 
| 
      
 166 
     | 
    
         
            +
                  end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                  it " option contain 'plus' parameters" do
         
     | 
| 
      
 169 
     | 
    
         
            +
                    assert_equal ["hoge","mage"], @format.first[:plus]
         
     | 
| 
      
 170 
     | 
    
         
            +
                  end
         
     | 
| 
      
 171 
     | 
    
         
            +
                end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                after do
         
     | 
| 
      
 174 
     | 
    
         
            +
                  ENV.delete("T")
         
     | 
| 
      
 175 
     | 
    
         
            +
                  ENV.delete("PLUS")
         
     | 
| 
      
 176 
     | 
    
         
            +
                end
         
     | 
| 
      
 177 
     | 
    
         
            +
              end
         
     | 
| 
      
 178 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,232 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.push( File.join(File.dirname(File.expand_path(__FILE__)), '../') )
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe Flextures::Dumper do
         
     | 
| 
      
 5 
     | 
    
         
            +
              describe "TRANSLATE function rules" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                describe :binary do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  describe :yml do
         
     | 
| 
      
 8 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @trans = Flextures::Dumper::TRANSLATER[:binary]
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    it "nil translate 'null' string" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                      assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  describe :binary do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 19 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 20 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:binary]
         
     | 
| 
      
 21 
     | 
    
         
            +
                      end
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  describe :boolean do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    describe :yml do
         
     | 
| 
      
 27 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 28 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:boolean]
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                      it "nil translate 'null' string" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 33 
     | 
    
         
            +
                      end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                      it "0 translate false" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                        assert_equal false,  @trans.call( 0, :yml )
         
     | 
| 
      
 37 
     | 
    
         
            +
                      end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                      it "natural number translat true" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                        assert_equal true,   @trans.call( 1, :yml )
         
     | 
| 
      
 41 
     | 
    
         
            +
                      end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                      it " empty string translate dalse" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                        assert_equal false,  @trans.call( "", :yml )
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      it "string translate true" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                        assert_equal true,  @trans.call( "Hello", :yml )
         
     | 
| 
      
 49 
     | 
    
         
            +
                      end
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 53 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 54 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:boolean]
         
     | 
| 
      
 55 
     | 
    
         
            +
                      end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  describe :date do
         
     | 
| 
      
 60 
     | 
    
         
            +
                    describe :yml do
         
     | 
| 
      
 61 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 62 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:date]
         
     | 
| 
      
 63 
     | 
    
         
            +
                      end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                      it "nil translate 'null' string" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 67 
     | 
    
         
            +
                      end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                      it "empty string translate 'null' string" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                        assert_equal "null", @trans.call( "", :yml )
         
     | 
| 
      
 71 
     | 
    
         
            +
                      end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                      it "false translate 'null' string" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                        assert_equal "null", @trans.call( false, :yml )
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 79 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 80 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:date]
         
     | 
| 
      
 81 
     | 
    
         
            +
                      end
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                  describe :datetime do
         
     | 
| 
      
 86 
     | 
    
         
            +
                    describe :yml do
         
     | 
| 
      
 87 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 88 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:datetime]
         
     | 
| 
      
 89 
     | 
    
         
            +
                      end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                      it "nil translate 'null' string" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 93 
     | 
    
         
            +
                      end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                      it "empty string translate 'null' string" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                        assert_equal "null", @trans.call( "", :yml )
         
     | 
| 
      
 97 
     | 
    
         
            +
                      end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                      it "false translate 'null' string" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                        assert_equal "null", @trans.call( false, :yml )
         
     | 
| 
      
 101 
     | 
    
         
            +
                      end
         
     | 
| 
      
 102 
     | 
    
         
            +
                    end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 105 
     | 
    
         
            +
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  describe :float do
         
     | 
| 
      
 109 
     | 
    
         
            +
                    describe :yml do
         
     | 
| 
      
 110 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 111 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:float]
         
     | 
| 
      
 112 
     | 
    
         
            +
                      end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                      it "integral number don't translate" do
         
     | 
| 
      
 115 
     | 
    
         
            +
                        assert_equal 10, @trans.call( 10, :yml )
         
     | 
| 
      
 116 
     | 
    
         
            +
                      end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                      it "floating number don't translate" do
         
     | 
| 
      
 119 
     | 
    
         
            +
                        assert_equal 1.5, @trans.call( 1.5, :yml )
         
     | 
| 
      
 120 
     | 
    
         
            +
                      end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                      it "nil translate 'null' string" do
         
     | 
| 
      
 123 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 124 
     | 
    
         
            +
                      end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                      it "0 don't translate" do
         
     | 
| 
      
 127 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 128 
     | 
    
         
            +
                      end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                      it "false don't translate" do
         
     | 
| 
      
 131 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 132 
     | 
    
         
            +
                      end
         
     | 
| 
      
 133 
     | 
    
         
            +
                    end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 136 
     | 
    
         
            +
                    end
         
     | 
| 
      
 137 
     | 
    
         
            +
                  end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  describe :integer do
         
     | 
| 
      
 140 
     | 
    
         
            +
                    describe :yml do
         
     | 
| 
      
 141 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 142 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:integer]
         
     | 
| 
      
 143 
     | 
    
         
            +
                      end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                      it "integral number don't translate" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                        assert_equal 10, @trans.call( 10, :yml )
         
     | 
| 
      
 147 
     | 
    
         
            +
                      end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                      it "float number is floored" do
         
     | 
| 
      
 150 
     | 
    
         
            +
                        assert_equal 1, @trans.call( 1.5, :yml )
         
     | 
| 
      
 151 
     | 
    
         
            +
                      end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                      it "nil translate 'null' string" do
         
     | 
| 
      
 154 
     | 
    
         
            +
                        assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 155 
     | 
    
         
            +
                      end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                      it "0 don't translate" do
         
     | 
| 
      
 158 
     | 
    
         
            +
                        assert_equal 0, @trans.call( 0, :yml )
         
     | 
| 
      
 159 
     | 
    
         
            +
                      end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                      it "false translate 0" do
         
     | 
| 
      
 162 
     | 
    
         
            +
                        assert_equal 0, @trans.call( false, :yml )
         
     | 
| 
      
 163 
     | 
    
         
            +
                      end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                      it "true translate 1" do
         
     | 
| 
      
 166 
     | 
    
         
            +
                        assert_equal 1, @trans.call( true, :yml )
         
     | 
| 
      
 167 
     | 
    
         
            +
                      end
         
     | 
| 
      
 168 
     | 
    
         
            +
                    end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                    describe :csv do
         
     | 
| 
      
 171 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 172 
     | 
    
         
            +
                        @trans = Flextures::Dumper::TRANSLATER[:integer]
         
     | 
| 
      
 173 
     | 
    
         
            +
                      end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                      it "integral number don't translate" do
         
     | 
| 
      
 176 
     | 
    
         
            +
                        assert_equal 10, @trans.call( 10, :csv )
         
     | 
| 
      
 177 
     | 
    
         
            +
                      end
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                      it 'nil translate empty string' do
         
     | 
| 
      
 180 
     | 
    
         
            +
                        assert_equal "", @trans.call( nil, :csv )
         
     | 
| 
      
 181 
     | 
    
         
            +
                      end
         
     | 
| 
      
 182 
     | 
    
         
            +
                    end
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                    describe :string do
         
     | 
| 
      
 185 
     | 
    
         
            +
                      describe :yml do
         
     | 
| 
      
 186 
     | 
    
         
            +
                        before do
         
     | 
| 
      
 187 
     | 
    
         
            +
                          @trans = Flextures::Dumper::TRANSLATER[:string]
         
     | 
| 
      
 188 
     | 
    
         
            +
                        end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                        it "nil translate 'null' string" do
         
     | 
| 
      
 191 
     | 
    
         
            +
                          assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 192 
     | 
    
         
            +
                        end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                        it "empty string don't translate" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                          assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 196 
     | 
    
         
            +
                        end
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                        it "false don't translate" do
         
     | 
| 
      
 199 
     | 
    
         
            +
                          assert_equal false, @trans.call( false, :yml )
         
     | 
| 
      
 200 
     | 
    
         
            +
                        end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                        it "true don't translate" do
         
     | 
| 
      
 203 
     | 
    
         
            +
                          assert_equal true, @trans.call( true, :yml )
         
     | 
| 
      
 204 
     | 
    
         
            +
                        end
         
     | 
| 
      
 205 
     | 
    
         
            +
                      end
         
     | 
| 
      
 206 
     | 
    
         
            +
                    end
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                    describe :null do
         
     | 
| 
      
 209 
     | 
    
         
            +
                      describe :yml do
         
     | 
| 
      
 210 
     | 
    
         
            +
                        before do
         
     | 
| 
      
 211 
     | 
    
         
            +
                          @trans = Flextures::Dumper::TRANSLATER[:null]
         
     | 
| 
      
 212 
     | 
    
         
            +
                        end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                        it "values is 'null' string" do
         
     | 
| 
      
 215 
     | 
    
         
            +
                          assert_equal "null", @trans.call( nil, :yml )
         
     | 
| 
      
 216 
     | 
    
         
            +
                        end
         
     | 
| 
      
 217 
     | 
    
         
            +
                      end
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
                      describe :csv do
         
     | 
| 
      
 220 
     | 
    
         
            +
                        before do
         
     | 
| 
      
 221 
     | 
    
         
            +
                          @trans = Flextures::Dumper::TRANSLATER[:null]
         
     | 
| 
      
 222 
     | 
    
         
            +
                        end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
                        it "values is empty string" do
         
     | 
| 
      
 225 
     | 
    
         
            +
                          assert_equal "", @trans.call( nil, :csv )
         
     | 
| 
      
 226 
     | 
    
         
            +
                        end
         
     | 
| 
      
 227 
     | 
    
         
            +
                      end
         
     | 
| 
      
 228 
     | 
    
         
            +
                    end
         
     | 
| 
      
 229 
     | 
    
         
            +
                  end
         
     | 
| 
      
 230 
     | 
    
         
            +
                end
         
     | 
| 
      
 231 
     | 
    
         
            +
              end
         
     | 
| 
      
 232 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,37 +1,42 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            $:.push( File.join(File.dirname(File.expand_path(__FILE__)), '../') )
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
            describe :Extention do
         
     | 
| 
      
 5 
     | 
    
         
            +
              describe "Array#to_hash" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                describe "when column size is equal data size" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  before do
         
     | 
| 
       7 
8 
     | 
    
         
             
                    @keys   = %W[id name hp]
         
     | 
| 
       8 
9 
     | 
    
         
             
                    @values = %W[1 hoge 100]
         
     | 
| 
       9 
10 
     | 
    
         
             
                    @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  it "return hash" do
         
     | 
| 
       12 
14 
     | 
    
         
             
                    assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=>"100" }
         
     | 
| 
       13 
15 
     | 
    
         
             
                  end
         
     | 
| 
       14 
16 
     | 
    
         
             
                end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                describe "when column size is bigger than data size" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  before do
         
     | 
| 
       17 
20 
     | 
    
         
             
                    @keys   = %W[id name hp]
         
     | 
| 
       18 
21 
     | 
    
         
             
                    @values = %W[1 hoge]
         
     | 
| 
       19 
22 
     | 
    
         
             
                    @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
         
     | 
| 
       20 
23 
     | 
    
         
             
                  end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  it "return hash, overflow key is filled 'nil'" do
         
     | 
| 
       22 
26 
     | 
    
         
             
                    assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=> nil }
         
     | 
| 
       23 
27 
     | 
    
         
             
                  end
         
     | 
| 
       24 
28 
     | 
    
         
             
                end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                describe "when column size is smaller than data size" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  before do
         
     | 
| 
       27 
32 
     | 
    
         
             
                    @keys   = %W[id name]
         
     | 
| 
       28 
33 
     | 
    
         
             
                    @values = %W[1 hoge 200]
         
     | 
| 
       29 
34 
     | 
    
         
             
                    @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
         
     | 
| 
       30 
35 
     | 
    
         
             
                  end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  it "return hash, overflow value is cut offed" do
         
     | 
| 
       32 
38 
     | 
    
         
             
                    assert_equal @h, { "id"=>"1", "name"=>"hoge" }
         
     | 
| 
       33 
39 
     | 
    
         
             
                  end
         
     | 
| 
       34 
40 
     | 
    
         
             
                end
         
     | 
| 
       35 
41 
     | 
    
         
             
              end
         
     | 
| 
       36 
42 
     | 
    
         
             
            end
         
     | 
| 
       37 
     | 
    
         
            -
             
     |