MasterRecord 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/MasterRecord.gemspec +4 -2
- data/README.rdoc +5 -0
- data/VERSION +1 -1
- data/data/country.yml +2 -0
- data/lib/MasterRecord.rb +8 -0
- data/spec/MasterRecord_spec.rb +12 -3
- metadata +13 -11
data/ChangeLog
ADDED
data/MasterRecord.gemspec
CHANGED
@@ -5,20 +5,22 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "MasterRecord"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Takeshi Morita"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-20"
|
13
13
|
s.description = "Object Mapper for csv or tsv or yaml etc.. you can use find,find_one_by|field|,find_by_|field|"
|
14
14
|
s.email = "laten@nifty.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
|
+
"ChangeLog",
|
16
17
|
"LICENSE.txt",
|
17
18
|
"README.rdoc"
|
18
19
|
]
|
19
20
|
s.files = [
|
20
21
|
".document",
|
21
22
|
".rspec",
|
23
|
+
"ChangeLog",
|
22
24
|
"Gemfile",
|
23
25
|
"LICENSE.txt",
|
24
26
|
"MasterRecord.gemspec",
|
data/README.rdoc
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
:name => MasterRecord.string,
|
22
22
|
:population => MasterRecord.integer,
|
23
23
|
:salutation => lambda{|r| "'#{r}!!'" }
|
24
|
+
:now => lambda{|r|"lambda{ Time.now.localtime('" + r + "')}"},
|
24
25
|
}
|
25
26
|
include MasterRecord
|
26
27
|
end
|
@@ -45,6 +46,8 @@
|
|
45
46
|
Item.load_data(MasterRecord::TSV.load_file(File.expand_path("./data/item.tsv", File.dirname(__FILE__))))
|
46
47
|
Item.find().count => 3
|
47
48
|
Item.find_by_price(50)[0].name => "ガム"
|
49
|
+
Item.find_one_by_price(50)[:id] => "3"
|
50
|
+
Item.find_one_by_price(40).attributes => {:id => "2",:identity => "Item@2",:name => "チョコレート",:price => 40}
|
48
51
|
|
49
52
|
#1:
|
50
53
|
# name: "Japan"
|
@@ -60,6 +63,8 @@
|
|
60
63
|
Country.find().count => 2
|
61
64
|
Country.find_one_by_population(500000000).name => "China"
|
62
65
|
Country.find().map(&:salutation) => ["こんにちは!!","您好!!"]}
|
66
|
+
Country.find("1").now.call.to_s => "2011-12-18 01:01:00 +0900"
|
67
|
+
Country.find("2").now.call.to_s => "2011-12-18 00:01:00 +0800"
|
63
68
|
|
64
69
|
|
65
70
|
== Contributing to MasterRecord
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/data/country.yml
CHANGED
data/lib/MasterRecord.rb
CHANGED
data/spec/MasterRecord_spec.rb
CHANGED
@@ -19,13 +19,15 @@ class Country
|
|
19
19
|
CountryFields = {
|
20
20
|
:name => MasterRecord.string,
|
21
21
|
:population => MasterRecord.integer,
|
22
|
-
:salutation => lambda{|r| "'#{r}!!'" }
|
22
|
+
:salutation => lambda{|r| "'#{r}!!'" },
|
23
|
+
:now => lambda{|r|"lambda{ Time.now.localtime('" + r + "')}"},
|
23
24
|
}
|
24
25
|
include MasterRecord
|
25
26
|
end
|
26
27
|
describe "Masterrecord" do
|
27
28
|
describe "csv" do
|
28
29
|
before do
|
30
|
+
#id,name,age
|
29
31
|
#1,ひろし,10
|
30
32
|
#2,たけし,20
|
31
33
|
#3,まこと,30
|
@@ -47,7 +49,9 @@ describe "Masterrecord" do
|
|
47
49
|
Item.load_data(MasterRecord::TSV.load_file(File.expand_path("../data/item.tsv", File.dirname(__FILE__))))
|
48
50
|
end
|
49
51
|
it{ Item.find().count.should == 3}
|
50
|
-
it{ Item.find_by_price(50)[0]
|
52
|
+
it{ Item.find_by_price(50)[0]["name"].should == "ガム"}
|
53
|
+
it{ Item.find_one_by_price(50)[:id].should == "3"}
|
54
|
+
it{ Item.find_one_by_price(40).attributes.should == {:id => "2",:identity => "Item@2",:name => "チョコレート",:price => 40}}
|
51
55
|
end
|
52
56
|
describe "yml" do
|
53
57
|
before do
|
@@ -55,15 +59,20 @@ describe "Masterrecord" do
|
|
55
59
|
# name: "Japan"
|
56
60
|
# population: 120000000
|
57
61
|
# salutation: "こんにちは"
|
62
|
+
# now: "+09:00"
|
58
63
|
#2:
|
59
64
|
# name: "China"
|
60
65
|
# population: 500000000
|
61
66
|
# salutation: "您好"
|
67
|
+
# now: "+08:00"
|
62
68
|
Country.load_data(
|
63
69
|
MasterRecord::YAML.load_file(Country.fields,File.expand_path("../data/country.yml", File.dirname(__FILE__))))
|
70
|
+
@now = Time.new(2011,12,18,1,1,0)
|
71
|
+
Time.stub!(:now).and_return(@now)
|
64
72
|
end
|
65
73
|
it{ Country.find().count.should == 2}
|
66
|
-
it{ Country.find_one_by_population(500000000).name.should == "China"}
|
67
74
|
it{ Country.find().map(&:salutation).should == ["こんにちは!!","您好!!"]}
|
75
|
+
it{ Country.find("1").now.call.to_s.should == "2011-12-18 01:01:00 +0900"}
|
76
|
+
it{ Country.find("2").now.call.to_s.should == "2011-12-18 00:01:00 +0800"}
|
68
77
|
end
|
69
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MasterRecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &11611540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11611540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &11610740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11610740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &11609720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11609720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &11608860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,17 +54,19 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *11608860
|
58
58
|
description: Object Mapper for csv or tsv or yaml etc.. you can use find,find_one_by|field|,find_by_|field|
|
59
59
|
email: laten@nifty.com
|
60
60
|
executables: []
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files:
|
63
|
+
- ChangeLog
|
63
64
|
- LICENSE.txt
|
64
65
|
- README.rdoc
|
65
66
|
files:
|
66
67
|
- .document
|
67
68
|
- .rspec
|
69
|
+
- ChangeLog
|
68
70
|
- Gemfile
|
69
71
|
- LICENSE.txt
|
70
72
|
- MasterRecord.gemspec
|
@@ -96,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
98
|
version: '0'
|
97
99
|
segments:
|
98
100
|
- 0
|
99
|
-
hash: -
|
101
|
+
hash: -2812055945714536566
|
100
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
103
|
none: false
|
102
104
|
requirements:
|