gorm 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gorm.rb +19 -17
- data/lib/gorm/cog_tool.rb +15 -0
- data/lib/gorm/version.rb +1 -1
- metadata +5 -4
data/lib/gorm.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
2
|
-
require 'gorm/schema'
|
3
2
|
require 'gorm/version'
|
3
|
+
require 'gorm/schema'
|
4
4
|
require 'cog'
|
5
5
|
|
6
|
-
# Inject this tools templates onto the cog template lookup path
|
7
|
-
# Do not remove this line
|
8
|
-
Cog::Config.instance.tool_templates_path = File.expand_path(File.join(__FILE__, '..', '..', 'cog', 'templates'))
|
9
|
-
|
10
|
-
# Set the template which is used to create generators for this tool
|
11
|
-
# Do not remove this line
|
12
|
-
Cog::Config.instance.tool_generator_template = 'gorm/generator.rb'
|
13
|
-
|
14
6
|
# Custom cog tool gorm
|
15
7
|
module Gorm
|
16
|
-
|
8
|
+
|
17
9
|
# Creates a Schema under the given package +path+ and makes it available to a
|
18
10
|
# block that can then define it using the Schema::SchemaDefinitionMethods.
|
11
|
+
# @param path [String] A / separated path where the source files should be generated. Do not include any file extension, they will be added automatically depending on the target language.
|
12
|
+
# @option opt [String] :namespace (nil) if provided, all generated classes will be placed inside this namespace.
|
13
|
+
# @yield [Schema] use this object to define your schema
|
14
|
+
# @return [nil]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# require 'gorm'
|
19
18
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
19
|
+
# # The following schema will generate these files
|
20
|
+
# # - my_app/persistence/Database.h
|
21
|
+
# # - my_app/persistence/Database.cpp
|
22
|
+
# Gorm.schema 'my_app/persistence/Database', :namespace => 'MyApp' do |s|
|
23
|
+
# s.migration do |m|
|
24
|
+
# # Define the initial version of the schema.
|
25
|
+
# # Any tables added here will be created in the directory
|
26
|
+
# # - my_app/persistence/Database/
|
27
|
+
# end
|
28
|
+
# end
|
24
29
|
#
|
25
|
-
# ==== Options
|
26
|
-
# * <tt>:namespace</tt> - If provided, all generated classes will be placed
|
27
|
-
# inside this namespace.
|
28
30
|
def self.schema(path, opt={}, &block) # :yields: s
|
29
31
|
s = Schema.new path, opt
|
30
32
|
block.call s unless s.nil?
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'cog'
|
2
|
+
|
3
|
+
# Register gorm as a tool with cog
|
4
|
+
Cog::Config.instance.register_tool __FILE__ do |tool|
|
5
|
+
|
6
|
+
# Define how new gorm generators are created
|
7
|
+
#
|
8
|
+
# Add context as required by your generator template.
|
9
|
+
#
|
10
|
+
# When the block is executed, +self+ will be an instance of Cog::Config::Tool::GeneratorStamper
|
11
|
+
tool.stamp_generator do
|
12
|
+
stamp 'gorm/generator.rb', generator_dest, :absolute_destination => true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/gorm/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kevin Tonon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
@@ -85,6 +85,7 @@ extra_rdoc_files: []
|
|
85
85
|
|
86
86
|
files:
|
87
87
|
- LICENSE
|
88
|
+
- lib/gorm/cog_tool.rb
|
88
89
|
- lib/gorm/column.rb
|
89
90
|
- lib/gorm/migration.rb
|
90
91
|
- lib/gorm/schema.rb
|