padrino-gen 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/README.rdoc +29 -28
  2. data/VERSION +1 -1
  3. data/lib/padrino-gen/generators/actions.rb +3 -3
  4. data/lib/padrino-gen/generators/app/app.rb.tt +5 -6
  5. data/lib/padrino-gen/generators/app.rb +6 -8
  6. data/lib/padrino-gen/generators/cli.rb +2 -2
  7. data/lib/padrino-gen/generators/components/actions.rb +6 -6
  8. data/lib/padrino-gen/generators/components/mocks/mocha_gen.rb +1 -1
  9. data/lib/padrino-gen/generators/components/mocks/rr_gen.rb +2 -2
  10. data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +6 -7
  11. data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +6 -6
  12. data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +5 -6
  13. data/lib/padrino-gen/generators/components/orms/mongoid_gen.rb +7 -8
  14. data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +5 -6
  15. data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +5 -6
  16. data/lib/padrino-gen/generators/components/renderers/erb_gen.rb +5 -5
  17. data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +5 -28
  18. data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +6 -7
  19. data/lib/padrino-gen/generators/components/scripts/mootools_gen.rb +6 -7
  20. data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +6 -7
  21. data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +6 -6
  22. data/lib/padrino-gen/generators/components/stylesheets/less_gen.rb +43 -0
  23. data/lib/padrino-gen/generators/components/stylesheets/sass_gen.rb +35 -0
  24. data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +6 -8
  25. data/lib/padrino-gen/generators/components/tests/cucumber_test_gen.rb +9 -8
  26. data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +7 -9
  27. data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +6 -7
  28. data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +6 -8
  29. data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +6 -8
  30. data/lib/padrino-gen/generators/controller.rb +3 -4
  31. data/lib/padrino-gen/generators/mailer.rb +4 -4
  32. data/lib/padrino-gen/generators/migration.rb +3 -4
  33. data/lib/padrino-gen/generators/model.rb +3 -3
  34. data/lib/padrino-gen/generators/project/config/apps.rb.tt +1 -1
  35. data/lib/padrino-gen/generators/project.rb +11 -9
  36. data/lib/padrino-gen/generators/templates/Gemfile.tt +2 -1
  37. data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
  38. data/lib/padrino-gen/generators/templates/mailer_initializer.rb.tt +1 -1
  39. data/lib/padrino-gen/padrino-tasks/activerecord.rb +8 -8
  40. data/lib/padrino-gen/padrino-tasks/datamapper.rb +1 -1
  41. data/lib/padrino-gen.rb +12 -12
  42. data/padrino-gen.gemspec +7 -11
  43. data/test/helper.rb +3 -3
  44. data/test/test_app_generator.rb +1 -1
  45. data/test/test_mailer_generator.rb +3 -1
  46. data/test/test_migration_generator.rb +5 -5
  47. data/test/test_model_generator.rb +7 -7
  48. data/test/test_project_generator.rb +27 -8
  49. metadata +7 -11
  50. data/lib/padrino-gen/generators/project/app/.empty_directory +0 -0
  51. data/lib/padrino-gen/generators/project/app/app.rb.tt +0 -37
  52. data/lib/padrino-gen/generators/project/app/controllers/.empty_directory +0 -0
  53. data/lib/padrino-gen/generators/project/app/helpers/.empty_directory +0 -0
  54. data/lib/padrino-gen/generators/project/app/views/.empty_directory +0 -0
  55. data/lib/padrino-gen/generators/project/app/views/layouts/.emptydirectory +0 -0
data/README.rdoc CHANGED
@@ -18,31 +18,32 @@ all starting dependencies and guidelines provided within the generated files to
18
18
  to using Padrino.
19
19
 
20
20
  One important feature of the generators is that they were built from the ground up to support a wide variety
21
- of tools, libraries and gems for use within your padrino application.
21
+ of tools, libraries and gems for use within your padrino application.
22
22
 
23
23
  The simplest possible command to generate a base application would be:
24
24
 
25
25
  $ padrino-gen project demo_project
26
-
27
- This would construct a Padrino application DemoApp (which extends from Padrino::Application)
28
- inside the folder 'demo_project' at our current path. Inside the application there would be configuration and
26
+
27
+ This would construct a Padrino application DemoApp (which extends from Padrino::Application)
28
+ inside the folder 'demo_project' at our current path. Inside the application there would be configuration and
29
29
  setup performed for the default components.
30
30
 
31
31
  You can define specific components to be used:
32
32
 
33
33
  $ padrino-gen project demo_project -t rspec -r haml -m rr -s jquery -d datamapper
34
-
34
+
35
35
  You can also instruct the generator to skip a certain component to avoid using one at all (or to use your own):
36
36
 
37
37
  $ padrino-gen project demo_project --test none --renderer none
38
-
38
+
39
39
  The available components and their default options are listed below:
40
40
 
41
- test:: rspec (default), bacon, shoulda, cucumber, testspec, riot
42
- renderer:: haml (default), erb
43
- mock:: none (default), mocha, rr
44
- script:: none (default), jquery, prototype, mootools, rightjs
45
- orm:: none (default), mongomapper, mongoid, activerecord, sequel, couchrest
41
+ test:: rspec (default), bacon, shoulda, cucumber, testspec, riot
42
+ renderer:: haml (default), erb
43
+ stylesheet:: sass (default), less
44
+ mock:: none (default), mocha, rr
45
+ script:: none (default), jquery, prototype, mootools, rightjs
46
+ orm:: none (default), mongomapper, mongoid, activerecord, sequel, couchrest
46
47
 
47
48
  To learn more about the project generator, check out the guide to
48
49
  {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
@@ -65,7 +66,7 @@ By default these apps are mounted under:
65
66
 
66
67
  * /one
67
68
  * /two
68
-
69
+
69
70
  but you can edit config/apps.rb and change it.
70
71
 
71
72
  To learn more about the subapp generator, check out the guide to
@@ -75,20 +76,20 @@ To learn more about the subapp generator, check out the guide to
75
76
 
76
77
  Padrino provides generator support for quickly creating new models within your Padrino application. Note that
77
78
  the models (and migrations) generated are specifically tailored towards the ORM component and testing framework
78
- chosen during application generation.
79
+ chosen during application generation.
79
80
 
80
- Very important to note that model generators are intended primarily to work within applications
81
- created through the Padrino application generator and that follow Padrino conventions. Using model generators
81
+ Very important to note that model generators are intended primarily to work within applications
82
+ created through the Padrino application generator and that follow Padrino conventions. Using model generators
82
83
  within an existing application not generated by Padrino will likely not work as expected.
83
84
 
84
85
  Using the model generator is as simple as:
85
86
 
86
87
  $ padrino-gen model User
87
-
88
+
88
89
  You can also specify desired fields to be contained within your User model:
89
90
 
90
91
  $ padrino-gen model User name:string age:integer email:string
91
-
92
+
92
93
  To learn more about the model generator, check out the guide to
93
94
  {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
94
95
 
@@ -97,43 +98,43 @@ To learn more about the model generator, check out the guide to
97
98
  Padrino provides generator for quickly generating new migrations to change or manipulate the database schema.
98
99
  These migrations generated will be tailored towards the ORM chosen when generating the application.
99
100
 
100
- Very important to note that migration generators are intended primarily to work within applications
101
- created through the Padrino application generator and that follow Padrino conventions. Using migration generators
101
+ Very important to note that migration generators are intended primarily to work within applications
102
+ created through the Padrino application generator and that follow Padrino conventions. Using migration generators
102
103
  within an existing application not generated by Padrino will likely not work as expected.
103
104
 
104
105
  Using the migration generator is as simple as:
105
106
 
106
107
  $ padrino-gen migration AddFieldsToUsers
107
108
  $ padrino-gen migration RemoveFieldsFromUsers
108
-
109
+
109
110
  To learn more about the migration generator, check out the guide to
110
111
  {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
111
112
 
112
113
  === Controller Generator
113
114
 
114
115
  Padrino provides generator support for quickly creating new controllers within your Padrino application. Note that
115
- the controller tests are generated specifically tailored towards the testing framework chosen
116
- during application generation.
116
+ the controller tests are generated specifically tailored towards the testing framework chosen
117
+ during application generation.
117
118
 
118
- Very important to note that controller generators are intended primarily to work within applications
119
- created through the Padrino application generator and that follow Padrino conventions.
119
+ Very important to note that controller generators are intended primarily to work within applications
120
+ created through the Padrino application generator and that follow Padrino conventions.
120
121
 
121
122
  Using the controller generator is as simple as:
122
123
 
123
124
  $ padrino-gen controller Admin
124
-
125
+
125
126
  You can also specify desired actions to be added to your controller:
126
127
 
127
128
  $ padrino-gen controller Admin get:index get:new post:create
128
-
129
+
129
130
  To learn more about the controller generator, check out the guide to
130
131
  {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
131
132
 
132
133
  === Mailer Generator
133
134
 
134
135
  Padrino provides generator support for quickly creating new mailers within your Padrino application.
135
- Very important to note that mailer generators are intended primarily to work within applications
136
- created through the Padrino application generator and that follow Padrino conventions.
136
+ Very important to note that mailer generators are intended primarily to work within applications
137
+ created through the Padrino application generator and that follow Padrino conventions.
137
138
 
138
139
  Using the mailer generator is as simple as:
139
140
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.6
1
+ 0.9.7
@@ -159,6 +159,6 @@ module Padrino
159
159
  @available_choices[component] + [:none]
160
160
  end
161
161
  end
162
- end
163
- end
164
- end
162
+ end # Actions
163
+ end # Generators
164
+ end # Padrino
@@ -1,9 +1,8 @@
1
1
  class <%= @class_name %> < Padrino::Application
2
2
  configure do
3
- register MailerInitializer if defined?(MailerInitializer) # Remove this if your not using mailer
4
3
  ##
5
4
  # Application-specific configuration options
6
- #
5
+ #
7
6
  # set :raise_errors, true # Show exceptions (default for development)
8
7
  # set :public, "foo/bar" # Location for static assets (default root/public)
9
8
  # set :sessions, false # Enabled by default
@@ -15,12 +14,12 @@ class <%= @class_name %> < Padrino::Application
15
14
  # disable :flash # Disables rack-flash (enabled by default)
16
15
  # enable :authentication # Enable padrino-admin authentication (disabled by default)
17
16
  # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
18
- #
17
+ #
19
18
  end
20
19
 
21
20
  ##
22
21
  # You can configure for a specified environment like:
23
- #
22
+ #
24
23
  # configure :development do
25
24
  # set :foo, :bar
26
25
  # end
@@ -28,8 +27,8 @@ class <%= @class_name %> < Padrino::Application
28
27
 
29
28
  ##
30
29
  # You can manage errors like:
31
- #
32
- # errors 404 do
30
+ #
31
+ # error 404 do
33
32
  # render 'errors/404'
34
33
  # end
35
34
  #
@@ -27,16 +27,16 @@ module Padrino
27
27
  # Copies over the Padrino base admin application
28
28
  def create_app
29
29
  self.destination_root = options[:root]
30
- @class_name = name.underscore.classify
30
+ @class_name = name.gsub(/\W/, "_").underscore.classify
31
31
  if in_app_root?
32
32
  directory("app/", destination_root(name))
33
33
  append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"#{@class_name}\").to(\"/#{name.underscore}\")"
34
-
34
+
35
35
  return if self.behavior == :revoke
36
36
  say (<<-TEXT).gsub(/ {10}/,'')
37
37
 
38
38
  =================================================================
39
- Your #{@class_name} Application now is installed.
39
+ Your #{@class_name} Application now is installed.
40
40
  It's available on /#{name.underscore}
41
41
  You can setup a new path editing config/apps.rb
42
42
  =================================================================
@@ -46,8 +46,6 @@ module Padrino
46
46
  say "You are not at the root of a Padrino application! (config/boot.rb not found)" and exit unless in_app_root?
47
47
  end
48
48
  end
49
-
50
- end
51
-
52
- end
53
- end
49
+ end # App
50
+ end # Generators
51
+ end # Padrino
@@ -5,7 +5,7 @@ module Padrino
5
5
  ##
6
6
  # This class bootstrap +config/boot+ and perform +Padrino::Generators.load_components!+ for handle
7
7
  # 3rd party generators
8
- #
8
+ #
9
9
  class Cli < Thor::Group
10
10
 
11
11
  # Include related modules
@@ -13,7 +13,7 @@ module Padrino
13
13
 
14
14
  class_option :root, :desc => "The root destination", :aliases => '-r', :default => nil, :type => :string
15
15
 
16
- # We need to TRY to load boot because some of our app dependencies maybe have
16
+ # We need to TRY to load boot because some of our app dependencies maybe have
17
17
  # custom generators, so is necessary know who are.
18
18
  def load_boot
19
19
  begin
@@ -70,11 +70,11 @@ module Padrino
70
70
  # For the removal of migration files
71
71
  # removes the migration file based on the migration name
72
72
  def remove_migration(name)
73
- migration_path = Dir[destination_root('db/migrate/*.rb')].find do |f|
73
+ migration_path = Dir[destination_root('db/migrate/*.rb')].find do |f|
74
74
  File.basename(f) =~ /#{name.to_s.underscore}/
75
75
  end
76
76
  return unless migration_path
77
- if behavior == :revoke
77
+ if behavior == :revoke
78
78
  create_file migration_path # we use create to reverse the operation of a revoke
79
79
  end
80
80
  end
@@ -114,7 +114,7 @@ module Padrino
114
114
  end
115
115
  action_declarations.join("\n ")
116
116
  end
117
- end
118
- end
119
- end
120
- end
117
+ end # Actions
118
+ end # Components
119
+ end # Generators
120
+ end # Padrino
@@ -2,7 +2,7 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Mocks
5
-
5
+
6
6
  module MochaGen
7
7
  def setup_mock
8
8
  require_dependencies 'mocha', :group => 'test'
@@ -10,7 +10,7 @@ module Padrino
10
10
  when 'rspec'
11
11
  inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "Spec::Runner.configure do |conf|\n"
12
12
  when 'riot'
13
- inject_into_file "test/test_config.rb"," Riot.rr\n", :after => "class Riot::Situation\n"
13
+ inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\"\n"
14
14
  else
15
15
  insert_mocking_include "RR::Adapters::RRMethods", :path => "test/test_config.rb"
16
16
  end
@@ -19,4 +19,4 @@ module Padrino
19
19
  end # Mocks
20
20
  end # Components
21
21
  end # Generators
22
- end # Padrino
22
+ end # Padrino
@@ -8,7 +8,7 @@ module Padrino
8
8
  AR = (<<-AR).gsub(/^ {10}/, '')
9
9
  ##
10
10
  # You can use other adapters like:
11
- #
11
+ #
12
12
  # ActiveRecord::Base.configurations[:development] = {
13
13
  # :adapter => 'mysql',
14
14
  # :encoding => 'utf8',
@@ -116,9 +116,8 @@ module Padrino
116
116
  :add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
117
117
  :remove => Proc.new { |field, kind| "t.remove :#{field}" })
118
118
  end
119
-
120
- end
121
- end
122
- end
123
- end
124
- end
119
+ end # ActiverecordGen
120
+ end # Orms
121
+ end # Components
122
+ end # Generators
123
+ end # Padrino
@@ -16,6 +16,7 @@ module Padrino
16
16
 
17
17
  def setup_orm
18
18
  require_dependencies 'couchrest'
19
+ require_dependencies 'json_pure'
19
20
  create_file("config/database.rb", COUCHREST.gsub(/!NAME!/, name.underscore))
20
21
  empty_directory('app/models')
21
22
  end
@@ -48,9 +49,8 @@ module Padrino
48
49
  def create_migration_file(migration_name, name, columns)
49
50
  # NO MIGRATION NEEDED
50
51
  end
51
- end
52
-
53
- end
54
- end
55
- end
56
- end
52
+ end # ActiverecordGen
53
+ end # Orms
54
+ end # Components
55
+ end # Generators
56
+ end # Padrino
@@ -90,9 +90,8 @@ module Padrino
90
90
  :remove => Proc.new { |field, kind| "drop_column :#{field}" }
91
91
  )
92
92
  end
93
- end
94
-
95
- end
96
- end
97
- end
98
- end
93
+ end # DatamapperGen
94
+ end # Orms
95
+ end # Components
96
+ end # Generators
97
+ end # Padrino
@@ -48,10 +48,10 @@ module Padrino
48
48
  # field <name>, :type => <type>, :default => <value>
49
49
  !FIELDS!
50
50
 
51
- # You can define indexes on documents using the index macro:
51
+ # You can define indexes on documents using the index macro:
52
52
  # index :field <, :unique => true>
53
53
 
54
- # You can create a composite key in mongoid to replace the default id using the key macro:
54
+ # You can create a composite key in mongoid to replace the default id using the key macro:
55
55
  # key :field <, :another_field, :one_more ....>
56
56
 
57
57
  end
@@ -73,9 +73,8 @@ module Padrino
73
73
  def create_migration_file(migration_name, name, columns)
74
74
  # NO MIGRATION NEEDED
75
75
  end
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
76
+ end # MongoidGen
77
+ end # Orms
78
+ end # Components
79
+ end # Generators
80
+ end # Padrino
@@ -48,9 +48,8 @@ module Padrino
48
48
  def create_migration_file(migration_name, name, columns)
49
49
  # NO MIGRATION NEEDED
50
50
  end
51
- end
52
-
53
- end
54
- end
55
- end
56
- end
51
+ end # MongomapperGen
52
+ end # Orms
53
+ end # Components
54
+ end # Generators
55
+ end # Padrino
@@ -76,9 +76,8 @@ module Padrino
76
76
  :remove => Proc.new { |field, kind| "drop_column :#{field}" }
77
77
  )
78
78
  end
79
- end
80
-
81
- end
82
- end
83
- end
84
- end
79
+ end # SequelGen
80
+ end # Orms
81
+ end # Components
82
+ end # Generators
83
+ end # Padrino
@@ -7,8 +7,8 @@ module Padrino
7
7
  def setup_renderer
8
8
  # Nothing to do
9
9
  end
10
- end
11
- end
12
- end
13
- end
14
- end
10
+ end # ErbGen
11
+ end # Renderers
12
+ end # Components
13
+ end # Generators
14
+ end # Padrino
@@ -5,34 +5,11 @@ module Padrino
5
5
 
6
6
  module HamlGen
7
7
 
8
- SASS_INIT = (<<-SASS).gsub(/^ {10}/, '')
9
- # Enables support for SASS template reloading for rack.
10
- # Store SASS files by default within 'app/stylesheets/sass'
11
- # See http://nex-3.com/posts/88-sass-supports-rack for more details.
12
-
13
- module SassInitializer
14
- def self.registered(app)
15
- require 'sass/plugin/rack'
16
- Sass::Plugin.options[:template_location] = File.join(Padrino.root, "app/stylesheets")
17
- Sass::Plugin.options[:css_location] = File.join(Padrino.root, "public/stylesheets")
18
- app.use Sass::Plugin::Rack
19
- end
20
- end
21
- SASS
22
-
23
- SASS_REGISTER = (<<-SASSR).gsub(/^ {10}/, '')
24
- register SassInitializer # Remove if not using SASS\n
25
- SASSR
26
-
27
8
  def setup_renderer
28
9
  require_dependencies 'haml'
29
- create_file destination_root('/lib/sass.rb'), SASS_INIT
30
- inject_into_file destination_root('/app/app.rb'), SASS_REGISTER, :after => "configure do\n"
31
- empty_directory destination_root('/app/stylesheets')
32
10
  end
33
- end
34
-
35
- end
36
- end
37
- end
38
- end
11
+ end # HamlGen
12
+ end # Renderers
13
+ end # Components
14
+ end # Generators
15
+ end # Padrino
@@ -2,15 +2,14 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Scripts
5
-
5
+
6
6
  module JqueryGen
7
7
  def setup_script
8
8
  copy_file('templates/scripts/jquery.js', destination_root("/public/javascripts/jquery.js"))
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
10
  end
11
- end
12
-
13
- end
14
- end
15
- end
16
- end
11
+ end # JqueryGen
12
+ end # Scripts
13
+ end # Components
14
+ end # Generators
15
+ end # Padrino
@@ -2,15 +2,14 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Scripts
5
-
5
+
6
6
  module MootoolsGen
7
7
  def setup_script
8
8
  copy_file('templates/scripts/mootools-core.js', destination_root("/public/javascripts/mootools-core.js"))
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
10
  end
11
- end
12
-
13
- end
14
- end
15
- end
16
- end
11
+ end # MootoolsGen
12
+ end # Scripts
13
+ end # Components
14
+ end # Generators
15
+ end # Padrino
@@ -2,16 +2,15 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Scripts
5
-
5
+
6
6
  module PrototypeGen
7
7
  def setup_script
8
8
  copy_file('templates/scripts/protopak.js', destination_root("/public/javascripts/protopak.js"))
9
9
  copy_file('templates/scripts/lowpro.js', destination_root("/public/javascripts/lowpro.js"))
10
10
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
11
11
  end
12
- end
13
-
14
- end
15
- end
16
- end
17
- end
12
+ end # PrototypeGen
13
+ end # Scripts
14
+ end # Components
15
+ end # Generators
16
+ end # Padrino
@@ -2,14 +2,14 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Scripts
5
-
5
+
6
6
  module RightjsGen
7
7
  def setup_script
8
8
  copy_file('templates/scripts/right.js', destination_root("/public/javascripts/right.js"))
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
10
  end
11
- end
12
- end
13
- end
14
- end
15
- end
11
+ end # RightjsGen
12
+ end # Scripts
13
+ end # Components
14
+ end # Generators
15
+ end # Padrino
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,35 @@
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