Class: Compass::Installers::RailsInstaller
- Inherits:
-
Base
- Object
- Base
- Compass::Installers::RailsInstaller
show all
- Defined in:
- lib/compass/installers/rails.rb
Instance Attribute Summary
Attributes inherited from Base
#manifest, #options, #target_path, #template_path, #working_path
Attributes included from Actions
#logger
Instance Method Summary
collapse
Methods inherited from Base
#compilation_required?, #configure_option_with_default, #initialize, #install, installer, #manifest_file, #run, #targetize, #templatize
Methods included from Actions
#basename, #compile, #copy, #directory, #relativize, #separate, #strip_trailing_separator, #write_file
Instance Method Details
6
7
8
9
10
11
12
13
14
|
# File 'lib/compass/installers/rails.rb', line 6
def configure
configuration_file = targetize('config/initializers/compass.rb')
if File.exists?(configuration_file)
open(configuration_file) do |config|
eval(config.read, nil, configuration_file)
end
end
Compass.configuration.set_maybe(options)
end
|
#css_dir ⇒ Object
48
49
50
|
# File 'lib/compass/installers/rails.rb', line 48
def css_dir
Compass.configuration.css_dir
end
|
#finalize(options = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/compass/installers/rails.rb', line 27
def finalize(options = {})
if options[:create]
puts <<-NEXTSTEPS
Congratulations! Your rails project has been configured to use Compass.
Sass will automatically compile your stylesheets during the next
page request and keep them up to date when they change.
Make sure you restart your server!
Next add these lines to the head of your layouts:
NEXTSTEPS
end
puts stylesheet_links
puts "\n(You are using haml, aren't you?)"
end
|
#images_dir ⇒ Object
52
53
54
|
# File 'lib/compass/installers/rails.rb', line 52
def images_dir
separate "public/images"
end
|
#init ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/compass/installers/rails.rb', line 16
def init
set_sass_dir unless sass_dir
set_css_dir unless css_dir
directory targetize(css_dir)
directory targetize(sass_dir)
write_file targetize('config/initializers/compass.rb'), initializer_contents
end
|
#initializer_contents ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/compass/installers/rails.rb', line 82
def initializer_contents
%Q{require 'compass'
# If you have any compass plugins, require them here.
Compass.configuration do |config|
config.project_path = RAILS_ROOT
config.sass_dir = "#{sass_dir}"
config.css_dir = "#{css_dir}"
end
Compass.configure_sass_plugin!
}
end
|
#javascripts_dir ⇒ Object
56
57
58
|
# File 'lib/compass/installers/rails.rb', line 56
def javascripts_dir
separate "public/javascripts"
end
|
#prepare ⇒ Object
24
25
|
# File 'lib/compass/installers/rails.rb', line 24
def prepare
end
|
#sass_dir ⇒ Object
44
45
46
|
# File 'lib/compass/installers/rails.rb', line 44
def sass_dir
Compass.configuration.sass_dir
end
|
#set_css_dir ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/compass/installers/rails.rb', line 70
def set_css_dir
recommended_location = separate("public/stylesheets/compiled")
default_location = separate("public/stylesheets")
puts
print %Q{Compass recommends that you keep your compiled css in #{recommended_location}/
instead the Sass default of #{default_location}/.
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
answer = gets.downcase[0]
Compass.configuration.css_dir = answer == ?n ? default_location : recommended_location
end
|
#set_sass_dir ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/compass/installers/rails.rb', line 60
def set_sass_dir
recommended_location = separate('app/stylesheets')
default_location = separate('public/stylesheets/sass')
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
instead of the Sass default location of #{default_location}.
Is this OK? (Y/n) }
answer = gets.downcase[0]
Compass.configuration.sass_dir = answer == ?n ? default_location : recommended_location
end
|
#stylesheet_links ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/compass/installers/rails.rb', line 102
def stylesheet_links
html = "%head\n"
manifest.each_stylesheet do |stylesheet|
ss_line = " = stylesheet_link_tag '#{stylesheet_prefix}#{stylesheet.to.sub(/\.sass$/,'.css')}'"
if stylesheet.options[:media]
ss_line += ", :media => '#{stylesheet.options[:media]}'"
end
if stylesheet.options[:ie]
ss_line = " /[if IE]\n " + ss_line
end
html << ss_line + "\n"
end
html
end
|
#stylesheet_prefix ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/compass/installers/rails.rb', line 94
def stylesheet_prefix
if css_dir.length >= 19
"#{css_dir[19..-1]}/"
else
nil
end
end
|