smart_model 0.3.4 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/README.rdoc CHANGED
@@ -1,61 +1,69 @@
1
- = SmartModel
1
+ = SmartModel - (http://nathanpro.github.com/SmartModel)
2
2
 
3
3
  == What is
4
- SmartModel is a rails 3 library(plugin and gem) made to improve the way you use MongoMapper. It gives you aliases, and even a model generator for mongoDB models.
4
+ SmartModel is a Rails 3 Library(plugin and gem) made to improve the way you use MongoMapper.
5
+ It gives you aliases, and even a model generator for MongoDB models.
5
6
 
6
7
  == Setup
7
8
  === As plugin
8
- To setup SmartModel as a plugin , you need mongo_mapper(that needs bson_ext) , so add this to your Gemfile
9
- gem 'mongo_mapper'
10
- gem 'bson_ext'
9
+ To setup SmartModel as a plugin, you need mongo_mapper (that needs bson_ext), so add this to your Gemfile:
10
+ gem 'mongo_mapper'
11
+ gem 'bson_ext'
11
12
  And then run
12
- rails plugin install http://github.com/nathanPro/SmartModel.git
13
+ $ rails plugin install http://github.com/nathanPro/SmartModel.git
13
14
  === As a gem
14
- Just add
15
- gem 'smart_model'
16
- To your Gemfile and run
17
- [sudo] bundle install
18
- And everything is OK!
15
+ Just add:
16
+ gem 'smart_model'
17
+ To your Gemfile and run:
18
+ $ [sudo] bundle install
19
+
20
+ And you are done!
19
21
 
20
22
  == Generator
21
23
  SmartModel gives you the smart_model generator:
22
- rails g smart_model project name:string content:string created_at:date in_progress:done
24
+ $ rails g smart_model project name:string content:string created_at:date in_progress:done
25
+
23
26
  That creates a model Project with the SmartModel::Base module included
24
27
 
25
28
  == SmartModel::Base
26
29
  Is a class with all the MongoMapper::Document methods, and with SmartModel::Attributes and SmartModel::Relationships included
27
30
  === SmartModel::Attributes
28
31
  It is responsible for handling the columns of yout database. To add a title columns to your project model, that keeps a string ,in example, you can just type this:
29
- class Project
30
- include SmartModel::Attributes # Load SmartModel
31
- string :title , :required => true # Create title column ,that accept strings
32
- end
32
+ class Project
33
+ include SmartModel::Attributes # Load SmartModel
34
+ string :title , :required => true # Create title column ,that accept strings
35
+ end
36
+
33
37
  Or if you have many columns with the same behaviour , you can just manage them just like this:
34
- class Project
35
- include SmartModel::Attributes
36
- strings [:title , : content] , :required => true # Create :title and :content columns
37
- end
38
+ class Project
39
+ include SmartModel::Attributes
40
+ strings [:title , : content] , :required => true # Create :title and :content columns
41
+ end
42
+
38
43
  The given methods are
39
44
  string(s) , integer(s) , boolean(s) , array(s) , objectid(s) , date(s)
45
+
40
46
  === SmartModel::Relationships
41
47
  It is responsible for making the belongs_to method also create de column in the database for the id
42
- class Project
43
- include SmartModel::Relationships
44
- belongs_to :task
45
- # however , if you call , in example
46
- # string :title
47
- # it will raise an error , because you didn't included the Attributes module
48
- end
48
+ class Project
49
+ include SmartModel::Relationships
50
+ belongs_to :task
51
+ # however , if you call , in example
52
+ # string :title
53
+ # it will raise an error , because you didn't included the Attributes module
54
+ end
49
55
 
50
56
  == TO-DO
51
- create a scaffold generator
57
+ Create a scaffold generator
52
58
 
53
59
  == Why have I done it?
54
- I was on vacation , so , I decided to code something usefull , and this was my first idea
60
+ I was on vacation, so, I decided to code something usefull, and this was my first idea.
61
+
62
+ == Contributors / Maintainers
55
63
 
56
- == Contributors
57
- Nathan Proença (nathan@vieiraproenca@gmail.com) and Rodrigo Alves Vieira (rodrigo3n@gmail.com)
64
+ * Nathan Proença (nathan@vieiraproenca.com)
65
+ * Rodrigo Alves Vieira (rodrigo3n@gmail.com)
58
66
 
59
- == License
60
- Read under the amazing MIT license
67
+ == Copyright
61
68
 
69
+ Copyright © 2010 Nathan Proença. Read LICENCE for details.
data/Rakefile CHANGED
@@ -5,11 +5,16 @@ require 'rake/rdoctask'
5
5
  desc 'Default: run unit tests.'
6
6
  task :default => :test
7
7
 
8
+ task :build do
9
+ system 'gem build smart_model.gemspec'
10
+ end
11
+
8
12
  desc 'Test the smart_model Gem and Plugin.'
9
13
  Rake::TestTask.new(:test) do |t|
10
14
  t.libs << 'lib'
11
15
  t.libs << 'test'
12
16
  t.pattern = 'test/**/*_test.rb'
17
+ t.test_files = Dir["test/**/*_test.rb"]
13
18
  t.verbose = true
14
19
  end
15
20
 
@@ -1,11 +1,11 @@
1
1
  Description:
2
- Create rails files for model generator, using MongoMapper and SmartMongo.
2
+ Create Rails files for model generator, using MongoMapper and SmartModel.
3
3
 
4
4
  Example:
5
- rails generate smart_model Thing
5
+ rails generate smart_model Post
6
6
 
7
7
  This will create:
8
- app/models/thing.rb
9
- test/unit/thing_test.rb
10
- test/fixtures/things.yml
8
+ app/models/post.rb
9
+ test/unit/post_test.rb
10
+ test/fixtures/post.yml
11
11
 
@@ -1,4 +1,4 @@
1
- class SmartModelGenerator < Rails::Generators::Base
1
+ class SmartModelGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
  argument :name , :type => :string
4
4
  argument :db_fields, :type => :hash
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'mongo_mapper'
3
2
 
4
3
  module SmartModel
5
4
  module Attributes
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'mongo_mapper'
3
2
 
4
3
  module SmartModel
5
4
  module Relationships
data/lib/smart_model.rb CHANGED
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- require 'mongo_mapper'
3
- require 'smart_model/attributes'
4
- require 'smart_model/relationships'
1
+ %w(rubygems smart_model/attributes smart_model/relationships).each { |gem| require gem }
5
2
 
6
3
  module SmartModel
7
4
  module Base
data/rails/init.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "attributes")
2
2
  require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "relationships")
3
- require File.join(File.dirname(__FILE__), "..", "lib", "smart_model.rb")
3
+ require File.join(File.dirname(__FILE__), "..", "lib", "smart_model")
4
4
 
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class SmartModelGeneratorTest < Test::Unit::TestCase
4
+ end
@@ -1,11 +1,5 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class SmartModelTest < ActiveSupport::TestCase
4
-
5
- test "SmartModel model proper inclusion" do
6
- class TestSmartModelLoading
7
- include SmartModel::Base
8
- end
9
- end
1
+ require 'test_helper'
10
2
 
3
+ class SmartModelTest < Test::Unit::TestCase
11
4
  end
5
+
data/test/test_helper.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'active_support'
4
- require '../lib/smart_model.rb'
5
-
1
+ %w(rubygems test/unit active_support).each { |gem| require gem }
2
+ require File.expand_path('') + '/lib/smart_model'
3
+ require File.expand_path('') + '/rails/init'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 7
10
+ version: 0.3.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Nathan Proen\xC3\xA7a"
@@ -15,78 +15,32 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-10 00:00:00 -03:00
18
+ date: 2010-06-25 00:00:00 -03:00
19
19
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 996871346
30
- segments:
31
- - 3
32
- - 0
33
- - 0beta4
34
- version: 3.0.0beta4
35
- type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: mongo_mapper
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 59
46
- segments:
47
- - 0
48
- - 8
49
- - 2
50
- version: 0.8.2
51
- type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: bson_ext
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 21
62
- segments:
63
- - 1
64
- - 0
65
- - 1
66
- version: 1.0.1
67
- type: :runtime
68
- version_requirements: *id003
20
+ dependencies: []
21
+
69
22
  description: Gives you support to use MongoDB and MongoMapper in Rails apps
70
23
  email: nathan@vieiraproenca.com
71
24
  executables: []
72
25
 
73
26
  extensions: []
74
27
 
75
- extra_rdoc_files: []
76
-
28
+ extra_rdoc_files:
29
+ - README.rdoc
77
30
  files:
78
- - lib/generators/smart_model/templates/model.rb
31
+ - lib/smart_model/attributes.rb
32
+ - lib/smart_model/relationships.rb
33
+ - lib/smart_model.rb
79
34
  - lib/generators/smart_model/templates/fixture.yml
35
+ - lib/generators/smart_model/templates/model.rb
80
36
  - lib/generators/smart_model/templates/test.rb
81
- - lib/generators/smart_model/USAGE
82
37
  - lib/generators/smart_model/smart_model_generator.rb
83
- - lib/smart_model.rb
84
- - lib/smart_model/attributes.rb
85
- - lib/smart_model/relationships.rb
86
- - test/smart_model_test.rb
38
+ - lib/generators/smart_model/USAGE
87
39
  - test/test_helper.rb
40
+ - test/smart_model_test.rb
41
+ - test/smart_model_generator_test.rb
88
42
  - rails/init.rb
89
- - MIT-LICENSE
43
+ - LICENSE
90
44
  - Rakefile
91
45
  - README.rdoc
92
46
  has_rdoc: true
@@ -94,8 +48,8 @@ homepage: http://github.com/nathanpro/SmartModel
94
48
  licenses: []
95
49
 
96
50
  post_install_message:
97
- rdoc_options: []
98
-
51
+ rdoc_options:
52
+ - --charset=UTF-8
99
53
  require_paths:
100
54
  - lib
101
55
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -118,10 +72,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
72
  version: "0"
119
73
  requirements: []
120
74
 
121
- rubyforge_project:
75
+ rubyforge_project: smart_model
122
76
  rubygems_version: 1.3.7
123
77
  signing_key:
124
78
  specification_version: 3
125
- summary: Jump all the power of MongoDB and MongoMappers into your Rails application
126
- test_files: []
127
-
79
+ summary: Jump all the power of MongoDB and MongoMapper into your Rails application
80
+ test_files:
81
+ - test/smart_model_test.rb
82
+ - test/smart_model_generator_test.rb