compass-rails 1.0.0.rc.1

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 (46) hide show
  1. data/.gitignore +18 -0
  2. data/.travis.yml +5 -0
  3. data/Appraisals +17 -0
  4. data/Gemfile +22 -0
  5. data/Guardfile +9 -0
  6. data/LICENSE +22 -0
  7. data/README.md +191 -0
  8. data/Rakefile +34 -0
  9. data/compass-rails.gemspec +21 -0
  10. data/gemfiles/rails2.gemfile +21 -0
  11. data/gemfiles/rails2.gemfile.lock +87 -0
  12. data/gemfiles/rails3.gemfile +21 -0
  13. data/gemfiles/rails3.gemfile.lock +134 -0
  14. data/gemfiles/rails31.gemfile +22 -0
  15. data/gemfiles/rails31.gemfile.lock +151 -0
  16. data/gemfiles/rails32.gemfile +22 -0
  17. data/gemfiles/rails32.gemfile.lock +148 -0
  18. data/lib/compass-rails.rb +207 -0
  19. data/lib/compass-rails/configuration.rb +1 -0
  20. data/lib/compass-rails/configuration/3_1.rb +51 -0
  21. data/lib/compass-rails/configuration/default.rb +75 -0
  22. data/lib/compass-rails/installer.rb +30 -0
  23. data/lib/compass-rails/patches.rb +6 -0
  24. data/lib/compass-rails/patches/3_1.rb +28 -0
  25. data/lib/compass-rails/patches/importer.rb +26 -0
  26. data/lib/compass-rails/patches/sprite_importer.rb +38 -0
  27. data/lib/compass-rails/railties.rb +11 -0
  28. data/lib/compass-rails/railties/2_3.rb +56 -0
  29. data/lib/compass-rails/railties/3_0.rb +48 -0
  30. data/lib/compass-rails/railties/3_1.rb +90 -0
  31. data/lib/compass-rails/version.rb +5 -0
  32. data/lib/compass/app_integration/rails.rb +10 -0
  33. data/test/fixtures/.gitkeep +0 -0
  34. data/test/helpers/command_helper.rb +120 -0
  35. data/test/helpers/debug_helper.rb +12 -0
  36. data/test/helpers/file_helper.rb +53 -0
  37. data/test/helpers/rails_helper.rb +65 -0
  38. data/test/helpers/rails_project.rb +186 -0
  39. data/test/integrations/.gitkeep +0 -0
  40. data/test/integrations/rails3_test.rb +37 -0
  41. data/test/integrations/rails_23_test.rb +28 -0
  42. data/test/integrations/rails_31_test.rb +47 -0
  43. data/test/integrations/rails_32_test.rb +46 -0
  44. data/test/test_helper.rb +15 -0
  45. data/test/units/.gitkeep +0 -0
  46. metadata +160 -0
@@ -0,0 +1,186 @@
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
+
11
+ GEMFILE = 'Gemfile'
12
+ GEMFILE_LOCK = 'Gemfile.lock'
13
+ ENVIRONMENT = 'config/environment.rb'
14
+ COMPASS_CONFIG = 'config/compass.rb'
15
+ APPLICATION_FILE = 'config/application.rb'
16
+ BOOT_FILE = 'config/boot.rb'
17
+
18
+
19
+ attr_reader :directory, :version
20
+
21
+ def initialize(directory, version)
22
+ @directory = Pathname.new(directory)
23
+ @version = version
24
+ configure_for_bundler!
25
+ end
26
+
27
+ ## FILE METHODS
28
+
29
+ def to_s
30
+ directory_name
31
+ end
32
+
33
+ def directory_name
34
+ File.basename(directory)
35
+ end
36
+
37
+ def has_file?(file)
38
+ File.exist? directory.join(file)
39
+ end
40
+
41
+ def screen_file
42
+ case version
43
+ when RAILS_3_1, RAILS_3_2
44
+ return directory.join('app', 'assets', 'stylesheets', 'screen.css.scss')
45
+ when RAILS_2, RAILS_3
46
+ return directory.join('app', 'assets', 'stylesheets','screen.scss')
47
+ end
48
+ end
49
+
50
+ def has_screen_file?
51
+ screen_file.exist?
52
+ end
53
+
54
+ def has_compass_import?
55
+ File.read(screen_file).include?("compass/reset")
56
+ end
57
+
58
+ def has_config?
59
+ directory.join('config', 'compass.rb').exist?
60
+ end
61
+
62
+ # RAILS METHODS
63
+
64
+ def rails3?
65
+ directory.join(APPLICATION_FILE).exist?
66
+ end
67
+
68
+ def rails2?
69
+ directory.join(BOOT_FILE).exist? && !directory.join(APPLICATION_FILE).exist?
70
+ end
71
+
72
+ def boots?
73
+ string = 'THIS IS MY RANDOM AWESOME TEST STRING'
74
+ test_string = "puts \"#{string}\""
75
+ matcher = %r{#{string}}
76
+ r = runner(test_string)
77
+ if r =~ matcher
78
+ return true
79
+ else
80
+ return false
81
+ end
82
+ end
83
+
84
+ def runner(string)
85
+ case version
86
+ when RAILS_3_1, RAILS_3, RAILS_3_2
87
+ rails_command(['runner', "'#{string}'"], version)
88
+ when RAILS_2
89
+ run_command("script/runner '#{string}'", GEMFILES[version])
90
+ end
91
+ end
92
+
93
+ # COMPASS METHODS
94
+
95
+ def run_compass(command)
96
+ run_command("compass #{command}", GEMFILES[version])
97
+ end
98
+
99
+ def set_compass(property, value)
100
+ file = directory.join(COMPASS_CONFIG)
101
+ unless file.exist?
102
+ touch file
103
+ end
104
+ inject_at_bottom(file, "#{property} = '#{value}'")
105
+ end
106
+
107
+ def set_rails(property, value)
108
+ value = if value.is_a?(Symbol)
109
+ "\n config.#{property} = :#{value}\n"
110
+ else
111
+ "\n config.#{property} = '#{value}'\n"
112
+ end
113
+ inject_into_file(directory.join(APPLICATION_FILE), value, :after, '# Enable the asset pipeline')
114
+ end
115
+
116
+ ## GEM METHODS
117
+
118
+ def configure_for_bundler!
119
+ return if [RAILS_3_1, RAILS_3, RAILS_3_2].include?(version)
120
+ bundle = <<-BUNDLER
121
+ class Rails::Boot
122
+ def run
123
+ load_initializer
124
+
125
+ Rails::Initializer.class_eval do
126
+ def load_gems
127
+ @bundler_loaded ||= Bundler.require :default, Rails.env
128
+ end
129
+ end
130
+
131
+ Rails::Initializer.run(:set_load_path)
132
+ end
133
+ end
134
+ BUNDLER
135
+ inject_into_file(directory.join('config/boot.rb'), bundle, :before, 'Rails.boot!')
136
+
137
+ touch directory.join('config/preinitializer.rb')
138
+ preinit = <<-PREINIT
139
+ begin
140
+ require "rubygems"
141
+ require "bundler"
142
+ rescue LoadError
143
+ raise "Could not load the bundler gem. Install it with `gem install bundler`."
144
+ end
145
+
146
+ if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
147
+ raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
148
+ "Run `gem install bundler` to upgrade."
149
+ end
150
+
151
+ begin
152
+ # Set up load paths for all bundled gems
153
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
154
+ Bundler.setup
155
+ rescue Bundler::GemNotFound
156
+ raise RuntimeError, "Bundler couldn't find some gems." +
157
+ "Did you run `bundle install`?"
158
+ end
159
+ PREINIT
160
+ inject_at_bottom(directory.join('config/preinitializer.rb'), preinit)
161
+
162
+ touch directory.join('Gemfile')
163
+
164
+ end
165
+
166
+ def bundle
167
+ raise "NO BUNDLE FOR U"
168
+ end
169
+
170
+ private
171
+
172
+ ## GEM METHODS
173
+
174
+ def add_to_gemfile(name, requirements)
175
+ gemfile = directory.join(GEMFILE)
176
+ debug("Adding gem #{name} to file: #{gemfile}".foreground(:green))
177
+ if requirements
178
+ gem_string = " gem '#{name}', #{requirements}\n"
179
+ else
180
+ gem_string = " gem '#{name}'\n"
181
+ end
182
+ inject_at_bottom(gemfile, gem_string)
183
+ end
184
+ end
185
+ end
186
+ end
File without changes
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ class Rails3Test < Test::Unit::TestCase
3
+ include CompassRails::Test::RailsHelpers
4
+ RAILS_VERSION = RAILS_3
5
+
6
+ def test_rails_app_created
7
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
8
+ assert project.boots?
9
+ end
10
+ end
11
+
12
+ def test_installs_compass
13
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
14
+ project.run_compass('init')
15
+ assert project.has_config?
16
+ assert project.has_screen_file?
17
+ assert project.has_compass_import?
18
+ end
19
+ end
20
+
21
+ def test_compass_compile
22
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
23
+ project.run_compass('init')
24
+ project.run_compass('compile')
25
+ assert project.directory.join('public/stylesheets/screen.css').exist?
26
+ end
27
+ end
28
+
29
+ def test_install_blueprint
30
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
31
+ project.run_compass('init')
32
+ project.run_compass('install blueprint --force')
33
+ assert project.directory.join('app/assets/stylesheets/partials').directory?
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+ class Rails23Test < Test::Unit::TestCase
3
+ include CompassRails::Test::RailsHelpers
4
+ RAILS_VERSION = RAILS_2
5
+
6
+ def test_rails_app_created
7
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
8
+ assert project.boots?
9
+ end
10
+ end
11
+
12
+ def test_installs_compass
13
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
14
+ project.run_compass('init')
15
+ assert project.has_config?
16
+ assert project.has_screen_file?
17
+ assert project.has_compass_import?
18
+ end
19
+ end
20
+
21
+ def test_install_blueprint
22
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
23
+ project.run_compass('install blueprint --force')
24
+ assert project.directory.join('app/assets/stylesheets/partials').directory?
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+ class Rails31Test < Test::Unit::TestCase
3
+ include CompassRails::Test::RailsHelpers
4
+
5
+ RAILS_VERSION = RAILS_3_1
6
+
7
+ def test_rails_app_created
8
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
9
+ assert project.boots?
10
+ end
11
+ end
12
+
13
+ def test_installs_compass
14
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
15
+ project.run_compass('init')
16
+ assert project.has_config?
17
+ assert project.has_screen_file?
18
+ assert project.has_compass_import?
19
+ end
20
+ end
21
+
22
+ def test_compass_compile
23
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
24
+ project.run_compass('init')
25
+ project.run_compass('compile')
26
+ assert project.directory.join('public/assets/screen.css').exist?
27
+ end
28
+ end
29
+
30
+ def test_install_blueprint
31
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
32
+ project.run_compass('init')
33
+ project.run_compass('install blueprint --force')
34
+ assert project.directory.join('app/assets/stylesheets/partials').directory?
35
+ end
36
+ end
37
+
38
+
39
+ def test_compass_preferred_syntax
40
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
41
+ project.set_rails('sass.preferred_syntax', :sass)
42
+ project.run_compass('init')
43
+ assert project.directory.join('app/assets/stylesheets/screen.css.sass').exist?
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+ class Rails32Test < Test::Unit::TestCase
3
+ include CompassRails::Test::RailsHelpers
4
+ RAILS_VERSION = RAILS_3_2
5
+
6
+ def test_rails_app_created
7
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
8
+ assert project.boots?
9
+ end
10
+ end
11
+
12
+
13
+ def test_installs_compass
14
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
15
+ project.run_compass('init')
16
+ assert project.has_config?
17
+ assert project.has_screen_file?
18
+ assert project.has_compass_import?
19
+ end
20
+ end
21
+
22
+ def test_compass_compile
23
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
24
+ project.run_compass('init')
25
+ project.run_compass('compile')
26
+ assert project.directory.join('public/assets/screen.css').exist?
27
+ end
28
+ end
29
+
30
+ def test_install_blueprint
31
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
32
+ project.run_compass('init')
33
+ project.run_compass('install blueprint --force')
34
+ assert project.directory.join('app/assets/stylesheets/partials').directory?
35
+ end
36
+ end
37
+
38
+ def test_compass_preferred_syntax
39
+ within_rails_app('test_railtie', RAILS_VERSION) do |project|
40
+ project.set_rails('sass.preferred_syntax', :sass)
41
+ project.run_compass('init')
42
+ assert project.directory.join('app/assets/stylesheets/screen.css.sass').exist?
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'compass-rails'
3
+ require 'rainbow'
4
+ module CompassRails
5
+ module Test
6
+ ROOT_PATH = File.expand_path('../../', __FILE__)
7
+ TESTING_VERSION = '0.12.alpha'
8
+ end
9
+ end
10
+
11
+ %w(debug file command rails).each do |helper|
12
+ require File.join(File.expand_path('../', __FILE__), 'helpers', "#{helper}_helper")
13
+ end
14
+
15
+ require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
File without changes
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15424055
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ - rc
11
+ - 1
12
+ version: 1.0.0.rc.1
13
+ platform: ruby
14
+ authors:
15
+ - Scott Davis
16
+ - Chris Eppstein
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2012-01-31 00:00:00 -08:00
22
+ default_executable:
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
25
+ name: rails
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: compass
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 15424133
47
+ segments:
48
+ - 0
49
+ - 12
50
+ - rc
51
+ - 0
52
+ version: 0.12.rc.0
53
+ type: :runtime
54
+ version_requirements: *id002
55
+ description: Integrate Compass into Rails 2.3 and up.
56
+ email:
57
+ - jetviper21@gmail.com
58
+ - chris@eppsteins.net
59
+ executables: []
60
+
61
+ extensions: []
62
+
63
+ extra_rdoc_files: []
64
+
65
+ files:
66
+ - .gitignore
67
+ - .travis.yml
68
+ - Appraisals
69
+ - Gemfile
70
+ - Guardfile
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - compass-rails.gemspec
75
+ - gemfiles/rails2.gemfile
76
+ - gemfiles/rails2.gemfile.lock
77
+ - gemfiles/rails3.gemfile
78
+ - gemfiles/rails3.gemfile.lock
79
+ - gemfiles/rails31.gemfile
80
+ - gemfiles/rails31.gemfile.lock
81
+ - gemfiles/rails32.gemfile
82
+ - gemfiles/rails32.gemfile.lock
83
+ - lib/compass-rails.rb
84
+ - lib/compass-rails/configuration.rb
85
+ - lib/compass-rails/configuration/3_1.rb
86
+ - lib/compass-rails/configuration/default.rb
87
+ - lib/compass-rails/installer.rb
88
+ - lib/compass-rails/patches.rb
89
+ - lib/compass-rails/patches/3_1.rb
90
+ - lib/compass-rails/patches/importer.rb
91
+ - lib/compass-rails/patches/sprite_importer.rb
92
+ - lib/compass-rails/railties.rb
93
+ - lib/compass-rails/railties/2_3.rb
94
+ - lib/compass-rails/railties/3_0.rb
95
+ - lib/compass-rails/railties/3_1.rb
96
+ - lib/compass-rails/version.rb
97
+ - lib/compass/app_integration/rails.rb
98
+ - test/fixtures/.gitkeep
99
+ - test/helpers/command_helper.rb
100
+ - test/helpers/debug_helper.rb
101
+ - test/helpers/file_helper.rb
102
+ - test/helpers/rails_helper.rb
103
+ - test/helpers/rails_project.rb
104
+ - test/integrations/.gitkeep
105
+ - test/integrations/rails3_test.rb
106
+ - test/integrations/rails_23_test.rb
107
+ - test/integrations/rails_31_test.rb
108
+ - test/integrations/rails_32_test.rb
109
+ - test/test_helper.rb
110
+ - test/units/.gitkeep
111
+ has_rdoc: true
112
+ homepage: https://github.com/Compass/compass-rails
113
+ licenses: []
114
+
115
+ post_install_message:
116
+ rdoc_options: []
117
+
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">"
133
+ - !ruby/object:Gem::Version
134
+ hash: 25
135
+ segments:
136
+ - 1
137
+ - 3
138
+ - 1
139
+ version: 1.3.1
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.4.2
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Integrate Compass into Rails 2.3 and up.
147
+ test_files:
148
+ - test/fixtures/.gitkeep
149
+ - test/helpers/command_helper.rb
150
+ - test/helpers/debug_helper.rb
151
+ - test/helpers/file_helper.rb
152
+ - test/helpers/rails_helper.rb
153
+ - test/helpers/rails_project.rb
154
+ - test/integrations/.gitkeep
155
+ - test/integrations/rails3_test.rb
156
+ - test/integrations/rails_23_test.rb
157
+ - test/integrations/rails_31_test.rb
158
+ - test/integrations/rails_32_test.rb
159
+ - test/test_helper.rb
160
+ - test/units/.gitkeep