ygg 0.0.2 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,34 +11,32 @@ Lightweight YAML persistence solution with sofisticated ORM-class models and rel
11
11
  require "ygg"
12
12
 
13
13
  class User < Ygg::Model
14
- attr_accessor :name, :pass
14
+ key :name, :pass
15
15
  end
16
16
 
17
17
  class Article < Ygg::Model
18
- attr_accessor :title, :content
18
+ key :title, :content
19
19
  end
20
20
 
21
- Ygg.load "data.yaml"
22
-
23
- user = User.create :index => "johnr",
24
- :name => "John Robertson",
21
+ load :data do
22
+ user = User.new :name => "John Robertson",
25
23
  :pass => "secret"
26
24
 
27
- article = Article.create :index => "first-ygg"
28
- article.title = "Using Ygg for the first time"
29
- article.content = "The API is inspired in classic ORMs like ActiveRecord"
25
+ article = Article.new :title => "Using Ygg for the first time"
26
+ article.content = "The API is inspired in classic ORMs like ActiveRecord"
30
27
 
31
- user >> article # This declaration creations a relationships between the user and the article
28
+ user & article # This declaration creations a relationships between the user and the article
32
29
 
33
- Ygg.save
30
+ end
34
31
 
35
32
  And then for obtaining all articles belonging to "johnr"
36
33
 
37
34
  # require and Model declarations here
38
35
 
39
- Ygg.load "data.yaml"
40
-
41
- puts User.get("johnr") >= Article
36
+ load :data do
37
+ jrob = User.all.by_name("John Robertson")
38
+ puts jrob > Article
39
+ end
42
40
 
43
41
  Further documentation on functions will be added when the core reaches some stability.
44
42
 
@@ -0,0 +1,3 @@
1
+ ---
2
+ - !ruby/object:YggDemo::User
3
+ name: John Doe
@@ -0,0 +1,10 @@
1
+ dfl jlk : : &234alñkdjfasdkñlfj
2
+ alskñrjf
3
+ aj--
4
+ - adfadsf
5
+
6
+ -aer--
7
+
8
+ asdf
9
+ : safd
10
+ a
@@ -0,0 +1,177 @@
1
+ ---
2
+ - !ruby/object:YggDemo::User
3
+ name: Andrei Simonov
4
+ - !ruby/object:YggDemo::User
5
+ name: Jane Eyre
6
+ - !ruby/object:YggDemo::User
7
+ name: Jane Eyre
8
+ - !ruby/object:YggDemo::User
9
+ name: Jane Eyre
10
+ - !ruby/object:YggDemo::User
11
+ name: Jane Eyre
12
+ - !ruby/object:YggDemo::User
13
+ name: Jane Eyre
14
+ - !ruby/object:YggDemo::User
15
+ name: Jane Eyre
16
+ - !ruby/object:YggDemo::User
17
+ name: Jane Eyre
18
+ - !ruby/object:YggDemo::User
19
+ name: Jane Eyre
20
+ - !ruby/object:YggDemo::User
21
+ name: Jane Eyre
22
+ - !ruby/object:YggDemo::User
23
+ name: Jane Eyre
24
+ - !ruby/object:YggDemo::User
25
+ name: Jane Eyre
26
+ - !ruby/object:YggDemo::User
27
+ name: Jane Eyre
28
+ - !ruby/object:YggDemo::User
29
+ name: Jane Eyre
30
+ - !ruby/object:YggDemo::User
31
+ name: Jane Eyre
32
+ - !ruby/object:YggDemo::User
33
+ name: Jane Eyre
34
+ - !ruby/object:YggDemo::User
35
+ name: Jane Eyre
36
+ - !ruby/object:YggDemo::User
37
+ name: Jane Eyre
38
+ - !ruby/object:YggDemo::User
39
+ name: Jane Eyre
40
+ - !ruby/object:YggDemo::User
41
+ name: Jane Eyre
42
+ - !ruby/object:YggDemo::User
43
+ name: Jane Eyre
44
+ - !ruby/object:YggDemo::User
45
+ name: Jane Eyre
46
+ - !ruby/object:YggDemo::User
47
+ name: Jane Eyre
48
+ - !ruby/object:YggDemo::User
49
+ name: Jane Eyre
50
+ - !ruby/object:YggDemo::User
51
+ name: Jane Eyre
52
+ - !ruby/object:YggDemo::User
53
+ name: Jane Eyre
54
+ - !ruby/object:YggDemo::User
55
+ name: Jane Eyre
56
+ - !ruby/object:YggDemo::User
57
+ name: Jane Eyre
58
+ - !ruby/object:YggDemo::User
59
+ name: Jane Eyre
60
+ - !ruby/object:YggDemo::User
61
+ name: Jane Eyre
62
+ - !ruby/object:YggDemo::User
63
+ name: Jane Eyre
64
+ - !ruby/object:YggDemo::User
65
+ name: Jane Eyre
66
+ - !ruby/object:YggDemo::User
67
+ name: Jane Eyre
68
+ - !ruby/object:YggDemo::User
69
+ name: Jane Eyre
70
+ - !ruby/object:YggDemo::User
71
+ name: Jane Eyre
72
+ - !ruby/object:YggDemo::User
73
+ name: Jane Eyre
74
+ - !ruby/object:YggDemo::User
75
+ name: Jane Eyre
76
+ - !ruby/object:YggDemo::User
77
+ name: Jane Eyre
78
+ - !ruby/object:YggDemo::User
79
+ name: Jane Eyre
80
+ - !ruby/object:YggDemo::User
81
+ name: Jane Eyre
82
+ - !ruby/object:YggDemo::User
83
+ name: Jane Eyre
84
+ - !ruby/object:YggDemo::User
85
+ name: Jane Eyre
86
+ - !ruby/object:YggDemo::User
87
+ name: Jane Eyre
88
+ - !ruby/object:YggDemo::User
89
+ name: Jane Eyre
90
+ - !ruby/object:YggDemo::User
91
+ name: Jane Eyre
92
+ - !ruby/object:YggDemo::User
93
+ name: Jane Eyre
94
+ - !ruby/object:YggDemo::User
95
+ name: Jane Eyre
96
+ - !ruby/object:YggDemo::User
97
+ name: Jane Eyre
98
+ - !ruby/object:YggDemo::User
99
+ name: Jane Eyre
100
+ - !ruby/object:YggDemo::User
101
+ name: Jane Eyre
102
+ - !ruby/object:YggDemo::User
103
+ name: Jane Eyre
104
+ - !ruby/object:YggDemo::User
105
+ name: Jane Eyre
106
+ - !ruby/object:YggDemo::User
107
+ name: Jane Eyre
108
+ - !ruby/object:YggDemo::User
109
+ name: Jane Eyre
110
+ - !ruby/object:YggDemo::User
111
+ name: Jane Eyre
112
+ - !ruby/object:YggDemo::User
113
+ name: Jane Eyre
114
+ - !ruby/object:YggDemo::User
115
+ name: Jane Eyre
116
+ - !ruby/object:YggDemo::User
117
+ name: Jane Eyre
118
+ - !ruby/object:YggDemo::User
119
+ name: Jane Eyre
120
+ - !ruby/object:YggDemo::User
121
+ name: Jane Eyre
122
+ - !ruby/object:YggDemo::User
123
+ name: Jane Eyre
124
+ - !ruby/object:YggDemo::User
125
+ name: Jane Eyre
126
+ - !ruby/object:YggDemo::User
127
+ name: Jane Eyre
128
+ - !ruby/object:YggDemo::User
129
+ name: Jane Eyre
130
+ - !ruby/object:YggDemo::User
131
+ name: Jane Eyre
132
+ - !ruby/object:YggDemo::User
133
+ name: Jane Eyre
134
+ - !ruby/object:YggDemo::User
135
+ name: Jane Eyre
136
+ - !ruby/object:YggDemo::User
137
+ name: Jane Eyre
138
+ - !ruby/object:YggDemo::User
139
+ name: Jane Eyre
140
+ - !ruby/object:YggDemo::User
141
+ name: Jane Eyre
142
+ - !ruby/object:YggDemo::User
143
+ name: Jane Eyre
144
+ - !ruby/object:YggDemo::User
145
+ name: Jane Eyre
146
+ - !ruby/object:YggDemo::User
147
+ name: Jane Eyre
148
+ - !ruby/object:YggDemo::User
149
+ name: Jane Eyre
150
+ - !ruby/object:YggDemo::User
151
+ name: Jane Eyre
152
+ - !ruby/object:YggDemo::User
153
+ name: Jane Eyre
154
+ - !ruby/object:YggDemo::User
155
+ name: Jane Eyre
156
+ - !ruby/object:YggDemo::User
157
+ name: Jane Eyre
158
+ - !ruby/object:YggDemo::User
159
+ name: Jane Eyre
160
+ - !ruby/object:YggDemo::User
161
+ name: Jane Eyre
162
+ - !ruby/object:YggDemo::User
163
+ name: Jane Eyre
164
+ - !ruby/object:YggDemo::User
165
+ name: Jane Eyre
166
+ - !ruby/object:YggDemo::User
167
+ name: Jane Eyre
168
+ - !ruby/object:YggDemo::User
169
+ name: Jane Eyre
170
+ - !ruby/object:YggDemo::User
171
+ name: Jane Eyre
172
+ - !ruby/object:YggDemo::User
173
+ name: Jane Eyre
174
+ - !ruby/object:YggDemo::User
175
+ name: Jane Eyre
176
+ - !ruby/object:YggDemo::User
177
+ name: Jane Eyre
@@ -0,0 +1,153 @@
1
+ ---
2
+ - !ruby/object:YggDemo::User
3
+ name: Susan Surrender Susan
4
+ - !ruby/object:YggDemo::User
5
+ name: Jane Eyre
6
+ - !ruby/object:YggDemo::User
7
+ name: Jane Eyre
8
+ - !ruby/object:YggDemo::User
9
+ name: Jane Eyre
10
+ - !ruby/object:YggDemo::User
11
+ name: Jane Eyre
12
+ - !ruby/object:YggDemo::User
13
+ name: Jane Eyre
14
+ - !ruby/object:YggDemo::User
15
+ name: Jane Eyre
16
+ - !ruby/object:YggDemo::User
17
+ name: Jane Eyre
18
+ - !ruby/object:YggDemo::User
19
+ name: Jane Eyre
20
+ - !ruby/object:YggDemo::User
21
+ name: Jane Eyre
22
+ - !ruby/object:YggDemo::User
23
+ name: Jane Eyre
24
+ - !ruby/object:YggDemo::User
25
+ name: Jane Eyre
26
+ - !ruby/object:YggDemo::User
27
+ name: Jane Eyre
28
+ - !ruby/object:YggDemo::User
29
+ name: Jane Eyre
30
+ - !ruby/object:YggDemo::User
31
+ name: Jane Eyre
32
+ - !ruby/object:YggDemo::User
33
+ name: Jane Eyre
34
+ - !ruby/object:YggDemo::User
35
+ name: Jane Eyre
36
+ - !ruby/object:YggDemo::User
37
+ name: Jane Eyre
38
+ - !ruby/object:YggDemo::User
39
+ name: Jane Eyre
40
+ - !ruby/object:YggDemo::User
41
+ name: Jane Eyre
42
+ - !ruby/object:YggDemo::User
43
+ name: Jane Eyre
44
+ - !ruby/object:YggDemo::User
45
+ name: Jane Eyre
46
+ - !ruby/object:YggDemo::User
47
+ name: Jane Eyre
48
+ - !ruby/object:YggDemo::User
49
+ name: Jane Eyre
50
+ - !ruby/object:YggDemo::User
51
+ name: Jane Eyre
52
+ - !ruby/object:YggDemo::User
53
+ name: Jane Eyre
54
+ - !ruby/object:YggDemo::User
55
+ name: Jane Eyre
56
+ - !ruby/object:YggDemo::User
57
+ name: Jane Eyre
58
+ - !ruby/object:YggDemo::User
59
+ name: Jane Eyre
60
+ - !ruby/object:YggDemo::User
61
+ name: Jane Eyre
62
+ - !ruby/object:YggDemo::User
63
+ name: Jane Eyre
64
+ - !ruby/object:YggDemo::User
65
+ name: Jane Eyre
66
+ - !ruby/object:YggDemo::User
67
+ name: Jane Eyre
68
+ - !ruby/object:YggDemo::User
69
+ name: Jane Eyre
70
+ - !ruby/object:YggDemo::User
71
+ name: Jane Eyre
72
+ - !ruby/object:YggDemo::User
73
+ name: Jane Eyre
74
+ - !ruby/object:YggDemo::User
75
+ name: Jane Eyre
76
+ - !ruby/object:YggDemo::User
77
+ name: Jane Eyre
78
+ - !ruby/object:YggDemo::User
79
+ name: Jane Eyre
80
+ - !ruby/object:YggDemo::User
81
+ name: Jane Eyre
82
+ - !ruby/object:YggDemo::User
83
+ name: Jane Eyre
84
+ - !ruby/object:YggDemo::User
85
+ name: Jane Eyre
86
+ - !ruby/object:YggDemo::User
87
+ name: Jane Eyre
88
+ - !ruby/object:YggDemo::User
89
+ name: Jane Eyre
90
+ - !ruby/object:YggDemo::User
91
+ name: Jane Eyre
92
+ - !ruby/object:YggDemo::User
93
+ name: Jane Eyre
94
+ - !ruby/object:YggDemo::User
95
+ name: Jane Eyre
96
+ - !ruby/object:YggDemo::User
97
+ name: Jane Eyre
98
+ - !ruby/object:YggDemo::User
99
+ name: Jane Eyre
100
+ - !ruby/object:YggDemo::User
101
+ name: Jane Eyre
102
+ - !ruby/object:YggDemo::User
103
+ name: Jane Eyre
104
+ - !ruby/object:YggDemo::User
105
+ name: Jane Eyre
106
+ - !ruby/object:YggDemo::User
107
+ name: Jane Eyre
108
+ - !ruby/object:YggDemo::User
109
+ name: Jane Eyre
110
+ - !ruby/object:YggDemo::User
111
+ name: Jane Eyre
112
+ - !ruby/object:YggDemo::User
113
+ name: Jane Eyre
114
+ - !ruby/object:YggDemo::User
115
+ name: Jane Eyre
116
+ - !ruby/object:YggDemo::User
117
+ name: Jane Eyre
118
+ - !ruby/object:YggDemo::User
119
+ name: Jane Eyre
120
+ - !ruby/object:YggDemo::User
121
+ name: Jane Eyre
122
+ - !ruby/object:YggDemo::User
123
+ name: Jane Eyre
124
+ - !ruby/object:YggDemo::User
125
+ name: Jane Eyre
126
+ - !ruby/object:YggDemo::User
127
+ name: Jane Eyre
128
+ - !ruby/object:YggDemo::User
129
+ name: Jane Eyre
130
+ - !ruby/object:YggDemo::User
131
+ name: Jane Eyre
132
+ - !ruby/object:YggDemo::User
133
+ name: Jane Eyre
134
+ - !ruby/object:YggDemo::User
135
+ name: Jane Eyre
136
+ - !ruby/object:YggDemo::User
137
+ name: Jane Eyre
138
+ - !ruby/object:YggDemo::User
139
+ name: Jane Eyre
140
+ - !ruby/object:YggDemo::User
141
+ name: Jane Eyre
142
+ - !ruby/object:YggDemo::User
143
+ name: Jane Eyre
144
+ - !ruby/object:YggDemo::User
145
+ name: Jane Eyre
146
+ - !ruby/object:YggDemo::User
147
+ name: Jane Eyre
148
+ - !ruby/object:YggDemo::User
149
+ name: Jane Eyre
150
+ - !ruby/object:YggDemo::User
151
+ name: Jane Eyre
152
+ - !ruby/object:YggDemo::User
153
+ name: Jane Eyre
@@ -0,0 +1,6 @@
1
+ ---
2
+ - !ruby/object:YggDemo::User
3
+ name: Xavier Via
4
+ - !ruby/object:YggDemo::Account
5
+ amount: 45
6
+ currency: us
@@ -0,0 +1,3 @@
1
+ ---
2
+ - !ruby/object:YggDemo::User
3
+ name: Jane Eyre
@@ -0,0 +1,16 @@
1
+ require "yaml"
2
+
3
+ OUTPUT_FILE = "tree.ygg"
4
+
5
+ class User
6
+ attr_accessor :name, :nick
7
+ def initialize(name, nick)
8
+ @name = name; @nick = nick
9
+ end
10
+ end
11
+
12
+ the_users = [ User.new("Xavier Via", "xav"), User.new("Gonzalo Rube", "gon") ]
13
+
14
+ File.open OUTPUT_FILE, "w" do |file|
15
+ file.write the_users.to_yaml
16
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ - !ruby/object:User
3
+ name: Xavier Via
4
+ nick: xav
5
+ - !ruby/object:User
6
+ name: Gonzalo Rube
7
+ nick: gon
@@ -0,0 +1,26 @@
1
+ Feature: Accessors to loaded resources (object)
2
+ In order to conveniently access loadad resources
3
+ As a Ygg user
4
+ I want to setup useful accessors
5
+
6
+ Scenario: Getting all objects of type User and Account
7
+ Given the class User has the field :name
8
+ And the class Account has the field :amount
9
+ And the class Account has the field :currency
10
+ And the file "emulations/samples/user.ygg" contains:
11
+ """
12
+ - !ruby/object:YggDemo::User
13
+ name: Xavier Via
14
+ - !ruby/object:YggDemo::Account
15
+ amount: 45
16
+ currency: us
17
+ """
18
+ When I load the file and request for objects of type User
19
+ Then I should get an user named "Xavier Via"
20
+
21
+ Scenario: The User is a Record
22
+ Given the class User has the field :name
23
+ And extends Record
24
+ And I have the file "emulations/samples/user.ygg"
25
+ When I load the file and ask User for records
26
+ Then I should get an user named "Xavier Via"