stympy-mongo-generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +15 -0
- data/lib/mongo_generators.rb +3 -0
- data/rails_generators/mongo_model/USAGE +16 -0
- data/rails_generators/mongo_model/mongo_model_generator.rb +24 -0
- data/rails_generators/mongo_model/templates/model.rb +7 -0
- data/tasks/deployment.rake +2 -0
- metadata +70 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Benjamin Curtis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= Mongo Generators
|
2
|
+
|
3
|
+
Mongo-related Rails generator scripts.
|
4
|
+
|
5
|
+
|
6
|
+
== Install
|
7
|
+
|
8
|
+
gem install stympy-mongo-generators
|
9
|
+
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Once you install the gem, the generators will be available to all Rails
|
14
|
+
applications on your system. If you run script/generate without any
|
15
|
+
additional arguments you should see the available generators listed.
|
16
|
+
|
17
|
+
To run the generator, go to your rails project directory and call it
|
18
|
+
using the script/generate or script/destroy command.
|
19
|
+
|
20
|
+
script/generate mongo_model Post name:string body:string published:boolean
|
21
|
+
|
22
|
+
== Thanks
|
23
|
+
|
24
|
+
Thanks to Ryan Bate's nifty-generators for being the scaffold of this project. :)
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('mongo-generators', '0.1.0') do |p|
|
6
|
+
p.project = "mongogenerators"
|
7
|
+
p.description = "MongoDB-related generator scripts for Rails."
|
8
|
+
p.url = "http://github.com/stympy/mongo-generators"
|
9
|
+
p.author = 'Benjamin Curtis'
|
10
|
+
p.email = "benjamin.curtis@gmail.com"
|
11
|
+
p.ignore_pattern = ["script/*"]
|
12
|
+
p.development_dependencies = []
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new model. Pass the model name, either CamelCased or
|
3
|
+
under_scored, and an optional list of attribute pairs as arguments.
|
4
|
+
|
5
|
+
Attribute pairs are key_name:mongo_type arguments specifying the
|
6
|
+
model's attributes. Timestamps are added by default.
|
7
|
+
|
8
|
+
Examples:
|
9
|
+
`./script/generate model account`
|
10
|
+
|
11
|
+
creates an Account model:
|
12
|
+
Model: app/models/account.rb
|
13
|
+
|
14
|
+
`./script/generate model post title:string body:string published:boolean`
|
15
|
+
|
16
|
+
creates a Post model with a string title, string body, and published flag.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class MongoModelGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
m.directory 'app/models'
|
5
|
+
m.template 'model.rb', "app/models/#{file_name}.rb"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def attributes
|
12
|
+
@attributes ||= @args.collect do |attribute|
|
13
|
+
MongoAttribute.new(*attribute.split(":"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class MongoAttribute
|
19
|
+
attr_accessor :name, :type
|
20
|
+
|
21
|
+
def initialize(name, type)
|
22
|
+
@name, @type = name, type.capitalize
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stympy-mongo-generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Curtis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-24 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: MongoDB-related generator scripts for Rails.
|
17
|
+
email: benjamin.curtis@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGELOG
|
24
|
+
- lib/mongo_generators.rb
|
25
|
+
- LICENSE
|
26
|
+
- README.rdoc
|
27
|
+
- tasks/deployment.rake
|
28
|
+
files:
|
29
|
+
- CHANGELOG
|
30
|
+
- lib/mongo_generators.rb
|
31
|
+
- LICENSE
|
32
|
+
- rails_generators/mongo_model/mongo_model_generator.rb
|
33
|
+
- rails_generators/mongo_model/templates/model.rb
|
34
|
+
- rails_generators/mongo_model/USAGE
|
35
|
+
- Rakefile
|
36
|
+
- README.rdoc
|
37
|
+
- tasks/deployment.rake
|
38
|
+
has_rdoc: false
|
39
|
+
homepage: http://github.com/stympy/mongo-generators
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --line-numbers
|
43
|
+
- --inline-source
|
44
|
+
- --title
|
45
|
+
- mongo-generators
|
46
|
+
- --main
|
47
|
+
- README.rdoc
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "1.2"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.2.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: MongoDB-related generator scripts for Rails.
|
69
|
+
test_files: []
|
70
|
+
|