meta_rails 0.0.1.beta3 → 0.0.1.beta4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,9 @@ class MetaRailsGenerator < Rails::Generators::NamedBase
18
18
  @m = canonicalize_model(m)
19
19
  template 'model.rb.erb', "app/models/#{@m.name.underscore}.rb"
20
20
  migration << migration_template.result(binding)
21
+ if @m.resource
22
+ template 'controller.rb.erb', "app/controller/#{@m.name.underscore.pluralize}_controller.rb"
23
+ end
21
24
  end
22
25
 
23
26
  File.open('./meta_rails_migration.rb', 'w') do |f|
@@ -33,6 +36,7 @@ class MetaRailsGenerator < Rails::Generators::NamedBase
33
36
  def canonicalize_model(m)
34
37
  return OpenStruct.new({
35
38
  :name => m['name'],
39
+ :resource => !!m['resource'],
36
40
  :belongs_to => Array(m['belongs_to']),
37
41
  :has_many => Array(m['has_many']),
38
42
  :fields => Array(m['fields']).collect { |f| canonicalize_field(f) }
@@ -0,0 +1,40 @@
1
+ module MetaRails
2
+ module Restable
3
+ def self.included(klass)
4
+ klass.send(:extend, ClassMethods)
5
+ end
6
+
7
+ def index
8
+ end
9
+
10
+ def new
11
+ end
12
+
13
+ def update
14
+ end
15
+
16
+ def delete
17
+ end
18
+
19
+ private
20
+
21
+ def model_class
22
+ return self.class.model_class
23
+ end
24
+
25
+ def model_name
26
+ end
27
+
28
+ def models_name
29
+ end
30
+
31
+ module ClassMethods
32
+ def model_class(klass=nil)
33
+ @class = klass if klass
34
+ return @class
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ end
@@ -0,0 +1,4 @@
1
+ class <%= @m.name.pluralize.titleize %>Controller < ActionController
2
+ include MetaRails::Restable
3
+ model_class <%= @.name.titleize %>
4
+ end
@@ -1,6 +1,6 @@
1
1
  create_table :<%= @m.name.tableize %> do |t|
2
- <%= @m.fields.collect { |f| "t.#{f.type} :#{f.name}" }.join("\n") %>
3
- <%= @m.belongs_to.collect { |b| "t.references :#{b.underscore}" }.join("\n") %>
2
+ <%= @m.fields.collect { |f| " t.#{f.type} :#{f.name}" }.join("\n") %>
3
+ <%= @m.belongs_to.collect { |b| " t.references :#{b.underscore}" }.join("\n") %>
4
4
  t.timestamps
5
5
  end
6
- <%= @m.belongs_to.collect { |b| "add_index :#{@m.name.tableize}, :#{b.underscore}_id" } %>
6
+ <%= @m.belongs_to.collect { |b| " add_index :#{@m.name.tableize}, :#{b.underscore}_id" }.join("\n") %>
@@ -1,4 +1,4 @@
1
1
  class <%= @m.name.classify %> < ActiveRecord::Base
2
- <%= @m.has_many.collect { |hm| "has_many :#{hm}" }.join("\n") %>
3
- <%= @m.belongs_to.collect { |b| "belongs_to :#{b}" }.join("\n") %>
2
+ <%= @m.has_many.collect { |hm| " has_many :#{hm}" }.join("\n") %>
3
+ <%= @m.belongs_to.collect { |b| " belongs_to :#{b}" }.join("\n") %>
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module MetaRails
2
- VERSION = "0.0.1.beta3"
2
+ VERSION = "0.0.1.beta4"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: meta_rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.0.1.beta3
5
+ version: 0.0.1.beta4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Su
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-15 00:00:00 -07:00
14
- default_executable:
13
+ date: 2011-09-28 00:00:00 Z
15
14
  dependencies: []
16
15
 
17
16
  description: Use one YAML file to describe the scaffolding of your rails project
@@ -30,11 +29,12 @@ files:
30
29
  - lib/meta_rails.rb
31
30
  - lib/meta_rails/USAGE
32
31
  - lib/meta_rails/generator.rb
32
+ - lib/meta_rails/restable.rb
33
+ - lib/meta_rails/templates/controller.rb.erb
33
34
  - lib/meta_rails/templates/migration.erb
34
35
  - lib/meta_rails/templates/model.rb.erb
35
36
  - lib/meta_rails/version.rb
36
37
  - meta_rails.gemspec
37
- has_rdoc: true
38
38
  homepage: ""
39
39
  licenses: []
40
40
 
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements: []
59
59
 
60
60
  rubyforge_project: meta_rails
61
- rubygems_version: 1.6.2
61
+ rubygems_version: 1.8.9
62
62
  signing_key:
63
63
  specification_version: 3
64
64
  summary: Quick rails model prototyping