couchrest_model_thought 1.0.0.beta8 → 1.0.0.beta9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://gemcutter.org"
2
2
 
3
- gem 'rails', '3.0.0.beta4'
4
- gem 'couchrest', '1.0.0.beta2'
3
+ gem 'rails', '3.0.0.rc'
4
+ gem 'couchrest', '1.0.0.beta3'
5
5
  gem 'couchrest_extended_document', '1.0.0.beta6'
6
6
  gem 'activesupport'
7
7
  gem 'activemodel'
@@ -1,5 +1,5 @@
1
1
  module CouchRest
2
2
  module Model
3
- VERSION = "1.0.0.beta8".freeze
3
+ VERSION = "1.0.0.beta9".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,69 @@
1
+ module Couchrest
2
+ module Generators
3
+ class CouchrestGenerator < Rails::Generators::NamedBase
4
+
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
8
+
9
+ check_class_collision
10
+
11
+ class_option :timestamps, :type => :boolean
12
+ class_option :parent, :type => :string, :desc => "The parent class for the generated model"
13
+
14
+ def create_model_file
15
+ template 'model.erb', File.join('app/models', class_path, "#{file_name}.rb")
16
+ end
17
+
18
+ hook_for :test_framework
19
+
20
+ end
21
+
22
+ class ActiveModel < Rails::Generators::ActiveModel
23
+ def self.all(klass)
24
+ "#{klass}.all"
25
+ end
26
+
27
+ def self.find(klass, params=nil)
28
+ "#{klass}.get(#{params})"
29
+ end
30
+
31
+ def self.build(klass, params=nil)
32
+ if params
33
+ "#{klass}.new(#{params})"
34
+ else
35
+ "#{klass}.new"
36
+ end
37
+ end
38
+
39
+ def save
40
+ "#{name}.save"
41
+ end
42
+
43
+ def update_attributes(params=nil)
44
+ "#{name}.update(#{params})"
45
+ end
46
+
47
+ def errors
48
+ "#{name}.errors"
49
+ end
50
+
51
+ def destroy
52
+ "#{name}.destroy"
53
+ end
54
+ end
55
+
56
+ end
57
+ end
58
+
59
+ module Rails
60
+ module Generators
61
+ class GeneratedAttribute #:nodoc:
62
+ def declaration
63
+ declaration = @name
64
+ declaration << ", :cast_as => '#{@type}'" unless !self.default.to_s.empty?
65
+ declaration
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,24 @@
1
+ module Couchrest
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ desc "Creates a CouchRest initializer for your application."
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_initializer
10
+ template "couch_config.rb", "config/initializers/couch_config.rb"
11
+ end
12
+
13
+ def show_readme
14
+ readme "README"
15
+ end
16
+
17
+ protected
18
+
19
+ def readme(path)
20
+ say File.read(File.expand_path(path, self.class.source_root))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+
2
+ ===============================================================================
3
+
4
+ Thanks for using CouchRest_Model
5
+
6
+ ===============================================================================
@@ -0,0 +1,8 @@
1
+ CouchConfig.setup do |config|
2
+
3
+ config.database_name = 'development'
4
+
5
+ # For being Used Later
6
+ config.design_directory = ''
7
+
8
+ end
@@ -0,0 +1,9 @@
1
+ class <%= class_name %> < <%= options[:parent] != nil ? options[:parent].classify : 'CouchRest::Model::Base' %>
2
+ use_database '<%= class_name..underscore %>'
3
+ <% attributes.each do |attribute| -%>
4
+ property :<%= attribute.declaration %>
5
+ <% end %>
6
+
7
+ timestamps!
8
+
9
+ end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 0
9
- - beta8
10
- version: 1.0.0.beta8
9
+ - beta9
10
+ version: 1.0.0.beta9
11
11
  platform: ruby
12
12
  authors:
13
13
  - J. Chris Anderson
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-07-21 00:00:00 +03:00
22
+ date: 2010-07-30 00:00:00 +03:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -141,6 +141,11 @@ files:
141
141
  - lib/couchrest/model/class_proxy.rb
142
142
  - lib/couchrest/model/associations.rb
143
143
  - lib/couchrest/model.rb
144
+ - lib/generators/couchrest/install_generator.rb
145
+ - lib/generators/couchrest/couch_rest_generator.rb
146
+ - lib/generators/couchrest/templates/model.erb
147
+ - lib/generators/couchrest/templates/README
148
+ - lib/generators/couchrest/templates/couch_config.rb
144
149
  - spec/spec.opts
145
150
  - spec/couchrest/view_spec.rb
146
151
  - spec/couchrest/persistence_spec.rb