compass-edge 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/VERSION.yml +1 -1
  2. data/features/command_line.feature +18 -11
  3. data/features/extensions.feature +20 -0
  4. data/features/step_definitions/command_line_steps.rb +26 -2
  5. data/features/step_definitions/extension_steps.rb +13 -0
  6. data/lib/compass/app_integration.rb +21 -0
  7. data/lib/compass/app_integration/rails.rb +18 -0
  8. data/lib/compass/app_integration/rails/configuration_defaults.rb +8 -0
  9. data/lib/compass/app_integration/rails/installer.rb +3 -5
  10. data/lib/compass/app_integration/stand_alone.rb +20 -1
  11. data/lib/compass/app_integration/stand_alone/configuration_defaults.rb +5 -1
  12. data/lib/compass/app_integration/stand_alone/installer.rb +0 -4
  13. data/lib/compass/commands.rb +1 -1
  14. data/lib/compass/commands/create_project.rb +2 -0
  15. data/lib/compass/commands/generate_grid_background.rb +1 -1
  16. data/lib/compass/commands/help.rb +20 -8
  17. data/lib/compass/commands/installer_command.rb +14 -14
  18. data/lib/compass/commands/interactive.rb +61 -0
  19. data/lib/compass/commands/project_base.rb +2 -2
  20. data/lib/compass/commands/project_stats.rb +2 -0
  21. data/lib/compass/commands/update_project.rb +2 -0
  22. data/lib/compass/commands/write_configuration.rb +9 -1
  23. data/lib/compass/configuration/data.rb +5 -2
  24. data/lib/compass/configuration/defaults.rb +2 -1
  25. data/lib/compass/configuration/helpers.rb +38 -10
  26. data/lib/compass/configuration/serialization.rb +2 -2
  27. data/lib/compass/exec/project_options_parser.rb +4 -0
  28. data/lib/compass/frameworks.rb +5 -1
  29. data/lib/compass/frameworks/blueprint/templates/project/welcome.html.haml +6 -1
  30. data/lib/compass/installers/bare_installer.rb +0 -4
  31. data/lib/compass/installers/base.rb +1 -0
  32. metadata +5 -18
  33. data/examples/ninesixty/extensions/ninesixty/README.mkdn +0 -56
  34. data/examples/ninesixty/extensions/ninesixty/compass-960-plugin.gemspec +0 -36
  35. data/examples/ninesixty/extensions/ninesixty/lib/ninesixty.rb +0 -1
  36. data/examples/ninesixty/extensions/ninesixty/lib/ninesixty/compass_plugin.rb +0 -5
  37. data/examples/ninesixty/extensions/ninesixty/sass/960/_grid.sass +0 -64
  38. data/examples/ninesixty/extensions/ninesixty/sass/960/_text.sass +0 -59
  39. data/examples/ninesixty/extensions/ninesixty/templates/project/grid.sass +0 -34
  40. data/examples/ninesixty/extensions/ninesixty/templates/project/manifest.rb +0 -2
  41. data/examples/ninesixty/extensions/ninesixty/templates/project/text.sass +0 -10
  42. data/examples/yui/extensions/yui/stylesheets/_yui.sass +0 -7
  43. data/examples/yui/extensions/yui/stylesheets/yui/modules/_base.sass +0 -70
  44. data/examples/yui/extensions/yui/stylesheets/yui/modules/_fonts.sass +0 -45
  45. data/examples/yui/extensions/yui/stylesheets/yui/modules/_grids.sass +0 -385
  46. data/examples/yui/extensions/yui/stylesheets/yui/modules/_reset.sass +0 -61
  47. data/examples/yui/extensions/yui/templates/project/manifest.rb +0 -1
  48. data/examples/yui/extensions/yui/templates/project/screen.sass +0 -4
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 9
4
- :patch: 3
4
+ :patch: 4
5
5
  :build:
@@ -77,9 +77,8 @@ Feature: Command Line
77
77
  Scenario: Initializing a rails project
78
78
  Given I'm in a newly created rails project: my_rails_project
79
79
  When I initialize a project using: compass init rails --sass-dir app/stylesheets --css-dir public/stylesheets/compiled
80
- Then a config file config/compass.config is reported created
81
- Then a config file config/compass.config is created
82
- And a ruby file config/compass.config is created
80
+ Then a config file config/compass.rb is reported created
81
+ Then a config file config/compass.rb is created
83
82
  And a sass file config/initializers/compass.rb is created
84
83
  And a sass file app/stylesheets/screen.sass is created
85
84
  And a sass file app/stylesheets/print.sass is created
@@ -130,16 +129,23 @@ Feature: Command Line
130
129
  And an image file images/buttons/tick.png is created
131
130
  And a css file tmp/buttons.css is created
132
131
 
132
+ @now
133
133
  Scenario: Basic help
134
134
  When I run: compass help
135
- Then I should be shown a list of available commands
136
- And the list of commands should describe the compile command
137
- And the list of commands should describe the create command
138
- And the list of commands should describe the grid-img command
139
- And the list of commands should describe the help command
140
- And the list of commands should describe the init command
141
- And the list of commands should describe the install command
142
- And the list of commands should describe the version command
135
+ Then I should see the following "primary" commands:
136
+ | compile |
137
+ | create |
138
+ | init |
139
+ | watch |
140
+ And I should see the following "other" commands:
141
+ | config |
142
+ | grid-img |
143
+ | help |
144
+ | install |
145
+ | interactive |
146
+ | stats |
147
+ | validate |
148
+ | version |
143
149
 
144
150
  Scenario: Recompiling a project with no material changes
145
151
  Given I am using the existing project in test/fixtures/stylesheets/compass
@@ -193,6 +199,7 @@ Feature: Command Line
193
199
  And a png file assets/wide_grid.png is not created
194
200
 
195
201
  Scenario: Generate a compass configuration file
202
+ Given I should clean up the directory: config
196
203
  When I run: compass config config/compass.rb --sass-dir sass --css-dir assets/css
197
204
  Then a configuration file config/compass.rb is created
198
205
  And the following configuration properties are set in config/compass.rb:
@@ -0,0 +1,20 @@
1
+ Feature: Extensions
2
+ In order to have an open source ecosystem for stylesheets
3
+ As a compass user
4
+ I can install extensions that others have created
5
+ And I can create and publish my own extensions
6
+
7
+ Scenario: Extensions directory for stand_alone projects
8
+ Given I am using the existing project in test/fixtures/stylesheets/compass
9
+ And the "extensions" directory exists
10
+ And and I have a fake extension at extensions/testing
11
+ When I run: compass --list-frameworks
12
+ Then the list of frameworks includes "testing"
13
+
14
+ Scenario: Extensions directory for rails projects
15
+ Given I'm in a newly created rails project: my_rails_project
16
+ And the "my_rails_project/vendor/plugins/compass/extensions" directory exists
17
+ And and I have a fake extension at my_rails_project/vendor/plugins/compass/extensions/testing
18
+ When I run: compass --list-frameworks
19
+ Then the list of frameworks includes "testing"
20
+
@@ -44,6 +44,10 @@ Given /^I'm in a newly created rails project: (.+)$/ do |project_name|
44
44
  end
45
45
  end
46
46
 
47
+ Given /^I should clean up the directory: (\w+)$/ do |directory|
48
+ @cleanup_directories << directory
49
+ end
50
+
47
51
  # When Actions are performed
48
52
  When /^I create a project using: compass create ([^\s]+) ?(.+)?$/ do |dir, args|
49
53
  @cleanup_directories << dir
@@ -160,8 +164,21 @@ Then /^I am told how to compile my sass stylesheets$/ do
160
164
  @last_result.should =~ /You must compile your sass stylesheets into CSS when they change.\nThis can be done in one of the following ways:/
161
165
  end
162
166
 
163
- Then /^I should be shown a list of available commands$/ do
164
- @last_result.should =~ /^Available commands:$/
167
+ Then /^I should be shown a list of "([^"]+)" commands$/ do |kind|
168
+ @last_result.should =~ /^#{kind.capitalize} Commands:$/
169
+ @last_command_list = []
170
+ found = false
171
+ indent = nil
172
+ @last_result.split("\n").each do |line|
173
+ if line =~ /^#{kind.capitalize} Commands:$/
174
+ found = true
175
+ elsif found && line =~ /^\s+/
176
+ @last_command_list << line
177
+ elsif found && line =~ /^$|^\w/
178
+ break
179
+ end
180
+ end
181
+
165
182
  end
166
183
 
167
184
  Then /^the list of commands should describe the ([^ ]+) command$/ do |command|
@@ -196,4 +213,11 @@ Then /^I am told statistics for each file:$/ do |table|
196
213
  end
197
214
  end
198
215
 
216
+ Then /^I should see the following "([^"]+)" commands:$/ do |kind, table|
217
+
199
218
 
219
+ Then %Q{I should be shown a list of "#{kind}" commands}
220
+
221
+ commands = @last_command_list.map{|c| c =~ /^\s+\* ([^ ]+)\s+- [A-Z].+$/; [$1]}
222
+ table.diff!(commands)
223
+ end
@@ -0,0 +1,13 @@
1
+ Given /^the "([^\"]*)" directory exists$/ do |directory|
2
+ FileUtils.mkdir_p directory
3
+ end
4
+
5
+ Given /^and I have a fake extension at (.*)$/ do |directory|
6
+ FileUtils.mkdir_p File.join(directory, 'stylesheets')
7
+ FileUtils.mkdir_p File.join(directory, 'templates/project')
8
+ end
9
+
10
+ Then /^the list of frameworks includes "([^\"]*)"$/ do |framework|
11
+ @last_result.split("\n").map{|f| f.strip}.should include(framework)
12
+ end
13
+
@@ -1,3 +1,24 @@
1
1
  %w(stand_alone rails merb).each do |lib|
2
2
  require "compass/app_integration/#{lib}"
3
3
  end
4
+
5
+ module Compass
6
+ module AppIntegration
7
+ module Helpers
8
+ def lookup(project_type)
9
+ eval "Compass::AppIntegration::#{camelize(project_type)}"
10
+ rescue NameError
11
+ raise Compass::Error, "No application integration exists for #{project_type}"
12
+ end
13
+
14
+ protected
15
+
16
+ # Stolen from ActiveSupport
17
+ def camelize(s)
18
+ s.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
19
+ end
20
+
21
+ end
22
+ extend Helpers
23
+ end
24
+ end
@@ -5,4 +5,22 @@ end
5
5
  require 'compass/app_integration/rails/runtime' if defined?(ActionController::Base)
6
6
 
7
7
 
8
+ module Compass
9
+ module AppIntegration
10
+ module Rails
11
+
12
+ extend self
13
+
14
+ def installer(*args)
15
+ Installer.new(*args)
16
+ end
17
+
18
+ def configuration
19
+ Compass::Configuration::Data.new('rails').
20
+ extend(ConfigurationDefaults)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
8
26
 
@@ -3,6 +3,10 @@ module Compass
3
3
  module Rails
4
4
  module ConfigurationDefaults
5
5
 
6
+ def default_project_type
7
+ :rails
8
+ end
9
+
6
10
  def default_images_dir
7
11
  File.join("public", "images")
8
12
  end
@@ -23,6 +27,10 @@ module Compass
23
27
  "/stylesheets"
24
28
  end
25
29
 
30
+ def default_extensions_dir
31
+ "vendor/plugins/compass/extensions"
32
+ end
33
+
26
34
  end
27
35
  end
28
36
  end
@@ -10,10 +10,6 @@ module Compass
10
10
  module Rails
11
11
  class Installer < Compass::Installers::ManifestInstaller
12
12
 
13
- def default_configuration
14
- Compass::Configuration::Data.new.extend(ConfigurationDefaults)
15
- end
16
-
17
13
  def completed_configuration
18
14
  config = {}
19
15
  config[:sass_dir] = prompt_sass_dir unless sass_dir_without_default
@@ -22,8 +18,10 @@ module Compass
22
18
  end
23
19
 
24
20
  def write_configuration_files(config_file = nil)
25
- config_file ||= targetize('config/compass.config')
21
+ config_file ||= targetize('config/compass.rb')
22
+ directory File.dirname(config_file)
26
23
  write_file config_file, config_contents
24
+ directory File.dirname(targetize('config/initializers/compass.rb'))
27
25
  write_file targetize('config/initializers/compass.rb'), initializer_contents
28
26
  end
29
27
 
@@ -1,3 +1,22 @@
1
1
  %w(configuration_defaults installer).each do |lib|
2
2
  require "compass/app_integration/stand_alone/#{lib}"
3
- end
3
+ end
4
+
5
+ module Compass
6
+ module AppIntegration
7
+ module StandAlone
8
+
9
+ extend self
10
+
11
+ def installer(*args)
12
+ Installer.new(*args)
13
+ end
14
+
15
+ def configuration
16
+ Compass::Configuration::Data.new('stand_alone').
17
+ extend(ConfigurationDefaults)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,10 @@ module Compass
2
2
  module AppIntegration
3
3
  module StandAlone
4
4
  module ConfigurationDefaults
5
+ def default_project_type
6
+ :stand_alone
7
+ end
8
+
5
9
  def sass_dir_without_default
6
10
  "src"
7
11
  end
@@ -21,4 +25,4 @@ module Compass
21
25
 
22
26
  end
23
27
  end
24
- end
28
+ end
@@ -35,10 +35,6 @@ module Compass
35
35
  write_configuration_files unless config_files_exist? || !@manifest.generate_config?
36
36
  end
37
37
 
38
- def default_configuration
39
- Compass::Configuration::Data.new.extend(Compass::AppIntegration::StandAlone::ConfigurationDefaults)
40
- end
41
-
42
38
  def completed_configuration
43
39
  nil
44
40
  end
@@ -6,6 +6,6 @@ require 'compass/commands/registry'
6
6
  %w(base generate_grid_background help list_frameworks project_base
7
7
  update_project watch_project create_project installer_command
8
8
  print_version project_stats stamp_pattern validate_project
9
- write_configuration).each do |lib|
9
+ write_configuration interactive).each do |lib|
10
10
  require "compass/commands/#{lib}"
11
11
  end
@@ -68,6 +68,8 @@ module Compass
68
68
  end
69
69
  end
70
70
 
71
+ def primary; true; end
72
+
71
73
  def parse!(arguments)
72
74
  parser = option_parser(arguments)
73
75
  parse_options!(parser, arguments)
@@ -66,7 +66,7 @@ Options:
66
66
  def initialize(working_path, options)
67
67
  super
68
68
  assert_project_directory_exists!
69
- Compass.add_configuration(options)
69
+ Compass.add_configuration(options, 'command_line')
70
70
  end
71
71
 
72
72
  def perform
@@ -11,16 +11,16 @@ Description:
11
11
 
12
12
  To get help on a particular command please specify the command.
13
13
 
14
- Available commands:
15
-
16
14
  }
17
- Compass::Commands.all.sort_by{|c| c.to_s}.each do |command|
18
- banner << " * #{command}"
19
- if Compass::Commands[command].respond_to? :description
20
- banner << "\t- #{Compass::Commands[command].description(command)}"
21
- end
22
- banner << "\n"
15
+
16
+ primary_commands = Compass::Commands.all.select do |c|
17
+ cmd = Compass::Commands[c]
18
+ cmd.respond_to?(:primary) && cmd.primary
23
19
  end
20
+ other_commands = Compass::Commands.all - primary_commands
21
+
22
+ banner << command_list("Primary Commands:", primary_commands)
23
+ banner << command_list("Other Commands:", other_commands)
24
24
 
25
25
  banner << "\nAvailable Frameworks & Patterns:\n\n"
26
26
  Compass::Frameworks::ALL.each do |framework|
@@ -38,6 +38,18 @@ Available commands:
38
38
 
39
39
  super
40
40
  end
41
+
42
+ def command_list(header, commands)
43
+ list = "#{header}\n"
44
+ commands.sort_by{|c| c.to_s}.each do |command|
45
+ list << " * #{command}"
46
+ if Compass::Commands[command].respond_to? :description
47
+ list << "\t- #{Compass::Commands[command].description(command)}"
48
+ end
49
+ list << "\n"
50
+ end
51
+ list
52
+ end
41
53
  end
42
54
  class Help < Base
43
55
  register :help
@@ -6,28 +6,28 @@ module Compass
6
6
  include Compass::Installers
7
7
 
8
8
  def configure!
9
- Compass.add_configuration(installer.default_configuration)
10
- Compass.add_project_configuration
11
- Compass.add_configuration(options)
12
- Compass.add_configuration(installer.completed_configuration)
9
+ if respond_to?(:is_project_creation?) && is_project_creation?
10
+ Compass.add_configuration(options.delete(:project_type) || :stand_alone)
11
+ else
12
+ Compass.add_project_configuration(:project_type => options.delete(:project_type))
13
+ end
14
+ Compass.add_configuration(options, 'command_line')
13
15
  if File.exists?(Compass.configuration.extensions_path)
14
16
  Compass::Frameworks.discover(Compass.configuration.extensions_path)
15
17
  end
18
+ Compass.add_configuration(installer.completed_configuration, 'installer')
19
+ end
20
+
21
+ def app
22
+ @app ||= Compass::AppIntegration.lookup(Compass.configuration.project_type)
16
23
  end
17
24
 
18
25
  def installer
19
- installer_class = if options[:bare]
20
- "Compass::Installers::BareInstaller"
26
+ @installer ||= if options[:bare]
27
+ Compass::Installers::BareInstaller.new(*installer_args)
21
28
  else
22
- project_type = options[:project_type] || Compass.configuration.project_type
23
- "Compass::AppIntegration::#{camelize(project_type)}::Installer"
29
+ app.installer(*installer_args)
24
30
  end
25
- @installer = eval("#{installer_class}.new *installer_args")
26
- end
27
-
28
- # Stolen from ActiveSupport
29
- def camelize(s)
30
- s.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
31
31
  end
32
32
 
33
33
  def installer_args
@@ -0,0 +1,61 @@
1
+
2
+ require 'compass/commands/project_base'
3
+ require 'compass/commands/update_project'
4
+
5
+ module Compass
6
+ module Commands
7
+ module InteractiveOptionsParser
8
+ def set_options(opts)
9
+ opts.banner = %Q{
10
+ Usage: compass interactive [path/to/project] [options]
11
+
12
+ Description:
13
+ Interactively evaluate SassScript
14
+
15
+ Options:
16
+ }.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n")
17
+
18
+ super
19
+ end
20
+ end
21
+ class Interactive < ProjectBase
22
+
23
+ register :interactive
24
+
25
+ def initialize(working_path, options)
26
+ super
27
+ end
28
+
29
+ def perform
30
+ require 'sass/repl'
31
+ Sass::Repl.new.run
32
+ end
33
+
34
+ class << self
35
+
36
+ def option_parser(arguments)
37
+ parser = Compass::Exec::CommandOptionParser.new(arguments)
38
+ parser.extend(Compass::Exec::GlobalOptionsParser)
39
+ parser.extend(Compass::Exec::ProjectOptionsParser)
40
+ parser.extend(InteractiveOptionsParser)
41
+ end
42
+
43
+ def usage
44
+ option_parser([]).to_s
45
+ end
46
+
47
+ def description(command)
48
+ "Interactively evaluate SassScript"
49
+ end
50
+
51
+ def parse!(arguments)
52
+ parser = option_parser(arguments)
53
+ parser.parse!
54
+ parser.options
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+ end
61
+ end