ygg 0.0.2 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -14
- data/emulations/samples/event.ygg +3 -0
- data/emulations/samples/invalid_resource.ygg +10 -0
- data/emulations/samples/to_modify.ygg +177 -0
- data/emulations/samples/to_modify_2.ygg +153 -0
- data/emulations/samples/user.ygg +6 -0
- data/emulations/samples/valid.ygg +3 -0
- data/emulations/save_yaml_object.rb +16 -0
- data/emulations/tree.ygg +7 -0
- data/features/accessors.feature +26 -0
- data/features/dsl.feature +24 -0
- data/features/events.feature +17 -0
- data/features/simple_record.feature +40 -0
- data/features/steps/accessors.rb +8 -0
- data/features/steps/dsl.rb +20 -0
- data/features/steps/events.rb +12 -0
- data/features/steps/simple_record.rb +104 -0
- data/features/support/env.rb +2 -0
- data/features/support/hooks.rb +3 -0
- data/lib/ygg.rb +97 -3
- data/lib/ygg/bck/base.rb +63 -0
- data/lib/ygg/bck/branch.rb +31 -0
- data/lib/ygg/bck/exceptions.rb +3 -0
- data/lib/ygg/bck/link.rb +6 -0
- data/lib/ygg/{base.rb → bck/model.rb} +7 -107
- data/lib/ygg/databundle.rb +25 -0
- data/lib/ygg/exceptions.rb +6 -0
- data/lib/ygg/record.rb +7 -0
- data/lib/ygg/session.rb +44 -0
- data/lib/ygg/version.rb +3 -3
- data/spec/spec_helper.rb +61 -0
- data/spec/ygg/databundle_spec.rb +54 -0
- data/spec/ygg/session_spec.rb +203 -0
- data/spec/ygg/ygg_spec.rb +364 -0
- data/ygg.gemspec +5 -0
- metadata +67 -4
data/README.rdoc
CHANGED
@@ -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
|
-
|
14
|
+
key :name, :pass
|
15
15
|
end
|
16
16
|
|
17
17
|
class Article < Ygg::Model
|
18
|
-
|
18
|
+
key :title, :content
|
19
19
|
end
|
20
20
|
|
21
|
-
|
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
|
-
|
28
|
-
|
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
|
-
|
28
|
+
user & article # This declaration creations a relationships between the user and the article
|
32
29
|
|
33
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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,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,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
|
data/emulations/tree.ygg
ADDED
@@ -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"
|