padrino-lazy 0.0.1alpha → 0.0.2alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +79 -0
- data/bin/padrino-lazy +3 -2
- data/lib/padrino-lazy/version.rb +3 -1
- metadata +5 -3
data/README.rdoc
CHANGED
@@ -18,6 +18,10 @@ I hope this idea will be included in Padrino Framework.
|
|
18
18
|
4. generate a model from base model
|
19
19
|
5. generate a migration file
|
20
20
|
|
21
|
+
=== Install
|
22
|
+
|
23
|
+
gem install padrino-lazy --pre
|
24
|
+
|
21
25
|
== Usage
|
22
26
|
|
23
27
|
Step 1-2-3
|
@@ -33,10 +37,85 @@ Step 4-5
|
|
33
37
|
--b base model name (es: BaseModel)
|
34
38
|
--m model name to create (es: User)
|
35
39
|
|
40
|
+
== Example
|
41
|
+
$ padrino-lazy base --c config --b BaseModel --f
|
42
|
+
"create_at:datetime is_active:boolean"
|
43
|
+
|
44
|
+
now we have
|
45
|
+
* lib/base_model.rb
|
46
|
+
class BaseModel
|
47
|
+
include DataMapper::Resource
|
48
|
+
|
49
|
+
# property <name>, <type>
|
50
|
+
property :id, Serial
|
51
|
+
property :create_at, DateTime
|
52
|
+
property :is_active, Boolean
|
53
|
+
end
|
54
|
+
|
55
|
+
* config/config.yml
|
56
|
+
---
|
57
|
+
- base: BaseModel
|
58
|
+
fields: create_at:datetime is_active:boolean
|
59
|
+
|
60
|
+
---
|
61
|
+
$ padrino-lazy model --c config --b BaseModel --f "name:string
|
62
|
+
have_children:boolean born:date foo:integer" --m User
|
63
|
+
|
64
|
+
* app/models/user.rb
|
65
|
+
|
66
|
+
class User < BaseModel
|
67
|
+
|
68
|
+
# property <name>, <type>
|
69
|
+
property :name, String
|
70
|
+
property :have_children, Boolean
|
71
|
+
property :born, Date
|
72
|
+
property :foo, Integer
|
73
|
+
end
|
74
|
+
|
75
|
+
* db/migrate/001_create_users.rb
|
76
|
+
migration 1, :create_users do
|
77
|
+
up do
|
78
|
+
create_table :users do
|
79
|
+
column :id, Integer, :serial => true
|
80
|
+
column :name, String
|
81
|
+
column :have_children, Boolean
|
82
|
+
column :born, Date
|
83
|
+
column :foo, Integer
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
down do
|
88
|
+
drop_table :users
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
* db/migrate/002_add_basic_model_to_user.rb
|
93
|
+
migration 2, :add_basic_model_to_user do
|
94
|
+
up do
|
95
|
+
modify_table :users do
|
96
|
+
add_column :name, String
|
97
|
+
add_column :have_children, Boolean
|
98
|
+
add_column :born, Date
|
99
|
+
add_column :foo, Integer
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
down do
|
104
|
+
modify_table :users do
|
105
|
+
drop_column :name
|
106
|
+
drop_column :have_children
|
107
|
+
drop_column :born
|
108
|
+
drop_column :foo
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
36
114
|
== Known issue
|
37
115
|
|
38
116
|
* VERY VERY alpha code !! (thanks to my pig/lazy side :D )
|
39
117
|
* --f options need dobule quote around fields
|
118
|
+
* --b write in CamelCase
|
40
119
|
* TESTING only with datamapper and activerecord into linux machine
|
41
120
|
|
42
121
|
=== TODO:
|
data/bin/padrino-lazy
CHANGED
@@ -73,12 +73,13 @@ command :model do |c|
|
|
73
73
|
lazy_work lazy, options
|
74
74
|
|
75
75
|
File.open("app/models/#{options.model.to_underscore}.rb","w+"){|f| f.puts lazy }
|
76
|
-
|
76
|
+
say "#{@base_current[:fields.to_s]}"
|
77
77
|
# create migration
|
78
|
-
%x{ padrino g migration AddBasicModelTo#{options.model} #{
|
78
|
+
%x{ padrino g migration AddBasicModelTo#{options.model} #{@base_current[:fields.to_s]} }
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
|
82
83
|
##################################
|
83
84
|
### PADRINO-LAZY ###
|
84
85
|
##################################
|
data/lib/padrino-lazy/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Manages current Padrino lazy version for use in gem generation.
|
3
3
|
module Padrino
|
4
4
|
module Lazy
|
5
|
-
VERSION = '0.0.
|
5
|
+
VERSION = '0.0.2alpha' unless defined?(Padrino::Lazy::VERSION)
|
6
6
|
##
|
7
7
|
# Return the current Padrino version
|
8
8
|
#
|
@@ -11,3 +11,5 @@ module Padrino
|
|
11
11
|
end
|
12
12
|
end # Lazy
|
13
13
|
end # Padrino
|
14
|
+
|
15
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-lazy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2alpha
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-23 00:00:00.000000000 +02:00
|
13
|
+
default_executable:
|
13
14
|
dependencies: []
|
14
15
|
description: padrino model base generator for the Padrino Ruby Web Framework
|
15
16
|
email: waydotnet@gmail.com
|
@@ -25,6 +26,7 @@ files:
|
|
25
26
|
- padrino-lazy.gemspec
|
26
27
|
- bin/padrino-lazy
|
27
28
|
- lib/padrino-lazy/version.rb
|
29
|
+
has_rdoc: true
|
28
30
|
homepage: http://www.waydotnet.com
|
29
31
|
licenses: []
|
30
32
|
post_install_message:
|
@@ -46,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
48
|
version: 1.3.1
|
47
49
|
requirements: []
|
48
50
|
rubyforge_project: padrino-lazy
|
49
|
-
rubygems_version: 1.
|
51
|
+
rubygems_version: 1.6.2
|
50
52
|
signing_key:
|
51
53
|
specification_version: 3
|
52
54
|
summary: Padrino model base generator for Padrino Framework
|