rails3-generators 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = rails3-generators
2
2
 
3
- Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic and Mongomapper
3
+ Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper, and Mongoid
4
4
 
5
5
  == Note on Patches/Pull Requests
6
6
 
@@ -19,3 +19,5 @@ Authlogic: Jeff Tucker
19
19
  MongoMapper: Jai-Gouk Kim
20
20
 
21
21
  Machinist: Darcy Laycock
22
+
23
+ Mongoid: Guillaume Belleguic
data/Rakefile CHANGED
@@ -6,10 +6,10 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "rails3-generators"
8
8
  gem.summary = %Q{Rails 3 compatible generators}
9
- gem.description = %Q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper and Machinist}
9
+ gem.description = %Q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper, and Mongoid}
10
10
  gem.email = "andre@arko.net"
11
11
  gem.homepage = "http://github.com/indirect/rails3-generators"
12
- gem.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim", "Darcy Laycock"]
12
+ gem.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim", "Darcy Laycock", "Guillaume Belleguic"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  end
15
15
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -0,0 +1,21 @@
1
+ require 'generators/mongoid'
2
+
3
+ module Mongoid
4
+ module Generators
5
+ class ModelGenerator < Base
6
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
+
8
+ check_class_collision
9
+
10
+ class_option :timestamps, :type => :boolean, :default => true
11
+ class_option :parent, :type => :string, :desc => "The parent class for the generated model"
12
+ class_option :versioning, :type => :boolean, :default => false, :desc => "Enable mongoid versioning"
13
+
14
+ def create_model_file
15
+ template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
16
+ end
17
+
18
+ hook_for :test_framework
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class <%= class_name %><%= "< #{options[:parent].classify}" if options[:parent] %>
2
+ <% unless options[:parent] -%>
3
+ include Mongoid::Document
4
+ <% if options[:timestamps] %>
5
+ include Mongoid::Timestamps
6
+ <% end %>
7
+ <% if options[:versioning] %>
8
+ include Mongoid::Versioning
9
+ <% end %>
10
+ <% end -%>
11
+ <% attributes.each do |attribute| -%>
12
+ field :<%= attribute.name %>, :type => <%= attribute.type_class %>
13
+ <% end -%>
14
+ end
@@ -0,0 +1,61 @@
1
+ require 'rails/generators/named_base'
2
+ # require 'rails/generators/migration'
3
+ require 'rails/generators/active_model'
4
+
5
+ module Mongoid
6
+ module Generators
7
+ class Base < Rails::Generators::NamedBase #:nodoc:
8
+
9
+ def self.source_root
10
+ @_mongoid_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
11
+ 'mongoid', generator_name, 'templates'))
12
+ end
13
+
14
+ end
15
+
16
+ class ActiveModel < Rails::Generators::ActiveModel #:nodoc:
17
+ def self.all(klass)
18
+ "#{klass}.all"
19
+ end
20
+
21
+ def self.find(klass, params=nil)
22
+ "#{klass}.first(#{params})"
23
+ end
24
+
25
+ def self.build(klass, params=nil)
26
+ if params
27
+ "#{klass}.new(#{params})"
28
+ else
29
+ "#{klass}.new"
30
+ end
31
+ end
32
+
33
+ def save
34
+ "#{name}.save"
35
+ end
36
+
37
+ def update_attributes(params=nil)
38
+ "#{name}.update(#{params})"
39
+ end
40
+
41
+ def errors
42
+ "#{name}.errors"
43
+ end
44
+
45
+ def destroy
46
+ "#{name}.destroy"
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ module Rails
53
+ module Generators
54
+ class GeneratedAttribute #:nodoc:
55
+ def type_class
56
+ return 'DateTime' if type.to_s == 'datetime'
57
+ return type.to_s.camelcase
58
+ end
59
+ end
60
+ end
61
+ end
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3-generators}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim", "Darcy Laycock"]
12
- s.date = %q{2010-03-28}
13
- s.description = %q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper and Machinist}
11
+ s.authors = ["Jose Valim", "Anuj Dutta", "Paul Berry", "Jeff Tucker", "Louis T.", "Jai-Gouk Kim", "Darcy Laycock", "Guillaume Belleguic"]
12
+ s.date = %q{2010-04-02}
13
+ s.description = %q{Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper, and Mongoid}
14
14
  s.email = %q{andre@arko.net}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
@@ -70,6 +70,9 @@ Gem::Specification.new do |s|
70
70
  "lib/generators/machinist/model/model_generator.rb",
71
71
  "lib/generators/machinist/model/templates/blueprint.rb",
72
72
  "lib/generators/machinist/model/templates/machinist_initializer.rb",
73
+ "lib/generators/mongoid.rb",
74
+ "lib/generators/mongoid/model/model_generator.rb",
75
+ "lib/generators/mongoid/model/templates/model.rb",
73
76
  "lib/generators/mongomapper.rb",
74
77
  "lib/generators/mongomapper/model/model_generator.rb",
75
78
  "lib/generators/mongomapper/model/templates/model.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 3
9
- version: 0.5.3
8
+ - 4
9
+ version: 0.5.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Valim
@@ -16,11 +16,12 @@ authors:
16
16
  - Louis T.
17
17
  - Jai-Gouk Kim
18
18
  - Darcy Laycock
19
+ - Guillaume Belleguic
19
20
  autorequire:
20
21
  bindir: bin
21
22
  cert_chain: []
22
23
 
23
- date: 2010-03-28 00:00:00 -04:00
24
+ date: 2010-04-02 00:00:00 -04:00
24
25
  default_executable:
25
26
  dependencies:
26
27
  - !ruby/object:Gem::Dependency
@@ -37,7 +38,7 @@ dependencies:
37
38
  version: 1.2.9
38
39
  type: :development
39
40
  version_requirements: *id001
40
- description: Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper and Machinist
41
+ description: Rails 3 compatible generators for DataMapper, Haml, Factory-girl, Authlogic, Mongomapper, and Mongoid
41
42
  email: andre@arko.net
42
43
  executables: []
43
44
 
@@ -100,6 +101,9 @@ files:
100
101
  - lib/generators/machinist/model/model_generator.rb
101
102
  - lib/generators/machinist/model/templates/blueprint.rb
102
103
  - lib/generators/machinist/model/templates/machinist_initializer.rb
104
+ - lib/generators/mongoid.rb
105
+ - lib/generators/mongoid/model/model_generator.rb
106
+ - lib/generators/mongoid/model/templates/model.rb
103
107
  - lib/generators/mongomapper.rb
104
108
  - lib/generators/mongomapper/model/model_generator.rb
105
109
  - lib/generators/mongomapper/model/templates/model.rb