newplugin 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +36 -34
- data/bin/newplugin-gen +4 -4
- data/lib/newplugin.rb +1 -1
- data/newplugin_generators/app/USAGE +5 -0
- data/{generators → newplugin_generators}/app/app_generator.rb +1 -2
- data/{generators → newplugin_generators}/app/templates/MIT-LICENSE +0 -0
- data/{generators → newplugin_generators}/app/templates/README +0 -0
- data/{generators → newplugin_generators}/app/templates/Rakefile +0 -0
- data/{generators → newplugin_generators}/app/templates/init.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/install.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/lib/module.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/tasks/tasks.rake +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/app/controllers/application.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/app/controllers/application_controller.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/boot.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/database.yml +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environment.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/in_memory.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/mysql.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/postgresql.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/sqlite.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/sqlite3.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/initializers/plugin.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/app_root/config/routes.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/test/test_helper.rb +0 -0
- data/{generators → newplugin_generators}/app/templates/uninstall.rb +0 -0
- data/newplugin_generators/controller/USAGE +5 -0
- data/{generators → newplugin_generators}/controller/controller_generator.rb +11 -3
- data/{generators → newplugin_generators}/controller/templates/controller.rb +0 -0
- data/newplugin_generators/migration/USAGE +4 -0
- data/{generators → newplugin_generators}/migration/migration_generator.rb +8 -0
- data/{generators → newplugin_generators}/migration/templates/migration.rb +0 -0
- data/newplugin_generators/model/USAGE +15 -0
- data/{generators → newplugin_generators}/model/model_generator.rb +8 -0
- data/{generators → newplugin_generators}/model/templates/fixtures.yml +0 -0
- data/{generators → newplugin_generators}/model/templates/migration.rb +2 -0
- data/{generators → newplugin_generators}/model/templates/model.rb +0 -0
- data/newplugin_generators/scaffold/USAGE +19 -0
- data/newplugin_generators/scaffold/scaffold_generator.rb +25 -0
- metadata +37 -35
- data/generators/app/USAGE +0 -5
- data/generators/controller/USAGE +0 -2
- data/generators/migration/USAGE +0 -2
- data/generators/model/USAGE +0 -2
data/Manifest.txt
CHANGED
|
@@ -3,41 +3,43 @@ Manifest.txt
|
|
|
3
3
|
README.rdoc
|
|
4
4
|
Rakefile
|
|
5
5
|
bin/newplugin-gen
|
|
6
|
-
generators/app/USAGE
|
|
7
|
-
generators/app/app_generator.rb
|
|
8
|
-
generators/app/templates/MIT-LICENSE
|
|
9
|
-
generators/app/templates/README
|
|
10
|
-
generators/app/templates/Rakefile
|
|
11
|
-
generators/app/templates/init.rb
|
|
12
|
-
generators/app/templates/install.rb
|
|
13
|
-
generators/app/templates/lib/module.rb
|
|
14
|
-
generators/app/templates/tasks/tasks.rake
|
|
15
|
-
generators/app/templates/test/app_root/app/controllers/application.rb
|
|
16
|
-
generators/app/templates/test/app_root/app/controllers/application_controller.rb
|
|
17
|
-
generators/app/templates/test/app_root/config/boot.rb
|
|
18
|
-
generators/app/templates/test/app_root/config/database.yml
|
|
19
|
-
generators/app/templates/test/app_root/config/environment.rb
|
|
20
|
-
generators/app/templates/test/app_root/config/environments/in_memory.rb
|
|
21
|
-
generators/app/templates/test/app_root/config/environments/mysql.rb
|
|
22
|
-
generators/app/templates/test/app_root/config/environments/postgresql.rb
|
|
23
|
-
generators/app/templates/test/app_root/config/environments/sqlite.rb
|
|
24
|
-
generators/app/templates/test/app_root/config/environments/sqlite3.rb
|
|
25
|
-
generators/app/templates/test/app_root/config/initializers/plugin.rb
|
|
26
|
-
generators/app/templates/test/app_root/config/routes.rb
|
|
27
|
-
generators/app/templates/test/test_helper.rb
|
|
28
|
-
generators/app/templates/uninstall.rb
|
|
29
|
-
generators/controller/USAGE
|
|
30
|
-
generators/controller/controller_generator.rb
|
|
31
|
-
generators/controller/templates/controller.rb
|
|
32
|
-
generators/migration/USAGE
|
|
33
|
-
generators/migration/migration_generator.rb
|
|
34
|
-
generators/migration/templates/migration.rb
|
|
35
|
-
generators/model/USAGE
|
|
36
|
-
generators/model/model_generator.rb
|
|
37
|
-
generators/model/templates/fixtures.yml
|
|
38
|
-
generators/model/templates/migration.rb
|
|
39
|
-
generators/model/templates/model.rb
|
|
40
6
|
lib/newplugin.rb
|
|
7
|
+
newplugin_generators/app/USAGE
|
|
8
|
+
newplugin_generators/app/app_generator.rb
|
|
9
|
+
newplugin_generators/app/templates/MIT-LICENSE
|
|
10
|
+
newplugin_generators/app/templates/README
|
|
11
|
+
newplugin_generators/app/templates/Rakefile
|
|
12
|
+
newplugin_generators/app/templates/init.rb
|
|
13
|
+
newplugin_generators/app/templates/install.rb
|
|
14
|
+
newplugin_generators/app/templates/lib/module.rb
|
|
15
|
+
newplugin_generators/app/templates/tasks/tasks.rake
|
|
16
|
+
newplugin_generators/app/templates/test/app_root/app/controllers/application.rb
|
|
17
|
+
newplugin_generators/app/templates/test/app_root/app/controllers/application_controller.rb
|
|
18
|
+
newplugin_generators/app/templates/test/app_root/config/boot.rb
|
|
19
|
+
newplugin_generators/app/templates/test/app_root/config/database.yml
|
|
20
|
+
newplugin_generators/app/templates/test/app_root/config/environment.rb
|
|
21
|
+
newplugin_generators/app/templates/test/app_root/config/environments/in_memory.rb
|
|
22
|
+
newplugin_generators/app/templates/test/app_root/config/environments/mysql.rb
|
|
23
|
+
newplugin_generators/app/templates/test/app_root/config/environments/postgresql.rb
|
|
24
|
+
newplugin_generators/app/templates/test/app_root/config/environments/sqlite.rb
|
|
25
|
+
newplugin_generators/app/templates/test/app_root/config/environments/sqlite3.rb
|
|
26
|
+
newplugin_generators/app/templates/test/app_root/config/initializers/plugin.rb
|
|
27
|
+
newplugin_generators/app/templates/test/app_root/config/routes.rb
|
|
28
|
+
newplugin_generators/app/templates/test/test_helper.rb
|
|
29
|
+
newplugin_generators/app/templates/uninstall.rb
|
|
30
|
+
newplugin_generators/controller/USAGE
|
|
31
|
+
newplugin_generators/controller/controller_generator.rb
|
|
32
|
+
newplugin_generators/controller/templates/controller.rb
|
|
33
|
+
newplugin_generators/migration/USAGE
|
|
34
|
+
newplugin_generators/migration/migration_generator.rb
|
|
35
|
+
newplugin_generators/migration/templates/migration.rb
|
|
36
|
+
newplugin_generators/model/USAGE
|
|
37
|
+
newplugin_generators/model/model_generator.rb
|
|
38
|
+
newplugin_generators/model/templates/fixtures.yml
|
|
39
|
+
newplugin_generators/model/templates/migration.rb
|
|
40
|
+
newplugin_generators/model/templates/model.rb
|
|
41
|
+
newplugin_generators/scaffold/USAGE
|
|
42
|
+
newplugin_generators/scaffold/scaffold_generator.rb
|
|
41
43
|
test/test_generator_helper.rb
|
|
42
44
|
test/test_helper.rb
|
|
43
45
|
test/test_new_plugin.rb
|
data/bin/newplugin-gen
CHANGED
|
@@ -13,8 +13,9 @@ if %w(-v --version).include? ARGV.first
|
|
|
13
13
|
exit(0)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
generator
|
|
17
|
-
|
|
16
|
+
generator = ARGV[0]
|
|
17
|
+
generators_path = File.join(File.dirname(__FILE__), "../newplugin_generators")
|
|
18
|
+
generators = Dir[File.join(generators_path,'*')].map {|f| File.basename(f) }
|
|
18
19
|
|
|
19
20
|
unless generators.include?(generator)
|
|
20
21
|
puts <<-DOC
|
|
@@ -27,7 +28,6 @@ unless generators.include?(generator)
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
require 'rubigen/scripts/generate'
|
|
30
|
-
source = RubiGen::PathSource.new(:application,File.join(File.dirname(__FILE__), "../generators"))
|
|
31
31
|
RubiGen::Base.reset_sources
|
|
32
|
-
RubiGen::Base.append_sources
|
|
32
|
+
RubiGen::Base.append_sources RubiGen::PathSource.new(:application,generators_path)
|
|
33
33
|
RubiGen::Scripts::Generate.new.run(ARGV[1..-1], :generator => generator)
|
data/lib/newplugin.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/{generators → newplugin_generators}/app/templates/test/app_root/app/controllers/application.rb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/mysql.rb
RENAMED
|
File without changes
|
|
File without changes
|
data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/sqlite.rb
RENAMED
|
File without changes
|
data/{generators → newplugin_generators}/app/templates/test/app_root/config/environments/sqlite3.rb
RENAMED
|
File without changes
|
data/{generators → newplugin_generators}/app/templates/test/app_root/config/initializers/plugin.rb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -9,14 +9,22 @@ class ControllerGenerator < RubiGen::Base
|
|
|
9
9
|
@name = args.shift
|
|
10
10
|
@actions = args
|
|
11
11
|
|
|
12
|
-
@file_name
|
|
13
|
-
@class_name
|
|
12
|
+
@file_name = @name.underscore
|
|
13
|
+
@class_name = @name.pluralize == @name ? @name.classify.pluralize : @name.classify
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def manifest
|
|
17
17
|
record do |m|
|
|
18
|
-
m.directory "test/app_root/app/controllers"
|
|
18
|
+
m.directory File.dirname("test/app_root/app/controllers/#{file_name}")
|
|
19
19
|
m.template "controller.rb","test/app_root/app/controllers/#{file_name}_controller.rb"
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
protected
|
|
24
|
+
def banner
|
|
25
|
+
<<-EOS
|
|
26
|
+
USAGE: #{File.basename($0)} #{spec.name} ControllerName [action] [action] [options]
|
|
27
|
+
|
|
28
|
+
EOS
|
|
29
|
+
end
|
|
22
30
|
end
|
|
File without changes
|
|
@@ -19,4 +19,12 @@ class MigrationGenerator < RubiGen::Base
|
|
|
19
19
|
m.migration_template 'migration.rb', "test/app_root/db/migrate"
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
protected
|
|
24
|
+
def banner
|
|
25
|
+
<<-EOS
|
|
26
|
+
USAGE: #{File.basename($0)} #{spec.name} MigrationName [options]
|
|
27
|
+
|
|
28
|
+
EOS
|
|
29
|
+
end
|
|
22
30
|
end
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
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 column_name:sql_type arguments specifying the
|
|
6
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
|
7
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
|
8
|
+
|
|
9
|
+
You don't have to think up every attribute up front, but it helps to
|
|
10
|
+
sketch out a few so you can start working with the model immediately.
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
`newplugin-gen model account`
|
|
14
|
+
|
|
15
|
+
`newplugin-gen model post title:string body:text published:boolean`
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Scaffolds an entire resource, from model and migration to controller
|
|
3
|
+
|
|
4
|
+
Pass the name of the model (in singular form), either CamelCased or
|
|
5
|
+
under_scored, as the first argument, and an optional list of attribute
|
|
6
|
+
pairs.
|
|
7
|
+
|
|
8
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
|
9
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
|
10
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
|
11
|
+
|
|
12
|
+
You don't have to think up every attribute up front, but it helps to
|
|
13
|
+
sketch out a few so you can start working with the resource immediately.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
`newplugin-gen scaffold post`
|
|
17
|
+
`newplugin-gen scaffold post title:string body:text published:boolean`
|
|
18
|
+
`newplugin-gen scaffold purchase order_id:integer amount:decimal`
|
|
19
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'active_record'
|
|
3
|
+
|
|
4
|
+
class ScaffoldGenerator < RubiGen::Base
|
|
5
|
+
|
|
6
|
+
def initialize(runtime_args, runtime_options = {})
|
|
7
|
+
super
|
|
8
|
+
usage if args.empty?
|
|
9
|
+
RubiGen::Scripts::Generate.new.run(args.clone, :generator => 'model')
|
|
10
|
+
RubiGen::Scripts::Generate.new.run(args[0].pluralize.to_a, :generator => 'controller')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def manifest
|
|
14
|
+
record do |m|
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
def banner
|
|
20
|
+
<<-EOS
|
|
21
|
+
USAGE: #{File.basename($0)} #{spec.name} ModelName [field:type, field:type]
|
|
22
|
+
|
|
23
|
+
EOS
|
|
24
|
+
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: newplugin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ZhangJinzhu
|
|
@@ -38,41 +38,43 @@ files:
|
|
|
38
38
|
- README.rdoc
|
|
39
39
|
- Rakefile
|
|
40
40
|
- bin/newplugin-gen
|
|
41
|
-
- generators/app/USAGE
|
|
42
|
-
- generators/app/app_generator.rb
|
|
43
|
-
- generators/app/templates/MIT-LICENSE
|
|
44
|
-
- generators/app/templates/README
|
|
45
|
-
- generators/app/templates/Rakefile
|
|
46
|
-
- generators/app/templates/init.rb
|
|
47
|
-
- generators/app/templates/install.rb
|
|
48
|
-
- generators/app/templates/lib/module.rb
|
|
49
|
-
- generators/app/templates/tasks/tasks.rake
|
|
50
|
-
- generators/app/templates/test/app_root/app/controllers/application.rb
|
|
51
|
-
- generators/app/templates/test/app_root/app/controllers/application_controller.rb
|
|
52
|
-
- generators/app/templates/test/app_root/config/boot.rb
|
|
53
|
-
- generators/app/templates/test/app_root/config/database.yml
|
|
54
|
-
- generators/app/templates/test/app_root/config/environment.rb
|
|
55
|
-
- generators/app/templates/test/app_root/config/environments/in_memory.rb
|
|
56
|
-
- generators/app/templates/test/app_root/config/environments/mysql.rb
|
|
57
|
-
- generators/app/templates/test/app_root/config/environments/postgresql.rb
|
|
58
|
-
- generators/app/templates/test/app_root/config/environments/sqlite.rb
|
|
59
|
-
- generators/app/templates/test/app_root/config/environments/sqlite3.rb
|
|
60
|
-
- generators/app/templates/test/app_root/config/initializers/plugin.rb
|
|
61
|
-
- generators/app/templates/test/app_root/config/routes.rb
|
|
62
|
-
- generators/app/templates/test/test_helper.rb
|
|
63
|
-
- generators/app/templates/uninstall.rb
|
|
64
|
-
- generators/controller/USAGE
|
|
65
|
-
- generators/controller/controller_generator.rb
|
|
66
|
-
- generators/controller/templates/controller.rb
|
|
67
|
-
- generators/migration/USAGE
|
|
68
|
-
- generators/migration/migration_generator.rb
|
|
69
|
-
- generators/migration/templates/migration.rb
|
|
70
|
-
- generators/model/USAGE
|
|
71
|
-
- generators/model/model_generator.rb
|
|
72
|
-
- generators/model/templates/fixtures.yml
|
|
73
|
-
- generators/model/templates/migration.rb
|
|
74
|
-
- generators/model/templates/model.rb
|
|
75
41
|
- lib/newplugin.rb
|
|
42
|
+
- newplugin_generators/app/USAGE
|
|
43
|
+
- newplugin_generators/app/app_generator.rb
|
|
44
|
+
- newplugin_generators/app/templates/MIT-LICENSE
|
|
45
|
+
- newplugin_generators/app/templates/README
|
|
46
|
+
- newplugin_generators/app/templates/Rakefile
|
|
47
|
+
- newplugin_generators/app/templates/init.rb
|
|
48
|
+
- newplugin_generators/app/templates/install.rb
|
|
49
|
+
- newplugin_generators/app/templates/lib/module.rb
|
|
50
|
+
- newplugin_generators/app/templates/tasks/tasks.rake
|
|
51
|
+
- newplugin_generators/app/templates/test/app_root/app/controllers/application.rb
|
|
52
|
+
- newplugin_generators/app/templates/test/app_root/app/controllers/application_controller.rb
|
|
53
|
+
- newplugin_generators/app/templates/test/app_root/config/boot.rb
|
|
54
|
+
- newplugin_generators/app/templates/test/app_root/config/database.yml
|
|
55
|
+
- newplugin_generators/app/templates/test/app_root/config/environment.rb
|
|
56
|
+
- newplugin_generators/app/templates/test/app_root/config/environments/in_memory.rb
|
|
57
|
+
- newplugin_generators/app/templates/test/app_root/config/environments/mysql.rb
|
|
58
|
+
- newplugin_generators/app/templates/test/app_root/config/environments/postgresql.rb
|
|
59
|
+
- newplugin_generators/app/templates/test/app_root/config/environments/sqlite.rb
|
|
60
|
+
- newplugin_generators/app/templates/test/app_root/config/environments/sqlite3.rb
|
|
61
|
+
- newplugin_generators/app/templates/test/app_root/config/initializers/plugin.rb
|
|
62
|
+
- newplugin_generators/app/templates/test/app_root/config/routes.rb
|
|
63
|
+
- newplugin_generators/app/templates/test/test_helper.rb
|
|
64
|
+
- newplugin_generators/app/templates/uninstall.rb
|
|
65
|
+
- newplugin_generators/controller/USAGE
|
|
66
|
+
- newplugin_generators/controller/controller_generator.rb
|
|
67
|
+
- newplugin_generators/controller/templates/controller.rb
|
|
68
|
+
- newplugin_generators/migration/USAGE
|
|
69
|
+
- newplugin_generators/migration/migration_generator.rb
|
|
70
|
+
- newplugin_generators/migration/templates/migration.rb
|
|
71
|
+
- newplugin_generators/model/USAGE
|
|
72
|
+
- newplugin_generators/model/model_generator.rb
|
|
73
|
+
- newplugin_generators/model/templates/fixtures.yml
|
|
74
|
+
- newplugin_generators/model/templates/migration.rb
|
|
75
|
+
- newplugin_generators/model/templates/model.rb
|
|
76
|
+
- newplugin_generators/scaffold/USAGE
|
|
77
|
+
- newplugin_generators/scaffold/scaffold_generator.rb
|
|
76
78
|
- test/test_generator_helper.rb
|
|
77
79
|
- test/test_helper.rb
|
|
78
80
|
- test/test_new_plugin.rb
|
data/generators/controller/USAGE
DELETED
data/generators/migration/USAGE
DELETED
data/generators/model/USAGE
DELETED