flextures 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/flextures.gemspec +8 -5
- data/lib/flextures.rb +0 -1
- data/lib/flextures/flextures.rb +17 -8
- data/lib/flextures/flextures_loader.rb +28 -14
- data/lib/flextures/version.rb +1 -1
- data/test/unit/test_flextures_args.rb +94 -0
- data/test/unit/test_flextures_dumper.rb +1 -5
- data/test/unit/test_flextures_hooks.rb +34 -0
- data/test/unit/test_flextures_loader.rb +179 -0
- metadata +8 -5
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.3
|
data/flextures.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "flextures"
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["baban"]
|
12
|
-
s.date = "2012-09-
|
12
|
+
s.date = "2012-09-23"
|
13
13
|
s.description = "load and dump fixtures"
|
14
14
|
s.email = "babanba.n@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -44,7 +44,10 @@ Gem::Specification.new do |s|
|
|
44
44
|
"lib/flextures/version.rb",
|
45
45
|
"test/test_helper.rb",
|
46
46
|
"test/unit/test_flextures.rb",
|
47
|
+
"test/unit/test_flextures_args.rb",
|
47
48
|
"test/unit/test_flextures_dumper.rb",
|
49
|
+
"test/unit/test_flextures_hooks.rb",
|
50
|
+
"test/unit/test_flextures_loader.rb",
|
48
51
|
"test/unit/test_simple.rb"
|
49
52
|
]
|
50
53
|
s.homepage = "http://github.com/baban/flextures"
|
@@ -57,14 +60,14 @@ Gem::Specification.new do |s|
|
|
57
60
|
s.specification_version = 3
|
58
61
|
|
59
62
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_development_dependency(%q<bundler>, ["= 1.
|
63
|
+
s.add_development_dependency(%q<bundler>, ["= 1.2.0"])
|
61
64
|
s.add_development_dependency(%q<jeweler>, ["= 1.8.3"])
|
62
65
|
else
|
63
|
-
s.add_dependency(%q<bundler>, ["= 1.
|
66
|
+
s.add_dependency(%q<bundler>, ["= 1.2.0"])
|
64
67
|
s.add_dependency(%q<jeweler>, ["= 1.8.3"])
|
65
68
|
end
|
66
69
|
else
|
67
|
-
s.add_dependency(%q<bundler>, ["= 1.
|
70
|
+
s.add_dependency(%q<bundler>, ["= 1.2.0"])
|
68
71
|
s.add_dependency(%q<jeweler>, ["= 1.8.3"])
|
69
72
|
end
|
70
73
|
end
|
data/lib/flextures.rb
CHANGED
data/lib/flextures/flextures.rb
CHANGED
@@ -95,24 +95,33 @@ module Flextures
|
|
95
95
|
def self.parse option={}
|
96
96
|
table_names = []
|
97
97
|
if ENV["T"] or ENV["TABLE"]
|
98
|
-
table_names = (ENV["T"] or ENV["TABLE"]).split(',').map{ |name| { table: name } }
|
98
|
+
table_names = (ENV["T"] or ENV["TABLE"]).split(',').map{ |name| { table: name, file: name } }
|
99
99
|
end
|
100
100
|
if ENV["M"] or ENV["MODEL"]
|
101
|
-
table_names = (ENV["M"] or ENV["MODEL"]).split(',').map
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
table_names = (ENV["M"] or ENV["MODEL"]).split(',').map do |name|
|
102
|
+
name = name.constantize.table_name
|
103
|
+
{ table: name, file: name }
|
104
|
+
end
|
105
105
|
end
|
106
|
+
|
107
|
+
table_names = Flextures::deletable_tables.map{ |table| { table: table } } if table_names.empty?
|
108
|
+
|
106
109
|
# ENV["FIXTURES"]の中身を解析
|
107
110
|
fixtures_args_parser =->(s){
|
108
111
|
names = s.split(',')
|
109
|
-
|
110
|
-
[ table_names.first.merge( file: names.first ) ]
|
112
|
+
if ENV["TABLE"] or ENV["T"] or ENV["MODEL"] or ENV["M"]
|
113
|
+
[ table_names.first.merge( file: names.first ) ]
|
114
|
+
else
|
111
115
|
names.map{ |name| { table: name, file: name } }
|
116
|
+
end
|
112
117
|
}
|
118
|
+
# ファイル名を調整
|
113
119
|
table_names = fixtures_args_parser.call ENV["FIXTURES"] if ENV["FIXTURES"]
|
114
|
-
table_names = fixtures_args_parser.call ENV["
|
120
|
+
table_names = fixtures_args_parser.call ENV["FILE"] if ENV["FILE"]
|
121
|
+
table_names = fixtures_args_parser.call ENV["F"] if ENV["F"]
|
122
|
+
|
115
123
|
table_names = table_names.map{ |option| option.merge dir: ENV["DIR"] } if ENV["DIR"]
|
124
|
+
table_names = table_names.map{ |option| option.merge dir: ENV["D"] } if ENV["D"]
|
116
125
|
# read mode だとcsvもyaml存在しないファイルは返さない
|
117
126
|
table_names.select! &exist if option[:mode] && option[:mode] == 'read'
|
118
127
|
table_names
|
@@ -15,7 +15,7 @@ module Flextures
|
|
15
15
|
|
16
16
|
@@table_cache = {}
|
17
17
|
|
18
|
-
#
|
18
|
+
# column set default value
|
19
19
|
COMPLETER = {
|
20
20
|
binary:->{ 0 },
|
21
21
|
boolean:->{ false },
|
@@ -30,7 +30,7 @@ module Flextures
|
|
30
30
|
timestamp:->{ DateTime.now },
|
31
31
|
}
|
32
32
|
|
33
|
-
#
|
33
|
+
# colum data translate
|
34
34
|
TRANSLATER = {
|
35
35
|
binary:->(d){
|
36
36
|
return d if d.nil?
|
@@ -106,25 +106,39 @@ module Flextures
|
|
106
106
|
|
107
107
|
[table_name, "#{dir_name}#{file_name}",ext]
|
108
108
|
end
|
109
|
+
|
110
|
+
# flextures関数の引数をパースして
|
111
|
+
# 単純な読み込み向け形式に変換します
|
112
|
+
#
|
113
|
+
# @params [Hash] 読み込むテーブルとファイル名のペア
|
114
|
+
# @return [Array] 読み込テーブルごとに切り分けられた設定のハッシュを格納
|
115
|
+
def self.parse_flextures_options *fixtures
|
116
|
+
options = {}
|
117
|
+
options = fixtures.shift if fixtures.size > 1 and fixtures.first.is_a?(Hash)
|
118
|
+
|
119
|
+
# :allですべてのfixtureを反映
|
120
|
+
fixtures = Flextures::deletable_tables if fixtures.size== 1 and :all == fixtures.first
|
121
|
+
|
122
|
+
last_hash = {}
|
123
|
+
last_hash = fixtures.pop if fixtures.last.is_a? Hash # ハッシュ取り出し
|
124
|
+
|
125
|
+
load_hash = fixtures.inject({}){ |h,name| h[name.to_sym] = name; h }
|
126
|
+
load_hash.merge!(last_hash)
|
127
|
+
load_hash.map { |k,v| { table: k, file: v, loader: :fun } }
|
128
|
+
end
|
109
129
|
|
110
130
|
# fixturesをまとめてロード、主にテストtest/unit, rspec で使用する
|
111
131
|
#
|
112
132
|
# 全テーブルが対象
|
113
|
-
#
|
133
|
+
# flextures :all
|
114
134
|
# テーブル名で一覧する
|
115
|
-
#
|
135
|
+
# flextures :users, :items
|
116
136
|
# ハッシュで指定
|
117
|
-
#
|
137
|
+
# flextures :users => :users2
|
138
|
+
#
|
139
|
+
# @params [Hash] 読み込むテーブルとファイル名のペア
|
118
140
|
def self.flextures *fixtures
|
119
|
-
|
120
|
-
options = fixtures.shift if fixtures.size > 1 and fixtures.first.is_a?(Hash)
|
121
|
-
|
122
|
-
# :allですべてのfixtureを反映
|
123
|
-
fixtures = Flextures::deletable_tables if fixtures.size== 1 and :all == fixtures.first
|
124
|
-
fixtures_hash = fixtures.pop if fixtures.last and fixtures.last.is_a? Hash # ハッシュ取り出し
|
125
|
-
fixtures.each{ |table_name| Loader::load table: table_name, loader: :fun }
|
126
|
-
fixtures_hash.each{ |k,v| Loader::load table: k, file: v, loader: :fun } if fixtures_hash
|
127
|
-
fixtures
|
141
|
+
parse_flextures_options(*fixtures).each{ |option| Loader::load option }
|
128
142
|
end
|
129
143
|
|
130
144
|
# csv 優先で存在している fixtures をロード
|
data/lib/flextures/version.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FlexturesArgsTest < Test::Unit::TestCase
|
4
|
+
context Flextures::ARGS do
|
5
|
+
context " TABLE=テーブル名 を設定している場合 " do
|
6
|
+
setup do
|
7
|
+
ENV["TABLE"] = "users"
|
8
|
+
@format = Flextures::ARGS.parse
|
9
|
+
end
|
10
|
+
should "テーブル名を指定できている" do
|
11
|
+
assert_equal "users", @format.first[:table]
|
12
|
+
end
|
13
|
+
should "ファイル名はテーブル名と同じ" do
|
14
|
+
assert_equal "users", @format.first[:file]
|
15
|
+
end
|
16
|
+
teardown do
|
17
|
+
ENV.delete("TABLE")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context " T=テーブル名を設定している場合 " do
|
21
|
+
setup do
|
22
|
+
ENV["T"] = "s_user"
|
23
|
+
@format = Flextures::ARGS.parse
|
24
|
+
end
|
25
|
+
should "テーブル名を指定できている" do
|
26
|
+
assert_equal "s_user", @format.first[:table]
|
27
|
+
end
|
28
|
+
should "ファイル名はテーブル名と同じ" 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=でダンプするディレクトリを変更できる " do
|
36
|
+
setup do
|
37
|
+
ENV["T"] = "users"
|
38
|
+
ENV["DIR"] = "test/fixtures/"
|
39
|
+
@format = Flextures::ARGS.parse
|
40
|
+
end
|
41
|
+
should "ディレクトリ名を取得できる" do
|
42
|
+
assert_equal "test/fixtures/", @format.first[:dir]
|
43
|
+
end
|
44
|
+
should "テーブル名を指定できている" do
|
45
|
+
assert_equal "users", @format.first[:table]
|
46
|
+
end
|
47
|
+
should "ファイル名はテーブル名と同じ" 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=でもダンプするディレクトリを変更できる " do
|
56
|
+
setup do
|
57
|
+
ENV["T"] = "users"
|
58
|
+
ENV["D"] = "test/fixtures/"
|
59
|
+
@format = Flextures::ARGS.parse
|
60
|
+
end
|
61
|
+
should "ディレクトリ名を取得できる" do
|
62
|
+
assert_equal "test/fixtures/", @format.first[:dir]
|
63
|
+
end
|
64
|
+
should "テーブル名を指定できている" do
|
65
|
+
assert_equal "users", @format.first[:table]
|
66
|
+
end
|
67
|
+
should "ファイル名はテーブル名と同じ" 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=でもダンプするファイルを変更できる " do
|
76
|
+
setup do
|
77
|
+
ENV["T"] = "users"
|
78
|
+
ENV["FIXTURES"] = "user_another"
|
79
|
+
@format = Flextures::ARGS.parse
|
80
|
+
end
|
81
|
+
should "テーブル名は指定したもの" do
|
82
|
+
assert_equal "users", @format.first[:table]
|
83
|
+
end
|
84
|
+
should "ファイル名はテーブル名と違う指定したものに変わっている" 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
|
+
end
|
93
|
+
end
|
94
|
+
|
@@ -157,13 +157,9 @@ class FlexturesDumperTest < Test::Unit::TestCase
|
|
157
157
|
assert_equal false, @trans.call( false, :yml )
|
158
158
|
end
|
159
159
|
should "「true」は「true」" do
|
160
|
-
assert_equal
|
160
|
+
assert_equal true, @trans.call( true, :yml )
|
161
161
|
end
|
162
162
|
end
|
163
|
-
context :csv do
|
164
|
-
end
|
165
|
-
end
|
166
|
-
context :text do
|
167
163
|
end
|
168
164
|
end
|
169
165
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FlexturesHookTest < Test::Unit::TestCase
|
4
|
+
context Flextures::Loader do
|
5
|
+
context ".parse_flextures_options" do
|
6
|
+
context "通常動作" do
|
7
|
+
setup do
|
8
|
+
@ret = Flextures::Loader.parse_flextures_options(:users)
|
9
|
+
end
|
10
|
+
should "指定したテーブル分だけハッシュが返されている" do
|
11
|
+
assert_equal 1, @ret.size
|
12
|
+
end
|
13
|
+
should "ハッシュの中身は読み込み設定のハッシュ" do
|
14
|
+
h = { table: :users, file: :users, loader: :fun }
|
15
|
+
assert_equal h, @ret.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context "違うファイルをロードした時" do
|
19
|
+
setup do
|
20
|
+
@ret = Flextures::Loader.parse_flextures_options( :users => :users_another3 )
|
21
|
+
end
|
22
|
+
should "指定したテーブル分だけハッシュが返されている" do
|
23
|
+
assert_equal 1, @ret.size
|
24
|
+
end
|
25
|
+
should "ハッシュの中身は読み込み設定のハッシュ" do
|
26
|
+
h = { table: :users, file: :users_another3, loader: :fun }
|
27
|
+
assert_equal h, @ret.first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ruby -I"lib:lib:test" -I"/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib" "/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" test/**/test_*.rb
|
4
|
+
# ruby -I"lib:lib:test" "/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" test/**/test_*.rb
|
5
|
+
|
6
|
+
class FlexturesLoaderTest < Test::Unit::TestCase
|
7
|
+
context Flextures::Loader do
|
8
|
+
context "TRANSLATER" do
|
9
|
+
context :binary do
|
10
|
+
should "nil" do
|
11
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
context :boolean do
|
15
|
+
should "nilはそのまま" do
|
16
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
|
17
|
+
end
|
18
|
+
should "trueもそのまま" do
|
19
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
|
20
|
+
end
|
21
|
+
should "falseもそのまま" do
|
22
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
|
23
|
+
end
|
24
|
+
should "0" do
|
25
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
|
26
|
+
end
|
27
|
+
should "1" do
|
28
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
|
29
|
+
end
|
30
|
+
should "-1" do
|
31
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
|
32
|
+
end
|
33
|
+
should "空白文字" do
|
34
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
|
35
|
+
end
|
36
|
+
should "文字" do
|
37
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context :date do
|
41
|
+
should "正常値の文字列" do
|
42
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
|
43
|
+
end
|
44
|
+
should "Timeオブジェクト" do
|
45
|
+
now = Time.now
|
46
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
47
|
+
end
|
48
|
+
should "DateTimeオブジェクト" do
|
49
|
+
now = DateTime.now
|
50
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
51
|
+
end
|
52
|
+
should "日付っぽい数字" do
|
53
|
+
now = "20111121"
|
54
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
|
55
|
+
end
|
56
|
+
should "nil" do
|
57
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
|
58
|
+
end
|
59
|
+
should "空文字" do
|
60
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context :datetime do
|
64
|
+
should "正常値の文字列" do
|
65
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
|
66
|
+
end
|
67
|
+
should "Timeオブジェクト" do
|
68
|
+
now = Time.now
|
69
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
70
|
+
end
|
71
|
+
should "DateTimeオブジェクト" do
|
72
|
+
now = DateTime.now
|
73
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
74
|
+
end
|
75
|
+
should "日付っぽい数字" do
|
76
|
+
now = "20111121"
|
77
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
|
78
|
+
end
|
79
|
+
should "nil" do
|
80
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
|
81
|
+
end
|
82
|
+
should "空文字" do
|
83
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
context :decimal do
|
87
|
+
should "null" do
|
88
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:decimal].call(nil)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
context :float do
|
92
|
+
should "null" do
|
93
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:float].call(nil)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context :integer do
|
97
|
+
should "null" do
|
98
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:integer].call(nil)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
context :string do
|
102
|
+
should "null" do
|
103
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:string].call(nil)
|
104
|
+
end
|
105
|
+
should "空文字" do
|
106
|
+
assert_equal "", Flextures::Loader::TRANSLATER[:string].call("")
|
107
|
+
end
|
108
|
+
should "タブ混じり" do
|
109
|
+
s="\taaaaa"
|
110
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
111
|
+
end
|
112
|
+
should "改行混じり" do
|
113
|
+
s="aa\naaa"
|
114
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
115
|
+
end
|
116
|
+
should "スペース混じり" do
|
117
|
+
s="aa aaa"
|
118
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
119
|
+
end
|
120
|
+
# "@#%{}|[]&:`'>?~"
|
121
|
+
end
|
122
|
+
context :text do
|
123
|
+
should "null" do
|
124
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:text].call(nil)
|
125
|
+
end
|
126
|
+
should "空文字" do
|
127
|
+
assert_equal "", Flextures::Loader::TRANSLATER[:text].call("")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
context :time do
|
131
|
+
should "正常値の文字列" do
|
132
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:time].call("2011/11/21").strftime("%Y/%m/%d")
|
133
|
+
end
|
134
|
+
should "Timeオブジェクト" do
|
135
|
+
now = Time.now
|
136
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
|
137
|
+
end
|
138
|
+
should "DateTimeオブジェクト" do
|
139
|
+
now = DateTime.now
|
140
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
|
141
|
+
end
|
142
|
+
should "日付っぽい数字はDateTime型" do
|
143
|
+
now = "20111121"
|
144
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:time].call(now).is_a?(DateTime)
|
145
|
+
end
|
146
|
+
should "nilはnilのまま" do
|
147
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:time].call(nil)
|
148
|
+
end
|
149
|
+
should "空文字はnil" do
|
150
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:time].call("")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
context :timestamp do
|
154
|
+
should "正常値の文字列はDateTimeに変換" do
|
155
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:timestamp].call("2011/11/21").strftime("%Y/%m/%d")
|
156
|
+
end
|
157
|
+
should "Timeオブジェクト" do
|
158
|
+
now = Time.now
|
159
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
|
160
|
+
end
|
161
|
+
should "DateTimeオブジェクトはDateTime" do
|
162
|
+
now = DateTime.now
|
163
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
|
164
|
+
end
|
165
|
+
should "日付っぽい数字はDateTime" do
|
166
|
+
now = "20111121"
|
167
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:timestamp].call(now).is_a?(DateTime)
|
168
|
+
end
|
169
|
+
should "nilからnil" do
|
170
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call(nil)
|
171
|
+
end
|
172
|
+
should "空文字はnil" do
|
173
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call("")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flextures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.2.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: jeweler
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +78,10 @@ files:
|
|
78
78
|
- lib/flextures/version.rb
|
79
79
|
- test/test_helper.rb
|
80
80
|
- test/unit/test_flextures.rb
|
81
|
+
- test/unit/test_flextures_args.rb
|
81
82
|
- test/unit/test_flextures_dumper.rb
|
83
|
+
- test/unit/test_flextures_hooks.rb
|
84
|
+
- test/unit/test_flextures_loader.rb
|
82
85
|
- test/unit/test_simple.rb
|
83
86
|
homepage: http://github.com/baban/flextures
|
84
87
|
licenses:
|
@@ -95,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
98
|
version: '0'
|
96
99
|
segments:
|
97
100
|
- 0
|
98
|
-
hash: -
|
101
|
+
hash: -159357549
|
99
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
103
|
none: false
|
101
104
|
requirements:
|