compass-rails 2.0.1 → 4.0.0
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +23 -4
- data/Appraisals +18 -9
- data/CHANGELOG.md +18 -0
- data/Gemfile +4 -7
- data/README.md +12 -11
- data/Rakefile +4 -23
- data/compass-rails.gemspec +3 -2
- data/gemfiles/rails52.gemfile +20 -0
- data/gemfiles/rails60.gemfile +21 -0
- data/gemfiles/rails_edge.gemfile +21 -0
- data/lib/compass-rails/patches/3_1.rb +2 -2
- data/lib/compass-rails/patches/4_0.rb +20 -17
- data/lib/compass-rails/patches/compass.rb +2 -2
- data/lib/compass-rails/patches/importer.rb +10 -12
- data/lib/compass-rails/patches/sass_importer.rb +67 -7
- data/lib/compass-rails/patches/sprite_importer.rb +4 -4
- data/lib/compass-rails/patches.rb +0 -3
- data/lib/compass-rails/railties/3_1.rb +5 -12
- data/lib/compass-rails/railties/4_0.rb +11 -9
- data/lib/compass-rails/railties.rb +1 -3
- data/lib/compass-rails/version.rb +1 -3
- data/lib/compass-rails.rb +12 -125
- data/test/compass_rails_spec.rb +58 -0
- data/test/fixtures/assets/images/letters/a.png +0 -0
- data/test/fixtures/assets/images/letters/b.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
- data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
- data/test/helpers/command_helper.rb +2 -15
- data/test/helpers/debug_helper.rb +1 -1
- data/test/helpers/file_helper.rb +2 -17
- data/test/helpers/rails_helper.rb +37 -38
- data/test/helpers/rails_project.rb +30 -70
- data/test/test_helper.rb +8 -3
- metadata +50 -18
- data/gemfiles/rails31.gemfile +0 -22
- data/gemfiles/rails32.gemfile +0 -22
- data/gemfiles/rails40.gemfile +0 -22
- data/lib/compass-rails/installer.rb +0 -30
- data/test/integrations/.gitkeep +0 -0
- data/test/integrations/rails_31_test.rb +0 -46
- data/test/integrations/rails_32_test.rb +0 -46
- data/test/integrations/rails_40_test.rb +0 -46
- data/test/units/.gitkeep +0 -0
data/lib/compass-rails.rb
CHANGED
@@ -4,63 +4,45 @@ require "compass-rails/configuration"
|
|
4
4
|
|
5
5
|
module CompassRails
|
6
6
|
|
7
|
-
RAILS_4 = %r{^4.[0|1|2]}
|
8
7
|
RAILS_32 = %r{^3.2}
|
9
8
|
RAILS_31 = %r{^3.1}
|
10
9
|
|
11
10
|
extend self
|
12
11
|
|
13
|
-
def load_rails
|
14
|
-
return true if rails_loaded?
|
15
|
-
return if defined?(::Rails) && ::Rails.respond_to?(:application) && !::Rails.application.nil?
|
16
|
-
|
17
|
-
rails_path = Dir.pwd
|
18
|
-
if File.exists?(File.join(rails_path, 'config', 'application.rb'))
|
19
|
-
raise 'Rails application not found' if rails_config_path == '/'
|
20
|
-
rails_config_path = File.join(rails_config_path, '..')
|
21
|
-
#load the rails config
|
22
|
-
require "#{rails_config_path}/config/application.rb"
|
23
|
-
require 'sass-rails'
|
24
|
-
require 'sprockets/railtie'
|
25
|
-
@app ||= ::Rails.application.initialize!
|
26
|
-
require 'rails/engine'
|
27
|
-
return true
|
28
|
-
end
|
29
|
-
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
12
|
def setup_fake_rails_env_paths(sprockets_env)
|
35
13
|
return unless rails_loaded?
|
14
|
+
|
15
|
+
if sprockets_env.respond_to?(:trail, true)
|
16
|
+
sprockets_trail = sprockets_env.send(:trail)
|
17
|
+
else
|
18
|
+
sprockets_trail = sprockets_env.index
|
19
|
+
end
|
20
|
+
|
36
21
|
keys = ['app/assets', 'lib/assets', 'vendor/assets']
|
37
22
|
local = keys.map {|path| ::Rails.root.join(path) }.map { |path| [File.join(path, 'images'), File.join(path, 'stylesheets')] }.flatten!
|
38
|
-
|
23
|
+
sprockets_trail.paths.unshift(*local)
|
39
24
|
paths = []
|
40
25
|
::Rails::Engine.subclasses.each do |subclass|
|
41
26
|
paths = subclass.paths
|
42
27
|
keys.each do |key|
|
43
|
-
|
28
|
+
sprockets_trail.paths.unshift(*paths[key].existent_directories)
|
44
29
|
end
|
45
30
|
end
|
46
31
|
end
|
47
32
|
|
48
33
|
def sass_config
|
49
|
-
load_rails
|
50
34
|
::Rails.application.config.sass
|
51
35
|
end
|
52
36
|
|
53
37
|
def sprockets
|
54
|
-
|
55
|
-
@sprockets ||= ::Rails.application.assets
|
38
|
+
@sprockets ||= Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)
|
56
39
|
end
|
57
40
|
|
58
41
|
def context
|
59
|
-
load_rails
|
60
42
|
@context ||= begin
|
61
43
|
sprockets.version = ::Rails.env + "-#{sprockets.version}"
|
62
44
|
setup_fake_rails_env_paths(sprockets)
|
63
|
-
context = ::
|
45
|
+
context = ::CompassRails.sprockets.context_class
|
64
46
|
context.extend(::Sprockets::Helpers::IsolatedHelper)
|
65
47
|
context.extend(::Sprockets::Helpers::RailsHelper)
|
66
48
|
context.extend(::Sass::Rails::Railtie::SassContext)
|
@@ -70,10 +52,6 @@ module CompassRails
|
|
70
52
|
end
|
71
53
|
end
|
72
54
|
|
73
|
-
def installer(*args)
|
74
|
-
CompassRails::Installer.new(*args)
|
75
|
-
end
|
76
|
-
|
77
55
|
def rails_loaded?
|
78
56
|
defined?(::Rails)
|
79
57
|
end
|
@@ -94,29 +72,11 @@ module CompassRails
|
|
94
72
|
version_match RAILS_32
|
95
73
|
end
|
96
74
|
|
97
|
-
def rails4?
|
98
|
-
return false unless defined?(::Rails)
|
99
|
-
version_match RAILS_4
|
100
|
-
end
|
101
|
-
|
102
75
|
def version_match(version)
|
103
|
-
|
104
|
-
return false
|
105
|
-
end
|
106
|
-
|
107
|
-
true
|
108
|
-
end
|
109
|
-
|
110
|
-
def booted!
|
111
|
-
CompassRails.const_set(:BOOTED, true)
|
112
|
-
end
|
113
|
-
|
114
|
-
def booted?
|
115
|
-
defined?(CompassRails::BOOTED) && CompassRails::BOOTED
|
76
|
+
!(rails_version =~ version).nil?
|
116
77
|
end
|
117
78
|
|
118
79
|
def configuration
|
119
|
-
load_rails
|
120
80
|
config = Compass::Configuration::Data.new('rails')
|
121
81
|
config.extend(CompassRails::Configuration)
|
122
82
|
config
|
@@ -126,50 +86,6 @@ module CompassRails
|
|
126
86
|
::Rails.application.config.assets.prefix
|
127
87
|
end
|
128
88
|
|
129
|
-
def env_production?
|
130
|
-
if defined?(::Rails) && ::Rails.respond_to?(:env)
|
131
|
-
::Rails.env.production?
|
132
|
-
elsif defined?(RAILS_ENV)
|
133
|
-
RAILS_ENV == "production"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def root
|
138
|
-
@root ||= begin
|
139
|
-
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
140
|
-
::Rails.root
|
141
|
-
elsif defined?(RAILS_ROOT)
|
142
|
-
Pathname.new(RAILS_ROOT)
|
143
|
-
else
|
144
|
-
Pathname.new(Dir.pwd)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def check_for_double_boot!
|
150
|
-
if booted?
|
151
|
-
Compass::Util.compass_warn("Warning: Compass was booted twice. Compass-rails has got your back; please remove your compass initializer.")
|
152
|
-
else
|
153
|
-
booted!
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def sass_plugin_enabled?
|
158
|
-
unless rails31?
|
159
|
-
defined?(Sass::Plugin) && !Sass::Plugin.options[:never_update]
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
# Rails projects without asset pipeline use this in their compass initializer.
|
164
|
-
def initialize!(config = nil)
|
165
|
-
check_for_double_boot!
|
166
|
-
config ||= Compass.detect_configuration_file(root)
|
167
|
-
Compass.add_project_configuration(config, :project_type => :rails)
|
168
|
-
Compass.discover_extensions!
|
169
|
-
Compass.configure_sass_plugin!
|
170
|
-
Compass.handle_configuration_change! if sass_plugin_enabled?
|
171
|
-
end
|
172
|
-
|
173
89
|
def configure_rails!(app)
|
174
90
|
return unless app.config.respond_to?(:sass)
|
175
91
|
sass_config = app.config.sass
|
@@ -192,31 +108,6 @@ module CompassRails
|
|
192
108
|
end
|
193
109
|
end
|
194
110
|
|
195
|
-
def boot_config
|
196
|
-
config = begin
|
197
|
-
if (config_file = Compass.detect_configuration_file) &&
|
198
|
-
(config_data = Compass.configuration_for(config_file))
|
199
|
-
config_data
|
200
|
-
else
|
201
|
-
Compass::Configuration::Data.new("compass_rails_boot")
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
config.tap do |c|
|
206
|
-
c.top_level.project_type = :rails
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def asset_pipeline_enabled?
|
211
|
-
return false unless rails_loaded? && ::Rails.respond_to?(:application) && !::Rails.application.nil?
|
212
|
-
rails_config = ::Rails.application.config
|
213
|
-
if rails_config.respond_to?(:assets)
|
214
|
-
rails_config.assets.enabled != false
|
215
|
-
else
|
216
|
-
false
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
111
|
private
|
221
112
|
|
222
113
|
# sets the sass config value only if the corresponding compass-based setting
|
@@ -231,10 +122,6 @@ end
|
|
231
122
|
|
232
123
|
if defined?(::Rails)
|
233
124
|
Compass::AppIntegration.register(:rails, "::CompassRails")
|
234
|
-
Compass.add_configuration(CompassRails.boot_config)
|
235
|
-
|
236
125
|
require "compass-rails/patches"
|
237
126
|
require "compass-rails/railties"
|
238
|
-
require "compass-rails/installer"
|
239
127
|
end
|
240
|
-
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CompassRails do
|
4
|
+
include CompassRails::Test::RailsHelpers
|
5
|
+
|
6
|
+
it "compiles a basic compass stylesheet" do
|
7
|
+
within_rails_app('test_railtie') do |project|
|
8
|
+
project.setup_asset_fixtures!
|
9
|
+
|
10
|
+
assert project.boots?
|
11
|
+
|
12
|
+
project.precompile!
|
13
|
+
|
14
|
+
project.compiled_stylesheet 'public/assets/application*.css' do |css|
|
15
|
+
refute css.empty?
|
16
|
+
assert_match 'body container', css
|
17
|
+
assert_match "-webkit-linear-gradient", css
|
18
|
+
assert_match "-moz-border-radius", css
|
19
|
+
assert_match '.numbers-sprite-1', css
|
20
|
+
assert_match '.numbers-sprite-2', css
|
21
|
+
assert_match '.letters-a', css
|
22
|
+
assert_match '.letters-a', css
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "supports rails config arguments" do
|
28
|
+
within_rails_app('test_railtie') do |project|
|
29
|
+
assert_equal "scss", project.rails_property("sass.preferred_syntax")
|
30
|
+
assert_equal "public/assets", project.rails_property("compass.css_dir")
|
31
|
+
|
32
|
+
project.set_rails('sass.preferred_syntax', :sass)
|
33
|
+
project.set_rails('compass.css_dir', "public/stylesheets")
|
34
|
+
|
35
|
+
assert_equal "sass", project.rails_property("sass.preferred_syntax")
|
36
|
+
assert_equal "public/stylesheets", project.rails_property("compass.css_dir")
|
37
|
+
end
|
38
|
+
end unless ENV['DEBUG_COMPILE']
|
39
|
+
|
40
|
+
it "compiles when in production mode" do
|
41
|
+
within_rails_app('test_railtie') do |project|
|
42
|
+
project.setup_asset_fixtures!
|
43
|
+
|
44
|
+
# Mimic Rails production mode
|
45
|
+
project.set_rails('assets.compile', false)
|
46
|
+
|
47
|
+
assert project.boots?
|
48
|
+
|
49
|
+
project.precompile!
|
50
|
+
|
51
|
+
project.compiled_stylesheet 'public/assets/application*.css' do |css|
|
52
|
+
refute css.empty?
|
53
|
+
assert_match 'body container', css
|
54
|
+
assert_match '.numbers-sprite-1', css
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Import Compass
|
2
|
+
@import "compass";
|
3
|
+
|
4
|
+
// Glob import SCSS partials
|
5
|
+
@import "partials/*";
|
6
|
+
|
7
|
+
// Import Sprites
|
8
|
+
@import "letters/*.png";
|
9
|
+
@include all-letters-sprites;
|
10
|
+
|
11
|
+
// Inline Sprites
|
12
|
+
$numbers-inline: true;
|
13
|
+
@import "numbers/sprite-*.png";
|
14
|
+
@include all-numbers-sprites;
|
15
|
+
|
16
|
+
// Try out some compass stuff
|
17
|
+
body{
|
18
|
+
@include background-image(linear-gradient(white, #aaaaaa));
|
19
|
+
|
20
|
+
container{
|
21
|
+
@include border-radius(4px, 4px);
|
22
|
+
}
|
23
|
+
}
|
@@ -43,7 +43,7 @@ module CompassRails
|
|
43
43
|
BUNDLER_COMMAND = 'bundle'
|
44
44
|
|
45
45
|
def run_command(command, gemfile=nil)
|
46
|
-
debug
|
46
|
+
debug "Running: #{command} with gemfile: #{gemfile}"
|
47
47
|
capture_all_output { CompassRails::Test::CommandRunner.new(command, gemfile).run }
|
48
48
|
end
|
49
49
|
|
@@ -75,14 +75,10 @@ class CompassRails::Test::CommandRunner
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def run
|
78
|
-
|
79
|
-
with_clean_env do
|
80
|
-
%x{#{@command}}
|
81
|
-
end
|
78
|
+
with_clean_env { %x{#{@command}} }
|
82
79
|
end
|
83
80
|
|
84
81
|
def exec
|
85
|
-
announce
|
86
82
|
with_clean_env { Kernel.exec(@command) }
|
87
83
|
end
|
88
84
|
|
@@ -96,15 +92,6 @@ class CompassRails::Test::CommandRunner
|
|
96
92
|
restore_env
|
97
93
|
end
|
98
94
|
|
99
|
-
def announce
|
100
|
-
return
|
101
|
-
if @gemfile
|
102
|
-
puts ">> BUNDLE_GEMFILE=#{@gemfile} #{@command}"
|
103
|
-
else
|
104
|
-
puts ">> #{@command}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
95
|
def unset_bundler_env_vars
|
109
96
|
BUNDLER_ENV_VARS.each do |key|
|
110
97
|
@original_env[key] = ENV[key]
|
data/test/helpers/file_helper.rb
CHANGED
@@ -3,20 +3,10 @@ module CompassRails
|
|
3
3
|
module FileHelper
|
4
4
|
include DebugHelper
|
5
5
|
|
6
|
-
|
7
|
-
debug(Rainbow("Creating Directory: #{dir}").foreground(:green))
|
8
|
-
::FileUtils.mkdir_p dir
|
9
|
-
assert File.directory?(dir), "mkdir_p: #{dir} failed"
|
10
|
-
end
|
11
|
-
|
12
|
-
def rm_rf(path)
|
13
|
-
debug(Rainbow("Removing: #{path}").foreground(:red))
|
14
|
-
::FileUtils.rm_rf(path)
|
15
|
-
assert !File.directory?(path), "rm_rf: #{path} failed"
|
16
|
-
end
|
6
|
+
delegate :mkdir_p, :rm, :rm_rf, :cp_r, :touch, to: ::FileUtils
|
17
7
|
|
18
8
|
def cd(path, &block)
|
19
|
-
debug
|
9
|
+
debug "Entering: #{path}"
|
20
10
|
Dir.chdir(path, &block)
|
21
11
|
end
|
22
12
|
|
@@ -26,11 +16,6 @@ module CompassRails
|
|
26
16
|
File.open(file_name, 'w') { |file| file << content }
|
27
17
|
end
|
28
18
|
|
29
|
-
def touch(file)
|
30
|
-
debug(Rainbow("Touching File: #{file}").foreground(:green))
|
31
|
-
::FileUtils.touch(file)
|
32
|
-
end
|
33
|
-
|
34
19
|
def inject_into_file(file_name, replacement, position, anchor)
|
35
20
|
case position
|
36
21
|
when :after
|
@@ -1,59 +1,58 @@
|
|
1
|
-
|
2
1
|
module CompassRails
|
3
2
|
module Test
|
4
3
|
module RailsHelpers
|
5
4
|
include FileHelper
|
6
5
|
include DebugHelper
|
7
6
|
include CommandHelper
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
RAILS_6_1 = "6.1"
|
8
|
+
RAILS_6_0 = "6.0"
|
9
|
+
RAILS_5_2 = "5.2"
|
11
10
|
|
12
11
|
WORKING_DIR = File.join(ROOT_PATH, 'rails-temp')
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
VERSION_LOOKUP = {
|
14
|
+
RAILS_6_1 => %r{^6\.1\.},
|
15
|
+
RAILS_6_0 => %r{^6\.0\.},
|
16
|
+
RAILS_5_2 => %r{^5\.2\.},
|
18
17
|
}
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
GEMFILES = {
|
20
|
+
RAILS_6_1 => GEMFILES_DIR.join("rails_edge.gemfile").to_s,
|
21
|
+
RAILS_6_0 => GEMFILES_DIR.join("rails60.gemfile").to_s,
|
22
|
+
RAILS_5_2 => GEMFILES_DIR.join("rails52.gemfile").to_s,
|
24
23
|
}
|
25
24
|
|
26
|
-
|
27
|
-
RAILS_4_0 => 'new',
|
28
|
-
RAILS_3_2 => 'new',
|
29
|
-
RAILS_3_1 => 'new'
|
30
|
-
}
|
25
|
+
GENERATOR_OPTIONS = ['-q', '-G', '-O', '--skip-bundle']
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
def rails_command(options)
|
28
|
+
debug cmd = "rails #{options.join(' ')}"
|
29
|
+
run_command(cmd, GEMFILES[rails_version])
|
30
|
+
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def generate_rails_app(name, version, options=[])
|
41
|
-
options += GENERATOR_OPTIONS[version]
|
42
|
-
rails_command([GENERATOR_COMMAND[version], name, *options], version)
|
43
|
-
end
|
32
|
+
def rails_version
|
33
|
+
@rails_version ||= VERSION_LOOKUP.detect { |version, regex| CompassRails.version_match(regex) }.first
|
34
|
+
end
|
44
35
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
36
|
+
# Generate a rails application without polluting our current set of requires
|
37
|
+
# with the rails libraries. This will allow testing against multiple versions of rails
|
38
|
+
# by manipulating the load path.
|
39
|
+
def generate_rails_app(name, options = [])
|
40
|
+
options += GENERATOR_OPTIONS
|
41
|
+
rails_command(['new', name, *options])
|
42
|
+
end
|
43
|
+
|
44
|
+
def within_rails_app(named, &block)
|
45
|
+
dir = "#{named}-#{rails_version}"
|
46
|
+
rm_rf File.join(WORKING_DIR, dir)
|
47
|
+
mkdir_p WORKING_DIR
|
48
|
+
cd(WORKING_DIR) do
|
49
|
+
generate_rails_app(dir, [])
|
50
|
+
cd(dir) do
|
51
|
+
yield RailsProject.new(File.join(WORKING_DIR, dir), rails_version)
|
52
|
+
end
|
53
53
|
end
|
54
|
+
rm_rf File.join(WORKING_DIR, dir) unless ENV['DEBUG_COMPILE']
|
54
55
|
end
|
55
|
-
rm_rf File.join(WORKING_DIR, dir)
|
56
|
-
end
|
57
56
|
|
58
57
|
end
|
59
58
|
end
|
@@ -7,21 +7,14 @@ module CompassRails
|
|
7
7
|
include RailsHelpers
|
8
8
|
include Kernal::Captures
|
9
9
|
|
10
|
-
|
11
|
-
GEMFILE = 'Gemfile'
|
12
|
-
GEMFILE_LOCK = 'Gemfile.lock'
|
13
|
-
ENVIRONMENT = 'config/environment.rb'
|
14
|
-
COMPASS_CONFIG = 'config/compass.rb'
|
15
10
|
APPLICATION_FILE = 'config/application.rb'
|
16
|
-
BOOT_FILE = 'config/boot.rb'
|
17
|
-
|
18
11
|
|
19
|
-
attr_reader :directory, :version
|
12
|
+
attr_reader :directory, :version
|
20
13
|
|
21
|
-
def initialize(directory, version
|
14
|
+
def initialize(directory, version)
|
22
15
|
@directory = Pathname.new(directory)
|
23
16
|
@version = version
|
24
|
-
|
17
|
+
disable_cookies! if version == '3.1'
|
25
18
|
end
|
26
19
|
|
27
20
|
## FILE METHODS
|
@@ -34,89 +27,56 @@ module CompassRails
|
|
34
27
|
File.basename(directory)
|
35
28
|
end
|
36
29
|
|
37
|
-
def
|
38
|
-
|
30
|
+
def file(path)
|
31
|
+
directory.join(path)
|
39
32
|
end
|
40
33
|
|
41
|
-
|
42
|
-
if asset_pipeline_enabled
|
43
|
-
return directory.join('app', 'assets', 'stylesheets', 'screen.css.scss')
|
44
|
-
else
|
45
|
-
return directory.join('app', 'assets', 'stylesheets','screen.scss')
|
46
|
-
end
|
47
|
-
end
|
34
|
+
# RAILS METHODS
|
48
35
|
|
49
|
-
def
|
50
|
-
|
36
|
+
def boots?
|
37
|
+
rails_property("compass.project_type") == "rails"
|
51
38
|
end
|
52
39
|
|
53
|
-
def
|
54
|
-
|
40
|
+
def precompile!
|
41
|
+
run_command("rake assets:precompile", GEMFILES[version])
|
55
42
|
end
|
56
43
|
|
57
|
-
def
|
58
|
-
|
44
|
+
def setup_asset_fixtures!
|
45
|
+
rm_rf file("app/assets")
|
46
|
+
cp_r CompassRails::Test.root.join('test', 'fixtures', 'assets'), file("app")
|
59
47
|
end
|
60
48
|
|
61
|
-
|
62
|
-
|
63
|
-
def rails3?
|
64
|
-
directory.join(APPLICATION_FILE).exist?
|
49
|
+
def precompiled?(path)
|
50
|
+
!Dir[asset_path(path)].empty?
|
65
51
|
end
|
66
52
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
r = runner(test_string)
|
72
|
-
if r =~ matcher
|
73
|
-
return true
|
74
|
-
else
|
75
|
-
return false
|
53
|
+
def compiled_stylesheet(path, &block)
|
54
|
+
File.open(asset_path(path)).read.tap do |css|
|
55
|
+
debug(css)
|
56
|
+
yield css if block_given?
|
76
57
|
end
|
77
58
|
end
|
78
59
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# COMPASS METHODS
|
84
|
-
|
85
|
-
def run_compass(command)
|
86
|
-
run_command("compass #{command}", GEMFILES[version])
|
60
|
+
def asset_path(path_pattern)
|
61
|
+
Dir[file(path_pattern)].first.tap do |asset|
|
62
|
+
raise 'Asset not found' if asset.nil?
|
63
|
+
end
|
87
64
|
end
|
88
65
|
|
89
|
-
def
|
90
|
-
|
91
|
-
unless file.exist?
|
92
|
-
touch file
|
93
|
-
end
|
94
|
-
inject_at_bottom(file, "#{property} = '#{value}'")
|
66
|
+
def rails_property(key)
|
67
|
+
rails_command(['runner', "'puts Rails.application.config.#{key}'"]).chomp
|
95
68
|
end
|
96
69
|
|
97
70
|
def set_rails(property, value)
|
98
|
-
value =
|
99
|
-
"\n config.#{property} = :#{value}\n"
|
100
|
-
else
|
101
|
-
"\n config.#{property} = '#{value}'\n"
|
102
|
-
end
|
71
|
+
value = "\n config.#{property} = #{value.inspect}\n"
|
103
72
|
inject_into_file(directory.join(APPLICATION_FILE), value, :after, 'class Application < Rails::Application')
|
104
73
|
end
|
105
74
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
def add_to_gemfile(name, requirements)
|
111
|
-
gemfile = directory.join(GEMFILE)
|
112
|
-
debug(Rainbow("Adding gem #{name} to file: #{gemfile}").foreground(:green))
|
113
|
-
if requirements
|
114
|
-
gem_string = " gem '#{name}', #{requirements}\n"
|
115
|
-
else
|
116
|
-
gem_string = " gem '#{name}'\n"
|
117
|
-
end
|
118
|
-
inject_at_bottom(gemfile, gem_string)
|
75
|
+
def disable_cookies!
|
76
|
+
value = "\n config.middleware.delete 'ActionDispatch::Session::CookieStore'\n"
|
77
|
+
inject_into_file(directory.join(APPLICATION_FILE), value, :after, 'class Application < Rails::Application')
|
119
78
|
end
|
79
|
+
|
120
80
|
end
|
121
81
|
end
|
122
82
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'minitest/autorun'
|
2
2
|
require 'compass-rails'
|
3
|
-
require '
|
3
|
+
require 'active_support/all'
|
4
4
|
|
5
5
|
module CompassRails
|
6
6
|
module Test
|
7
7
|
ROOT_PATH = File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def self.root
|
10
|
+
Pathname.new(ROOT_PATH)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -12,4 +16,5 @@ end
|
|
12
16
|
require File.join(File.expand_path('../', __FILE__), 'helpers', "#{helper}_helper")
|
13
17
|
end
|
14
18
|
|
15
|
-
require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
|
19
|
+
require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
|
20
|
+
|