guard-rails-assets 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +33 -0
- data/Gemfile +7 -2
- data/Rakefile +15 -0
- data/guard-rails-assets.gemspec +18 -16
- data/lib/guard/rails-assets.rb +16 -9
- data/lib/guard/rails-assets/cli_runner.rb +14 -10
- data/lib/guard/rails-assets/rails_runner.rb +79 -73
- data/lib/guard/rails-assets/templates/Guardfile +0 -0
- data/lib/guard/rails-assets/version.rb +1 -1
- data/spec/guard/rails-assets/cli_runner_spec.rb +7 -9
- data/spec/guard/rails-assets/rails_runner_spec.rb +4 -5
- data/spec/guard/rails-assets_spec.rb +26 -28
- data/spec/spec_helper.rb +19 -17
- data/spec/support/shared_examples.rb +7 -9
- data/spec/support/stdout_helper.rb +2 -4
- data/spec_helper.rb +23 -0
- metadata +52 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b80e50e640f2d4d6f94a7ca6a21eb357dfc7a3e
|
4
|
+
data.tar.gz: 61213ce0c830a579ad4ffb67497e1c0612d6559a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9f072b1ef2e25a3eaeb8dad7c1d338563b892f8e7d11ee078ffe76eafd886154ffadb769609e7599da1bbc97a1399a3fcab011c21482e6d7b1b286966524f5
|
7
|
+
data.tar.gz: c5ffa77814dc51311990efb254c4996eb96e2d4f0025e6a9649459be4968f8dc1b080a5132c10b32f4fdc4637814e545b2524ca9b98081745267e463c52af78a
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-12-17 03:53:47 +0100 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 2
|
9
|
+
Lint/Eval:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
# Offense count: 1
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Max: 38
|
15
|
+
|
16
|
+
# Offense count: 17
|
17
|
+
# Configuration parameters: AllowURI, URISchemes.
|
18
|
+
Metrics/LineLength:
|
19
|
+
Max: 138
|
20
|
+
|
21
|
+
# Offense count: 2
|
22
|
+
# Configuration parameters: CountComments.
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 19
|
25
|
+
|
26
|
+
# Offense count: 5
|
27
|
+
Style/Documentation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
# Configuration parameters: Exclude.
|
32
|
+
Style/FileName:
|
33
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'pry', :
|
5
|
+
gem 'pry', group: [:development, :test]
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'transpec', require: false
|
9
|
+
gem 'rubocop', require: false
|
10
|
+
end
|
data/Rakefile
CHANGED
@@ -1 +1,16 @@
|
|
1
|
+
require 'nenv'
|
1
2
|
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
default_tasks = []
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
default_tasks << RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.verbose = Nenv.ci?
|
9
|
+
end
|
10
|
+
|
11
|
+
unless Nenv.ci?
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
default_tasks << RuboCop::RakeTask.new(:rubocop)
|
14
|
+
end
|
15
|
+
|
16
|
+
task default: default_tasks.map(&:name)
|
data/guard-rails-assets.gemspec
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'guard/rails-assets/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'guard-rails-assets'
|
7
7
|
s.version = Guard::RailsAssetsVersion::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
8
|
+
s.authors = ['Dmytrii Nagirniak']
|
9
|
+
s.email = ['dnagir@gmail.com']
|
10
|
+
s.homepage = 'http://github.com/guard/guard-rails-assets'
|
11
|
+
s.summary = 'Guard for compiling Rails assets'
|
12
|
+
s.description = 'guard-rails-assets automatically generates JavaScript, CSS, Image files using Rails assets pipelie'
|
13
13
|
|
14
|
-
s.licenses =
|
14
|
+
s.licenses = %w(MIT WTFPL)
|
15
15
|
|
16
|
-
s.rubyforge_project =
|
16
|
+
s.rubyforge_project = 'guard-rails-assets'
|
17
17
|
|
18
|
-
s.add_dependency
|
19
|
-
s.add_dependency
|
20
|
-
s.add_dependency
|
21
|
-
s.
|
18
|
+
s.add_dependency 'guard', '~> 2.6'
|
19
|
+
s.add_dependency 'guard-compat', '~> 1.1'
|
20
|
+
s.add_dependency 'rake'
|
21
|
+
s.add_dependency 'rails', '>= 3.1.1'
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
23
|
+
s.add_development_dependency 'nenv', '~> 0.1'
|
22
24
|
|
23
25
|
s.files = `git ls-files`.split("\n")
|
24
26
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
-
s.require_paths = [
|
27
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
28
|
+
s.require_paths = ['lib']
|
27
29
|
end
|
data/lib/guard/rails-assets.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require 'guard'
|
2
|
-
require 'guard/guard'
|
1
|
+
require 'guard/compat/plugin'
|
3
2
|
|
4
3
|
module Guard
|
5
|
-
class RailsAssets <
|
6
|
-
def initialize(
|
4
|
+
class RailsAssets < Plugin
|
5
|
+
def initialize(options = {})
|
7
6
|
super
|
8
7
|
@options = options || {}
|
9
8
|
@run_on = @options[:run_on] || [:start, :change]
|
@@ -24,7 +23,7 @@ module Guard
|
|
24
23
|
compile_assets if run_for? :all
|
25
24
|
end
|
26
25
|
|
27
|
-
def run_on_change(
|
26
|
+
def run_on_change(_paths = [])
|
28
27
|
compile_assets if run_for? :change
|
29
28
|
end
|
30
29
|
|
@@ -33,10 +32,10 @@ module Guard
|
|
33
32
|
result = runner.compile_assets
|
34
33
|
|
35
34
|
if result
|
36
|
-
|
35
|
+
Compat::UI.notify 'Assets compiled'
|
37
36
|
puts 'Assets compiled.'
|
38
37
|
else
|
39
|
-
|
38
|
+
Compat::UI.notify 'see the details in the terminal', title: "Can't compile assets", image: :failed
|
40
39
|
puts 'Failed to compile assets.'
|
41
40
|
end
|
42
41
|
end
|
@@ -50,9 +49,17 @@ module Guard
|
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
def run_for?
|
52
|
+
def run_for?(command)
|
54
53
|
@run_on.include?(command)
|
55
54
|
end
|
55
|
+
|
56
|
+
def self.template(plugin_location)
|
57
|
+
File.read(template_path(plugin_location))
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.template_path(plugin_location)
|
61
|
+
# workaround because Guard discards the '-' when detecting template path
|
62
|
+
File.join(plugin_location, 'lib', 'guard', 'rails-assets', 'templates', 'Guardfile')
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
58
|
-
|
@@ -1,15 +1,19 @@
|
|
1
|
+
require 'guard/rails-assets'
|
2
|
+
|
1
3
|
module Guard
|
2
|
-
class RailsAssets
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
class RailsAssets
|
5
|
+
class CliRunner
|
6
|
+
def initialize(options = {})
|
7
|
+
@rails_env = (options[:rails_env] || 'test').to_s
|
8
|
+
@digest = options[:digest]
|
9
|
+
@digest = true if @digest.nil?
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
def compile_assets
|
13
|
+
task = 'assets:precompile'
|
14
|
+
task += ':nondigest' unless @digest
|
15
|
+
system "bundle exec rake assets:clean #{task} RAILS_ENV=#{@rails_env}"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -1,93 +1,99 @@
|
|
1
1
|
require 'rake/dsl_definition'
|
2
2
|
module Guard
|
3
|
+
class RailsAssets
|
4
|
+
class RailsRunner
|
5
|
+
include Rake::DSL
|
3
6
|
|
4
|
-
|
5
|
-
|
7
|
+
@rails_booted = false # Only one rails app is allowed, so make it a class var
|
8
|
+
@rails_env = nil
|
9
|
+
@digest = nil
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
class << self
|
12
|
+
attr_reader :rails_booted
|
13
|
+
attr_accessor :digest
|
14
|
+
attr_accessor :rails_env
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
def initialize(options = {})
|
18
|
+
self.class.rails_env = (options[:rails_env] || 'test').to_s unless self.class.rails_booted
|
19
|
+
self.class.digest = options[:digest]
|
20
|
+
end
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
def self.apply_hacks
|
23
|
+
# TODO: Hack due to Rails 3.1 issue: https://github.com/rails/rails/issues/2663#issuecomment-1990121
|
24
|
+
ENV['RAILS_GROUPS'] ||= 'assets'
|
25
|
+
ENV['RAILS_ENV'] ||= rails_env
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
# Methods to run the asset pipeline
|
29
|
+
# See as a reference https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake
|
30
|
+
def self.boot_rails
|
31
|
+
return if @rails_booted
|
32
|
+
puts "Booting Rails for #{rails_env} environment."
|
33
|
+
require 'fileutils'
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
apply_hacks
|
36
|
+
require 'rake'
|
37
|
+
require "#{Dir.pwd}/config/environment.rb"
|
38
|
+
app = ::Rails.application
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def clean
|
40
|
-
Rake::Task["tmp:cache:clear"].execute
|
41
|
-
# copy from the "assets:clean" Rake task
|
42
|
-
config = ::Rails.application.config
|
43
|
-
public_asset_path = File.join(::Rails.public_path, config.assets.prefix)
|
44
|
-
rm_rf public_asset_path, :secure => true
|
45
|
-
end
|
40
|
+
app.assets.cache = nil # don't touch my FS pls. (can we use `app.config.assets.cache_store = false` instead)?
|
41
|
+
app.load_tasks
|
42
|
+
@rails_booted = true
|
43
|
+
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
config.assets.
|
45
|
+
def clean
|
46
|
+
Rake::Task['tmp:cache:clear'].execute
|
47
|
+
# copy from the "assets:clean" Rake task
|
48
|
+
config = ::Rails.application.config
|
49
|
+
public_asset_path = File.join(::Rails.public_path, config.assets.prefix)
|
50
|
+
rm_rf public_asset_path, secure: true
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
def precompile
|
54
|
+
config = ::Rails.application.config
|
55
|
+
unless config.assets.enabled
|
56
|
+
warn 'Cannot precompile assets if sprockets is disabled. Enabling it.'
|
57
|
+
config.assets.enabled = true
|
58
|
+
end
|
57
59
|
|
58
|
-
|
60
|
+
# Ensure that action view is loaded and the appropriate
|
61
|
+
# sprockets hooks get executed
|
62
|
+
_ = ActionView::Base
|
59
63
|
|
60
|
-
|
61
|
-
config.assets.digest = digest
|
62
|
-
config.assets.digests = {}
|
64
|
+
digest = self.class.digest.nil? ? config.assets.digest : self.class.digest
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
target,
|
68
|
-
config.assets.precompile,
|
69
|
-
:manifest_path => config.assets.manifest,
|
70
|
-
:digest => config.assets.digest,
|
71
|
-
:manifest => config.assets.digest.nil?)
|
72
|
-
compiler.compile
|
73
|
-
end
|
66
|
+
config.assets.compile = true
|
67
|
+
config.assets.digest = digest
|
68
|
+
config.assets.digests = {}
|
74
69
|
|
70
|
+
env = ::Rails.application.assets
|
71
|
+
target = File.join(::Rails.public_path, config.assets.prefix)
|
72
|
+
compiler = Sprockets::StaticCompiler.new(env,
|
73
|
+
target,
|
74
|
+
config.assets.precompile,
|
75
|
+
manifest_path: config.assets.manifest,
|
76
|
+
digest: config.assets.digest,
|
77
|
+
manifest: config.assets.digest.nil?)
|
78
|
+
compiler.compile
|
79
|
+
end
|
75
80
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
# Runs the asset pipeline compiler.
|
82
|
+
#
|
83
|
+
# @return [ Boolean ] Whether the compilation was successful or not
|
84
|
+
def compile_assets
|
85
|
+
self.class.boot_rails
|
86
|
+
return false unless self.class.rails_booted
|
87
|
+
begin
|
88
|
+
clean
|
89
|
+
precompile
|
90
|
+
true
|
91
|
+
rescue => e
|
92
|
+
puts "An error occurred compiling assets: #{e}"
|
93
|
+
false
|
94
|
+
ensure
|
95
|
+
::Rails.application.assets.instance_eval { expire_index! }
|
96
|
+
end
|
91
97
|
end
|
92
98
|
end
|
93
99
|
end
|
File without changes
|
@@ -1,18 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
describe Guard::RailsAssets::CliRunner do
|
4
|
-
|
1
|
+
require 'guard/rails-assets/cli_runner'
|
2
|
+
RSpec.describe Guard::RailsAssets::CliRunner do
|
5
3
|
it 'should run the command' do
|
6
|
-
subject.
|
7
|
-
subject.
|
4
|
+
allow(subject).to receive(:system)
|
5
|
+
expect(subject).to receive(:system).with('bundle exec rake assets:clean assets:precompile RAILS_ENV=test')
|
8
6
|
subject.compile_assets
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'with production environment' do
|
12
|
-
subject { Guard::RailsAssets::CliRunner.new(:
|
10
|
+
subject { Guard::RailsAssets::CliRunner.new(rails_env: :production) }
|
13
11
|
it 'should run the command' do
|
14
|
-
subject.
|
15
|
-
subject.
|
12
|
+
allow(subject).to receive(:system)
|
13
|
+
expect(subject).to receive(:system).with('bundle exec rake assets:clean assets:precompile RAILS_ENV=production')
|
16
14
|
subject.compile_assets
|
17
15
|
end
|
18
16
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
describe Guard::RailsAssets::RailsRunner do
|
1
|
+
require 'guard/rails-assets/rails_runner'
|
4
2
|
|
3
|
+
RSpec.describe Guard::RailsAssets::RailsRunner do
|
5
4
|
it 'should be tested properly as a Rails engine'
|
6
|
-
|
7
|
-
it {
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :compile_assets }
|
8
7
|
end
|
@@ -1,81 +1,79 @@
|
|
1
|
-
require '
|
1
|
+
require 'guard/compat/test/helper'
|
2
2
|
require 'guard/rails-assets'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require_relative '../support/shared_examples'
|
6
5
|
|
6
|
+
RSpec.describe Guard::RailsAssets do
|
7
7
|
context 'with any runner' do
|
8
|
-
|
9
|
-
let(:
|
10
|
-
|
11
|
-
subject { Guard::RailsAssets.new(['watchers'], options) }
|
8
|
+
let(:options) { { runner: :cli } }
|
9
|
+
let(:runner) { double('runner') }
|
10
|
+
subject { Guard::RailsAssets.new(options) }
|
12
11
|
|
13
12
|
before do
|
14
|
-
|
13
|
+
allow(Guard::RailsAssets::CliRunner).to receive(:new).and_return runner
|
15
14
|
end
|
16
15
|
|
17
16
|
describe '#start' do
|
18
|
-
it_behaves_like 'guard command', :
|
17
|
+
it_behaves_like 'guard command', command: :start, run: true
|
19
18
|
end
|
20
19
|
|
21
20
|
describe '#reload' do
|
22
|
-
it_behaves_like 'guard command', :
|
21
|
+
it_behaves_like 'guard command', command: :reload, run: false
|
23
22
|
end
|
24
23
|
|
25
24
|
describe '#run_all' do
|
26
|
-
it_behaves_like 'guard command', :
|
25
|
+
it_behaves_like 'guard command', command: :run_all, run: false
|
27
26
|
end
|
28
27
|
|
29
28
|
describe '#run_on_change' do
|
30
|
-
it_behaves_like 'guard command', :
|
29
|
+
it_behaves_like 'guard command', command: :run_on_change, run: true
|
31
30
|
end
|
32
31
|
|
33
32
|
describe 'run options' do
|
34
33
|
it 'should allow array of symbols' do
|
35
|
-
guard = Guard::RailsAssets.new(
|
36
|
-
guard.run_for?(:start).
|
37
|
-
guard.run_for?(:reload).
|
34
|
+
guard = Guard::RailsAssets.new(run_on: [:start, :change])
|
35
|
+
expect(guard.run_for?(:start)).to be_truthy
|
36
|
+
expect(guard.run_for?(:reload)).to be_falsey
|
38
37
|
end
|
39
38
|
|
40
39
|
it 'should allow symbol' do
|
41
|
-
guard = Guard::RailsAssets.new(
|
42
|
-
guard.run_for?(:start).
|
43
|
-
guard.run_for?(:reload).
|
40
|
+
guard = Guard::RailsAssets.new(run_on: :start)
|
41
|
+
expect(guard.run_for?(:start)).to be_truthy
|
42
|
+
expect(guard.run_for?(:reload)).to be_falsey
|
44
43
|
end
|
45
|
-
|
46
44
|
end
|
47
45
|
|
48
46
|
describe 'notifications' do
|
49
|
-
def stub_system_with
|
50
|
-
runner.
|
47
|
+
def stub_system_with(result)
|
48
|
+
expect(runner).to receive(:compile_assets).and_return result
|
51
49
|
end
|
52
50
|
|
53
51
|
it 'should notify on success' do
|
54
52
|
stub_system_with true
|
55
|
-
Guard::
|
53
|
+
expect(Guard::Compat::UI).to receive(:notify).with('Assets compiled')
|
56
54
|
subject.compile_assets
|
57
55
|
end
|
58
56
|
|
59
57
|
it 'should notify on failure' do
|
60
58
|
stub_system_with false
|
61
|
-
Guard::
|
59
|
+
expect(Guard::Compat::UI).to receive(:notify)
|
60
|
+
.with('see the details in the terminal', title: "Can't compile assets", image: :failed)
|
62
61
|
subject.compile_assets
|
63
62
|
end
|
64
63
|
end
|
65
|
-
|
66
64
|
end # context with any runner
|
67
65
|
|
68
66
|
describe 'picking a runner' do
|
69
67
|
it 'should use Rails runner by default' do
|
70
|
-
Guard::RailsAssets.new
|
68
|
+
expect(Guard::RailsAssets.new.runner.class).to eq(::Guard::RailsAssets::RailsRunner)
|
71
69
|
end
|
72
70
|
|
73
71
|
it 'should use CLI runner' do
|
74
|
-
Guard::RailsAssets.new(
|
72
|
+
expect(Guard::RailsAssets.new(runner: :cli).runner.class).to eq(::Guard::RailsAssets::CliRunner)
|
75
73
|
end
|
76
|
-
|
74
|
+
|
77
75
|
it 'should use RailsRunner' do
|
78
|
-
Guard::RailsAssets.new(
|
76
|
+
expect(Guard::RailsAssets.new(runner: :rails).runner.class).to eq(::Guard::RailsAssets::RailsRunner)
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
-
require '
|
2
|
-
require 'guard/rails-assets'
|
3
|
-
require 'support/shared_examples'
|
4
|
-
require 'support/stdout_helper'
|
5
|
-
require 'guard/rails-assets/cli_runner'
|
6
|
-
require 'guard/rails-assets/rails_runner'
|
1
|
+
require 'nenv'
|
7
2
|
|
8
3
|
RSpec.configure do |config|
|
9
|
-
config.
|
10
|
-
|
11
|
-
config.run_all_when_everything_filtered = true
|
12
|
-
|
13
|
-
config.before(:each) do
|
14
|
-
ENV["GUARD_ENV"] = 'test'
|
15
|
-
@project_path = Pathname.new(File.expand_path('../../', __FILE__))
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
16
6
|
end
|
17
7
|
|
18
|
-
config.
|
19
|
-
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
20
10
|
end
|
21
|
-
|
22
|
-
config.include(Helpers)
|
23
11
|
|
12
|
+
config.filter_run focus: !Nenv.ci?
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
|
15
|
+
config.disable_monkey_patching!
|
16
|
+
|
17
|
+
config.warnings = true
|
18
|
+
|
19
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
20
|
+
|
21
|
+
# config.profile_examples = 10
|
22
|
+
|
23
|
+
config.order = :random
|
24
|
+
|
25
|
+
Kernel.srand config.seed
|
24
26
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
shared_examples_for
|
2
|
-
|
3
|
-
def set_run_on_option info
|
1
|
+
RSpec.shared_examples_for 'guard command' do |info|
|
2
|
+
def run_on_option=(info)
|
4
3
|
# run_on_change -> change
|
5
4
|
# run_all -> all
|
6
5
|
run_option = info[:command].to_s.match(/(.*_)?(\w+)/)[2].to_sym
|
@@ -8,24 +7,23 @@ shared_examples_for "guard command" do |info|
|
|
8
7
|
end
|
9
8
|
|
10
9
|
it "should execute #{info[:command]} when said so" do
|
11
|
-
|
12
|
-
subject.
|
10
|
+
self.run_on_option = info
|
11
|
+
expect(subject).to receive(:compile_assets)
|
13
12
|
subject.send(info[:command])
|
14
13
|
end
|
15
14
|
it "should not execute #{info[:command]} when disabled" do
|
16
15
|
options[:run_on] = [:something_other]
|
17
|
-
subject.
|
16
|
+
expect(subject).not_to receive(:compile_assets)
|
18
17
|
subject.send(info[:command])
|
19
18
|
end
|
20
19
|
|
21
20
|
it "should #{info[:run] ? '' : 'not '}execute #{info[:command]} by default" do
|
22
21
|
options[:run_on] = nil
|
23
22
|
if info[:run]
|
24
|
-
subject.
|
23
|
+
expect(subject).to receive(:compile_assets)
|
25
24
|
else
|
26
|
-
subject.
|
25
|
+
expect(subject).not_to receive(:compile_assets)
|
27
26
|
end
|
28
27
|
subject.send(info[:command])
|
29
28
|
end
|
30
|
-
|
31
29
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
|
3
3
|
module Helpers
|
4
|
-
|
5
4
|
def capture(*streams)
|
6
|
-
streams.map!
|
5
|
+
streams.map!(&:to_s)
|
7
6
|
begin
|
8
7
|
result = StringIO.new
|
9
8
|
streams.each { |stream| eval "$#{stream} = result" }
|
@@ -13,5 +12,4 @@ module Helpers
|
|
13
12
|
end
|
14
13
|
result.string
|
15
14
|
end
|
16
|
-
|
17
|
-
end
|
15
|
+
end
|
data/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'guard/rails-assets'
|
3
|
+
require 'support/shared_examples'
|
4
|
+
require 'support/stdout_helper'
|
5
|
+
require 'guard/rails-assets/cli_runner'
|
6
|
+
require 'guard/rails-assets/rails_runner'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.color_enabled = true
|
10
|
+
config.filter_run focus: true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
|
13
|
+
config.before(:each) do
|
14
|
+
ENV['GUARD_ENV'] = 'test'
|
15
|
+
@project_path = Pathname.new(File.expand_path('../../', __FILE__))
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after(:each) do
|
19
|
+
ENV['GUARD_ENV'] = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
config.include(Helpers)
|
23
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rails-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytrii Nagirniak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-compat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rails
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: 3.1.1
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: 3.1.1
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '3.1'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '3.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nenv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.1'
|
69
97
|
description: guard-rails-assets automatically generates JavaScript, CSS, Image files
|
70
98
|
using Rails assets pipelie
|
71
99
|
email:
|
@@ -74,7 +102,10 @@ executables: []
|
|
74
102
|
extensions: []
|
75
103
|
extra_rdoc_files: []
|
76
104
|
files:
|
77
|
-
- .gitignore
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".rubocop_todo.yml"
|
78
109
|
- Gemfile
|
79
110
|
- README.md
|
80
111
|
- Rakefile
|
@@ -90,7 +121,8 @@ files:
|
|
90
121
|
- spec/spec_helper.rb
|
91
122
|
- spec/support/shared_examples.rb
|
92
123
|
- spec/support/stdout_helper.rb
|
93
|
-
|
124
|
+
- spec_helper.rb
|
125
|
+
homepage: http://github.com/guard/guard-rails-assets
|
94
126
|
licenses:
|
95
127
|
- MIT
|
96
128
|
- WTFPL
|
@@ -101,24 +133,18 @@ require_paths:
|
|
101
133
|
- lib
|
102
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
135
|
requirements:
|
104
|
-
- -
|
136
|
+
- - ">="
|
105
137
|
- !ruby/object:Gem::Version
|
106
138
|
version: '0'
|
107
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
140
|
requirements:
|
109
|
-
- -
|
141
|
+
- - ">="
|
110
142
|
- !ruby/object:Gem::Version
|
111
143
|
version: '0'
|
112
144
|
requirements: []
|
113
145
|
rubyforge_project: guard-rails-assets
|
114
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.4.5
|
115
147
|
signing_key:
|
116
148
|
specification_version: 4
|
117
149
|
summary: Guard for compiling Rails assets
|
118
|
-
test_files:
|
119
|
-
- spec/guard/rails-assets/cli_runner_spec.rb
|
120
|
-
- spec/guard/rails-assets/rails_runner_spec.rb
|
121
|
-
- spec/guard/rails-assets_spec.rb
|
122
|
-
- spec/spec_helper.rb
|
123
|
-
- spec/support/shared_examples.rb
|
124
|
-
- spec/support/stdout_helper.rb
|
150
|
+
test_files: []
|