glebtv-compass-rails 2.0.4

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +22 -0
  4. data/CHANGELOG.md +71 -0
  5. data/Gemfile +17 -0
  6. data/LICENSE +22 -0
  7. data/README.md +97 -0
  8. data/Rakefile +25 -0
  9. data/gemfiles/rails31.gemfile +18 -0
  10. data/gemfiles/rails32.gemfile +18 -0
  11. data/gemfiles/rails40.gemfile +18 -0
  12. data/gemfiles/rails42.gemfile +18 -0
  13. data/glebtv-compass-rails.gemspec +21 -0
  14. data/lib/compass-rails.rb +107 -0
  15. data/lib/compass-rails/configuration.rb +77 -0
  16. data/lib/compass-rails/patches.rb +33 -0
  17. data/lib/compass-rails/patches/compass.rb +12 -0
  18. data/lib/compass-rails/patches/importer.rb +24 -0
  19. data/lib/compass-rails/patches/sass_importer.rb +90 -0
  20. data/lib/compass-rails/patches/sprite_importer.rb +30 -0
  21. data/lib/compass-rails/patches/static_compiler.rb +12 -0
  22. data/lib/compass-rails/railtie.rb +51 -0
  23. data/lib/compass-rails/version.rb +5 -0
  24. data/lib/glebtv-compass-rails.rb +1 -0
  25. data/test/compass_rails_spec.rb +39 -0
  26. data/test/fixtures/.gitkeep +0 -0
  27. data/test/fixtures/assets/images/letters/a.png +0 -0
  28. data/test/fixtures/assets/images/letters/b.png +0 -0
  29. data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
  30. data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
  31. data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
  32. data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
  33. data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
  34. data/test/helpers/command_helper.rb +105 -0
  35. data/test/helpers/debug_helper.rb +12 -0
  36. data/test/helpers/file_helper.rb +38 -0
  37. data/test/helpers/rails_helper.rb +53 -0
  38. data/test/helpers/rails_project.rb +76 -0
  39. data/test/test_helper.rb +20 -0
  40. metadata +128 -0
@@ -0,0 +1,12 @@
1
+ module CompassRails
2
+ module Test
3
+ module DebugHelper
4
+
5
+ def debug(message)
6
+ #puts "#{message}\n" if ENV['DEBUG']
7
+ #$stdout.flush
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ module CompassRails
2
+ module Test
3
+ module FileHelper
4
+ include DebugHelper
5
+
6
+ delegate :mkdir_p, :rm, :rm_rf, :cp_r, :touch, to: ::FileUtils
7
+
8
+ def cd(path, &block)
9
+ debug "Entering: #{path}"
10
+ Dir.chdir(path, &block)
11
+ end
12
+
13
+ def inject_at_bottom(file_name, string)
14
+ content = File.read(file_name)
15
+ content = "#{content}#{string}"
16
+ File.open(file_name, 'w') { |file| file << content }
17
+ end
18
+
19
+ def inject_into_file(file_name, replacement, position, anchor)
20
+ case position
21
+ when :after
22
+ replace(file_name, Regexp.escape(anchor), "#{anchor}#{replacement}")
23
+ when :before
24
+ replace(file_name, Regexp.escape(anchor), "#{replacement}#{anchor}")
25
+ else
26
+ raise Compass::FilesystemConflict.new("You need to specify :before or :after")
27
+ end
28
+ end
29
+
30
+ def replace(destination, regexp, string)
31
+ content = File.read(destination)
32
+ content.gsub!(Regexp.new(regexp), string)
33
+ File.open(destination, 'wb') { |file| file.write(content) }
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,53 @@
1
+ module CompassRails
2
+ module Test
3
+ module RailsHelpers
4
+ include FileHelper
5
+ include DebugHelper
6
+ include CommandHelper
7
+ RAILS_4_2 = "4.2"
8
+
9
+ WORKING_DIR = File.join(ROOT_PATH, 'rails-temp')
10
+
11
+ VERSION_LOOKUP = {
12
+ RAILS_4_2 => %r{^4\.2\.},
13
+ }
14
+
15
+ GEMFILES = {
16
+ RAILS_4_2 => GEMFILES_DIR.join("rails42.gemfile").to_s,
17
+ }
18
+
19
+ GENERATOR_OPTIONS = ['-q', '-G', '-O', '--skip-bundle']
20
+
21
+ def rails_command(options)
22
+ debug cmd = "rails #{options.join(' ')}"
23
+ run_command(cmd, GEMFILES[rails_version])
24
+ end
25
+
26
+ def rails_version
27
+ @rails_version ||= VERSION_LOOKUP.detect { |version, regex| CompassRails.version_match(regex) }.first
28
+ end
29
+
30
+ # Generate a rails application without polluting our current set of requires
31
+ # with the rails libraries. This will allow testing against multiple versions of rails
32
+ # by manipulating the load path.
33
+ def generate_rails_app(name, options = [])
34
+ options += GENERATOR_OPTIONS
35
+ rails_command(['new', name, *options])
36
+ end
37
+
38
+ def within_rails_app(named, &block)
39
+ dir = "#{named}-#{rails_version}"
40
+ rm_rf File.join(WORKING_DIR, dir)
41
+ mkdir_p WORKING_DIR
42
+ cd(WORKING_DIR) do
43
+ generate_rails_app(dir, [])
44
+ cd(dir) do
45
+ yield RailsProject.new(File.join(WORKING_DIR, dir), rails_version)
46
+ end
47
+ end
48
+ rm_rf File.join(WORKING_DIR, dir) unless ENV['DEBUG_COMPILE']
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,76 @@
1
+ module CompassRails
2
+ module Test
3
+ class RailsProject
4
+ include FileHelper
5
+ include DebugHelper
6
+ include CommandHelper
7
+ include RailsHelpers
8
+ include Kernal::Captures
9
+
10
+ APPLICATION_FILE = 'config/application.rb'
11
+
12
+ attr_reader :directory, :version
13
+
14
+ def initialize(directory, version)
15
+ @directory = Pathname.new(directory)
16
+ @version = version
17
+ end
18
+
19
+ ## FILE METHODS
20
+
21
+ def to_s
22
+ directory_name
23
+ end
24
+
25
+ def directory_name
26
+ File.basename(directory)
27
+ end
28
+
29
+ def file(path)
30
+ directory.join(path)
31
+ end
32
+
33
+ # RAILS METHODS
34
+
35
+ def boots?
36
+ rails_property("compass.project_type") == "rails"
37
+ end
38
+
39
+ def precompile!
40
+ run_command("rake assets:precompile", GEMFILES[version])
41
+ end
42
+
43
+ def setup_asset_fixtures!
44
+ rm_rf file("app/assets")
45
+ cp_r CompassRails::Test.root.join('test', 'fixtures', 'assets'), file("app")
46
+ end
47
+
48
+ def precompiled?(path)
49
+ !Dir[asset_path(path)].empty?
50
+ end
51
+
52
+ def compiled_stylesheet(path, &block)
53
+ File.open(asset_path(path)).read.tap do |css|
54
+ debug(css)
55
+ yield css if block_given?
56
+ end
57
+ end
58
+
59
+ def asset_path(path_pattern)
60
+ Dir[file(path_pattern)].first.tap do |asset|
61
+ raise 'Asset not found' if asset.nil?
62
+ end
63
+ end
64
+
65
+ def rails_property(key)
66
+ rails_command(['runner', "'puts Rails.application.config.#{key}'"]).chomp
67
+ end
68
+
69
+ def set_rails(property, value)
70
+ value = "\n config.#{property} = #{value.inspect}\n"
71
+ inject_into_file(directory.join(APPLICATION_FILE), value, :after, 'class Application < Rails::Application')
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,20 @@
1
+ require 'minitest/autorun'
2
+ require 'compass-rails'
3
+ require 'active_support/all'
4
+
5
+ module CompassRails
6
+ module Test
7
+ ROOT_PATH = File.expand_path('../../', __FILE__)
8
+
9
+ def self.root
10
+ Pathname.new(ROOT_PATH)
11
+ end
12
+ end
13
+ end
14
+
15
+ %w(debug file command rails).each do |helper|
16
+ require File.join(File.expand_path('../', __FILE__), 'helpers', "#{helper}_helper")
17
+ end
18
+
19
+ require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
20
+
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glebtv-compass-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Scott Davis
8
+ - Chris Eppstein
9
+ - Craig McNamara
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-12-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: compass
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
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: '3.2'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.2'
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'
57
+ description: Integrate Compass into Rails 3.0 and up.
58
+ email:
59
+ - jetviper21@gmail.com
60
+ - chris@eppsteins.net
61
+ - craig.mcnamara@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - ".travis.yml"
68
+ - CHANGELOG.md
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - gemfiles/rails31.gemfile
74
+ - gemfiles/rails32.gemfile
75
+ - gemfiles/rails40.gemfile
76
+ - gemfiles/rails42.gemfile
77
+ - glebtv-compass-rails.gemspec
78
+ - lib/compass-rails.rb
79
+ - lib/compass-rails/configuration.rb
80
+ - lib/compass-rails/patches.rb
81
+ - lib/compass-rails/patches/compass.rb
82
+ - lib/compass-rails/patches/importer.rb
83
+ - lib/compass-rails/patches/sass_importer.rb
84
+ - lib/compass-rails/patches/sprite_importer.rb
85
+ - lib/compass-rails/patches/static_compiler.rb
86
+ - lib/compass-rails/railtie.rb
87
+ - lib/compass-rails/version.rb
88
+ - lib/glebtv-compass-rails.rb
89
+ - test/compass_rails_spec.rb
90
+ - test/fixtures/.gitkeep
91
+ - test/fixtures/assets/images/letters/a.png
92
+ - test/fixtures/assets/images/letters/b.png
93
+ - test/fixtures/assets/images/numbers/sprite-1.png
94
+ - test/fixtures/assets/images/numbers/sprite-2.png
95
+ - test/fixtures/assets/stylesheets/application.css.scss
96
+ - test/fixtures/assets/stylesheets/partials/_partial_1.scss
97
+ - test/fixtures/assets/stylesheets/partials/_partial_2.scss
98
+ - test/helpers/command_helper.rb
99
+ - test/helpers/debug_helper.rb
100
+ - test/helpers/file_helper.rb
101
+ - test/helpers/rails_helper.rb
102
+ - test/helpers/rails_project.rb
103
+ - test/test_helper.rb
104
+ homepage: https://github.com/Compass/glebtv-compass-rails
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Integrate Compass into Rails 3.0 and up.
128
+ test_files: []