yaddl 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,4 +1,5 @@
1
1
  module Yaddl
2
+ require "yaddl/railtie" if defined?(Rails)
2
3
  class Generator
3
4
 
4
5
  attr_accessor :markup
@@ -807,6 +808,5 @@ end.join } <td><%= link_to 'Show', #{name.underscore} %></td>
807
808
 
808
809
 
809
810
 
810
-
811
811
  end
812
812
  end
@@ -0,0 +1,11 @@
1
+ require 'yaddl'
2
+ require 'rails'
3
+ module Yaddl
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :yaddl
6
+
7
+ rake_tasks do
8
+ load "tasks/yaddl.rake"
9
+ end
10
+ end
11
+ end
data/lib/yaddl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yaddl
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,5 @@
1
+ class RelatedModel < ActiveRecord::Base
2
+ belongs_to :test_model
3
+
4
+ attr_accessible :test_model_id
5
+ end
@@ -0,0 +1,12 @@
1
+ class TestModel < ActiveRecord::Base
2
+ has_many :related_models, dependent: :destroy
3
+
4
+ attr_accessible :name
5
+
6
+ accepts_nested_attributes_for :related_models
7
+
8
+ # returns: string
9
+ def to_s
10
+ name
11
+ end
12
+ end
@@ -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
@@ -58,3 +58,53 @@ YaddlTest: test_create_test_model
58
58
  YaddlTest: test_defined
59
59
  -----------------------
60
60
   (0.0ms) rollback transaction
61
+  (0.4ms) begin transaction
62
+ ---------------------------------
63
+ YaddlTest: test_create_test_model
64
+ ---------------------------------
65
+  (0.2ms) rollback transaction
66
+  (0.1ms) begin transaction
67
+ -----------------------
68
+ YaddlTest: test_defined
69
+ -----------------------
70
+  (0.1ms) rollback transaction
71
+  (0.3ms) begin transaction
72
+ ---------------------------------
73
+ YaddlTest: test_create_test_model
74
+ ---------------------------------
75
+  (0.2ms) rollback transaction
76
+  (0.1ms) begin transaction
77
+ -----------------------
78
+ YaddlTest: test_defined
79
+ -----------------------
80
+  (0.1ms) rollback transaction
81
+  (0.3ms) begin transaction
82
+ ---------------------------------
83
+ YaddlTest: test_create_test_model
84
+ ---------------------------------
85
+  (0.1ms) rollback transaction
86
+  (0.1ms) begin transaction
87
+ -----------------------
88
+ YaddlTest: test_defined
89
+ -----------------------
90
+  (0.0ms) rollback transaction
91
+  (0.3ms) begin transaction
92
+ ---------------------------------
93
+ YaddlTest: test_create_test_model
94
+ ---------------------------------
95
+  (0.1ms) rollback transaction
96
+  (0.1ms) begin transaction
97
+ -----------------------
98
+ YaddlTest: test_defined
99
+ -----------------------
100
+  (0.1ms) rollback transaction
101
+  (0.3ms) begin transaction
102
+ ---------------------------------
103
+ YaddlTest: test_create_test_model
104
+ ---------------------------------
105
+  (0.1ms) rollback transaction
106
+  (0.1ms) begin transaction
107
+ -----------------------
108
+ YaddlTest: test_defined
109
+ -----------------------
110
+  (0.1ms) 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
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/yaddl_tasks.rake
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