flextures 3.1.1 → 3.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e1475921d9e2497f5f3e27ab528d2e94a6fc973
4
- data.tar.gz: 53a38f7501809ea48dc837e6a494f9ea1887299f
3
+ metadata.gz: 4a329b8898f61de2db35609a4550b01ff71d3161
4
+ data.tar.gz: 4a4990b17c74688bc183d88e87fea0c0d68c9f0c
5
5
  SHA512:
6
- metadata.gz: ae5da565b171cdfeca142e93f1c43783ec8f836abbf0a6b60be0cce3c96d412e708a8463b96691e9c35ef5b79cb24dd3b688a03d50683b956a9c50b180e07f98
7
- data.tar.gz: d400b6c54c592af58dd3a7962bee1c7519006474f5cc515180ba4d1d9eff7bcd977a38c1c494f768b379a060b1ba860c110abe8f519a605f62d869c6b6729ff1
6
+ metadata.gz: 56bef866d44651bfe71ae22c7d1d0f3adfc32663043a49435956bafdeb3488e3913d0a2b6eda6a8cf9e3cd3b71fc5a9ee3ecc5af3cd58cfcb64dd3a7bfd081c0
7
+ data.tar.gz: d21f5bd3ae482ff707a9681be5d6c3ff3020fc126db26c486a715fc37a864f9bc0815b53233c4a0ab40758c2e3abdbbba561d2cba184773d3e6ff8394dcb0fd5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flextures (3.1.1)
4
+ flextures (3.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -36,7 +36,7 @@ module Flextures
36
36
  },
37
37
  boolean:->(d){
38
38
  return d if d.nil?
39
- !(0==d || ""==d || !d)
39
+ !("false"==d || "0"==d || ""==d || 0==d || !d)
40
40
  },
41
41
  date:->(d){
42
42
  return d if d.nil?
@@ -1,3 +1,3 @@
1
1
  module Flextures
2
- VERSION="3.1.1"
2
+ VERSION="3.1.2"
3
3
  end
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
-
3
- class FlexturesTest < Test::Unit::TestCase
4
- should "data type test" do
5
- assert_equal Module, Flextures.class
6
- end
7
- end
8
-
1
+ # encoding: utf-8
2
+
3
+ class FlexturesTest < Test::Unit::TestCase
4
+ should "data type test" do
5
+ assert_equal Module, Flextures.class
6
+ end
7
+ end
8
+
@@ -1,147 +1,147 @@
1
- # encoding: utf-8
2
-
3
- class FlexturesArgsTest < Test::Unit::TestCase
4
- context Flextures::ARGS do
5
- context "if set TABLE='table_name' option " do
6
- setup do
7
- ENV["TABLE"] = "users"
8
- @format = Flextures::ARGS.parse
9
- end
10
- should "return table_name" do
11
- assert_equal "users", @format.first[:table]
12
- end
13
- should "filename is same table_name" do
14
- assert_equal "users", @format.first[:file]
15
- end
16
- teardown do
17
- ENV.delete("TABLE")
18
- end
19
- end
20
- context "if set T=table_name option " do
21
- setup do
22
- ENV["T"] = "s_user"
23
- @format = Flextures::ARGS.parse
24
- end
25
- should "retrun table_name" do
26
- assert_equal "s_user", @format.first[:table]
27
- end
28
- should "filename is same table_name" do
29
- assert_equal "s_user", @format.first[:file]
30
- end
31
- teardown do
32
- ENV.delete("T")
33
- end
34
- end
35
- context " DIR=option " do
36
- setup do
37
- ENV["T"] = "users"
38
- ENV["DIR"] = "test/fixtures/"
39
- @format = Flextures::ARGS.parse
40
- end
41
- should "directory name is exist" do
42
- assert_equal "test/fixtures/", @format.first[:dir]
43
- end
44
- should "set table name" do
45
- assert_equal "users", @format.first[:table]
46
- end
47
- should "file name is equal table name" do
48
- assert_equal "users", @format.first[:file]
49
- end
50
- teardown do
51
- ENV.delete("T")
52
- ENV.delete("DIR")
53
- end
54
- end
55
- context " D=option " do
56
- setup do
57
- ENV["T"] = "users"
58
- ENV["D"] = "test/fixtures/"
59
- @format = Flextures::ARGS.parse
60
- end
61
- should "directory name" do
62
- assert_equal "test/fixtures/", @format.first[:dir]
63
- end
64
- should "table name is exist" do
65
- assert_equal "users", @format.first[:table]
66
- end
67
- should "file name is equal table name" do
68
- assert_equal "users", @format.first[:file]
69
- end
70
- teardown do
71
- ENV.delete("T")
72
- ENV.delete("D")
73
- end
74
- end
75
- context " FIXTURES=option " do
76
- setup do
77
- ENV["T"] = "users"
78
- ENV["FIXTURES"] = "user_another"
79
- @format = Flextures::ARGS.parse
80
- end
81
- should "table name is exist" do
82
- assert_equal "users", @format.first[:table]
83
- end
84
- should " file name is changed by option's name " do
85
- assert_equal "user_another", @format.first[:file]
86
- end
87
- teardown do
88
- ENV.delete("T")
89
- ENV.delete("FIXTURES")
90
- end
91
- end
92
- context " MINUS option " do
93
- context "only one columns" do
94
- setup do
95
- ENV["T"]="users"
96
- ENV["MINUS"]="id"
97
- @format = Flextures::ARGS.parse
98
- end
99
- should " option contain 'minus' parameters" do
100
- assert_equal ["id"], @format.first[:minus]
101
- end
102
- end
103
- context "many columns" do
104
- setup do
105
- ENV["T"]="users"
106
- ENV["MINUS"]="id,created_at,updated_at"
107
- @format = Flextures::ARGS.parse
108
- end
109
- should " option contain 'minus' parameters" do
110
- assert_equal ["id","created_at","updated_at"], @format.first[:minus]
111
- end
112
- end
113
- teardown do
114
- ENV.delete("T")
115
- ENV.delete("MINUS")
116
- end
117
- end
118
- context " PLUS options " do
119
- setup do
120
- ENV["T"]="users"
121
- end
122
- context "only one columns" do
123
- setup do
124
- ENV["PLUS"]="hoge"
125
- @format = Flextures::ARGS.parse
126
- end
127
- should " option contain 'plus' parameters" do
128
- assert_equal ["hoge"], @format.first[:plus]
129
- end
130
- end
131
- context "many columns" do
132
- setup do
133
- ENV["PLUS"]="hoge,mage"
134
- @format = Flextures::ARGS.parse
135
- end
136
- should " option contain 'plus' parameters" do
137
- assert_equal ["hoge","mage"], @format.first[:plus]
138
- end
139
- end
140
- teardown do
141
- ENV.delete("T")
142
- ENV.delete("MINUS")
143
- end
144
- end
145
- end
146
- end
147
-
1
+ # encoding: utf-8
2
+
3
+ class FlexturesArgsTest < Test::Unit::TestCase
4
+ context Flextures::ARGS do
5
+ context "if set TABLE='table_name' option " do
6
+ setup do
7
+ ENV["TABLE"] = "users"
8
+ @format = Flextures::ARGS.parse
9
+ end
10
+ should "return table_name" do
11
+ assert_equal "users", @format.first[:table]
12
+ end
13
+ should "filename is same table_name" do
14
+ assert_equal "users", @format.first[:file]
15
+ end
16
+ teardown do
17
+ ENV.delete("TABLE")
18
+ end
19
+ end
20
+ context "if set T=table_name option " do
21
+ setup do
22
+ ENV["T"] = "s_user"
23
+ @format = Flextures::ARGS.parse
24
+ end
25
+ should "retrun table_name" do
26
+ assert_equal "s_user", @format.first[:table]
27
+ end
28
+ should "filename is same table_name" do
29
+ assert_equal "s_user", @format.first[:file]
30
+ end
31
+ teardown do
32
+ ENV.delete("T")
33
+ end
34
+ end
35
+ context " DIR=option " do
36
+ setup do
37
+ ENV["T"] = "users"
38
+ ENV["DIR"] = "test/fixtures/"
39
+ @format = Flextures::ARGS.parse
40
+ end
41
+ should "directory name is exist" do
42
+ assert_equal "test/fixtures/", @format.first[:dir]
43
+ end
44
+ should "set table name" do
45
+ assert_equal "users", @format.first[:table]
46
+ end
47
+ should "file name is equal table name" do
48
+ assert_equal "users", @format.first[:file]
49
+ end
50
+ teardown do
51
+ ENV.delete("T")
52
+ ENV.delete("DIR")
53
+ end
54
+ end
55
+ context " D=option " do
56
+ setup do
57
+ ENV["T"] = "users"
58
+ ENV["D"] = "test/fixtures/"
59
+ @format = Flextures::ARGS.parse
60
+ end
61
+ should "directory name" do
62
+ assert_equal "test/fixtures/", @format.first[:dir]
63
+ end
64
+ should "table name is exist" do
65
+ assert_equal "users", @format.first[:table]
66
+ end
67
+ should "file name is equal table name" do
68
+ assert_equal "users", @format.first[:file]
69
+ end
70
+ teardown do
71
+ ENV.delete("T")
72
+ ENV.delete("D")
73
+ end
74
+ end
75
+ context " FIXTURES=option " do
76
+ setup do
77
+ ENV["T"] = "users"
78
+ ENV["FIXTURES"] = "user_another"
79
+ @format = Flextures::ARGS.parse
80
+ end
81
+ should "table name is exist" do
82
+ assert_equal "users", @format.first[:table]
83
+ end
84
+ should " file name is changed by option's name " do
85
+ assert_equal "user_another", @format.first[:file]
86
+ end
87
+ teardown do
88
+ ENV.delete("T")
89
+ ENV.delete("FIXTURES")
90
+ end
91
+ end
92
+ context " MINUS option " do
93
+ context "only one columns" do
94
+ setup do
95
+ ENV["T"]="users"
96
+ ENV["MINUS"]="id"
97
+ @format = Flextures::ARGS.parse
98
+ end
99
+ should " option contain 'minus' parameters" do
100
+ assert_equal ["id"], @format.first[:minus]
101
+ end
102
+ end
103
+ context "many columns" do
104
+ setup do
105
+ ENV["T"]="users"
106
+ ENV["MINUS"]="id,created_at,updated_at"
107
+ @format = Flextures::ARGS.parse
108
+ end
109
+ should " option contain 'minus' parameters" do
110
+ assert_equal ["id","created_at","updated_at"], @format.first[:minus]
111
+ end
112
+ end
113
+ teardown do
114
+ ENV.delete("T")
115
+ ENV.delete("MINUS")
116
+ end
117
+ end
118
+ context " PLUS options " do
119
+ setup do
120
+ ENV["T"]="users"
121
+ end
122
+ context "only one columns" do
123
+ setup do
124
+ ENV["PLUS"]="hoge"
125
+ @format = Flextures::ARGS.parse
126
+ end
127
+ should " option contain 'plus' parameters" do
128
+ assert_equal ["hoge"], @format.first[:plus]
129
+ end
130
+ end
131
+ context "many columns" do
132
+ setup do
133
+ ENV["PLUS"]="hoge,mage"
134
+ @format = Flextures::ARGS.parse
135
+ end
136
+ should " option contain 'plus' parameters" do
137
+ assert_equal ["hoge","mage"], @format.first[:plus]
138
+ end
139
+ end
140
+ teardown do
141
+ ENV.delete("T")
142
+ ENV.delete("MINUS")
143
+ end
144
+ end
145
+ end
146
+ end
147
+
@@ -1,254 +1,266 @@
1
- # encoding: utf-8
2
-
3
- class FlexturesLoaderTest < Test::Unit::TestCase
4
- context Flextures::Loader do
5
- context "TRANSLATER" do
6
- context :binary do
7
- should "'nil' value not changed" do
8
- assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
9
- end
10
- end
11
- context :boolean do
12
- should "'nil' value not changed" do
13
- assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
14
- end
15
- should "'true' value not changed" do
16
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
17
- end
18
- should "'false' value not changed" do
19
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
20
- end
21
- should "'0' is change to 'false'" do
22
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
23
- end
24
- should "'1' is change to 'true'" do
25
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
26
- end
27
- should "'-1' is change to 'true'" do
28
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
29
- end
30
- should "'string data' is change to 'true'" do
31
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
32
- end
33
- should "'empty string' is change to 'true'" do
34
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
35
- end
36
- end
37
- context :date do
38
- should "正常値の文字列" do
39
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
40
- end
41
- should "Timeオブジェクト" do
42
- now = Time.now
43
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
44
- end
45
- should "DateTimeオブジェクト" do
46
- now = DateTime.now
47
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
48
- end
49
- should "日付っぽい数字" do
50
- now = "20111121"
51
- assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
52
- end
53
- should "nil" do
54
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
55
- end
56
- should "空文字" do
57
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
58
- end
59
- end
60
- context :datetime do
61
- should "正常値の文字列" do
62
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
63
- end
64
- should "Timeオブジェクト" do
65
- now = Time.now
66
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
67
- end
68
- should "DateTimeオブジェクト" do
69
- now = DateTime.now
70
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
71
- end
72
- should "日付っぽい数字" do
73
- now = "20111121"
74
- assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
75
- end
76
- should "nil" do
77
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
78
- end
79
- should "空文字" do
80
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
81
- end
82
- end
83
- context :decimal do
84
- should "null" do
85
- assert_equal nil, Flextures::Loader::TRANSLATER[:decimal].call(nil)
86
- end
87
- end
88
- context :float do
89
- should "null" do
90
- assert_equal nil, Flextures::Loader::TRANSLATER[:float].call(nil)
91
- end
92
- end
93
- context :integer do
94
- should "null" do
95
- assert_equal nil, Flextures::Loader::TRANSLATER[:integer].call(nil)
96
- end
97
- end
98
- context :string do
99
- should "null" do
100
- assert_equal nil, Flextures::Loader::TRANSLATER[:string].call(nil)
101
- end
102
- should "空文字" do
103
- assert_equal "", Flextures::Loader::TRANSLATER[:string].call("")
104
- end
105
- should "タブ混じり" do
106
- s="\taaaaa"
107
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
108
- end
109
- should "改行混じり" do
110
- s="aa\naaa"
111
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
112
- end
113
- should "スペース混じり" do
114
- s="aa aaa"
115
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
116
- end
117
- # "@#%{}|[]&:`'>?~"
118
- end
119
- context :text do
120
- should "null" do
121
- assert_equal nil, Flextures::Loader::TRANSLATER[:text].call(nil)
122
- end
123
- should "空文字" do
124
- assert_equal "", Flextures::Loader::TRANSLATER[:text].call("")
125
- end
126
- end
127
- context :time do
128
- should "正常値の文字列" do
129
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:time].call("2011/11/21").strftime("%Y/%m/%d")
130
- end
131
- should "Timeオブジェクト" do
132
- now = Time.now
133
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
134
- end
135
- should "DateTimeオブジェクト" do
136
- now = DateTime.now
137
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
138
- end
139
- should "日付っぽい数字はDateTime型" do
140
- now = "20111121"
141
- assert_equal true, Flextures::Loader::TRANSLATER[:time].call(now).is_a?(DateTime)
142
- end
143
- should "nilはnilのまま" do
144
- assert_equal nil, Flextures::Loader::TRANSLATER[:time].call(nil)
145
- end
146
- should "空文字はnil" do
147
- assert_equal nil, Flextures::Loader::TRANSLATER[:time].call("")
148
- end
149
- end
150
- context :timestamp do
151
- should "正常値の文字列はDateTimeに変換" do
152
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:timestamp].call("2011/11/21").strftime("%Y/%m/%d")
153
- end
154
- should "Timeオブジェクト" do
155
- now = Time.now
156
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
157
- end
158
- should "DateTimeオブジェクトはDateTime" do
159
- now = DateTime.now
160
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
161
- end
162
- should "日付っぽい数字はDateTime" do
163
- now = "20111121"
164
- assert_equal true, Flextures::Loader::TRANSLATER[:timestamp].call(now).is_a?(DateTime)
165
- end
166
- should "nilからnil" do
167
- assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call(nil)
168
- end
169
- should "空文字はnil" do
170
- assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call("")
171
- end
172
- end
173
- end
174
-
175
- context ".stair_list" do
176
- context " stair is 'false' " do
177
- context "argument is null" do
178
- setup do
179
- @list = Flextures::Loader::stair_list nil, false
180
- end
181
- should " return array include only empty string" do
182
- assert_equal @list, [""]
183
- end
184
- end
185
- context "argument is empty string" do
186
- setup do
187
- @list = Flextures::Loader::stair_list "", false
188
- end
189
- should " return array include only empty string" do
190
- assert_equal @list, [""]
191
- end
192
- end
193
- context "include '/' mark" do
194
- setup do
195
- @list = Flextures::Loader::stair_list "a/b/c", false
196
- end
197
- should " return directory list" do
198
- assert_equal @list, ["a/b/c"]
199
- end
200
- end
201
- end
202
- context " stair is 'true' " do
203
- context "argument is null" do
204
- setup do
205
- @list = Flextures::Loader::stair_list nil, true
206
- end
207
- should " return array include only empty string" do
208
- assert_equal @list, [""]
209
- end
210
- end
211
- context "argument is empty string" do
212
- setup do
213
- @list = Flextures::Loader::stair_list "", true
214
- end
215
- should " return array include only empty string" do
216
- assert_equal @list, [""]
217
- end
218
- end
219
- context "include '/' mark" do
220
- setup do
221
- @list = Flextures::Loader::stair_list "a/b/c", true
222
- end
223
- should " return directory list" do
224
- assert_equal @list, ["a/b/c","a/b","a",""]
225
- end
226
- end
227
- end
228
- end
229
-
230
- context ".loading_order" do
231
- context "simple test" do
232
- setup do
233
- @proc = Flextures::Loader.loading_order
234
- end
235
- should "not sort" do
236
- assert_equal ["a","b","c"].sort(&@proc), ["a","b","c"]
237
- end
238
- end
239
- context "set orderd table name" do
240
- setup do
241
- Flextures::Config.table_load_order=["b"]
242
- @proc = Flextures::Loader.loading_order
243
- end
244
- should "first table name is setted table" do
245
- assert_equal ["a","b","c"].sort(&@proc), ["b","a","c"]
246
- end
247
- teardown do
248
- Flextures::Config.table_load_order=[]
249
- end
250
- end
251
- end
252
- end
253
- end
254
-
1
+ # encoding: utf-8
2
+
3
+ class FlexturesLoaderTest < Test::Unit::TestCase
4
+ context Flextures::Loader do
5
+ context "TRANSLATER" do
6
+ context :binary do
7
+ should "'nil' value not changed" do
8
+ assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
9
+ end
10
+ end
11
+ context :boolean do
12
+ should "'nil' value not changed" do
13
+ assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
14
+ end
15
+ should "true value not changed" do
16
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
17
+ end
18
+ should "false value not changed" do
19
+ assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
20
+ end
21
+ should "0 is change to 'false'" do
22
+ assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
23
+ end
24
+ should "1 is change to 'true'" do
25
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
26
+ end
27
+ should "-1 is change to 'true'" do
28
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
29
+ end
30
+ should "'0' is change to 'false'" do
31
+ assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('0')
32
+ end
33
+ should "'1' is change to 'true'" do
34
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('1')
35
+ end
36
+ should "'true' value not changed" do
37
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('true')
38
+ end
39
+ should "'false' value not changed" do
40
+ assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('false')
41
+ end
42
+ should "'non-falsy string data' is change to 'true'" do
43
+ assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
44
+ end
45
+ should "'empty string' is change to 'true'" do
46
+ assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
47
+ end
48
+ end
49
+ context :date do
50
+ should "正常値の文字列" do
51
+ assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
52
+ end
53
+ should "Timeオブジェクト" do
54
+ now = Time.now
55
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
56
+ end
57
+ should "DateTimeオブジェクト" do
58
+ now = DateTime.now
59
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
60
+ end
61
+ should "日付っぽい数字" do
62
+ now = "20111121"
63
+ assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
64
+ end
65
+ should "nil" do
66
+ assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
67
+ end
68
+ should "空文字" do
69
+ assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
70
+ end
71
+ end
72
+ context :datetime do
73
+ should "正常値の文字列" do
74
+ assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
75
+ end
76
+ should "Timeオブジェクト" do
77
+ now = Time.now
78
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
79
+ end
80
+ should "DateTimeオブジェクト" do
81
+ now = DateTime.now
82
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
83
+ end
84
+ should "日付っぽい数字" do
85
+ now = "20111121"
86
+ assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
87
+ end
88
+ should "nil" do
89
+ assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
90
+ end
91
+ should "空文字" do
92
+ assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
93
+ end
94
+ end
95
+ context :decimal do
96
+ should "null" do
97
+ assert_equal nil, Flextures::Loader::TRANSLATER[:decimal].call(nil)
98
+ end
99
+ end
100
+ context :float do
101
+ should "null" do
102
+ assert_equal nil, Flextures::Loader::TRANSLATER[:float].call(nil)
103
+ end
104
+ end
105
+ context :integer do
106
+ should "null" do
107
+ assert_equal nil, Flextures::Loader::TRANSLATER[:integer].call(nil)
108
+ end
109
+ end
110
+ context :string do
111
+ should "null" do
112
+ assert_equal nil, Flextures::Loader::TRANSLATER[:string].call(nil)
113
+ end
114
+ should "空文字" do
115
+ assert_equal "", Flextures::Loader::TRANSLATER[:string].call("")
116
+ end
117
+ should "タブ混じり" do
118
+ s="\taaaaa"
119
+ assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
120
+ end
121
+ should "改行混じり" do
122
+ s="aa\naaa"
123
+ assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
124
+ end
125
+ should "スペース混じり" do
126
+ s="aa aaa"
127
+ assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
128
+ end
129
+ # "@#%{}|[]&:`'>?~"
130
+ end
131
+ context :text do
132
+ should "null" do
133
+ assert_equal nil, Flextures::Loader::TRANSLATER[:text].call(nil)
134
+ end
135
+ should "空文字" do
136
+ assert_equal "", Flextures::Loader::TRANSLATER[:text].call("")
137
+ end
138
+ end
139
+ context :time do
140
+ should "正常値の文字列" do
141
+ assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:time].call("2011/11/21").strftime("%Y/%m/%d")
142
+ end
143
+ should "Timeオブジェクト" do
144
+ now = Time.now
145
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
146
+ end
147
+ should "DateTimeオブジェクト" do
148
+ now = DateTime.now
149
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
150
+ end
151
+ should "日付っぽい数字はDateTime" do
152
+ now = "20111121"
153
+ assert_equal true, Flextures::Loader::TRANSLATER[:time].call(now).is_a?(DateTime)
154
+ end
155
+ should "nilはnilのまま" do
156
+ assert_equal nil, Flextures::Loader::TRANSLATER[:time].call(nil)
157
+ end
158
+ should "空文字はnil" do
159
+ assert_equal nil, Flextures::Loader::TRANSLATER[:time].call("")
160
+ end
161
+ end
162
+ context :timestamp do
163
+ should "正常値の文字列はDateTimeに変換" do
164
+ assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:timestamp].call("2011/11/21").strftime("%Y/%m/%d")
165
+ end
166
+ should "Timeオブジェクト" do
167
+ now = Time.now
168
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
169
+ end
170
+ should "DateTimeオブジェクトはDateTime" do
171
+ now = DateTime.now
172
+ assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
173
+ end
174
+ should "日付っぽい数字はDateTime" do
175
+ now = "20111121"
176
+ assert_equal true, Flextures::Loader::TRANSLATER[:timestamp].call(now).is_a?(DateTime)
177
+ end
178
+ should "nilからnil" do
179
+ assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call(nil)
180
+ end
181
+ should "空文字はnil" do
182
+ assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call("")
183
+ end
184
+ end
185
+ end
186
+
187
+ context ".stair_list" do
188
+ context " stair is 'false' " do
189
+ context "argument is null" do
190
+ setup do
191
+ @list = Flextures::Loader::stair_list nil, false
192
+ end
193
+ should " return array include only empty string" do
194
+ assert_equal @list, [""]
195
+ end
196
+ end
197
+ context "argument is empty string" do
198
+ setup do
199
+ @list = Flextures::Loader::stair_list "", false
200
+ end
201
+ should " return array include only empty string" do
202
+ assert_equal @list, [""]
203
+ end
204
+ end
205
+ context "include '/' mark" do
206
+ setup do
207
+ @list = Flextures::Loader::stair_list "a/b/c", false
208
+ end
209
+ should " return directory list" do
210
+ assert_equal @list, ["a/b/c"]
211
+ end
212
+ end
213
+ end
214
+ context " stair is 'true' " do
215
+ context "argument is null" do
216
+ setup do
217
+ @list = Flextures::Loader::stair_list nil, true
218
+ end
219
+ should " return array include only empty string" do
220
+ assert_equal @list, [""]
221
+ end
222
+ end
223
+ context "argument is empty string" do
224
+ setup do
225
+ @list = Flextures::Loader::stair_list "", true
226
+ end
227
+ should " return array include only empty string" do
228
+ assert_equal @list, [""]
229
+ end
230
+ end
231
+ context "include '/' mark" do
232
+ setup do
233
+ @list = Flextures::Loader::stair_list "a/b/c", true
234
+ end
235
+ should " return directory list" do
236
+ assert_equal @list, ["a/b/c","a/b","a",""]
237
+ end
238
+ end
239
+ end
240
+ end
241
+
242
+ context ".loading_order" do
243
+ context "simple test" do
244
+ setup do
245
+ @proc = Flextures::Loader.loading_order
246
+ end
247
+ should "not sort" do
248
+ assert_equal ["a","b","c"].sort(&@proc), ["a","b","c"]
249
+ end
250
+ end
251
+ context "set orderd table name" do
252
+ setup do
253
+ Flextures::Config.table_load_order=["b"]
254
+ @proc = Flextures::Loader.loading_order
255
+ end
256
+ should "first table name is setted table" do
257
+ assert_equal ["a","b","c"].sort(&@proc), ["b","a","c"]
258
+ end
259
+ teardown do
260
+ Flextures::Config.table_load_order=[]
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
-
3
- class SimpleTest < Test::Unit::TestCase
4
- should "comfirm should move" do
5
- assert_equal true, true
6
- end
7
- end
8
-
1
+ # encoding: utf-8
2
+
3
+ class SimpleTest < Test::Unit::TestCase
4
+ should "comfirm should move" do
5
+ assert_equal true, true
6
+ end
7
+ end
8
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flextures
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - baban
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler