yaddl 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +68 -0
- data/lib/tasks/{yaddl_tasks.rake → yaddl.rake} +0 -0
- data/lib/yaddl.rb +1 -1
- data/lib/yaddl/railtie.rb +11 -0
- data/lib/yaddl/version.rb +1 -1
- data/test/dummy/app/models/related_model.rb +5 -0
- data/test/dummy/app/models/test_model.rb +12 -0
- data/test/dummy/db/schema.yaml +21 -0
- data/test/dummy/log/test.log +50 -0
- data/test/yaddl_test.rb +4 -1
- metadata +10 -2
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Yaddl
|
2
|
+
|
3
|
+
This project rocks and uses MIT-LICENSE.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
```
|
8
|
+
rake yaddl:models
|
9
|
+
```
|
10
|
+
|
11
|
+
### Example Input
|
12
|
+
|
13
|
+
/db/schema.yaddl
|
14
|
+
```ruby
|
15
|
+
TestModel(name:string)
|
16
|
+
=to_s{name}
|
17
|
+
*RelatedModel
|
18
|
+
```
|
19
|
+
|
20
|
+
### Output
|
21
|
+
|
22
|
+
/app/models/test_model.rb
|
23
|
+
```
|
24
|
+
class TestModel < ActiveRecord::Base
|
25
|
+
has_many :related_models, dependent: :destroy
|
26
|
+
|
27
|
+
attr_accessible :name
|
28
|
+
|
29
|
+
accepts_nested_attributes_for :related_models
|
30
|
+
|
31
|
+
# returns: string
|
32
|
+
def to_s
|
33
|
+
name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
/app/models/related_model.rb
|
40
|
+
```
|
41
|
+
class RelatedModel < ActiveRecord::Base
|
42
|
+
belongs_to :test_model
|
43
|
+
|
44
|
+
attr_accessible :test_model_id
|
45
|
+
end
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
# Syntax
|
50
|
+
|
51
|
+
Legend:
|
52
|
+
- attribute:type - a model attribute; inline format will create 'primary references' for display ex: Model(name:string)
|
53
|
+
- =function - an property that is calculated not stored =value{ "ruby code" }
|
54
|
+
- ==setter - a property setter ex: ==value{ self.database_value = value; self.save }
|
55
|
+
- &cached - a value or model that is cached until a condition is met &cached{ 'condition summary' }
|
56
|
+
- Reference - has_one
|
57
|
+
- +Reference - belongs_to
|
58
|
+
- *Multiplicity - has_many
|
59
|
+
- **ManyToMany:OptionalBackingTable(join_model:attributes) - has and belongs to many
|
60
|
+
- attribute:*Reference - polymorphic association reference entry
|
61
|
+
- @Mixin - define or use mixin
|
62
|
+
- ___ - mixin name placeholder for named:@Mixin (these work in mixin code blocks and mixin attribute names)
|
63
|
+
- mmm/MMM(s) - model name placeholders (these work in any code blocks and mixin attribute names)
|
64
|
+
- {ruby_code} - ruby_code will be added to model
|
65
|
+
- !controller{ruby_code} - ruby_code will be added to controller
|
66
|
+
- !!{ruby_code} - unique ruby_code will be added to model only once
|
67
|
+
- if, unless, def, module, class - ruby code blocks (else and elsif are not currently supported at root)
|
68
|
+
- include, require, has_many, serialize, etc. - single line ruby methods
|
File without changes
|
data/lib/yaddl.rb
CHANGED
data/lib/yaddl/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
TestModel:
|
3
|
+
attributes:
|
4
|
+
name:
|
5
|
+
type: string
|
6
|
+
primary_ref:
|
7
|
+
-
|
8
|
+
methods:
|
9
|
+
to_s:
|
10
|
+
returns: string
|
11
|
+
getter: name
|
12
|
+
has_many:
|
13
|
+
related_models:
|
14
|
+
dependent: destroy
|
15
|
+
class_names:
|
16
|
+
- RelatedModel
|
17
|
+
RelatedModel:
|
18
|
+
belongs_to:
|
19
|
+
test_model:
|
20
|
+
class_names:
|
21
|
+
- TestModel
|
data/test/dummy/log/test.log
CHANGED
@@ -58,3 +58,53 @@ YaddlTest: test_create_test_model
|
|
58
58
|
YaddlTest: test_defined
|
59
59
|
-----------------------
|
60
60
|
[1m[35m (0.0ms)[0m rollback transaction
|
61
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
62
|
+
---------------------------------
|
63
|
+
YaddlTest: test_create_test_model
|
64
|
+
---------------------------------
|
65
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
66
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
67
|
+
-----------------------
|
68
|
+
YaddlTest: test_defined
|
69
|
+
-----------------------
|
70
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
71
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
72
|
+
---------------------------------
|
73
|
+
YaddlTest: test_create_test_model
|
74
|
+
---------------------------------
|
75
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
76
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
77
|
+
-----------------------
|
78
|
+
YaddlTest: test_defined
|
79
|
+
-----------------------
|
80
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
81
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
82
|
+
---------------------------------
|
83
|
+
YaddlTest: test_create_test_model
|
84
|
+
---------------------------------
|
85
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
86
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
87
|
+
-----------------------
|
88
|
+
YaddlTest: test_defined
|
89
|
+
-----------------------
|
90
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
91
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
92
|
+
---------------------------------
|
93
|
+
YaddlTest: test_create_test_model
|
94
|
+
---------------------------------
|
95
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
96
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
97
|
+
-----------------------
|
98
|
+
YaddlTest: test_defined
|
99
|
+
-----------------------
|
100
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
101
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
102
|
+
---------------------------------
|
103
|
+
YaddlTest: test_create_test_model
|
104
|
+
---------------------------------
|
105
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
106
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
107
|
+
-----------------------
|
108
|
+
YaddlTest: test_defined
|
109
|
+
-----------------------
|
110
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
data/test/yaddl_test.rb
CHANGED
@@ -4,6 +4,7 @@ class YaddlTest < ActiveSupport::TestCase
|
|
4
4
|
test "defined" do
|
5
5
|
assert_kind_of Module, Yaddl
|
6
6
|
end
|
7
|
+
|
7
8
|
test "create test model" do
|
8
9
|
y = Yaddl::Generator.new
|
9
10
|
y.markup = "TestModel(name:string)
|
@@ -23,19 +24,21 @@ class YaddlTest < ActiveSupport::TestCase
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
"
|
27
|
+
|
26
28
|
assert_file "app/models/related_model.rb", "class RelatedModel < ActiveRecord::Base
|
27
29
|
belongs_to :test_model
|
28
30
|
|
29
31
|
attr_accessible :test_model_id
|
30
32
|
end
|
31
33
|
"
|
34
|
+
|
32
35
|
assert_file "db/schema.yaml", "---
|
33
36
|
TestModel:
|
34
37
|
attributes:
|
35
38
|
name:
|
36
39
|
type: string
|
37
40
|
primary_ref:
|
38
|
-
-
|
41
|
+
-
|
39
42
|
methods:
|
40
43
|
to_s:
|
41
44
|
returns: string
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -51,15 +51,19 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
-
- lib/tasks/
|
54
|
+
- lib/tasks/yaddl.rake
|
55
|
+
- lib/yaddl/railtie.rb
|
55
56
|
- lib/yaddl/version.rb
|
56
57
|
- lib/yaddl.rb
|
57
58
|
- MIT-LICENSE
|
58
59
|
- Rakefile
|
60
|
+
- README.md
|
59
61
|
- test/dummy/app/assets/javascripts/application.js
|
60
62
|
- test/dummy/app/assets/stylesheets/application.css
|
61
63
|
- test/dummy/app/controllers/application_controller.rb
|
62
64
|
- test/dummy/app/helpers/application_helper.rb
|
65
|
+
- test/dummy/app/models/related_model.rb
|
66
|
+
- test/dummy/app/models/test_model.rb
|
63
67
|
- test/dummy/app/views/layouts/application.html.erb
|
64
68
|
- test/dummy/bin/bundle
|
65
69
|
- test/dummy/bin/rails
|
@@ -81,6 +85,7 @@ files:
|
|
81
85
|
- test/dummy/config/locales/en.yml
|
82
86
|
- test/dummy/config/routes.rb
|
83
87
|
- test/dummy/config.ru
|
88
|
+
- test/dummy/db/schema.yaml
|
84
89
|
- test/dummy/db/test.sqlite3
|
85
90
|
- test/dummy/log/test.log
|
86
91
|
- test/dummy/public/404.html
|
@@ -120,6 +125,8 @@ test_files:
|
|
120
125
|
- test/dummy/app/assets/stylesheets/application.css
|
121
126
|
- test/dummy/app/controllers/application_controller.rb
|
122
127
|
- test/dummy/app/helpers/application_helper.rb
|
128
|
+
- test/dummy/app/models/related_model.rb
|
129
|
+
- test/dummy/app/models/test_model.rb
|
123
130
|
- test/dummy/app/views/layouts/application.html.erb
|
124
131
|
- test/dummy/bin/bundle
|
125
132
|
- test/dummy/bin/rails
|
@@ -141,6 +148,7 @@ test_files:
|
|
141
148
|
- test/dummy/config/locales/en.yml
|
142
149
|
- test/dummy/config/routes.rb
|
143
150
|
- test/dummy/config.ru
|
151
|
+
- test/dummy/db/schema.yaml
|
144
152
|
- test/dummy/db/test.sqlite3
|
145
153
|
- test/dummy/log/test.log
|
146
154
|
- test/dummy/public/404.html
|