Permalink
Browse files

fixed rake tasks

  • Loading branch information...
brantwedel committed Mar 17, 2014
1 parent 888dde4 commit e1d446f3ea0035d31596758a367cefdb5a849510
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
yaddl (0.0.2)
yaddl (0.0.4)
rails (~> 4.0.0)
GEM
View
@@ -1,14 +1,14 @@
= Yaddl
# Yaddl
This project rocks and uses MIT-LICENSE.
= Usage
# Usage
```
rake yaddl:models
```
== Example Input
### Example Input
/db/schema.yaddl
```ruby
@@ -17,7 +17,7 @@ TestModel(name:string)
*RelatedModel
```
== Output
### Output
/app/models/test_model.rb
```
@@ -46,7 +46,7 @@ end
```
= Syntax
# Syntax
Legend:
- attribute:type - a model attribute; inline format will create 'primary references' for display ex: Model(name:string)
File renamed without changes.
View
@@ -1,4 +1,5 @@
module Yaddl
require "yaddl/railtie" if defined?(Rails)
class Generator
attr_accessor :markup
@@ -807,6 +808,5 @@ def parse_line(line, models, stack, depth)
end
end
View
@@ -0,0 +1,11 @@
require 'yaddl'
require 'rails'
module Yaddl
class Railtie < Rails::Railtie
railtie_name :yaddl
rake_tasks do
load "tasks/yaddl.rake"
end
end
end
View
@@ -1,3 +1,3 @@
module Yaddl
VERSION = "0.0.4"
VERSION = "0.0.5"
end
@@ -0,0 +1,5 @@
class RelatedModel < ActiveRecord::Base
belongs_to :test_model
attr_accessible :test_model_id
end
@@ -0,0 +1,12 @@
class TestModel < ActiveRecord::Base
has_many :related_models, dependent: :destroy
attr_accessible :name
accepts_nested_attributes_for :related_models
# returns: string
def to_s
name
end
end
View
@@ -0,0 +1,21 @@
---
TestModel:
attributes:
name:
type: string
primary_ref:
-
methods:
to_s:
returns: string
getter: name
has_many:
related_models:
dependent: destroy
class_names:
- RelatedModel
RelatedModel:
belongs_to:
test_model:
class_names:
- TestModel
View
@@ -4,6 +4,7 @@ class YaddlTest < ActiveSupport::TestCase
test "defined" do
assert_kind_of Module, Yaddl
end
test "create test model" do
y = Yaddl::Generator.new
y.markup = "TestModel(name:string)
@@ -23,19 +24,21 @@ def to_s
end
end
"
assert_file "app/models/related_model.rb", "class RelatedModel < ActiveRecord::Base
belongs_to :test_model
attr_accessible :test_model_id
end
"
assert_file "db/schema.yaml", "---
TestModel:
attributes:
name:
type: string
primary_ref:
-
-
methods:
to_s:
returns: string
View
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.summary = "Yet Another Data Definition Language"
s.description = "A concise data definition language and generator for active record with the ability to properly map model associations"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 4.0.0"

0 comments on commit e1d446f

Please sign in to comment.