smart_model 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +0 -2
- data/README.rdoc +14 -17
- data/Rakefile +24 -0
- data/lib/generators/smart_mongo/USAGE +9 -0
- data/lib/generators/smart_mongo/smart_mongo_generator.rb +8 -0
- data/lib/generators/smart_mongo/templates/initializer.rb +2 -0
- data/rails/init.rb +2 -2
- data/test/smart_model_test.rb +7 -5
- data/test/test_helper.rb +2 -0
- metadata +11 -7
data/MIT-LICENSE
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
Copyright (c) 2010 Nathan Proença
|
2
|
-
|
3
2
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
3
|
a copy of this software and associated documentation files (the
|
5
4
|
"Software"), to deal in the Software without restriction, including
|
@@ -18,4 +17,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
17
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
18
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
19
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
data/README.rdoc
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
= SmartModel
|
2
|
+
|
2
3
|
== What is
|
3
|
-
SmartModel is a rails 3 library 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. It gives you aliases, and even a model generator for mongoDB models.
|
4
5
|
|
5
6
|
== Setup
|
6
7
|
=== As plugin
|
7
|
-
To setup
|
8
|
+
To setup SmartModel as a plugin , you need mongo_mapper(that needs bson_ext) , so add this to your Gemfile
|
8
9
|
gem 'mongo_mapper'
|
9
10
|
gem 'bson_ext'
|
10
11
|
And then run
|
@@ -16,11 +17,14 @@ To your Gemfile and run
|
|
16
17
|
[sudo] bundle install
|
17
18
|
And everything is OK!
|
18
19
|
|
19
|
-
==
|
20
|
-
|
20
|
+
== Generators
|
21
|
+
SmartMongo gives you 2 generators:
|
22
|
+
=== smart_model
|
23
|
+
rails g smart_model
|
24
|
+
that creates a initializer that defines the MongoMapper database
|
21
25
|
=== smart_model
|
22
26
|
rails g smart_model project name:string content:string created_at:date in_progress:done
|
23
|
-
That creates a model Project inherited from
|
27
|
+
That creates a model Project inherited from SmartModel::Base
|
24
28
|
|
25
29
|
== SmartModel::Base
|
26
30
|
Is a class with all the MongoMapper::Document methods, that even gives you aliases for setting your database up
|
@@ -36,24 +40,17 @@ Or if you have many columns with the same behaviour , you can just manage them j
|
|
36
40
|
strings [:title , : content] , :required => true # Create :title and :content columns
|
37
41
|
end
|
38
42
|
The given methods are
|
39
|
-
string(s) , integer(s) , boolean(s) , array(s) , objectid(s) , date(s)
|
40
|
-
=== Relationships
|
41
|
-
With SmartModel::Base you can just do this :
|
42
|
-
class Task
|
43
|
-
include SmartModel::Base
|
44
|
-
strings [ :name , :description ]
|
45
|
-
boolean :done
|
46
|
-
belongs_to :project
|
47
|
-
end
|
48
|
-
That SmartModel already creates the db column and stablish the relationship.
|
43
|
+
string(s) , integer(s) , boolean(s) , array(s) , objectid(s) , date(s)
|
49
44
|
|
50
45
|
== TO-DO
|
51
|
-
create a scaffold generator
|
52
|
-
make the tests *test something*
|
46
|
+
create a scaffold generator
|
53
47
|
|
54
48
|
== Why have I done it?
|
55
49
|
I was on vacation , so , I decided to code something usefull , and this was my first idea
|
56
50
|
|
51
|
+
== Contributors
|
52
|
+
Nathan Proença (nathan@vieiraproenca@gmail.com) and Rodrigo Alves Vieira (rodrigo3n@gmail.com)
|
53
|
+
|
57
54
|
== License
|
58
55
|
Read under the amazing MIT license
|
59
56
|
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the smart_model Gem and Plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the smart_model Gem and Plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'SmartModel'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class SmartMongoGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
argument :db_name , :type => :string , :default => "#{RAILS_ROOT.to_s.split('/').last}-#{Rails.env}"
|
4
|
+
def setup
|
5
|
+
template "initializer.rb" , "config/initializers/setup_mongo_db.rb"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
data/rails/init.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "lib", "smart_model.rb")
|
2
|
-
require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "relationships")
|
3
1
|
require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "attributes")
|
2
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "relationships")
|
3
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "smart_model.rb")
|
4
4
|
|
data/test/smart_model_test.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require 'test_helper'
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
3
|
class SmartModelTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test "
|
6
|
-
|
4
|
+
|
5
|
+
test "SmartModel model proper inclusion" do
|
6
|
+
class TestSmartModelLoading
|
7
|
+
include SmartModel::Base
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
11
|
+
end
|
data/test/test_helper.rb
CHANGED
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Nathan Proen\xC3\xA7a"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-10 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: 1.0.1
|
67
67
|
type: :runtime
|
68
68
|
version_requirements: *id003
|
69
|
-
description: Gives you support to use MongoDB and MongoMapper
|
69
|
+
description: Gives you support to use MongoDB and MongoMapper in Rails apps
|
70
70
|
email: nathan@vieiraproenca.com
|
71
71
|
executables: []
|
72
72
|
|
@@ -80,6 +80,9 @@ files:
|
|
80
80
|
- lib/generators/smart_model/templates/test.rb
|
81
81
|
- lib/generators/smart_model/USAGE
|
82
82
|
- lib/generators/smart_model/smart_model_generator.rb
|
83
|
+
- lib/generators/smart_mongo/templates/initializer.rb
|
84
|
+
- lib/generators/smart_mongo/USAGE
|
85
|
+
- lib/generators/smart_mongo/smart_mongo_generator.rb
|
83
86
|
- lib/smart_model.rb
|
84
87
|
- lib/smart_model/attributes.rb
|
85
88
|
- lib/smart_model/relationships.rb
|
@@ -87,9 +90,10 @@ files:
|
|
87
90
|
- test/test_helper.rb
|
88
91
|
- rails/init.rb
|
89
92
|
- MIT-LICENSE
|
93
|
+
- Rakefile
|
90
94
|
- README.rdoc
|
91
95
|
has_rdoc: true
|
92
|
-
homepage: http://github.com/nathanpro/
|
96
|
+
homepage: http://github.com/nathanpro/SmartModel
|
93
97
|
licenses: []
|
94
98
|
|
95
99
|
post_install_message:
|
@@ -121,6 +125,6 @@ rubyforge_project:
|
|
121
125
|
rubygems_version: 1.3.7
|
122
126
|
signing_key:
|
123
127
|
specification_version: 3
|
124
|
-
summary:
|
128
|
+
summary: Jump all the power of MongoDB and MongoMappers into your Rails application
|
125
129
|
test_files: []
|
126
130
|
|