Skip to content

Commit

Permalink
WIP - Start integrating guard-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
rymai committed Oct 13, 2015
1 parent 2d59d92 commit 6f51b94
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 54 deletions.
12 changes: 6 additions & 6 deletions Gemfile
@@ -1,18 +1,18 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

gem 'rake'
gem "rake"

group :development do
gem 'ruby_gntp'
gem 'guard-rspec'
gem "ruby_gntp"
gem "guard-rspec"
end

# The test group will be
# installed on Travis CI
#
group :test do
gem 'rspec'
gem 'coveralls', require: false
gem "rspec"
gem "coveralls", require: false
end
2 changes: 1 addition & 1 deletion Guardfile
@@ -1,4 +1,4 @@
guard :rspec do
guard :rspec, cmd: "bundle exec rspec" do
watch(%r{^spec/(.*)_spec\.rb})
watch(%r{^lib/(.*)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^spec/spec_helper\.rb}) { "spec" }
Expand Down
29 changes: 15 additions & 14 deletions guard-compass.gemspec
@@ -1,23 +1,24 @@
# encoding: utf-8
$:.push File.expand_path('../lib', __FILE__)
require 'guard/compass/version'
$:.push File.expand_path("../lib", __FILE__)
require "guard/compass/version"

Gem::Specification.new do |s|
s.name = 'guard-compass'
s.name = "guard-compass"
s.version = Guard::CompassVersion::VERSION
s.platform = Gem::Platform::RUBY
s.license = 'MIT'
s.authors = ['Olivier Amblet', 'Rémy Coutable']
s.email = ['remy@rymai.me']
s.homepage = 'https://rubygems.org/gems/guard-compass'
s.summary = 'Guard plugin for Compass'
s.description = 'Guard::Compass automatically rebuilds scss|sass files when a modification occurs taking in account your compass configuration.'
s.license = "MIT"
s.authors = ["Olivier Amblet", "Rémy Coutable"]
s.email = ["remy@rymai.me"]
s.homepage = "https://rubygems.org/gems/guard-compass"
s.summary = "Guard plugin for Compass"
s.description = "Guard::Compass automatically rebuilds scss|sass files when a modification occurs taking in account your compass configuration."

s.required_ruby_version = '>= 1.9.2'
s.required_ruby_version = ">= 1.9.2"

s.add_runtime_dependency 'guard', '~> 2.0'
s.add_runtime_dependency 'compass', '>= 0.10.5'
s.add_dependency "guard", "~> 2.1"
s.add_dependency "guard-compat", "~> 1.1"
s.add_runtime_dependency "compass", ">= 0.10.5"

s.files = Dir.glob('{lib}/**/*') + %w[CHANGELOG.md LICENSE README.md]
s.require_path = 'lib'
s.files = Dir.glob("{lib}/**/*") + %w[CHANGELOG.md LICENSE README.md]
s.require_path = "lib"
end
10 changes: 6 additions & 4 deletions lib/guard/compass.rb
@@ -1,5 +1,5 @@
require 'guard'
require 'guard/plugin'
require "guard/compat/plugin"

require 'guard/watcher'
require 'guard/reporter'
require 'guard/compass_helper'
Expand Down Expand Up @@ -36,6 +36,8 @@ def create_watchers
# root_path is the path to the compass project
# working_path is the current Guard (and by extension Compass) working directory

# FIXME: watchers doesn't exist in the tests since initialize
# is stubbed in guard/compat/test/helper...
watchers.clear

config_file = (options[:configuration_file] || ::Compass.detect_configuration_file(root_path))
Expand Down Expand Up @@ -140,10 +142,10 @@ def perform
@updater.execute
rescue Sass::SyntaxError => e
msg = "#{e.sass_backtrace_str}"
::Guard::Notifier.notify msg, title: "Guard Compass", image: :failed
Guard::Compat::UI.notify msg, title: "Guard Compass", image: :failed
return false
rescue Exception => e
::Guard::Notifier.notify e.to_s, title: "Guard Compass", image: :failed
Guard::Compat::UI.notify e.to_s, title: "Guard Compass", image: :failed
return false
end
true
Expand Down
10 changes: 5 additions & 5 deletions lib/guard/reporter.rb
Expand Up @@ -4,16 +4,16 @@ module Guard
# it is currently subject to change.
class Reporter
def success(message)
UI.info(message)
Guard::Compat::UI.info(message)
end
def failure(message)
UI.error(message)
Guard::Compat::UI.error(message)
end
def unstable(message)
UI.info(message)
Guard::Compat::UI.info(message)
end
def announce(message)
UI.info(message)
Guard::Compat::UI.info(message)
end
end
end
end
47 changes: 25 additions & 22 deletions spec/guard/compass_spec.rb
@@ -1,5 +1,8 @@
require 'fileutils'
require 'spec_helper'
require "guard/compat/test/helper"
require "guard/compass"

require "fileutils"
require "spec_helper"

describe Guard::Compass do

Expand Down Expand Up @@ -31,20 +34,20 @@
describe "start" do
it "supports creation of the updater instance" do
@guard.updater.should be_nil
@guard.start.should be_true
@guard.start.should be true
@guard.updater.should_not be_nil
end

it "should not generate anything" do
File.exists?(@project_dir + "/stylesheets/screen.css").should be_false
File.exists?(@project_dir + "/stylesheets/screen.css").should be false
end
end

describe "default options" do
it "should have a default path mathching the run location" do
@guard.root_path.should == @project_path
@guard.working_path.should == @project_path
@guard.start.should be_true
@guard.start.should be true
end
end

Expand All @@ -68,26 +71,26 @@
describe "stop" do
it "Stop remove the updater" do
@guard.updater.should_not be_nil
@guard.stop.should be_true
@guard.stop.should be true
@guard.updater.should be_nil
end
end

describe "run_on_change" do
it "rebuilds all scss files in compass path" do
File.exists?(@project_dir + "/src/screen.scss").should(be_true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be_false
@guard.run_on_change(@project_dir + "/src/screen.scss").should(be_true) rescue raise inspect_configuration
File.exists?(@project_dir + "/stylesheets/screen.css").should be_true
File.exists?(@project_dir + "/src/screen.scss").should(be true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be false
@guard.run_on_change(@project_dir + "/src/screen.scss").should(be true) rescue raise inspect_configuration
File.exists?(@project_dir + "/stylesheets/screen.css").should be true
end
end

describe "run all" do
it "rebuilds all scss files in compass path" do
File.exists?(@project_dir + "/src/screen.scss").should(be_true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be_false
@guard.run_all.should be_true
File.exists?(@project_dir + "/stylesheets/screen.css").should be_true
File.exists?(@project_dir + "/src/screen.scss").should(be true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be false
@guard.run_all.should be true
File.exists?(@project_dir + "/stylesheets/screen.css").should be true
end
end

Expand Down Expand Up @@ -132,10 +135,10 @@
it "rebuilds all scss files in compass path" do
@guard.options[:configuration_file] = "#{@project_dir}/another_config_location/config.rb"
@guard.start
File.exists?("#{@project_dir}/another_src_location/screen.scss").should(be_true)
File.exists?("#{@project_dir}/another_stylesheets_location/screen.css").should be_false
@guard.run_on_change(@project_dir + "/another_src_location/screen.scss").should be_true
File.exists?(@project_dir + "/another_stylesheets_location/screen.css").should be_true
File.exists?("#{@project_dir}/another_src_location/screen.scss").should(be true)
File.exists?("#{@project_dir}/another_stylesheets_location/screen.css").should be false
@guard.run_on_change(@project_dir + "/another_src_location/screen.scss").should be true
File.exists?(@project_dir + "/another_stylesheets_location/screen.css").should be true
end
end

Expand All @@ -156,8 +159,8 @@
it "fails to build sass" do
@guard.reporter.should_receive(:failure).with("Cannot find a Compass configuration file, please add information to your Guardfile guard 'compass' declaration.")
@guard.start
File.exists?(@project_dir + "/src/screen.scss").should(be_true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be_false
File.exists?(@project_dir + "/src/screen.scss").should(be true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be false

@guard.run_on_change(@project_dir + "/bad_src/screen.scss")
end
Expand All @@ -178,8 +181,8 @@
end

it "fails to build sass" do
File.exists?(@project_dir + "/bad_src/screen.scss").should(be_true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be_false
File.exists?(@project_dir + "/bad_src/screen.scss").should(be true)
File.exists?(@project_dir + "/stylesheets/screen.css").should be false

@guard.run_on_change(@project_dir + "/bad_src/screen.scss")
end
Expand Down
3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Expand Up @@ -13,8 +13,7 @@
TMP_PATH = File.expand_path(File.dirname(__FILE__) + '/tmp_files')

RSpec.configure do |config|
config.color_enabled = true
config.filter_run focus: true
config.filter_run focus: ENV["CI"] != "true"
config.run_all_when_everything_filtered = true

$LOAD_PATH << LIB_PATH
Expand Down

0 comments on commit 6f51b94

Please sign in to comment.