chriseppstein-compass 0.3.9 → 0.4.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.
- data/Manifest +13 -2
- data/VERSION +1 -1
- data/compass.gemspec +4 -4
- data/frameworks/blueprint/templates/project/manifest.rb +5 -0
- data/frameworks/compass/templates/project/ie.sass +5 -2
- data/frameworks/compass/templates/project/manifest.rb +3 -0
- data/frameworks/compass/templates/project/print.sass +4 -2
- data/frameworks/compass/templates/project/screen.sass +5 -2
- data/frameworks/yui/templates/project/manifest.rb +1 -0
- data/lib/compass/actions.rb +92 -0
- data/lib/compass/commands/base.rb +9 -85
- data/lib/compass/commands/create_project.rb +23 -26
- data/lib/compass/commands/list_frameworks.rb +1 -1
- data/lib/compass/commands/print_version.rb +1 -1
- data/lib/compass/commands/project_base.rb +28 -43
- data/lib/compass/commands/update_project.rb +24 -37
- data/lib/compass/commands/watch_project.rb +4 -0
- data/lib/compass/compiler.rb +40 -0
- data/lib/compass/configuration.rb +52 -0
- data/lib/compass/core_ext.rb +1 -28
- data/lib/compass/errors.rb +7 -0
- data/lib/compass/exec.rb +8 -9
- data/lib/compass/installers/base.rb +135 -0
- data/lib/compass/installers/manifest.rb +57 -0
- data/lib/compass/installers/rails.rb +117 -0
- data/lib/compass/installers/stand_alone.rb +76 -0
- data/lib/compass/installers.rb +5 -0
- data/lib/compass/logger.rb +34 -0
- data/lib/compass/version.rb +35 -17
- data/lib/compass.rb +4 -1
- data/test/command_line_test.rb +10 -7
- metadata +25 -5
- data/frameworks/compass/templates/project/grid.png +0 -0
- data/lib/compass/commands/install_rails.rb +0 -97
@@ -0,0 +1,5 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'installers', 'manifest')
|
2
|
+
require File.join(File.dirname(__FILE__), 'installers', 'base')
|
3
|
+
require File.join(File.dirname(__FILE__), 'installers', 'stand_alone')
|
4
|
+
require File.join(File.dirname(__FILE__), 'installers', 'rails')
|
5
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Compass
|
2
|
+
class Logger
|
3
|
+
|
4
|
+
DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile]
|
5
|
+
|
6
|
+
attr_accessor :actions, :options
|
7
|
+
|
8
|
+
def initialize(*actions)
|
9
|
+
self.options = actions.last.is_a?(Hash) ? actions.pop : {}
|
10
|
+
@actions = DEFAULT_ACTIONS.dup
|
11
|
+
@actions += actions
|
12
|
+
end
|
13
|
+
|
14
|
+
# Record an action that has occurred
|
15
|
+
def record(action, *arguments)
|
16
|
+
log "#{action_padding(action)}#{action} #{arguments.join(' ')}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Emit a log message
|
20
|
+
def log(msg)
|
21
|
+
puts msg
|
22
|
+
end
|
23
|
+
|
24
|
+
# add padding to the left of an action that was performed.
|
25
|
+
def action_padding(action)
|
26
|
+
' ' * [(max_action_length - action.to_s.length), 0].max
|
27
|
+
end
|
28
|
+
|
29
|
+
# the maximum length of all the actions known to the logger.
|
30
|
+
def max_action_length
|
31
|
+
@max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/compass/version.rb
CHANGED
@@ -11,38 +11,56 @@ module Compass
|
|
11
11
|
def version
|
12
12
|
return @version if defined?(@version)
|
13
13
|
|
14
|
+
read_version_file
|
15
|
+
parse_version
|
16
|
+
|
17
|
+
if r = revision
|
18
|
+
@version[:rev] = r
|
19
|
+
@version[:string] << " [#{r[0...7]}]"
|
20
|
+
end
|
21
|
+
|
22
|
+
@version
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def scope(file) # :nodoc:
|
28
|
+
File.join(File.dirname(__FILE__), '..', '..', file)
|
29
|
+
end
|
30
|
+
|
31
|
+
def read_version_file
|
14
32
|
@version = {
|
15
33
|
:string => File.read(scope('VERSION')).strip
|
16
34
|
}
|
17
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_version
|
38
|
+
dotted_string, @version[:label] = @version[:string].split(/-/, 2)
|
18
39
|
numbers = dotted_string.split('.').map { |n| n.to_i }
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
40
|
+
[:major, :minor, :teeny].zip(numbers).each do |attr, value|
|
41
|
+
@version[attr] = value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def revision
|
46
|
+
revision_from_git || revision_from_file
|
47
|
+
end
|
23
48
|
|
49
|
+
def revision_from_file
|
24
50
|
if File.exists?(scope('REVISION'))
|
25
51
|
rev = File.read(scope('REVISION')).strip
|
26
52
|
rev = nil if rev !~ /[a-f0-9]+/
|
27
53
|
end
|
54
|
+
end
|
28
55
|
|
29
|
-
|
56
|
+
def revision_from_git
|
57
|
+
if File.exists?(scope('.git/HEAD'))
|
30
58
|
rev = File.read(scope('.git/HEAD')).strip
|
31
59
|
if rev =~ /^ref: (.*)$/
|
32
60
|
rev = File.read(scope(".git/#{$1}")).strip
|
33
61
|
end
|
34
62
|
end
|
35
|
-
|
36
|
-
if rev
|
37
|
-
@version[:rev] = rev
|
38
|
-
@version[:string] << " [#{rev[0...7]}]"
|
39
|
-
end
|
40
|
-
|
41
|
-
@version
|
42
|
-
end
|
43
|
-
|
44
|
-
def scope(file) # :nodoc:
|
45
|
-
File.join(File.dirname(__FILE__), '..', '..', file)
|
46
63
|
end
|
64
|
+
|
47
65
|
end
|
48
66
|
end
|
data/lib/compass.rb
CHANGED
@@ -25,7 +25,10 @@ module Compass
|
|
25
25
|
def base_directory
|
26
26
|
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
27
27
|
end
|
28
|
-
|
28
|
+
def lib_directory
|
29
|
+
File.expand_path(File.join(File.dirname(__FILE__)))
|
30
|
+
end
|
31
|
+
module_function :base_directory, :lib_directory
|
29
32
|
end
|
30
33
|
|
31
34
|
require File.join(File.dirname(__FILE__), 'compass', 'frameworks')
|
data/test/command_line_test.rb
CHANGED
@@ -6,6 +6,11 @@ require 'timeout'
|
|
6
6
|
|
7
7
|
class CommandLineTest < Test::Unit::TestCase
|
8
8
|
include Compass::TestCaseHelper
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
Compass.configuration.reset!
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_basic_install
|
10
15
|
within_tmp_directory do
|
11
16
|
compass "basic"
|
@@ -38,7 +43,7 @@ class CommandLineTest < Test::Unit::TestCase
|
|
38
43
|
Dir.chdir "basic" do
|
39
44
|
compass
|
40
45
|
assert_action_performed :compile, "src/screen.sass"
|
41
|
-
assert_action_performed :
|
46
|
+
assert_action_performed :identical, "stylesheets/screen.css"
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
@@ -47,15 +52,13 @@ class CommandLineTest < Test::Unit::TestCase
|
|
47
52
|
within_tmp_directory do
|
48
53
|
generate_rails_app("compass_rails")
|
49
54
|
Dir.chdir "compass_rails" do
|
50
|
-
compass
|
55
|
+
compass("--rails", ".") do |responder|
|
51
56
|
responder.respond_to "Is this OK? (Y/n) ", :with => "Y"
|
52
|
-
responder.respond_to "Emit compiled stylesheets to public/stylesheets/compiled
|
57
|
+
responder.respond_to "Emit compiled stylesheets to public/stylesheets/compiled/? (Y/n) ", :with => "Y"
|
53
58
|
end
|
54
59
|
# puts @last_result
|
55
|
-
assert_action_performed :create, "app/stylesheets/screen.sass"
|
56
|
-
assert_action_performed :create, "config/initializers/compass.rb"
|
57
|
-
assert_action_performed :create, "app/views/layouts/application.html.haml"
|
58
|
-
assert_action_performed :create, "config/initializers/compass.rb"
|
60
|
+
assert_action_performed :create, "./app/stylesheets/screen.sass"
|
61
|
+
assert_action_performed :create, "./config/initializers/compass.rb"
|
59
62
|
end
|
60
63
|
end
|
61
64
|
rescue LoadError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chriseppstein-compass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Eppstein
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-08 00:00:00 -08:00
|
13
13
|
default_executable: compass
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,17 +38,26 @@ extensions: []
|
|
38
38
|
|
39
39
|
extra_rdoc_files:
|
40
40
|
- bin/compass
|
41
|
+
- lib/compass/actions.rb
|
41
42
|
- lib/compass/commands/base.rb
|
42
43
|
- lib/compass/commands/create_project.rb
|
43
|
-
- lib/compass/commands/install_rails.rb
|
44
44
|
- lib/compass/commands/list_frameworks.rb
|
45
45
|
- lib/compass/commands/print_version.rb
|
46
46
|
- lib/compass/commands/project_base.rb
|
47
47
|
- lib/compass/commands/update_project.rb
|
48
48
|
- lib/compass/commands/watch_project.rb
|
49
|
+
- lib/compass/compiler.rb
|
50
|
+
- lib/compass/configuration.rb
|
49
51
|
- lib/compass/core_ext.rb
|
52
|
+
- lib/compass/errors.rb
|
50
53
|
- lib/compass/exec.rb
|
51
54
|
- lib/compass/frameworks.rb
|
55
|
+
- lib/compass/installers/base.rb
|
56
|
+
- lib/compass/installers/manifest.rb
|
57
|
+
- lib/compass/installers/rails.rb
|
58
|
+
- lib/compass/installers/stand_alone.rb
|
59
|
+
- lib/compass/installers.rb
|
60
|
+
- lib/compass/logger.rb
|
52
61
|
- lib/compass/merb.rb
|
53
62
|
- lib/compass/test_case.rb
|
54
63
|
- lib/compass/validate/COPYRIGHT.html
|
@@ -137,6 +146,7 @@ files:
|
|
137
146
|
- frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass
|
138
147
|
- frameworks/blueprint/templates/project/grid.png
|
139
148
|
- frameworks/blueprint/templates/project/ie.sass
|
149
|
+
- frameworks/blueprint/templates/project/manifest.rb
|
140
150
|
- frameworks/blueprint/templates/project/print.sass
|
141
151
|
- frameworks/blueprint/templates/project/screen.sass
|
142
152
|
- frameworks/blueprint.rb
|
@@ -165,8 +175,8 @@ files:
|
|
165
175
|
- frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass
|
166
176
|
- frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass
|
167
177
|
- frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass
|
168
|
-
- frameworks/compass/templates/project/grid.png
|
169
178
|
- frameworks/compass/templates/project/ie.sass
|
179
|
+
- frameworks/compass/templates/project/manifest.rb
|
170
180
|
- frameworks/compass/templates/project/print.sass
|
171
181
|
- frameworks/compass/templates/project/screen.sass
|
172
182
|
- frameworks/compass.rb
|
@@ -175,19 +185,29 @@ files:
|
|
175
185
|
- frameworks/yui/stylesheets/yui/modules/_base.sass
|
176
186
|
- frameworks/yui/stylesheets/yui/modules/_fonts.sass
|
177
187
|
- frameworks/yui/stylesheets/yui/modules/_grids.sass
|
188
|
+
- frameworks/yui/templates/project/manifest.rb
|
178
189
|
- frameworks/yui/templates/project/screen.sass
|
179
190
|
- frameworks/yui.rb
|
191
|
+
- lib/compass/actions.rb
|
180
192
|
- lib/compass/commands/base.rb
|
181
193
|
- lib/compass/commands/create_project.rb
|
182
|
-
- lib/compass/commands/install_rails.rb
|
183
194
|
- lib/compass/commands/list_frameworks.rb
|
184
195
|
- lib/compass/commands/print_version.rb
|
185
196
|
- lib/compass/commands/project_base.rb
|
186
197
|
- lib/compass/commands/update_project.rb
|
187
198
|
- lib/compass/commands/watch_project.rb
|
199
|
+
- lib/compass/compiler.rb
|
200
|
+
- lib/compass/configuration.rb
|
188
201
|
- lib/compass/core_ext.rb
|
202
|
+
- lib/compass/errors.rb
|
189
203
|
- lib/compass/exec.rb
|
190
204
|
- lib/compass/frameworks.rb
|
205
|
+
- lib/compass/installers/base.rb
|
206
|
+
- lib/compass/installers/manifest.rb
|
207
|
+
- lib/compass/installers/rails.rb
|
208
|
+
- lib/compass/installers/stand_alone.rb
|
209
|
+
- lib/compass/installers.rb
|
210
|
+
- lib/compass/logger.rb
|
191
211
|
- lib/compass/merb.rb
|
192
212
|
- lib/compass/test_case.rb
|
193
213
|
- lib/compass/validate/COPYRIGHT.html
|
Binary file
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'base')
|
2
|
-
require File.join(File.dirname(__FILE__), 'create_project')
|
3
|
-
|
4
|
-
module Compass
|
5
|
-
module Commands
|
6
|
-
class InstallRails < CreateProject
|
7
|
-
def initialize(*args)
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
|
-
def perform
|
12
|
-
set_install_location
|
13
|
-
set_output_location
|
14
|
-
directory options[:stylesheets_location]
|
15
|
-
framework_templates.each do |t|
|
16
|
-
template "project/#{t}", "#{options[:stylesheets_location]}/#{t}", options
|
17
|
-
end
|
18
|
-
write_file 'config/initializers/compass.rb', initializer_contents
|
19
|
-
if has_application_layout?
|
20
|
-
next_steps
|
21
|
-
else
|
22
|
-
write_file 'app/views/layouts/application.html.haml', application_layout_contents
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def initializer_contents
|
27
|
-
%Q{require 'compass'
|
28
|
-
# If you have any compass plugins, require them here.
|
29
|
-
Sass::Plugin.options[:template_location] = {
|
30
|
-
"\#{RAILS_ROOT}#{File::SEPARATOR}#{options[:stylesheets_location]}" => "\#{RAILS_ROOT}#{File::SEPARATOR}#{options[:css_location]}"
|
31
|
-
}
|
32
|
-
Compass::Frameworks::ALL.each do |framework|
|
33
|
-
Sass::Plugin.options[:template_location][framework.stylesheets_directory] = "\#{RAILS_ROOT}#{File::SEPARATOR}#{options[:css_location]}"
|
34
|
-
end
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def application_layout_contents
|
39
|
-
%Q{!!! XML
|
40
|
-
!!!
|
41
|
-
%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
|
42
|
-
%head
|
43
|
-
%meta{'http-equiv' => "content-type", :content => "text/html;charset=UTF-8"}
|
44
|
-
%title= @browser_title || 'Default Browser Title'
|
45
|
-
= stylesheet_link_tag '#{stylesheet_prefix}screen.css', :media => 'screen, projection'
|
46
|
-
= stylesheet_link_tag '#{stylesheet_prefix}print.css', :media => 'print'
|
47
|
-
/[if IE]
|
48
|
-
= stylesheet_link_tag '#{stylesheet_prefix}ie.css', :media => 'screen, projection'
|
49
|
-
%body
|
50
|
-
%h1 Welcome to Compass
|
51
|
-
= yield
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def next_steps
|
56
|
-
puts <<NEXTSTEPS
|
57
|
-
|
58
|
-
Congratulations! Your project has been configured to use Compass.
|
59
|
-
Next add these lines to the head of your application.html.haml:
|
60
|
-
|
61
|
-
%head
|
62
|
-
= stylesheet_link_tag '#{stylesheet_prefix}screen.css', :media => 'screen, projection'
|
63
|
-
= stylesheet_link_tag '#{stylesheet_prefix}print.css', :media => 'print'
|
64
|
-
/[if IE]
|
65
|
-
= stylesheet_link_tag '#{stylesheet_prefix}ie.css', :media => 'screen, projection'
|
66
|
-
|
67
|
-
(you are using haml, aren't you?)
|
68
|
-
NEXTSTEPS
|
69
|
-
end
|
70
|
-
|
71
|
-
def has_application_layout?
|
72
|
-
File.exists?(projectize('app/views/layouts/application.rhtml')) ||
|
73
|
-
File.exists?(projectize('app/views/layouts/application.html.erb')) ||
|
74
|
-
File.exists?(projectize('app/views/layouts/application.html.haml'))
|
75
|
-
end
|
76
|
-
|
77
|
-
def stylesheet_prefix
|
78
|
-
if options[:css_location].length >= 19
|
79
|
-
"#{options[:css_location][19..-1]}/"
|
80
|
-
else
|
81
|
-
nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def set_install_location
|
86
|
-
print "Compass recommends that you keep your stylesheets in app/stylesheets/ instead of the Sass default location of public/stylesheets/sass/.\nIs this OK? (Y/n) "
|
87
|
-
answer = gets
|
88
|
-
self.options[:stylesheets_location] = separate(answer.downcase[0] == ?n ? 'public/stylesheets/sass' : 'app/stylesheets')
|
89
|
-
end
|
90
|
-
def set_output_location
|
91
|
-
print "\nCompass recommends that you keep your compiled css in public/stylesheets/compiled/ instead the Sass default of public/stylesheets/.\nHowever, if you're exclusively using Sass, then public/stylesheets/ is recommended.\nEmit compiled stylesheets to public/stylesheets/compiled? (Y/n) "
|
92
|
-
answer = gets
|
93
|
-
self.options[:css_location] = separate(answer.downcase[0] == ?n ? 'public/stylesheets' : 'public/stylesheets/compiled')
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|