compass-rails 2.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +23 -4
  4. data/Appraisals +18 -9
  5. data/CHANGELOG.md +82 -0
  6. data/Gemfile +4 -8
  7. data/README.md +14 -12
  8. data/Rakefile +4 -23
  9. data/compass-rails.gemspec +3 -2
  10. data/gemfiles/rails52.gemfile +20 -0
  11. data/gemfiles/rails60.gemfile +21 -0
  12. data/gemfiles/rails_edge.gemfile +21 -0
  13. data/lib/compass-rails.rb +16 -125
  14. data/lib/compass-rails/patches.rb +0 -3
  15. data/lib/compass-rails/patches/3_1.rb +3 -12
  16. data/lib/compass-rails/patches/4_0.rb +23 -29
  17. data/lib/compass-rails/patches/compass.rb +3 -3
  18. data/lib/compass-rails/patches/importer.rb +10 -12
  19. data/lib/compass-rails/patches/sass_importer.rb +67 -7
  20. data/lib/compass-rails/patches/sprite_importer.rb +4 -4
  21. data/lib/compass-rails/railties.rb +1 -3
  22. data/lib/compass-rails/railties/3_1.rb +5 -12
  23. data/lib/compass-rails/railties/4_0.rb +11 -9
  24. data/lib/compass-rails/version.rb +1 -3
  25. data/test/compass_rails_spec.rb +58 -0
  26. data/test/fixtures/assets/images/letters/a.png +0 -0
  27. data/test/fixtures/assets/images/letters/b.png +0 -0
  28. data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
  29. data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
  30. data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
  31. data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
  32. data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
  33. data/test/helpers/command_helper.rb +2 -15
  34. data/test/helpers/debug_helper.rb +1 -1
  35. data/test/helpers/file_helper.rb +2 -17
  36. data/test/helpers/rails_helper.rb +37 -38
  37. data/test/helpers/rails_project.rb +30 -70
  38. data/test/test_helper.rb +8 -3
  39. metadata +55 -24
  40. data/changelog.markdown +0 -11
  41. data/gemfiles/rails31.gemfile +0 -23
  42. data/gemfiles/rails32.gemfile +0 -23
  43. data/gemfiles/rails40.gemfile +0 -23
  44. data/lib/compass-rails/installer.rb +0 -30
  45. data/test/integrations/.gitkeep +0 -0
  46. data/test/integrations/rails_31_test.rb +0 -46
  47. data/test/integrations/rails_32_test.rb +0 -46
  48. data/test/integrations/rails_40_test.rb +0 -46
  49. data/test/units/.gitkeep +0 -0
@@ -0,0 +1,3 @@
1
+ .partial1 {
2
+ display: none;
3
+ }
@@ -0,0 +1,3 @@
1
+ .partial2{
2
+ display: block;
3
+ }
@@ -43,7 +43,7 @@ module CompassRails
43
43
  BUNDLER_COMMAND = 'bundle'
44
44
 
45
45
  def run_command(command, gemfile=nil)
46
- debug(Rainbow("Running: #{command} with gemfile: #{gemfile}").foreground(:cyan))
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
- announce
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]
@@ -3,7 +3,7 @@ module CompassRails
3
3
  module DebugHelper
4
4
 
5
5
  def debug(message)
6
- puts Rainbow("#{message}\n").bright #if ENV['DEBUG']
6
+ puts "#{message}\n" if ENV['DEBUG']
7
7
  $stdout.flush
8
8
  end
9
9
 
@@ -3,20 +3,10 @@ module CompassRails
3
3
  module FileHelper
4
4
  include DebugHelper
5
5
 
6
- def mkdir_p(dir)
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(Rainbow("Entered: #{path}").foreground(:yellow))
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
- RAILS_4_0 = "4.0"
9
- RAILS_3_2 = "3.2"
10
- RAILS_3_1 = "3.1"
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
- GEMFILES = {
15
- RAILS_4_0 => GEMFILES_DIR.join("rails40.gemfile").to_s,
16
- RAILS_3_2 => GEMFILES_DIR.join("rails32.gemfile").to_s,
17
- RAILS_3_1 => GEMFILES_DIR.join("rails31.gemfile").to_s
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
- GENERATOR_OPTIONS = {
21
- RAILS_4_0 => ['-q', '-G', '-O', '--skip-bundle'],
22
- RAILS_3_2 => ['-q', '-G', '-O', '--skip-bundle'],
23
- RAILS_3_1 => ['-q', '-G', '-O', '--skip-bundle']
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
- GENERATOR_COMMAND = {
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
- def rails_command(options, version)
33
- debug(Rainbow("Running Rails command with: rails #{options.join(' ')}").foreground(:cyan))
34
- run_command("rails #{options.join(' ')}", GEMFILES[version])
35
- end
27
+ def rails_command(options)
28
+ debug cmd = "rails #{options.join(' ')}"
29
+ run_command(cmd, GEMFILES[rails_version])
30
+ end
36
31
 
37
- # Generate a rails application without polluting our current set of requires
38
- # with the rails libraries. This will allow testing against multiple versions of rails
39
- # by manipulating the load path.
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
- def within_rails_app(named, version, asset_pipeline_enabled = true, &block)
46
- dir = "#{named}-#{version}"
47
- rm_rf File.join(WORKING_DIR, dir)
48
- mkdir_p WORKING_DIR
49
- cd(WORKING_DIR) do
50
- generate_rails_app(dir, version, asset_pipeline_enabled ? [] : ["-S"])
51
- cd(dir) do
52
- yield RailsProject.new(File.join(WORKING_DIR, dir), version, asset_pipeline_enabled)
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, :asset_pipeline_enabled
12
+ attr_reader :directory, :version
20
13
 
21
- def initialize(directory, version, asset_pipeline_enabled = true)
14
+ def initialize(directory, version)
22
15
  @directory = Pathname.new(directory)
23
16
  @version = version
24
- @asset_pipeline_enabled = asset_pipeline_enabled
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 has_file?(file)
38
- File.exist? directory.join(file)
30
+ def file(path)
31
+ directory.join(path)
39
32
  end
40
33
 
41
- def screen_file
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 has_screen_file?
50
- screen_file.exist?
36
+ def boots?
37
+ rails_property("compass.project_type") == "rails"
51
38
  end
52
39
 
53
- def has_compass_import?
54
- File.read(screen_file).include?("compass/reset")
40
+ def precompile!
41
+ run_command("rake assets:precompile", GEMFILES[version])
55
42
  end
56
43
 
57
- def has_config?
58
- directory.join('config', 'compass.rb').exist?
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
- # RAILS METHODS
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 boots?
68
- string = 'THIS IS MY RANDOM AWESOME TEST STRING'
69
- test_string = "puts \"#{string}\""
70
- matcher = %r{#{string}}
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 runner(string)
80
- rails_command(['runner', "'#{string}'"], version)
81
- end
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 set_compass(property, value)
90
- file = directory.join(COMPASS_CONFIG)
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 = if value.is_a?(Symbol)
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
- private
107
-
108
- ## GEM METHODS
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 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'compass-rails'
3
- require 'rainbow'
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Davis
@@ -10,22 +10,50 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-10 00:00:00.000000000 Z
13
+ date: 2020-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: compass
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.12.2
21
+ version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 0.12.2
28
+ version: 1.0.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: sprockets
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '4.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: sass-rails
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "<"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.1'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '5.1'
29
57
  description: Integrate Compass into Rails 3.0 and up.
30
58
  email:
31
59
  - jetviper21@gmail.com
@@ -38,19 +66,18 @@ files:
38
66
  - ".gitignore"
39
67
  - ".travis.yml"
40
68
  - Appraisals
69
+ - CHANGELOG.md
41
70
  - Gemfile
42
71
  - Guardfile
43
72
  - LICENSE
44
73
  - README.md
45
74
  - Rakefile
46
- - changelog.markdown
47
75
  - compass-rails.gemspec
48
- - gemfiles/rails31.gemfile
49
- - gemfiles/rails32.gemfile
50
- - gemfiles/rails40.gemfile
76
+ - gemfiles/rails52.gemfile
77
+ - gemfiles/rails60.gemfile
78
+ - gemfiles/rails_edge.gemfile
51
79
  - lib/compass-rails.rb
52
80
  - lib/compass-rails/configuration.rb
53
- - lib/compass-rails/installer.rb
54
81
  - lib/compass-rails/patches.rb
55
82
  - lib/compass-rails/patches/3_1.rb
56
83
  - lib/compass-rails/patches/4_0.rb
@@ -64,18 +91,21 @@ files:
64
91
  - lib/compass-rails/railties/4_0.rb
65
92
  - lib/compass-rails/version.rb
66
93
  - sache.json
94
+ - test/compass_rails_spec.rb
67
95
  - test/fixtures/.gitkeep
96
+ - test/fixtures/assets/images/letters/a.png
97
+ - test/fixtures/assets/images/letters/b.png
98
+ - test/fixtures/assets/images/numbers/sprite-1.png
99
+ - test/fixtures/assets/images/numbers/sprite-2.png
100
+ - test/fixtures/assets/stylesheets/application.css.scss
101
+ - test/fixtures/assets/stylesheets/partials/_partial_1.scss
102
+ - test/fixtures/assets/stylesheets/partials/_partial_2.scss
68
103
  - test/helpers/command_helper.rb
69
104
  - test/helpers/debug_helper.rb
70
105
  - test/helpers/file_helper.rb
71
106
  - test/helpers/rails_helper.rb
72
107
  - test/helpers/rails_project.rb
73
- - test/integrations/.gitkeep
74
- - test/integrations/rails_31_test.rb
75
- - test/integrations/rails_32_test.rb
76
- - test/integrations/rails_40_test.rb
77
108
  - test/test_helper.rb
78
- - test/units/.gitkeep
79
109
  homepage: https://github.com/Compass/compass-rails
80
110
  licenses:
81
111
  - MIT
@@ -95,22 +125,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
125
  - !ruby/object:Gem::Version
96
126
  version: '0'
97
127
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.2.2
128
+ rubygems_version: 3.0.3
100
129
  signing_key:
101
130
  specification_version: 4
102
131
  summary: Integrate Compass into Rails 3.0 and up.
103
132
  test_files:
133
+ - test/compass_rails_spec.rb
104
134
  - test/fixtures/.gitkeep
135
+ - test/fixtures/assets/images/letters/a.png
136
+ - test/fixtures/assets/images/letters/b.png
137
+ - test/fixtures/assets/images/numbers/sprite-1.png
138
+ - test/fixtures/assets/images/numbers/sprite-2.png
139
+ - test/fixtures/assets/stylesheets/application.css.scss
140
+ - test/fixtures/assets/stylesheets/partials/_partial_1.scss
141
+ - test/fixtures/assets/stylesheets/partials/_partial_2.scss
105
142
  - test/helpers/command_helper.rb
106
143
  - test/helpers/debug_helper.rb
107
144
  - test/helpers/file_helper.rb
108
145
  - test/helpers/rails_helper.rb
109
146
  - test/helpers/rails_project.rb
110
- - test/integrations/.gitkeep
111
- - test/integrations/rails_31_test.rb
112
- - test/integrations/rails_32_test.rb
113
- - test/integrations/rails_40_test.rb
114
147
  - test/test_helper.rb
115
- - test/units/.gitkeep
116
- has_rdoc: