compass 1.0.0.alpha.21 → 1.0.0.rc.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +11 -5
  3. data/features/command_line.feature +5 -25
  4. data/features/step_definitions/command_line_steps.rb +3 -3
  5. data/lib/compass.rb +2 -2
  6. data/lib/compass/actions.rb +4 -3
  7. data/lib/compass/commands/update_project.rb +50 -45
  8. data/lib/compass/commands/watch_project.rb +62 -13
  9. data/lib/compass/compiler.rb +2 -0
  10. data/lib/compass/configuration/adapters.rb +21 -0
  11. data/lib/compass/configuration/helpers.rb +8 -0
  12. data/lib/compass/deprecation.rb +19 -0
  13. data/lib/compass/exec/global_options_parser.rb +0 -4
  14. data/lib/compass/generated_version.rb +4 -0
  15. data/lib/compass/logger.rb +31 -18
  16. data/lib/compass/sass_compiler.rb +134 -0
  17. data/lib/compass/sass_extensions/functions/sprites.rb +3 -3
  18. data/lib/compass/sprite_importer.rb +1 -1
  19. data/lib/compass/version.rb +29 -31
  20. data/test/fixtures/stylesheets/compass/css/background-clip.css +2 -0
  21. data/test/fixtures/stylesheets/compass/css/background-origin.css +2 -0
  22. data/test/fixtures/stylesheets/compass/css/background-size.css +3 -0
  23. data/test/fixtures/stylesheets/compass/css/browser-support.css +22 -11
  24. data/test/fixtures/stylesheets/compass/css/filters.css +6 -6
  25. data/test/fixtures/stylesheets/compass/css/grid_background.css +4 -0
  26. data/test/fixtures/stylesheets/compass/css/support.css +6 -6
  27. data/test/fixtures/stylesheets/compass/css/transition.css +19 -0
  28. data/test/fixtures/stylesheets/compass/css/vertical_rhythm_with_ems.css +1 -0
  29. data/test/fixtures/stylesheets/compass/css/vertical_rhythm_with_px.css +1 -0
  30. data/test/fixtures/stylesheets/compass/css/vertical_rhythm_with_rems.css +1 -0
  31. data/test/fixtures/stylesheets/sourcemaps/css/another_simple.css +1 -0
  32. data/test/fixtures/stylesheets/sourcemaps/css/another_simple.css.map +2 -1
  33. data/test/fixtures/stylesheets/sourcemaps/css/simple.css +1 -0
  34. data/test/fixtures/stylesheets/sourcemaps/css/simple.css.map +2 -1
  35. data/test/fixtures/stylesheets/sourcemaps/css/with_libraries.css +1 -0
  36. data/test/fixtures/stylesheets/sourcemaps/css/with_libraries.css.map +2 -1
  37. data/test/integrations/compass_test.rb +5 -4
  38. data/test/units/caniuse_test.rb +8 -2
  39. data/test/units/command_line_test.rb +3 -3
  40. data/test/units/compiler_test.rb +7 -2
  41. data/test/units/configuration_test.rb +1 -1
  42. metadata +9 -22
  43. data/RELEASE_VERSION +0 -1
  44. data/VERSION +0 -1
  45. data/lib/compass/watcher.rb +0 -11
  46. data/lib/compass/watcher/compiler.rb +0 -60
  47. data/lib/compass/watcher/project_watcher.rb +0 -179
  48. data/lib/compass/watcher/watch.rb +0 -51
  49. data/test/fixtures/stylesheets/valid/css/another_simple.css +0 -4
  50. data/test/fixtures/stylesheets/valid/css/simple.css +0 -4
  51. data/test/units/watcher/compiler_test.rb +0 -39
  52. data/test/units/watcher/project_watcher_test.rb +0 -85
  53. data/test/units/watcher/watch_test.rb +0 -42
@@ -1 +0,0 @@
1
- 1.0.0.alpha.21
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.0.alpha.20
@@ -1,11 +0,0 @@
1
- require 'compass/watcher/watch'
2
- require 'compass/watcher/compiler'
3
- require 'compass/watcher/project_watcher'
4
-
5
- module Compass
6
- module Watcher
7
- class WatcherException < Compass::Error; end
8
- class NoCallbackError < WatcherException; end
9
- class AbsolutePathError < WatcherException; end
10
- end
11
- end
@@ -1,60 +0,0 @@
1
- module Compass
2
- module Watcher
3
- class Compiler
4
- include Compass::Actions
5
- attr_reader :working_path, :memory_store, :backing_store, :cache_store, :compiler_options, :compiler
6
-
7
- def initialize(working_path, additional_options={})
8
- @working_path = working_path
9
- @compiler_options = create_compiler_options(additional_options)
10
- @memory_store ||= Sass::CacheStores::Memory.new
11
- @backing_store ||= compiler_options[:cache_store]
12
- @backing_store ||= Sass::CacheStores::Filesystem.new(determine_cache_location)
13
- @cache_store ||= Sass::CacheStores::Chain.new(@memory_store, @backing_store)
14
- @compiler ||= create_compiler
15
- end
16
-
17
- def compile
18
- @memory_cache.reset! if @memory_cache
19
- compiler.reset!
20
- if file = compiler.out_of_date?
21
- begin
22
- time = Time.now.strftime("%T")
23
- log_action(:info, "Change detected at #{time} to: #{compiler.relative_stylesheet_name(file)}", compiler_options)
24
- compiler.run
25
- GC.start
26
- rescue StandardError => e
27
- ::Compass::Exec::Helpers.report_error(e, compiler_options)
28
- end
29
- end
30
- end
31
-
32
- private #=========================================================================================>
33
-
34
- def create_compiler_options(additional_options)
35
- compiler_opts = {:sass => Compass.sass_engine_options, :cache_store => @cache_store, :quiet => true, :loud => [:identical, :overwrite, :create]}.merge(additional_options)
36
- compiler_opts[:cache_location] ||= determine_cache_location
37
- compiler_opts[:sourcemap] = Compass.configuration.sourcemap if compiler_opts[:sourcemap].nil?
38
- if compiler_opts.include?(:debug_info)
39
- compiler_opts[:sass][:debug_info] = compiler_opts.delete(:debug_info)
40
- end
41
-
42
- compiler_opts
43
- end
44
-
45
- def create_compiler
46
- @memory_store.reset!
47
- Compass::Compiler.new(
48
- working_path,
49
- Compass.configuration.sass_path,
50
- Compass.configuration.css_path,
51
- compiler_options.dup
52
- )
53
- end
54
-
55
- def determine_cache_location
56
- Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
57
- end
58
- end
59
- end
60
- end
@@ -1,179 +0,0 @@
1
- require 'forwardable'
2
- module Compass
3
- module Watcher
4
- class ProjectWatcher
5
- include Compass::Actions
6
- SASS_FILTER = '*.s[ac]ss'
7
- ALL_CHILDREN_SASS_FILTER = File.join('**', SASS_FILTER)
8
- POLLING_MESSAGE = 'Compass is polling for changes'
9
-
10
- attr_reader :options, :project_path, :watcher_compiler, :listener, :poll, :css_dir, :watchers
11
-
12
- alias :working_path :project_path
13
-
14
- extend Forwardable
15
-
16
- def_delegators :@watcher_compiler, :compiler, :compiler
17
- def_delegators :@watcher_compiler, :compile, :compile
18
-
19
- def initialize(project_path, watches=[], options={}, poll=false)
20
- @poll = poll
21
- @options = options
22
- @project_path = project_path
23
- @css_dir = Compass.configuration.css_dir
24
- @watchers = [SassWatch.new(&method(:sass_callback))] + watches
25
- @watcher_compiler = Compass::Watcher::Compiler.new(project_path, options)
26
- setup_listener
27
- end
28
-
29
- def watch!
30
- if Sass::Util.listen_geq_2?
31
- @listeners.each {|l| l.start}
32
- sleep
33
- else
34
- listener.start!
35
- end
36
- rescue Interrupt
37
- if Sass::Util.listen_geq_2?
38
- Listen.stop
39
- else
40
- listener.stop
41
- end
42
- logger.log "\nHappy Styling!"
43
- end
44
-
45
- def listeners
46
- @listeners || [@listener]
47
- end
48
-
49
- private #============================================================================>
50
-
51
- def setup_listener
52
- Sass::Util.load_listen!
53
- listen_opts = {:relative_paths => false}
54
-
55
- if Sass::Util.listen_geq_2?
56
- listen_opts.update(:force_polling => true) if poll
57
- listen_opts.update(:polling_fallback_message => POLLING_MESSAGE,
58
- :ignore => /\.css$/)
59
- @listeners = []
60
- directories_to_watch.each do |dir|
61
- # work around https://github.com/guard/listen/issues/243
62
- @listeners << Listen.to(dir, listen_opts, &method(:listen_callback))
63
- end
64
- else
65
- args = directories_to_watch + [listen_opts]
66
- @listener = Listen::Listener.new(*args, &method(:listen_callback))
67
- @listener = listener.force_polling(true) if poll
68
- @listener = listener.polling_fallback_message(POLLING_MESSAGE)
69
- @listener.ignore(/\.css$/)
70
- end
71
-
72
- @listener
73
- end
74
-
75
- def directories_to_watch
76
- @directories_to_watch ||= begin
77
- dirs = [Compass.configuration.sass_path] +
78
- Compass.configuration.sass_load_paths.map{|p| p.directories_to_watch}
79
- dirs.flatten!
80
- dirs.compact!
81
- dirs.select {|d| File.writable?(d) }
82
- dirs.uniq!
83
- dirs
84
- end
85
- end
86
-
87
- def listen_callback(modified_files, added_files, removed_files)
88
- # log_action(:info, ">>> Listen Callback fired added: #{added_files}, mod: #{modified_files}, rem: #{removed_files}", {})
89
- files = {:modified => modified_files,
90
- :added => added_files,
91
- :removed => removed_files}
92
-
93
- run_once, run_each = watchers.partition {|w| w.run_once_per_changeset?}
94
-
95
- run_once.each do |watcher|
96
- if file = files.values.flatten.detect{|f| watcher.match?(f) }
97
- action = files.keys.detect{|k| files[k].include?(file) }
98
- watcher.run_callback(project_path, relative_to(file, project_path), action)
99
- end
100
- end
101
-
102
- run_each.each do |watcher|
103
- files.each do |action, list|
104
- list.each do |file|
105
- if watcher.match?(file)
106
- watcher.run_callback(project_path, relative_to(file, project_path), action)
107
- end
108
- end
109
- end
110
- end
111
- end
112
-
113
- def sass_callback(base, file, action)
114
- #log_action(:info, ">>> Sass Callback fired #{action}, #{file}", {})
115
- full_filename = File.expand_path(File.join(base,file))
116
- case action
117
- when :modified
118
- sass_modified(full_filename)
119
- when :added
120
- sass_added(full_filename)
121
- when :removed
122
- sass_removed(full_filename)
123
- else
124
- raise ArgumentError, "Illegal Action: #{action.inspect}"
125
- end
126
- end
127
-
128
- def sass_modified(file)
129
- log_action(:info, "#{filename_for_display(file)} was modified", options)
130
- compile
131
- end
132
-
133
- def sass_added(file)
134
- log_action(:info, "#{filename_for_display(file)} was added", options)
135
- compile
136
- end
137
-
138
- def sass_removed(file)
139
- log_action(:info, "#{filename_for_display(file)} was removed", options)
140
- css_file = compiler.corresponding_css_file(file)
141
- sourcemap_file = compiler.corresponding_sourcemap_file(file)
142
- compile
143
- remove(css_file) if File.exists?(css_file)
144
- remove(sourcemap_file) if File.exists?(sourcemap_file)
145
- end
146
-
147
- def local_development_locations
148
- @local_development_locations ||= begin
149
- r = [Compass.configuration.sass_path] + Array(Compass.configuration.additional_import_paths)
150
- r.map!{|l| File.expand_path(l) }
151
- end
152
- end
153
-
154
- def filename_for_display(f)
155
- if framework = Frameworks::ALL.detect {|fmwk| in_directory?(fmwk.stylesheets_directory, f) }
156
- "(#{framework.name}) #{relative_to(f, framework.stylesheets_directory)}"
157
- elsif directories_to_watch.detect{|d| in_directory?(d, f) }
158
- relative_to_working_directory(f)
159
- else
160
- f
161
- end
162
- end
163
-
164
- def in_directory?(dir, f)
165
- dir && (f[0...(dir.size)] == dir)
166
- end
167
-
168
- def relative_to_working_directory(f)
169
- relative_to(f, Dir.pwd)
170
- end
171
-
172
- def relative_to(f, dir)
173
- Pathname.new(f).relative_path_from(Pathname.new(dir))
174
- rescue ArgumentError # does not share a common path.
175
- f
176
- end
177
- end
178
- end
179
- end
@@ -1,51 +0,0 @@
1
- module Compass
2
- module Watcher
3
- class BasicWatch
4
- attr_reader :callback
5
-
6
- def initialize(&block)
7
- unless block
8
- raise NoCallbackError, "A Block must be supplied in order to be watched"
9
- end
10
- @callback = block
11
- end
12
-
13
- def run_callback(base, relative, action)
14
- callback.call(base, relative, action)
15
- end
16
-
17
- def run_once_per_changeset?
18
- false
19
- end
20
-
21
- def match?(path)
22
- Sass::Util.abstract(self)
23
- end
24
- end
25
-
26
- class Watch < BasicWatch
27
- attr_reader :glob
28
-
29
- def initialize(glob, &block)
30
- super(&block)
31
- unless glob
32
- raise WatcherException, "A glob must be supplied in order to be watched"
33
- end
34
- @glob = glob
35
- end
36
-
37
- def match?(changed_path)
38
- File.fnmatch(glob, changed_path)
39
- end
40
- end
41
-
42
- class SassWatch < BasicWatch
43
- def match?(path)
44
- path =~ /s[ac]ss$/
45
- end
46
- def run_once_per_changeset?
47
- true
48
- end
49
- end
50
- end
51
- end
@@ -1,4 +0,0 @@
1
- /* line 1, ../sass/another_simple.scss */
2
- .another-simple-class {
3
- color: blue;
4
- }
@@ -1,4 +0,0 @@
1
- /* line 1, ../sass/simple.sass */
2
- div {
3
- color: red;
4
- }
@@ -1,39 +0,0 @@
1
- require 'test_helper'
2
- require 'compass'
3
-
4
- class WatcherCompilerTest < Test::Unit::TestCase
5
-
6
- def setup
7
- @working_path = File.join(fixture_path, 'stylesheets', 'valid')
8
- @to = File.join(@working_path, 'css')
9
- remove_to
10
- Compass.add_configuration({:sass_path => File.join(@working_path, 'sass'), :css_path => @to }, 'test')
11
- end
12
-
13
- test "it sould create a new instance of a compass compiler" do
14
- watch_compiler = Compass::Watcher::Compiler.new(@working_path, {})
15
- assert watch_compiler.compiler.is_a?(Compass::Compiler)
16
- end
17
-
18
- test "debug info gets passed into sass options" do
19
- watch_compiler = Compass::Watcher::Compiler.new(@working_path, {:debug_info => true})
20
- assert watch_compiler.compiler_options[:sass][:debug_info]
21
- end
22
-
23
- test "should run compiler" do
24
- watch_compiler = Compass::Watcher::Compiler.new(@working_path, {})
25
- watch_compiler.compiler.expects(:reset_staleness_checker!).once
26
- watch_compiler.compiler.expects(:run).once
27
- watch_compiler.expects(:log_action).once
28
- watch_compiler.compile
29
- end
30
-
31
- def remove_to
32
- ::FileUtils.rm_r @to if File.exists?(@to)
33
- end
34
-
35
- def teardown
36
- remove_to
37
- end
38
-
39
- end
@@ -1,85 +0,0 @@
1
- require 'test_helper'
2
- require 'compass'
3
-
4
- class ProjectWatcherTest < Test::Unit::TestCase
5
-
6
- def setup
7
- @working_path = File.join(fixture_path, 'stylesheets', 'valid')
8
- @to = File.join(@working_path, 'css')
9
- remove_to
10
- Compass.add_configuration({:sass_path => File.join(@working_path, 'sass'), :css_path => @to }, 'test')
11
- @project_watcher = Compass::Watcher::ProjectWatcher.new(@working_path)
12
- end
13
-
14
- def fullpath(basename)
15
- File.join(@working_path, basename)
16
- end
17
-
18
- def foo_basename
19
- "foo.scss"
20
- end
21
-
22
- def sample_basename
23
- File.join('sass', 'sample.scss')
24
- end
25
-
26
- test "should initalize correctly" do
27
- if Sass::Util.listen_geq_2?
28
- assert @project_watcher.listeners.is_a?(Array) && @project_watcher.listeners.size > 0
29
- else
30
- assert @project_watcher.listener.is_a?(Listen::Listener)
31
- end
32
- assert_equal 1, @project_watcher.watchers.size
33
- end
34
-
35
- test "should have 3 watchers" do
36
- Dir.chdir File.join(@working_path, 'sass') do
37
- @project_watcher = Compass::Watcher::ProjectWatcher.new(Dir.pwd)
38
- assert_equal 1, @project_watcher.watchers.size
39
- end
40
- end
41
-
42
- test "compiler" do
43
- assert @project_watcher.compiler.is_a?(Compass::Compiler)
44
- end
45
-
46
- test "sass callback add" do
47
- @project_watcher.expects(:sass_added).with(fullpath(foo_basename)).once
48
- @project_watcher.send(:sass_callback, @working_path, foo_basename, :added)
49
- end
50
-
51
- test "sass callback modified" do
52
- @project_watcher.expects(:sass_modified).with(fullpath(foo_basename)).once
53
- @project_watcher.send(:sass_callback, @working_path, foo_basename, :modified)
54
- end
55
-
56
- test "sass callback removed" do
57
- @project_watcher.expects(:sass_removed).with(fullpath(foo_basename)).once
58
- @project_watcher.send(:sass_callback, @working_path, foo_basename, :removed)
59
- end
60
-
61
- test "listen callback modified" do
62
- @project_watcher.expects(:sass_modified).with(fullpath(sample_basename)).once
63
- @project_watcher.send(:listen_callback, sample_basename, [], [])
64
- end
65
-
66
- test "listen callback added" do
67
- @project_watcher.expects(:sass_added).with(fullpath(sample_basename)).once
68
- @project_watcher.send(:listen_callback, [], sample_basename, [])
69
- end
70
-
71
- test "listen callback removed" do
72
- @project_watcher.expects(:sass_removed).with(fullpath(sample_basename)).once
73
- @project_watcher.send(:listen_callback, [], [], sample_basename)
74
- end
75
-
76
- def remove_to
77
- ::FileUtils.rm_r @to if File.exists?(@to)
78
- end
79
-
80
- def teardown
81
- remove_to
82
- end
83
-
84
-
85
- end