padrino-gen 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -10
- data/Rakefile +4 -15
- data/bin/padrino-gen +3 -0
- data/lib/padrino-gen/generators/actions.rb +10 -4
- data/lib/padrino-gen/generators/app/app.rb.tt +2 -2
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +9 -0
- data/lib/padrino-gen/generators/components/mocks/rr.rb +11 -0
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +112 -0
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +44 -0
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +86 -0
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +68 -0
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +43 -0
- data/lib/padrino-gen/generators/components/orms/sequel.rb +71 -0
- data/lib/padrino-gen/generators/components/renderers/erb.rb +3 -0
- data/lib/padrino-gen/generators/components/renderers/haml.rb +3 -0
- data/lib/padrino-gen/generators/components/scripts/extcore.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/jquery.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/mootools.rb +4 -0
- data/lib/padrino-gen/generators/components/scripts/prototype.rb +5 -0
- data/lib/padrino-gen/generators/components/scripts/rightjs.rb +4 -0
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +33 -0
- data/lib/padrino-gen/generators/components/stylesheets/sass.rb +25 -0
- data/lib/padrino-gen/generators/components/tests/bacon.rb +64 -0
- data/lib/padrino-gen/generators/components/tests/cucumber.rb +63 -0
- data/lib/padrino-gen/generators/components/tests/riot.rb +69 -0
- data/lib/padrino-gen/generators/components/tests/rspec.rb +66 -0
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +70 -0
- data/lib/padrino-gen/generators/components/tests/testspec.rb +63 -0
- data/lib/padrino-gen/generators/controller.rb +4 -4
- data/lib/padrino-gen/generators/project/config/apps.rb.tt +12 -4
- data/lib/padrino-gen/generators/project/config/boot.rb +1 -1
- data/lib/padrino-gen/generators/project.rb +1 -1
- data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
- data/lib/padrino-gen/generators/templates/scripts/ext-core.js +8 -0
- data/lib/padrino-gen/generators/templates/scripts/jquery.js +150 -15
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +1 -1
- data/lib/padrino-gen/padrino-tasks/mongomapper.rb +1 -1
- data/lib/padrino-gen/padrino-tasks/sequel.rb +37 -0
- data/lib/padrino-gen.rb +9 -2
- data/padrino-gen.gemspec +30 -28
- data/test/helper.rb +5 -0
- data/test/test_app_generator.rb +11 -19
- data/test/test_cli.rb +4 -6
- data/test/test_controller_generator.rb +43 -33
- data/test/test_mailer_generator.rb +11 -17
- data/test/test_migration_generator.rb +42 -47
- data/test/test_model_generator.rb +90 -89
- data/test/test_project_generator.rb +43 -39
- metadata +30 -28
- data/VERSION +0 -1
- data/lib/padrino-gen/generators/components/mocks/mocha_gen.rb +0 -20
- data/lib/padrino-gen/generators/components/mocks/rr_gen.rb +0 -22
- data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +0 -123
- data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +0 -56
- data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +0 -97
- data/lib/padrino-gen/generators/components/orms/mongoid_gen.rb +0 -80
- data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +0 -55
- data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +0 -83
- data/lib/padrino-gen/generators/components/renderers/erb_gen.rb +0 -14
- data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/mootools_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +0 -16
- data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +0 -15
- data/lib/padrino-gen/generators/components/stylesheets/less_gen.rb +0 -43
- data/lib/padrino-gen/generators/components/stylesheets/sass_gen.rb +0 -35
- data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +0 -75
- data/lib/padrino-gen/generators/components/tests/cucumber_test_gen.rb +0 -76
- data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +0 -80
- data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +0 -85
- data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +0 -81
- data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +0 -74
@@ -1,97 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module DatamapperGen
|
7
|
-
DM = (<<-DM).gsub(/^ {10}/, '')
|
8
|
-
##
|
9
|
-
# A MySQL connection:
|
10
|
-
# DataMapper.setup(:default, 'mysql://user:password@localhost/the_database_name')
|
11
|
-
#
|
12
|
-
# # A Postgres connection:
|
13
|
-
# DataMapper.setup(:default, 'postgres://user:password@localhost/the_database_name')
|
14
|
-
#
|
15
|
-
|
16
|
-
DataMapper.logger = logger
|
17
|
-
|
18
|
-
case Padrino.env
|
19
|
-
when :development then DataMapper.setup(:default, "sqlite3://" + Padrino.root('db', "development.db"))
|
20
|
-
when :production then DataMapper.setup(:default, "sqlite3://" + Padrino.root('db', "production.db"))
|
21
|
-
when :test then DataMapper.setup(:default, "sqlite3://" + Padrino.root('db', "test.db"))
|
22
|
-
end
|
23
|
-
DM
|
24
|
-
|
25
|
-
def setup_orm
|
26
|
-
require_dependencies 'data_objects', 'do_sqlite3', 'datamapper'
|
27
|
-
create_file("config/database.rb", DM)
|
28
|
-
empty_directory('app/models')
|
29
|
-
end
|
30
|
-
|
31
|
-
DM_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
32
|
-
class !NAME!
|
33
|
-
include DataMapper::Resource
|
34
|
-
|
35
|
-
# property <name>, <type>
|
36
|
-
property :id, Serial
|
37
|
-
!FIELDS!
|
38
|
-
end
|
39
|
-
MODEL
|
40
|
-
|
41
|
-
def create_model_file(name, fields)
|
42
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
43
|
-
model_contents = DM_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
|
44
|
-
field_tuples = fields.collect { |value| value.split(":") }
|
45
|
-
field_tuples.collect! { |field, kind| kind =~ /datetime/i ? [field, 'DateTime'] : [field, kind] } # fix datetime
|
46
|
-
column_declarations = field_tuples.collect { |field, kind|"property :#{field}, #{kind.camelize}" }.join("\n ")
|
47
|
-
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
48
|
-
create_file(model_path, model_contents)
|
49
|
-
end
|
50
|
-
|
51
|
-
DM_MIGRATION = (<<-MIGRATION).gsub(/^ {10}/, '')
|
52
|
-
migration !VERSION!, :!FILENAME! do
|
53
|
-
up do
|
54
|
-
!UP!
|
55
|
-
end
|
56
|
-
|
57
|
-
down do
|
58
|
-
!DOWN!
|
59
|
-
end
|
60
|
-
end
|
61
|
-
MIGRATION
|
62
|
-
|
63
|
-
DM_MODEL_UP_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
64
|
-
create_table :!TABLE! do
|
65
|
-
column :id, Integer, :serial => true
|
66
|
-
!FIELDS!
|
67
|
-
end
|
68
|
-
MIGRATION
|
69
|
-
|
70
|
-
DM_MODEL_DOWN_MG = (<<-MIGRATION).gsub(/^ {10}/, '')
|
71
|
-
drop_table :!TABLE!
|
72
|
-
MIGRATION
|
73
|
-
|
74
|
-
def create_model_migration(migration_name, name, columns)
|
75
|
-
output_model_migration(migration_name, name, columns,
|
76
|
-
:column_format => Proc.new { |field, kind| "column :#{field}, #{kind.camelize}" },
|
77
|
-
:base => DM_MIGRATION, :up => DM_MODEL_UP_MG, :down => DM_MODEL_DOWN_MG)
|
78
|
-
end
|
79
|
-
|
80
|
-
DM_CHANGE_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
81
|
-
modify_table :!TABLE! do
|
82
|
-
!COLUMNS!
|
83
|
-
end
|
84
|
-
MIGRATION
|
85
|
-
|
86
|
-
def create_migration_file(migration_name, name, columns)
|
87
|
-
output_migration_file(migration_name, name, columns,
|
88
|
-
:base => DM_MIGRATION, :change_format => DM_CHANGE_MG,
|
89
|
-
:add => Proc.new { |field, kind| "add_column :#{field}, #{kind.camelize}" },
|
90
|
-
:remove => Proc.new { |field, kind| "drop_column :#{field}" }
|
91
|
-
)
|
92
|
-
end
|
93
|
-
end # DatamapperGen
|
94
|
-
end # Orms
|
95
|
-
end # Components
|
96
|
-
end # Generators
|
97
|
-
end # Padrino
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module MongoidGen
|
7
|
-
|
8
|
-
MONGOID = (<<-MONGO).gsub(/^ {10}/, '')
|
9
|
-
|
10
|
-
# Connection.new takes host, port
|
11
|
-
host = 'localhost'
|
12
|
-
port = Mongo::Connection::DEFAULT_PORT
|
13
|
-
|
14
|
-
database_name = case Padrino.env
|
15
|
-
when :development then '!NAME!_development'
|
16
|
-
when :production then '!NAME!_production'
|
17
|
-
when :test then '!NAME!_test'
|
18
|
-
end
|
19
|
-
|
20
|
-
Mongoid.database = Mongo::Connection.new(host, port).db(database_name)
|
21
|
-
|
22
|
-
# You can also configure Mongoid this way
|
23
|
-
# Mongoid.configure do |config|
|
24
|
-
# name = @settings["database"]
|
25
|
-
# host = @settings["host"]
|
26
|
-
# config.master = Mongo::Connection.new.db(name)
|
27
|
-
# config.slaves = [
|
28
|
-
# Mongo::Connection.new(host, @settings["slave_one"]["port"], :slave_ok => true).db(name),
|
29
|
-
# Mongo::Connection.new(host, @settings["slave_two"]["port"], :slave_ok => true).db(name)
|
30
|
-
# ]
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# More installation and setup notes are on http://mongoid.org/docs/
|
34
|
-
MONGO
|
35
|
-
|
36
|
-
def setup_orm
|
37
|
-
require_dependencies 'mongo_ext', :require => 'mongo'
|
38
|
-
require_dependencies 'mongoid'
|
39
|
-
create_file("config/database.rb", MONGOID.gsub(/!NAME!/, name.underscore))
|
40
|
-
empty_directory('app/models')
|
41
|
-
end
|
42
|
-
|
43
|
-
MONGOID_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
44
|
-
class !NAME!
|
45
|
-
include Mongoid::Document
|
46
|
-
include Mongoid::Timestamps # adds created_at and updated_at fields
|
47
|
-
|
48
|
-
# field <name>, :type => <type>, :default => <value>
|
49
|
-
!FIELDS!
|
50
|
-
|
51
|
-
# You can define indexes on documents using the index macro:
|
52
|
-
# index :field <, :unique => true>
|
53
|
-
|
54
|
-
# You can create a composite key in mongoid to replace the default id using the key macro:
|
55
|
-
# key :field <, :another_field, :one_more ....>
|
56
|
-
|
57
|
-
end
|
58
|
-
MODEL
|
59
|
-
|
60
|
-
def create_model_file(name, fields)
|
61
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
62
|
-
field_tuples = fields.collect { |value| value.split(":") }
|
63
|
-
column_declarations = field_tuples.collect { |field, kind| "field :#{field}, :type => #{kind.camelize}" }.join("\n ")
|
64
|
-
model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.camelize)
|
65
|
-
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
66
|
-
create_file(model_path, model_contents)
|
67
|
-
end
|
68
|
-
|
69
|
-
def create_model_migration(filename, name, fields)
|
70
|
-
# NO MIGRATION NEEDED
|
71
|
-
end
|
72
|
-
|
73
|
-
def create_migration_file(migration_name, name, columns)
|
74
|
-
# NO MIGRATION NEEDED
|
75
|
-
end
|
76
|
-
end # MongoidGen
|
77
|
-
end # Orms
|
78
|
-
end # Components
|
79
|
-
end # Generators
|
80
|
-
end # Padrino
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module MongomapperGen
|
7
|
-
|
8
|
-
MONGO = (<<-MONGO).gsub(/^ {10}/, '')
|
9
|
-
MongoMapper.connection = Mongo::Connection.new('localhost', nil, :logger => logger)
|
10
|
-
|
11
|
-
case Padrino.env
|
12
|
-
when :development then MongoMapper.database = '!NAME!_development'
|
13
|
-
when :production then MongoMapper.database = '!NAME!_production'
|
14
|
-
when :test then MongoMapper.database = '!NAME!_test'
|
15
|
-
end
|
16
|
-
MONGO
|
17
|
-
|
18
|
-
def setup_orm
|
19
|
-
require_dependencies 'mongo_ext', :require => 'mongo'
|
20
|
-
require_dependencies 'mongo_mapper'
|
21
|
-
create_file("config/database.rb", MONGO.gsub(/!NAME!/, name.underscore))
|
22
|
-
empty_directory('app/models')
|
23
|
-
end
|
24
|
-
|
25
|
-
MM_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
26
|
-
class !NAME!
|
27
|
-
include MongoMapper::Document
|
28
|
-
|
29
|
-
# key <name>, <type>
|
30
|
-
!FIELDS!
|
31
|
-
timestamps!
|
32
|
-
end
|
33
|
-
MODEL
|
34
|
-
|
35
|
-
def create_model_file(name, fields)
|
36
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
37
|
-
field_tuples = fields.collect { |value| value.split(":") }
|
38
|
-
column_declarations = field_tuples.collect { |field, kind| "key :#{field}, #{kind.camelize}" }.join("\n ")
|
39
|
-
model_contents = MM_MODEL.gsub(/!NAME!/, name.to_s.camelize)
|
40
|
-
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
41
|
-
create_file(model_path, model_contents)
|
42
|
-
end
|
43
|
-
|
44
|
-
def create_model_migration(filename, name, fields)
|
45
|
-
# NO MIGRATION NEEDED
|
46
|
-
end
|
47
|
-
|
48
|
-
def create_migration_file(migration_name, name, columns)
|
49
|
-
# NO MIGRATION NEEDED
|
50
|
-
end
|
51
|
-
end # MongomapperGen
|
52
|
-
end # Orms
|
53
|
-
end # Components
|
54
|
-
end # Generators
|
55
|
-
end # Padrino
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Orms
|
5
|
-
|
6
|
-
module SequelGen
|
7
|
-
|
8
|
-
SEQUEL = (<<-SEQUEL).gsub(/^ {10}/, '')
|
9
|
-
Sequel::Model.plugin(:schema)
|
10
|
-
case Padrino.env
|
11
|
-
when :development then Sequel.connect("sqlite3://" + Padrino.root('db', "development.db"), :loggers => [logger])
|
12
|
-
when :production then Sequel.connect("sqlite3://" + Padrino.root('db', "production.db"), :loggers => [logger])
|
13
|
-
when :test then Sequel.connect("sqlite3://" + Padrino.root('db', "test.db"), :loggers => [logger])
|
14
|
-
end
|
15
|
-
SEQUEL
|
16
|
-
|
17
|
-
def setup_orm
|
18
|
-
require_dependencies 'sequel'
|
19
|
-
create_file("config/database.rb", SEQUEL)
|
20
|
-
empty_directory('app/models')
|
21
|
-
end
|
22
|
-
|
23
|
-
SQ_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
|
24
|
-
class !NAME! < Sequel::Model
|
25
|
-
|
26
|
-
end
|
27
|
-
MODEL
|
28
|
-
|
29
|
-
def create_model_file(name, fields)
|
30
|
-
model_path = destination_root('app/models/', "#{name.to_s.underscore}.rb")
|
31
|
-
model_contents = SQ_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
|
32
|
-
create_file(model_path, model_contents)
|
33
|
-
end
|
34
|
-
|
35
|
-
SQ_MIGRATION = (<<-MIGRATION).gsub(/^ {10}/, '')
|
36
|
-
class !FILECLASS! < Sequel::Migration
|
37
|
-
def up
|
38
|
-
!UP!
|
39
|
-
end
|
40
|
-
|
41
|
-
def down
|
42
|
-
!DOWN!
|
43
|
-
end
|
44
|
-
end
|
45
|
-
MIGRATION
|
46
|
-
|
47
|
-
|
48
|
-
SQ_MODEL_UP_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
49
|
-
create_table :!TABLE! do
|
50
|
-
primary_key :id
|
51
|
-
# <type> <name>
|
52
|
-
!FIELDS!
|
53
|
-
end
|
54
|
-
MIGRATION
|
55
|
-
|
56
|
-
SQ_MODEL_DOWN_MG = (<<-MIGRATION).gsub(/^ {10}/, '')
|
57
|
-
drop_table :!TABLE!
|
58
|
-
MIGRATION
|
59
|
-
|
60
|
-
def create_model_migration(migration_name, name, columns)
|
61
|
-
output_model_migration(migration_name, name, columns,
|
62
|
-
:column_format => Proc.new { |field, kind| "#{kind.camelize} :#{field}" },
|
63
|
-
:base => SQ_MIGRATION, :up => SQ_MODEL_UP_MG, :down => SQ_MODEL_DOWN_MG)
|
64
|
-
end
|
65
|
-
|
66
|
-
SQ_CHANGE_MG = (<<-MIGRATION).gsub(/^ {6}/, '')
|
67
|
-
alter_table :!TABLE! do
|
68
|
-
!COLUMNS!
|
69
|
-
end
|
70
|
-
MIGRATION
|
71
|
-
|
72
|
-
def create_migration_file(migration_name, name, columns)
|
73
|
-
output_migration_file(migration_name, name, columns,
|
74
|
-
:base => SQ_MIGRATION, :change_format => SQ_CHANGE_MG,
|
75
|
-
:add => Proc.new { |field, kind| "add_column :#{field}, #{kind.camelize}" },
|
76
|
-
:remove => Proc.new { |field, kind| "drop_column :#{field}" }
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end # SequelGen
|
80
|
-
end # Orms
|
81
|
-
end # Components
|
82
|
-
end # Generators
|
83
|
-
end # Padrino
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Scripts
|
5
|
-
|
6
|
-
module JqueryGen
|
7
|
-
def setup_script
|
8
|
-
copy_file('templates/scripts/jquery.js', destination_root("/public/javascripts/jquery.js"))
|
9
|
-
create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
|
10
|
-
end
|
11
|
-
end # JqueryGen
|
12
|
-
end # Scripts
|
13
|
-
end # Components
|
14
|
-
end # Generators
|
15
|
-
end # Padrino
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Scripts
|
5
|
-
|
6
|
-
module MootoolsGen
|
7
|
-
def setup_script
|
8
|
-
copy_file('templates/scripts/mootools-core.js', destination_root("/public/javascripts/mootools-core.js"))
|
9
|
-
create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
|
10
|
-
end
|
11
|
-
end # MootoolsGen
|
12
|
-
end # Scripts
|
13
|
-
end # Components
|
14
|
-
end # Generators
|
15
|
-
end # Padrino
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Scripts
|
5
|
-
|
6
|
-
module PrototypeGen
|
7
|
-
def setup_script
|
8
|
-
copy_file('templates/scripts/protopak.js', destination_root("/public/javascripts/protopak.js"))
|
9
|
-
copy_file('templates/scripts/lowpro.js', destination_root("/public/javascripts/lowpro.js"))
|
10
|
-
create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
|
11
|
-
end
|
12
|
-
end # PrototypeGen
|
13
|
-
end # Scripts
|
14
|
-
end # Components
|
15
|
-
end # Generators
|
16
|
-
end # Padrino
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Scripts
|
5
|
-
|
6
|
-
module RightjsGen
|
7
|
-
def setup_script
|
8
|
-
copy_file('templates/scripts/right.js', destination_root("/public/javascripts/right.js"))
|
9
|
-
create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
|
10
|
-
end
|
11
|
-
end # RightjsGen
|
12
|
-
end # Scripts
|
13
|
-
end # Components
|
14
|
-
end # Generators
|
15
|
-
end # Padrino
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Stylesheets
|
5
|
-
module LessGen
|
6
|
-
LESS_INIT = (<<-LESS).gsub(/^ {10}/, '')
|
7
|
-
# Enables support for Less template reloading for rack.
|
8
|
-
# Store Less files by default within 'app/stylesheets/'
|
9
|
-
# See http://github.com/kelredd/rack-less for more details.
|
10
|
-
|
11
|
-
module LessInitializer
|
12
|
-
def self.registered(app)
|
13
|
-
require 'rack/less'
|
14
|
-
# optional - use as necessary
|
15
|
-
Rack::Less.configure do |config|
|
16
|
-
config.compress = true
|
17
|
-
# other configs ...
|
18
|
-
end
|
19
|
-
app.use Rack::Less,
|
20
|
-
:root => app.root,
|
21
|
-
:source => 'stylesheets/',
|
22
|
-
:public => 'public/',
|
23
|
-
:hosted_at => '/stylesheets'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
LESS
|
28
|
-
|
29
|
-
LESS_REGISTER = (<<-LESSR).gsub(/^ {10}/, '')
|
30
|
-
register LessInitializer\n
|
31
|
-
LESSR
|
32
|
-
|
33
|
-
def setup_stylesheet
|
34
|
-
require_dependencies 'less', 'rack-less'
|
35
|
-
create_file destination_root('/lib/less.rb'), LESS_INIT
|
36
|
-
inject_into_file destination_root('/app/app.rb'), LESS_REGISTER, :after => "configure do\n"
|
37
|
-
empty_directory destination_root('/app/stylesheets')
|
38
|
-
end
|
39
|
-
end # LessGen
|
40
|
-
end # Stylesheets
|
41
|
-
end # Components
|
42
|
-
end # Generators
|
43
|
-
end # Padrino
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Stylesheets
|
5
|
-
module SassGen
|
6
|
-
SASS_INIT = (<<-SASS).gsub(/^ {10}/, '')
|
7
|
-
# Enables support for SASS template reloading for rack.
|
8
|
-
# Store SASS files by default within 'app/stylesheets/sass'
|
9
|
-
# See http://nex-3.com/posts/88-sass-supports-rack for more details.
|
10
|
-
|
11
|
-
module SassInitializer
|
12
|
-
def self.registered(app)
|
13
|
-
require 'sass/plugin/rack'
|
14
|
-
Sass::Plugin.options[:template_location] = Padrino.root("app/stylesheets")
|
15
|
-
Sass::Plugin.options[:css_location] = Padrino.root("public/stylesheets")
|
16
|
-
app.use Sass::Plugin::Rack
|
17
|
-
end
|
18
|
-
end
|
19
|
-
SASS
|
20
|
-
|
21
|
-
SASS_REGISTER = (<<-SASSR).gsub(/^ {10}/, '')
|
22
|
-
register SassInitializer\n
|
23
|
-
SASSR
|
24
|
-
|
25
|
-
def setup_stylesheet
|
26
|
-
require_dependencies 'haml'
|
27
|
-
create_file destination_root('/lib/sass.rb'), SASS_INIT
|
28
|
-
inject_into_file destination_root('/app/app.rb'), SASS_REGISTER, :after => "configure do\n"
|
29
|
-
empty_directory destination_root('/app/stylesheets')
|
30
|
-
end
|
31
|
-
end # SassGen
|
32
|
-
end # Stylesheets
|
33
|
-
end # Components
|
34
|
-
end # Generators
|
35
|
-
end # Padrino
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Generators
|
3
|
-
module Components
|
4
|
-
module Tests
|
5
|
-
|
6
|
-
module BaconGen
|
7
|
-
BACON_SETUP = (<<-TEST).gsub(/^ {10}/, '')
|
8
|
-
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
|
9
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
10
|
-
|
11
|
-
class Bacon::Context
|
12
|
-
include Rack::Test::Methods
|
13
|
-
end
|
14
|
-
|
15
|
-
def app
|
16
|
-
##
|
17
|
-
# You can hanlde all padrino applications using instead:
|
18
|
-
# Padrino.application
|
19
|
-
CLASS_NAME.tap { |app| }
|
20
|
-
end
|
21
|
-
TEST
|
22
|
-
|
23
|
-
BACON_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
|
24
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
|
25
|
-
|
26
|
-
describe "!NAME!Controller" do
|
27
|
-
it 'returns text at root' do
|
28
|
-
get "/"
|
29
|
-
last_response.body.should == "some text"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
TEST
|
33
|
-
|
34
|
-
BACON_RAKE = (<<-TEST).gsub(/^ {10}/, '')
|
35
|
-
require 'rake/testtask'
|
36
|
-
|
37
|
-
Rake::TestTask.new(:test) do |test|
|
38
|
-
test.pattern = '**/*_test.rb'
|
39
|
-
test.verbose = true
|
40
|
-
end
|
41
|
-
TEST
|
42
|
-
|
43
|
-
BACON_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '')
|
44
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
|
45
|
-
|
46
|
-
describe "!NAME! Model" do
|
47
|
-
it 'can be created' do
|
48
|
-
@!DNAME! = !NAME!.new
|
49
|
-
@!DNAME!.should.not.be.nil
|
50
|
-
end
|
51
|
-
end
|
52
|
-
TEST
|
53
|
-
|
54
|
-
# Setup the testing configuration helper and dependencies
|
55
|
-
def setup_test
|
56
|
-
require_dependencies 'bacon', :group => 'test'
|
57
|
-
insert_test_suite_setup BACON_SETUP, :path => 'test/test_config.rb'
|
58
|
-
create_file destination_root("test/test.rake"), BACON_RAKE
|
59
|
-
end
|
60
|
-
|
61
|
-
# Generates a controller test given the controllers name
|
62
|
-
def generate_controller_test(name)
|
63
|
-
bacon_contents = BACON_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
|
64
|
-
create_file destination_root("test/controllers/","#{name}_controller_test.rb"), bacon_contents, :skip => true
|
65
|
-
end
|
66
|
-
|
67
|
-
def generate_model_test(name)
|
68
|
-
bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.downcase.underscore)
|
69
|
-
create_file destination_root("test/models/#{name.to_s.downcase}_test.rb"), bacon_contents, :skip => true
|
70
|
-
end
|
71
|
-
end # BaconGen
|
72
|
-
end # Tests
|
73
|
-
end # Components
|
74
|
-
end # Generators
|
75
|
-
end # Padrino
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'padrino-gen/generators/components/tests/rspec_test_gen'
|
2
|
-
|
3
|
-
module Padrino
|
4
|
-
module Generators
|
5
|
-
module Components
|
6
|
-
module Tests
|
7
|
-
|
8
|
-
module CucumberGen
|
9
|
-
include Padrino::Generators::Components::Tests::RspecGen
|
10
|
-
|
11
|
-
CUCUMBER_SETUP = (<<-TEST).gsub(/^ {10}/, '')
|
12
|
-
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
|
13
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
|
14
|
-
|
15
|
-
require 'capybara/cucumber'
|
16
|
-
require 'spec/expectations'
|
17
|
-
|
18
|
-
##
|
19
|
-
# You can hanlde all padrino applications using instead:
|
20
|
-
# Padrino.application
|
21
|
-
Capybara.app = CLASS_NAME.tap { |app| }
|
22
|
-
TEST
|
23
|
-
|
24
|
-
CUCUMBER_YML = (<<-TEST).gsub(/^ {10}/, '')
|
25
|
-
default: --tags ~@wip --strict features
|
26
|
-
html_report: --tags ~@wip --strict --format html --out=features_report.html features
|
27
|
-
TEST
|
28
|
-
|
29
|
-
CUCUMBER_FEATURE = (<<-TEST).gsub(/^ {10}/, '')
|
30
|
-
Feature: Addition
|
31
|
-
In order to avoid silly mistakes
|
32
|
-
As a math idiot
|
33
|
-
I want to be told the sum of two numbers
|
34
|
-
|
35
|
-
Scenario: Add two numbers
|
36
|
-
Given I visit the calculator page
|
37
|
-
And I fill in '50' for 'first'
|
38
|
-
And I fill in '70' for 'second'
|
39
|
-
When I press 'Add'
|
40
|
-
Then I should see 'Answer: 120'
|
41
|
-
TEST
|
42
|
-
|
43
|
-
CUCUMBER_STEP = (<<-TEST).gsub(/^ {10}/, '')
|
44
|
-
Given /^I visit the calculator page$/ do
|
45
|
-
visit '/add'
|
46
|
-
end
|
47
|
-
|
48
|
-
Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
|
49
|
-
fill_in(field, :with => value)
|
50
|
-
end
|
51
|
-
|
52
|
-
When /^I press '(.*)'$/ do |name|
|
53
|
-
click_button(name)
|
54
|
-
end
|
55
|
-
|
56
|
-
Then /^I should see '(.*)'$/ do |text|
|
57
|
-
response_body.should contain(/#\{text}/m)
|
58
|
-
end
|
59
|
-
TEST
|
60
|
-
|
61
|
-
def setup_test_with_cucumber
|
62
|
-
require_dependencies 'cucumber', :group => 'test'
|
63
|
-
require_dependencies 'capybara', :group => 'test'
|
64
|
-
insert_test_suite_setup CUCUMBER_SETUP, :path => "features/support/env.rb"
|
65
|
-
create_file destination_root("features/add.feature"), CUCUMBER_FEATURE
|
66
|
-
create_file destination_root("features/step_definitions/add_steps.rb"), CUCUMBER_STEP
|
67
|
-
create_file destination_root("cucumber.yml"), CUCUMBER_YML
|
68
|
-
setup_test_without_cucumber
|
69
|
-
end
|
70
|
-
|
71
|
-
alias_method_chain :setup_test, :cucumber
|
72
|
-
end # CucumberGen
|
73
|
-
end # Tests
|
74
|
-
end # Components
|
75
|
-
end # Generators
|
76
|
-
end # Padrino
|