bsherman-compass 0.5.2
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.
- data/Manifest +178 -0
- data/README.markdown +17 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/bin/compass +8 -0
- data/compass.gemspec +37 -0
- data/examples/blueprint_default/index.html +73 -0
- data/examples/blueprint_default/parts/elements.html +246 -0
- data/examples/blueprint_default/parts/forms.html +100 -0
- data/examples/blueprint_default/parts/grid.html +206 -0
- data/examples/blueprint_default/parts/test-small.jpg +0 -0
- data/examples/blueprint_default/parts/test.jpg +0 -0
- data/examples/blueprint_default/parts/valid.png +0 -0
- data/examples/blueprint_plugins/index.html +60 -0
- data/examples/blueprint_plugins/parts/fancy_type.html +84 -0
- data/examples/blueprint_plugins/parts/test-small.jpg +0 -0
- data/examples/blueprint_plugins/parts/test.jpg +0 -0
- data/examples/blueprint_plugins/parts/valid.png +0 -0
- data/examples/blueprint_semantic/index.html +68 -0
- data/examples/blueprint_semantic/parts/fancy_type.html +84 -0
- data/examples/blueprint_semantic/parts/liquid.html +84 -0
- data/examples/blueprint_semantic/parts/test-small.jpg +0 -0
- data/examples/blueprint_semantic/parts/test.jpg +0 -0
- data/examples/blueprint_semantic/parts/valid.png +0 -0
- data/examples/compass/compass.html +19 -0
- data/examples/compass/sticky_footer.html.haml +14 -0
- data/examples/compass/utilities.html.haml +141 -0
- data/examples/yui/divisions.html.haml +179 -0
- data/examples/yui/index.html.haml +19 -0
- data/examples/yui/sub_divisions.html.haml +169 -0
- data/examples/yui/templates.html.haml +54 -0
- data/examples/yui/test.jpg +0 -0
- data/examples/yui/typography.html.haml +132 -0
- data/frameworks/blueprint.rb +2 -0
- data/frameworks/blueprint/lib/blueprint/constants.rb +17 -0
- data/frameworks/blueprint/lib/blueprint/grid_builder.rb +54 -0
- data/frameworks/blueprint/stylesheets/_blueprint.sass +3 -0
- data/frameworks/blueprint/stylesheets/blueprint/_ie.sass +49 -0
- data/frameworks/blueprint/stylesheets/blueprint/_print.sass +82 -0
- data/frameworks/blueprint/stylesheets/blueprint/_screen.sass +15 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass +30 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass +9 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +81 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +43 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +141 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass +58 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass +137 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +46 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +154 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass +37 -0
- data/frameworks/blueprint/templates/project/grid.png +0 -0
- data/frameworks/blueprint/templates/project/ie.sass +3 -0
- data/frameworks/blueprint/templates/project/manifest.rb +5 -0
- data/frameworks/blueprint/templates/project/print.sass +3 -0
- data/frameworks/blueprint/templates/project/screen.sass +8 -0
- data/frameworks/compass.rb +2 -0
- data/frameworks/compass/stylesheets/_compass.sass +1 -0
- data/frameworks/compass/stylesheets/compass/_layout.sass +1 -0
- data/frameworks/compass/stylesheets/compass/_reset.sass +3 -0
- data/frameworks/compass/stylesheets/compass/_utilities.sass +5 -0
- data/frameworks/compass/stylesheets/compass/layout/_sticky_footer.sass +17 -0
- data/frameworks/compass/stylesheets/compass/utilities/_general.sass +4 -0
- data/frameworks/compass/stylesheets/compass/utilities/_links.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_lists.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_print.sass +24 -0
- data/frameworks/compass/stylesheets/compass/utilities/_tables.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_text.sass +2 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.sass +11 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_inline_block.sass +6 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +56 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_tabs.sass +0 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass +19 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_hover_link.sass +5 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_link_colors.sass +24 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_unstyled_link.sass +5 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.sass +21 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal_list.sass +20 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_inline_list.sass +29 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass +20 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.sass +27 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.sass +9 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass +10 -0
- data/frameworks/compass/templates/project/ie.sass +6 -0
- data/frameworks/compass/templates/project/manifest.rb +3 -0
- data/frameworks/compass/templates/project/print.sass +6 -0
- data/frameworks/compass/templates/project/screen.sass +7 -0
- data/frameworks/yui.rb +2 -0
- data/frameworks/yui/COPYRIGHT +15 -0
- data/frameworks/yui/stylesheets/_yui.sass +7 -0
- data/frameworks/yui/stylesheets/yui/modules/_base.sass +60 -0
- data/frameworks/yui/stylesheets/yui/modules/_fonts.sass +38 -0
- data/frameworks/yui/stylesheets/yui/modules/_grids.sass +341 -0
- data/frameworks/yui/templates/project/manifest.rb +1 -0
- data/frameworks/yui/templates/project/screen.sass +4 -0
- data/lib/compass.rb +39 -0
- data/lib/compass/actions.rb +92 -0
- data/lib/compass/commands/base.rb +29 -0
- data/lib/compass/commands/create_project.rb +41 -0
- data/lib/compass/commands/list_frameworks.rb +16 -0
- data/lib/compass/commands/print_version.rb +23 -0
- data/lib/compass/commands/project_base.rb +82 -0
- data/lib/compass/commands/update_project.rb +25 -0
- data/lib/compass/commands/watch_project.rb +53 -0
- data/lib/compass/commands/write_configuration.rb +37 -0
- data/lib/compass/compiler.rb +40 -0
- data/lib/compass/configuration.rb +167 -0
- data/lib/compass/core_ext.rb +12 -0
- data/lib/compass/errors.rb +7 -0
- data/lib/compass/exec.rb +184 -0
- data/lib/compass/frameworks.rb +29 -0
- data/lib/compass/installers.rb +5 -0
- data/lib/compass/installers/base.rb +135 -0
- data/lib/compass/installers/manifest.rb +57 -0
- data/lib/compass/installers/rails.rb +118 -0
- data/lib/compass/installers/stand_alone.rb +76 -0
- data/lib/compass/logger.rb +34 -0
- data/lib/compass/merb.rb +43 -0
- data/lib/compass/test_case.rb +37 -0
- data/lib/compass/validate.rb +13 -0
- data/lib/compass/validate/COPYRIGHT.html +93 -0
- data/lib/compass/validate/JIGSAW_COPYRIGHT +64 -0
- data/lib/compass/validate/README.html +83 -0
- data/lib/compass/validate/XERCES_COPYING.txt +56 -0
- data/lib/compass/validate/css-validator-javadoc.jar +0 -0
- data/lib/compass/validate/css-validator.jar +0 -0
- data/lib/compass/validate/jigsaw.jar +0 -0
- data/lib/compass/validate/xerces.jar +0 -0
- data/lib/compass/validator.rb +59 -0
- data/lib/compass/version.rb +66 -0
- data/lib/sass_extensions.rb +13 -0
- data/test/command_line_test.rb +147 -0
- data/test/compass_test.rb +148 -0
- data/test/configuration_test.rb +29 -0
- data/test/fixtures/stylesheets/blueprint/css/typography.css +159 -0
- data/test/fixtures/stylesheets/blueprint/sass/ie.sass +3 -0
- data/test/fixtures/stylesheets/blueprint/sass/print.sass +3 -0
- data/test/fixtures/stylesheets/blueprint/sass/screen.sass +17 -0
- data/test/fixtures/stylesheets/blueprint/sass/typography.sass +3 -0
- data/test/fixtures/stylesheets/compass/css/layout.css +14 -0
- data/test/fixtures/stylesheets/compass/css/print.css +19 -0
- data/test/fixtures/stylesheets/compass/css/reset.css +66 -0
- data/test/fixtures/stylesheets/compass/css/utilities.css +23 -0
- data/test/fixtures/stylesheets/compass/sass/layout.sass +3 -0
- data/test/fixtures/stylesheets/compass/sass/print.sass +5 -0
- data/test/fixtures/stylesheets/compass/sass/reset.sass +1 -0
- data/test/fixtures/stylesheets/compass/sass/utilities.sass +5 -0
- data/test/fixtures/stylesheets/yui/css/mixins.css +16 -0
- data/test/fixtures/stylesheets/yui/sass/base.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/fonts.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/grids.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/mixins.sass +16 -0
- data/test/sass_extensions_test.rb +26 -0
- data/test/test_helper.rb +47 -0
- metadata +295 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
stylesheet 'screen.sass', :media => "screen, projection"
|
data/lib/compass.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'sass'
|
|
3
|
+
|
|
4
|
+
def assert_sass_version(obj)
|
|
5
|
+
unless obj.respond_to?(:version) && obj.version[:major] == 2 && obj.version[:minor] >= 1
|
|
6
|
+
raise LoadError.new("Compass requires Haml version 2.1 or greater.")
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
begin
|
|
11
|
+
assert_sass_version(Sass)
|
|
12
|
+
rescue LoadError
|
|
13
|
+
require 'haml'
|
|
14
|
+
assert_sass_version(Haml)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require File.join(File.dirname(__FILE__), 'sass_extensions')
|
|
18
|
+
|
|
19
|
+
['core_ext', 'version'].each do |file|
|
|
20
|
+
require File.join(File.dirname(__FILE__), 'compass', file)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module Compass
|
|
24
|
+
extend Compass::Version
|
|
25
|
+
def base_directory
|
|
26
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
27
|
+
end
|
|
28
|
+
def lib_directory
|
|
29
|
+
File.expand_path(File.join(File.dirname(__FILE__)))
|
|
30
|
+
end
|
|
31
|
+
module_function :base_directory, :lib_directory
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
require File.join(File.dirname(__FILE__), 'compass', 'configuration')
|
|
35
|
+
require File.join(File.dirname(__FILE__), 'compass', 'frameworks')
|
|
36
|
+
|
|
37
|
+
# make sure we're running inside Merb
|
|
38
|
+
require File.join(File.dirname(__FILE__), 'compass', 'merb') if defined?(Merb::Plugins)
|
|
39
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Actions
|
|
3
|
+
|
|
4
|
+
attr_writer :logger
|
|
5
|
+
|
|
6
|
+
def logger
|
|
7
|
+
@logger ||= Logger.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# copy/process a template in the compass template directory to the project directory.
|
|
11
|
+
def copy(from, to, options = nil)
|
|
12
|
+
options ||= self.options if self.respond_to?(:options)
|
|
13
|
+
contents = File.new(from).read
|
|
14
|
+
write_file to, contents, options
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# create a directory and all the directories necessary to reach it.
|
|
18
|
+
def directory(dir, options = nil)
|
|
19
|
+
options ||= self.options if self.respond_to?(:options)
|
|
20
|
+
if File.exists?(dir) && File.directory?(dir)
|
|
21
|
+
logger.record :exists, basename(dir)
|
|
22
|
+
elsif File.exists?(dir)
|
|
23
|
+
msg = "#{basename(dir)} already exists and is not a directory."
|
|
24
|
+
raise Compass::FilesystemConflict.new(msg)
|
|
25
|
+
else
|
|
26
|
+
logger.record :directory, separate("#{basename(dir)}/")
|
|
27
|
+
FileUtils.mkdir_p(dir) unless options[:dry_run]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Write a file given the file contents as a string
|
|
32
|
+
def write_file(file_name, contents, options = nil)
|
|
33
|
+
options ||= self.options if self.respond_to?(:options)
|
|
34
|
+
skip_write = options[:dry_run]
|
|
35
|
+
if File.exists?(file_name)
|
|
36
|
+
existing_contents = File.new(file_name).read
|
|
37
|
+
if existing_contents == contents
|
|
38
|
+
logger.record :identical, basename(file_name)
|
|
39
|
+
skip_write = true
|
|
40
|
+
elsif options[:force]
|
|
41
|
+
logger.record :overwrite, basename(file_name)
|
|
42
|
+
else
|
|
43
|
+
msg = "File #{basename(file_name)} already exists. Run with --force to force overwrite."
|
|
44
|
+
raise Compass::FilesystemConflict.new(msg)
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
logger.record :create, basename(file_name)
|
|
48
|
+
end
|
|
49
|
+
open(file_name,'w') do |file|
|
|
50
|
+
file.write(contents)
|
|
51
|
+
end unless skip_write
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Compile one Sass file
|
|
55
|
+
def compile(sass_filename, css_filename, options)
|
|
56
|
+
logger.record :compile, basename(sass_filename)
|
|
57
|
+
engine = ::Sass::Engine.new(open(sass_filename).read,
|
|
58
|
+
:filename => sass_filename,
|
|
59
|
+
:line_comments => options[:environment] == :development,
|
|
60
|
+
:style => options[:style],
|
|
61
|
+
:css_filename => css_filename,
|
|
62
|
+
:load_paths => options[:load_paths])
|
|
63
|
+
css_content = engine.render
|
|
64
|
+
write_file(css_filename, css_content, options.merge(:force => true))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def basename(file)
|
|
68
|
+
relativize(file) {|f| File.basename(file)}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def relativize(path)
|
|
72
|
+
if path.index(working_path+File::SEPARATOR) == 0
|
|
73
|
+
path[(working_path+File::SEPARATOR).length..-1]
|
|
74
|
+
elsif block_given?
|
|
75
|
+
yield path
|
|
76
|
+
else
|
|
77
|
+
path
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Write paths like we're on unix and then fix it
|
|
82
|
+
def separate(path)
|
|
83
|
+
path.gsub(%r{/}, File::SEPARATOR)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Removes the trailing separator, if any, from a path.
|
|
87
|
+
def strip_trailing_separator(path)
|
|
88
|
+
(path[-1..-1] == File::SEPARATOR) ? path[0..-2] : path
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Commands
|
|
3
|
+
class Base
|
|
4
|
+
|
|
5
|
+
include Actions
|
|
6
|
+
|
|
7
|
+
attr_accessor :working_path, :options
|
|
8
|
+
|
|
9
|
+
def initialize(working_path, options)
|
|
10
|
+
self.working_path = working_path
|
|
11
|
+
self.options = options
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def perform
|
|
15
|
+
raise StandardError.new("Not Implemented")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def framework
|
|
21
|
+
unless Compass::Frameworks[options[:framework]]
|
|
22
|
+
raise Compass::Error.new("No such framework: #{options[:framework].inspect}")
|
|
23
|
+
end
|
|
24
|
+
Compass::Frameworks[options[:framework]]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require File.join(File.dirname(__FILE__), 'base')
|
|
3
|
+
require File.join(File.dirname(__FILE__), 'update_project')
|
|
4
|
+
require File.join(Compass.lib_directory, 'compass', 'installers')
|
|
5
|
+
|
|
6
|
+
module Compass
|
|
7
|
+
module Commands
|
|
8
|
+
class CreateProject < ProjectBase
|
|
9
|
+
|
|
10
|
+
include Compass::Installers
|
|
11
|
+
|
|
12
|
+
attr_accessor :installer
|
|
13
|
+
|
|
14
|
+
def initialize(working_path, options)
|
|
15
|
+
super(working_path, options)
|
|
16
|
+
installer_args = [project_template_directory, project_directory, self.options]
|
|
17
|
+
@installer = case options[:project_type]
|
|
18
|
+
when :stand_alone
|
|
19
|
+
StandAloneInstaller.new *installer_args
|
|
20
|
+
when :rails
|
|
21
|
+
RailsInstaller.new *installer_args
|
|
22
|
+
else
|
|
23
|
+
raise "Unknown project type: #{project_type}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# all commands must implement perform
|
|
28
|
+
def perform
|
|
29
|
+
installer.init
|
|
30
|
+
installer.run(:skip_finalization => true)
|
|
31
|
+
UpdateProject.new(working_path, options).perform if installer.compilation_required?
|
|
32
|
+
installer.finalize(:create => true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def project_template_directory
|
|
36
|
+
File.join(framework.templates_directory, "project")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Commands
|
|
3
|
+
class ListFrameworks
|
|
4
|
+
attr_accessor :options
|
|
5
|
+
def initialize(working_path, options)
|
|
6
|
+
self.options = options
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def perform
|
|
10
|
+
Compass::Frameworks::ALL.each do |framework|
|
|
11
|
+
puts framework.name
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Commands
|
|
3
|
+
class PrintVersion
|
|
4
|
+
attr_accessor :options
|
|
5
|
+
def initialize(working_path, options)
|
|
6
|
+
self.options = options
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def perform
|
|
10
|
+
if options[:quiet]
|
|
11
|
+
# The quiet option may make scripting easier
|
|
12
|
+
puts ::Compass.version[:string]
|
|
13
|
+
else
|
|
14
|
+
lines = []
|
|
15
|
+
lines << "Compass #{::Compass.version[:string]}"
|
|
16
|
+
lines << "Copyright (c) 2008 Chris Eppstein"
|
|
17
|
+
lines << "Released under the MIT License."
|
|
18
|
+
puts lines.join("\n")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'sass'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require File.join(File.dirname(__FILE__), 'base')
|
|
6
|
+
|
|
7
|
+
module Compass
|
|
8
|
+
module Commands
|
|
9
|
+
class ProjectBase < Base
|
|
10
|
+
attr_accessor :project_directory, :project_name, :options
|
|
11
|
+
|
|
12
|
+
def initialize(working_path, options = {})
|
|
13
|
+
super(working_path, options)
|
|
14
|
+
self.project_name = determine_project_name(working_path, options)
|
|
15
|
+
Compass.configuration.project_path = determine_project_directory(working_path, options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def projectize(path)
|
|
21
|
+
File.join(project_directory, separate(path))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def project_directory
|
|
25
|
+
Compass.configuration.project_path
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def project_css_subdirectory
|
|
29
|
+
Compass.configuration.css_dir
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def project_src_subdirectory
|
|
33
|
+
Compass.configuration.sass_dir
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Read the configuration file for this project
|
|
37
|
+
def read_project_configuration
|
|
38
|
+
if File.exists?(projectize('config.rb'))
|
|
39
|
+
Compass.configuration.parse(projectize('config.rb'))
|
|
40
|
+
elsif File.exists?(projectize('src/config.rb'))
|
|
41
|
+
Compass.configuration.parse(projectize('src/config.rb'))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def assert_project_directory_exists!
|
|
46
|
+
if File.exists?(project_directory) && !File.directory?(project_directory)
|
|
47
|
+
raise Compass::FilesystemConflict.new("#{project_directory} is not a directory.")
|
|
48
|
+
elsif !File.directory?(project_directory)
|
|
49
|
+
raise Compass::Error.new("#{project_directory} does not exist.")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def determine_project_name(working_path, options)
|
|
56
|
+
if options[:project_name]
|
|
57
|
+
File.basename(strip_trailing_separator(options[:project_name]))
|
|
58
|
+
else
|
|
59
|
+
File.basename(working_path)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def determine_project_directory(working_path, options)
|
|
64
|
+
if options[:project_name]
|
|
65
|
+
if absolute_path?(options[:project_name])
|
|
66
|
+
options[:project_name]
|
|
67
|
+
else
|
|
68
|
+
File.join(working_path, options[:project_name])
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
working_path
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def absolute_path?(path)
|
|
76
|
+
# This is only going to work on unix, gonna need a better implementation.
|
|
77
|
+
path.index(File::SEPARATOR) == 0
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'project_base')
|
|
2
|
+
require File.join(Compass.lib_directory, 'compass', 'compiler')
|
|
3
|
+
|
|
4
|
+
module Compass
|
|
5
|
+
module Commands
|
|
6
|
+
class UpdateProject < ProjectBase
|
|
7
|
+
|
|
8
|
+
def initialize(working_path, options)
|
|
9
|
+
super
|
|
10
|
+
assert_project_directory_exists!
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def perform
|
|
14
|
+
read_project_configuration
|
|
15
|
+
Compass.configuration.set_maybe(options)
|
|
16
|
+
Compass.configuration.set_defaults!
|
|
17
|
+
Compass::Compiler.new(working_path,
|
|
18
|
+
projectize(Compass.configuration.sass_dir),
|
|
19
|
+
projectize(Compass.configuration.css_dir),
|
|
20
|
+
Compass.sass_engine_options).run
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'sass'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require File.join(File.dirname(__FILE__), 'base')
|
|
6
|
+
require File.join(File.dirname(__FILE__), 'update_project')
|
|
7
|
+
|
|
8
|
+
module Compass
|
|
9
|
+
module Commands
|
|
10
|
+
class WatchProject < UpdateProject
|
|
11
|
+
|
|
12
|
+
attr_accessor :last_update_time
|
|
13
|
+
|
|
14
|
+
def perform
|
|
15
|
+
puts ">>> Compiling all stylesheets."
|
|
16
|
+
super
|
|
17
|
+
self.last_update_time = most_recent_update_time
|
|
18
|
+
puts ">>> Compass is now watching for changes. Press Ctrl-C to Stop."
|
|
19
|
+
loop do
|
|
20
|
+
# TODO: Make this efficient by using filesystem monitoring.
|
|
21
|
+
begin
|
|
22
|
+
sleep 1
|
|
23
|
+
rescue Interrupt
|
|
24
|
+
puts ""
|
|
25
|
+
exit 0
|
|
26
|
+
end
|
|
27
|
+
file, t = should_update?
|
|
28
|
+
if t
|
|
29
|
+
begin
|
|
30
|
+
puts ">>> Change detected to: #{file}"
|
|
31
|
+
super
|
|
32
|
+
rescue StandardError => e
|
|
33
|
+
::Compass::Exec.report_error(e, options)
|
|
34
|
+
end
|
|
35
|
+
self.last_update_time = t
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def most_recent_update_time
|
|
41
|
+
Dir.glob(separate("#{projectize(Compass.configuration.sass_dir)}/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def should_update?
|
|
45
|
+
t = most_recent_update_time
|
|
46
|
+
if t > last_update_time
|
|
47
|
+
file = Dir.glob(separate("#{projectize(Compass.configuration.sass_dir)}/**/*.sass")).detect {|sass_file| File.stat(sass_file).mtime >= t}
|
|
48
|
+
[file, t]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'project_base')
|
|
2
|
+
|
|
3
|
+
module Compass
|
|
4
|
+
module Commands
|
|
5
|
+
class WriteConfiguration < ProjectBase
|
|
6
|
+
|
|
7
|
+
def initialize(working_path, options)
|
|
8
|
+
super
|
|
9
|
+
assert_project_directory_exists!
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def perform
|
|
13
|
+
read_project_configuration
|
|
14
|
+
Compass.configuration.set_maybe(options)
|
|
15
|
+
Compass.configuration.set_defaults!
|
|
16
|
+
config_file = projectize("config.rb")
|
|
17
|
+
if File.exists?(config_file)
|
|
18
|
+
if options[:force]
|
|
19
|
+
logger.record(:overwrite, config_file)
|
|
20
|
+
else
|
|
21
|
+
message = "#{config_file} already exists. Run with --force to overwrite."
|
|
22
|
+
raise Compass::FilesystemConflict.new(message)
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
logger.record(:create, basename(config_file))
|
|
26
|
+
end
|
|
27
|
+
project_path, Compass.configuration.project_path = Compass.configuration.project_path, nil
|
|
28
|
+
open(config_file,'w') do |config|
|
|
29
|
+
config.puts Compass.configuration.serialize
|
|
30
|
+
end
|
|
31
|
+
Compass.configuration.project_path = project_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|