guard-compass 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 392583dbb2cb95a232f982ea4112ba107e1b964b
4
+ data.tar.gz: 89c2c4163fb44ba6ac6430f9a347456461ccf9d0
5
+ SHA512:
6
+ metadata.gz: 9732f96f9c9d65eaede347bfe373dbe971cf394d9147714ef743f7a49e569535f1f32a58a3f5db75979dfe07f2f8991fedb43387662fda6c8dce1a9b48635b53
7
+ data.tar.gz: 4522bb4b9addfa2c2622da61442431072311631ec9a97b0a0287210ba50f4aad421982b49f91d177a87d1de038b02f7a25b62da43c842281a0186da740a74ce7
@@ -0,0 +1,41 @@
1
+ ## Unreleased Changes
2
+
3
+ No changes.
4
+
5
+ ## 0.0.8 - Jul 12, 2013
6
+
7
+ ### Bug fix
8
+
9
+ * [#11][] New `:compile_on_start` option to compile stylesheets when Guard is started. ([@mhayes][])
10
+ * [#7][] Fix crash on Sass syntax failure by displaying Growl notification instead. ([@bradphelan][])
11
+ * [#4][] Changed awkward reporter.announce text . ([@adamnbowen][])
12
+ * [#3][] Added compass syntax success/error notifications. ([@stefanoverna][])
13
+ * [#2][] Fix gemspec preventing `bundle install`. ([@rymai][])
14
+ * [#1][] You can now define the options `:project_path` and `:configuration_file` to
15
+ find and run Compass Compiler (see README for more information). This was a problem with
16
+ non-standard deployment. ([@oliamb][])
17
+
18
+ ### Improvement
19
+
20
+ * Create a watch rules based on the compass config (no more need to create watchers).
21
+
22
+ ## 0.0.6 - Oct 25, 2010
23
+
24
+ * Guard quit on ctrl-c when `guard-compass` is in.
25
+
26
+ ## 0.0.5 - Oct 24, 2010
27
+
28
+ * Initial release
29
+ <!--- The following link definition list is generated by PimpMyChangelog --->
30
+ [#1]: https://github.com/guard/guard-compass/issues/1
31
+ [#2]: https://github.com/guard/guard-compass/issues/2
32
+ [#3]: https://github.com/guard/guard-compass/issues/3
33
+ [#4]: https://github.com/guard/guard-compass/issues/4
34
+ [#7]: https://github.com/guard/guard-compass/issues/7
35
+ [#11]: https://github.com/guard/guard-compass/issues/11
36
+ [@adamnbowen]: https://github.com/adamnbowen
37
+ [@bradphelan]: https://github.com/bradphelan
38
+ [@mhayes]: https://github.com/mhayes
39
+ [@oliamb]: https://github.com/oliamb
40
+ [@rymai]: https://github.com/rymai
41
+ [@stefanoverna]: https://github.com/stefanoverna
@@ -0,0 +1,86 @@
1
+ # Guard::Compass
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/guard-compass.png)](http://badge.fury.io/rb/guard-compass) [![Build Status](https://travis-ci.org/guard/guard-compass.png?branch=master)](https://travis-ci.org/guard/guard-compass) [![Dependency Status](https://gemnasium.com/guard/guard-compass.png)](https://gemnasium.com/guard/guard-compass) [![Code Climate](https://codeclimate.com/github/guard/guard-compass.png)](https://codeclimate.com/github/guard/guard-compass) [![Coverage Status](https://coveralls.io/repos/guard/guard-compass/badge.png?branch=master)](https://coveralls.io/r/guard/guard-compass)
4
+
5
+ Guard::Compass allows to automatically run [Compass](https://github.com/chriseppstein/compass)
6
+ whenever a stylesheet file is modified.
7
+
8
+ * Tested against Ruby 1.8.7, 1.9.3, 2.0.0, JRuby (1.8 mode & 1.9 mode) & Rubinius (1.8 mode & 1.9 mode).
9
+
10
+ ## Install
11
+
12
+ Please be sure to have [Guard](http://github.com/guard/guard) installed before continue.
13
+
14
+ The simplest way to install Guard::Compass is to use [Bundler](http://gembundler.com/).
15
+
16
+ Add Guard::Compass to your `Gemfile`:
17
+
18
+ ```ruby
19
+ group :development do
20
+ gem 'guard-compass'
21
+ end
22
+ ```
23
+
24
+ and install it by running Bundler:
25
+
26
+ ```bash
27
+ $ bundle
28
+ ```
29
+
30
+ Add guard definition to your Guardfile by running the following command:
31
+
32
+ ```bash
33
+ guard init compass
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Please read [Guard usage doc](http://github.com/guard/guard#readme)
39
+
40
+ ## Configure Guard::Compass plug-in
41
+
42
+ The default configuration generated by 'guard init compass' looks like this
43
+
44
+ ```ruby
45
+ guard :compass
46
+ ```
47
+
48
+ ## Options
49
+
50
+ ### List of available options
51
+
52
+ ```ruby
53
+ :project_path => '../foo/bar' # path to the compass project directory (from guard working directory)
54
+ :configuration_file => '../compass_config.rb' # path to your compass configuration file (from guard working directory)
55
+ ```
56
+
57
+ By default, the project path is equal to the guard working directory (the folder from where you start Guard).
58
+ Compass will look into some default location for the config file from there.
59
+
60
+ The configuration_file is computed by compass. You don't need to define watchers like
61
+ in other Guard plug-in because they are generated from the Compass configuration files, cool!
62
+
63
+ For the complete list of options, please refer to the Compass documentation.
64
+
65
+ ## Development
66
+
67
+ * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-compass/master/frames).
68
+ * Source hosted at [GitHub](https://github.com/guard/guard-compass).
69
+
70
+ Pull requests are very welcome! Please try to follow these simple rules if applicable:
71
+
72
+ * Please create a topic branch for every separate change you make.
73
+ * Make sure your patches are well tested. All specs run by Travis CI must pass.
74
+ * Update the [README](https://github.com/guard/guard-compass/blob/master/README.md).
75
+ * Please **do not change** the version number.
76
+
77
+ For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
78
+ `#guard` (irc.freenode.net).
79
+
80
+ ## Maintainer
81
+
82
+ [Rémy Coutable](https://github.com/rymai) ([@rymai](http://twitter.com/rymai), [rymai.me](http://rymai.me))
83
+
84
+ ## Author
85
+
86
+ [Olivier Amblet](https://github.com/oliamb)
@@ -1,56 +1,163 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
+ require 'guard/watcher'
4
+ require 'guard/reporter'
5
+ require 'guard/compass_helper'
3
6
 
4
7
  require 'compass'
5
8
  require 'compass/commands'
6
9
  require 'compass/logger'
10
+ require 'compass/compiler'
11
+
12
+ module Compass
13
+ class Compiler
14
+ alias :old_handle_exception :handle_exception
15
+ def handle_exception(sass_filename, css_filename, e)
16
+ old_handle_exception(sass_filename, css_filename, e)
17
+ # rethrow the exception, we need it to notificate the user!
18
+ raise Sass::SyntaxError, "[#{File.basename(sass_filename)}:#{e.sass_line}] #{e.message}"
19
+ end
20
+ end
21
+ end
7
22
 
8
23
  module Guard
9
24
  class Compass < Guard
10
- attr_reader :updater
11
-
12
- VERSION = '0.0.6'
13
-
25
+ attr_reader :updater, :working_path
26
+ attr_accessor :reporter
27
+
14
28
  def initialize(watchers = [], options = {})
15
29
  super
16
- @options[:workdir] = File.expand_path(File.dirname("."))
30
+ @reporter = Reporter.new
31
+ @working_path = Pathname.pwd # the Guard base path is the current working_path
32
+ end
33
+
34
+ # Load Compass Configuration
35
+ def create_watchers
36
+ # root_path is the path to the compass project
37
+ # working_path is the current Guard (and by extension Compass) working directory
38
+
39
+ watchers.clear
40
+
41
+ config_file = (options[:configuration_file] || ::Compass.detect_configuration_file(root_path))
42
+ config_path = pathname(working_path, config_file)
43
+ src_path = pathname(root_path, ::Compass.configuration.sass_dir)
44
+
45
+ watchers.push Watcher.new(%r{^#{src_path.relative_path_from(working_path)}/.*})
46
+ watchers.push Watcher.new(%r{^#{config_path.relative_path_from(working_path)}$})
47
+ end
48
+
49
+ def root_path
50
+ options[:project_path].nil? ? working_path : pathname(working_path, options[:project_path])
51
+ end
52
+
53
+ def valid_sass_path?
54
+ if ::Compass.configuration.sass_dir.nil?
55
+ reporter.failure("Sass files src directory not set.\nPlease check your Compass configuration.")
56
+ return false
57
+ end
58
+
59
+ path = pathname(root_path, ::Compass.configuration.sass_dir )
60
+
61
+ unless path.exist?
62
+ reporter.failure("Sass files src directory not found: #{path}\nPlease check your Compass configuration.")
63
+ false
64
+ else
65
+ true
66
+ end
67
+ end
68
+
69
+ def valid_configuration_path?
70
+ config_file = (options[:configuration_file] || ::Compass.detect_configuration_file(root_path))
71
+
72
+ if config_file.nil?
73
+ reporter.failure "Cannot find a Compass configuration file, please add information to your Guardfile guard 'compass' declaration."
74
+ return false
75
+ end
76
+
77
+ config_path = pathname(working_path, config_file)
78
+
79
+ if config_path.exist?
80
+ true
81
+ else
82
+ reporter.failure "Compass configuration file not found: #{config_path}\nPlease check Guard configuration."
83
+ false
84
+ end
17
85
  end
18
-
86
+
19
87
  # Guard Interface Implementation
20
-
88
+
21
89
  # Compile all the sass|scss stylesheets
22
90
  def start
23
91
  create_updater
24
- UI.info "Guard::Compass is watching at your stylesheets."
92
+ if options[:compile_on_start]
93
+ reporter.announce "Guard::Compass is going to compile your stylesheets."
94
+ perform
95
+ else
96
+ reporter.announce "Guard::Compass is waiting to compile your stylesheets."
97
+ end
25
98
  true
26
99
  end
27
-
100
+
28
101
  def stop
29
102
  @updater = nil
30
103
  true
31
104
  end
32
-
105
+
33
106
  # Reload the configuration
34
107
  def reload
35
108
  create_updater
36
109
  true
37
110
  end
38
-
111
+
39
112
  # Compile all the sass|scss stylesheets
40
113
  def run_all
41
- @updater.execute
42
- true
114
+ perform
43
115
  end
44
-
116
+
45
117
  # Compile the changed stylesheets
46
118
  def run_on_change(paths)
47
- @updater.execute
48
- true
119
+ perform
49
120
  end
50
-
121
+
51
122
  private
123
+ include CompassHelper
124
+
125
+ # Cleanup of the given options
126
+ def cleanup_options
127
+ # Ensure configuration file make reference to an absolute path.
128
+ if options[:configuration_file]
129
+ options[:configuration_file] = pathname(working_path, options[:configuration_file]).to_s
130
+ end
131
+ end
132
+
133
+ def perform
134
+ if valid_sass_path?
135
+ begin
136
+ @updater.execute
137
+ rescue Sass::SyntaxError => e
138
+ msg = "#{e.sass_backtrace_str}"
139
+ ::Guard::Notifier.notify msg, :title => "Guard Compass", :image => :failed
140
+ return false
141
+ rescue Exception => e
142
+ ::Guard::Notifier.notify e.to_s, :title => "Guard Compass", :image => :failed
143
+ return false
144
+ end
145
+ true
146
+ else
147
+ false
148
+ end
149
+ end
150
+
52
151
  def create_updater
53
- @updater = ::Compass::Commands::UpdateProject.new(@options[:workdir] , @options)
152
+ cleanup_options
153
+ if valid_configuration_path?
154
+ @updater = ::Compass::Commands::UpdateProject.new(working_path.to_s, options)
155
+ create_watchers
156
+ return valid_sass_path?
157
+ else
158
+ return false
159
+ end
54
160
  end
161
+
55
162
  end
56
- end
163
+ end
@@ -1,3 +1,15 @@
1
- guard 'compass' do
2
- watch('^src/(.*)\.s[ac]ss')
3
- end
1
+ # Guard::Compass
2
+ #
3
+ # You don't need to configure watchers for guard 'compass' declaration as they generated
4
+ # from your Compass configuration file. You might need to define the Compass working directory
5
+ # and point to the configuration file depending of your project structure.
6
+ #
7
+ # Available options:
8
+ #
9
+ # * :workging_directory => Define the Compass working directory, relative to the Guardfile directory
10
+ # * :configuration_file => Path to the Compass configuration file, relative to :project_path
11
+ #
12
+ # Like usual, the Compass configuration path are relative to the :project_path
13
+
14
+ # guard 'compass', :project_path => 'not_current_dir', :configuration_file => 'path/to/my/compass_config.rb'
15
+ guard :compass
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module CompassVersion
3
+ VERSION = '0.0.8'
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require 'compass'
2
+ require 'compass/commands'
3
+ require 'compass/commands/project_base'
4
+ require 'compass/compiler'
5
+
6
+ module Guard
7
+ module CompassHelper
8
+ # Build a path agains components that might be relative or absolute.
9
+ # Whenever an absolute component is found, it became the new
10
+ # base path on which next relative components are built.
11
+ def pathname(*components)
12
+ result = Pathname.pwd
13
+ components.each do |c|
14
+ pc = Pathname.new(c)
15
+ if(pc.relative?)
16
+ result = result + pc
17
+ else
18
+ result = pc
19
+ end
20
+ end
21
+ return result
22
+ rescue
23
+ raise "Cannot process #{components.inspect}: #{$!}"
24
+ end
25
+
26
+ # Excerpt from Compass updater commands #
27
+
28
+ def check_for_sass_files!(compiler)
29
+ if compiler.sass_files.empty?
30
+ message = "Nothing to compile. If you're trying to start a new project, you have left off the directory argument.\n"
31
+ message << "Run \"compass -h\" to get help."
32
+ raise Compass::Error, message
33
+ end
34
+ end
35
+
36
+ def new_compiler_instance(working_path)
37
+ compiler_opts = ::Compass.sass_engine_options
38
+ compiler_opts.merge!(:quiet => options[:quiet],
39
+ :force => options[:force],
40
+ :dry_run => options[:dry_run])
41
+ ::Compass::Compiler.new(working_path,
42
+ ::Compass.configuration.sass_path,
43
+ ::Compass.configuration.css_path,
44
+ compiler_opts)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ module Guard
2
+ # Send a report to the Guard UI
3
+ # The Reporter is a wrapper arround guard UI because
4
+ # it is currently subject to change.
5
+ class Reporter
6
+ def success(message)
7
+ UI.info(message)
8
+ end
9
+ def failure(message)
10
+ UI.error(message)
11
+ end
12
+ def unstable(message)
13
+ UI.info(message)
14
+ end
15
+ def announce(message)
16
+ UI.info(message)
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,153 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: guard-compass
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Olivier Amblet
8
+ - Rémy Coutable
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-26 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 21
28
- segments:
29
- - 0
30
- - 2
31
- - 1
32
- version: 0.2.1
33
- prerelease: false
34
- type: :runtime
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
35
15
  name: guard
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 61
44
- segments:
45
- - 0
46
- - 10
47
- - 5
48
- version: 0.10.5
49
- prerelease: false
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '1.8'
50
21
  type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '1.8'
28
+ - !ruby/object:Gem::Dependency
51
29
  name: compass
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 19
60
- segments:
61
- - 1
62
- - 0
63
- - 2
64
- version: 1.0.2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 0.10.5
35
+ type: :runtime
65
36
  prerelease: false
66
- type: :development
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 0.10.5
42
+ - !ruby/object:Gem::Dependency
67
43
  name: bundler
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 7712058
76
- segments:
77
- - 2
78
- - 0
79
- - 0
80
- - rc
81
- version: 2.0.0.rc
82
- prerelease: false
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
83
49
  type: :development
84
- name: rspec
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- requirement: &id005 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 19
93
- segments:
94
- - 0
95
- - 1
96
- - 4
97
- version: 0.1.4
98
50
  prerelease: false
99
- type: :development
100
- name: guard-rspec
101
- version_requirements: *id005
102
- description: Guard::Compass automatically rebuilds scss|sass files when a modification occurs taking in account your compass configuration.
103
- email:
104
- - olivier@amblet.net
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Guard::Compass automatically rebuilds scss|sass files when a modification
57
+ occurs taking in account your compass configuration.
58
+ email:
59
+ - remy@rymai.me
105
60
  executables: []
106
-
107
61
  extensions: []
108
-
109
62
  extra_rdoc_files: []
110
-
111
- files:
63
+ files:
112
64
  - lib/guard/compass/templates/Guardfile
65
+ - lib/guard/compass/version.rb
113
66
  - lib/guard/compass.rb
67
+ - lib/guard/compass_helper.rb
68
+ - lib/guard/reporter.rb
69
+ - CHANGELOG.md
114
70
  - LICENSE
115
- - README.textile
116
- has_rdoc: true
117
- homepage: http://rubygems.org/gems/guard-compass
71
+ - README.md
72
+ homepage: https://github.com/guard/guard-compass
118
73
  licenses: []
119
-
74
+ metadata: {}
120
75
  post_install_message:
121
76
  rdoc_options: []
122
-
123
- require_paths:
77
+ require_paths:
124
78
  - lib
125
- required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- hash: 3
131
- segments:
132
- - 0
133
- version: "0"
134
- required_rubygems_version: !ruby/object:Gem::Requirement
135
- none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: 23
140
- segments:
141
- - 1
142
- - 3
143
- - 6
144
- version: 1.3.6
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
145
89
  requirements: []
146
-
147
- rubyforge_project: guard-compass
148
- rubygems_version: 1.3.7
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.3
149
92
  signing_key:
150
- specification_version: 3
93
+ specification_version: 4
151
94
  summary: Guard gem for Compass
152
95
  test_files: []
153
-
@@ -1,25 +0,0 @@
1
- h1. Guard Compass Plug-in
2
-
3
- Let you configure a Guard that will run compass whenever a stylesheet is updated.
4
-
5
- h2. Quick Start
6
-
7
- bc. $ (sudo) gem install compass
8
- $ compass -f blueprint my_compass_project
9
- $ cd my_compass_project
10
- $ bundle init
11
-
12
- Then, edit the Gemfile for it to looks like:
13
-
14
- bc. source "http://rubygems.org"
15
- gem 'guard-compass'
16
-
17
- You can now download missing gems and initialize the guard
18
-
19
- bc. $ bundle install
20
- $ guard init
21
- $ guard init compass
22
- $ guard
23
-
24
- Your scss(or sass) stylesheets are now guarded.
25
-