guard-haml-coffee 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d6697a599e04e7f9eead77b24bc06978cfd2da1
4
- data.tar.gz: d1a48068586bc2d3c675ca483ac1c232367ab5a9
3
+ metadata.gz: 9b14bb4eec9c034e4635a4144afd733c14a12ff1
4
+ data.tar.gz: 46f19eac971256c11358c5923ea1dbdc23606885
5
5
  SHA512:
6
- metadata.gz: 1fa2b1c70ecd84c2a944bfd6df5e877a7880b688eaf7244f1bc6145f3917c3f58cc96ffc6a2f33528e0832a9de1957ec1e8e0d73abb5be4505e6c9bb6ed2ed19
7
- data.tar.gz: 81b51bfff2e9a9978f07622146a9d3a2c51f9d29bf1cad0724d49d406b3bb151d803d23fd90c02936003549b66d7e66e332fc196361a112e1149985dc4d2703c
6
+ metadata.gz: 3833d9d35963c023e8d7e848f6f3c178777a0bc83aa4f4e290453cbc6ca1c2ea448e61207816e4b48ea1bc4937e9dfd56e8de4acc9c7fb187732ea50eeed7e76
7
+ data.tar.gz: a28fb3275739d8283ac5e511fbf4f19c39f40ed0ef28ab841f693b569e809bdc83a3ca526402c0b2813ddcfb7f3227ea1da793fa5bef50f33d894d24e8e1953b
@@ -8,7 +8,7 @@ require 'coffee-script'
8
8
  module Guard
9
9
  class HamlCoffee < Plugin
10
10
  VALID_GUARD_OPTIONS = %i(watchers group callbacks)
11
- VALID_OPTIONS = %i(object)
11
+ VALID_OPTIONS = %i(input output)
12
12
 
13
13
  def initialize(options = {})
14
14
  valid_options = VALID_OPTIONS + VALID_GUARD_OPTIONS
@@ -18,9 +18,7 @@ module Guard
18
18
  end
19
19
  end
20
20
 
21
- @options = {
22
- notifications: true
23
- }.merge(options)
21
+ @options = options.dup
24
22
  super(@options)
25
23
  end
26
24
 
@@ -41,8 +39,11 @@ module Guard
41
39
 
42
40
  file_name = "#{file_name}.js" if file_name.match("\.js").nil?
43
41
 
44
- file_dir = file_dir.gsub(Regexp.new("#{@options[:input]}(\/){0,1}"), '') if @options[:input]
45
- file_dir = File.join(@options[:output], file_dir) if @options[:output]
42
+ input = @options[:input]
43
+ file_dir = file_dir.gsub(Regexp.new("#{input}(\/){0,1}"), '') if input
44
+
45
+ output = @options[:output]
46
+ file_dir = File.join(output, file_dir) if output
46
47
 
47
48
  if file_dir == ''
48
49
  file_name
@@ -77,7 +78,7 @@ module Guard
77
78
  output_file = get_output(path)
78
79
  FileUtils.mkdir_p File.dirname(output_file)
79
80
  output = compile(basename, File.read(path))
80
- File.open(output_file, "w") { |f| f.write output }
81
+ File.write(output_file, output)
81
82
  Compat::UI.info "# compiled haml coffee in '#{path}' to js in '#{output_file}'"
82
83
  end
83
84
  rescue StandardError => error
@@ -1,7 +1,7 @@
1
1
  module Guard
2
2
  module Haml
3
3
  module Coffee
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -20,6 +20,11 @@ RSpec.describe Guard::HamlCoffee do
20
20
  fail msg % args.map(&:inspect).join(',')
21
21
  end
22
22
 
23
+ allow(IO).to receive(:write) do |*args|
24
+ msg = 'unstubbed call to IO.write(%s)'
25
+ fail msg % args.map(&:inspect).join(',')
26
+ end
27
+
23
28
  # prepare method expecations
24
29
  allow(File).to receive(:expand_path).with('../coffee-script.js', anything).and_return('foo.js')
25
30
  allow(IO).to receive(:read).with('foo.js').and_return('foo')
@@ -61,6 +66,20 @@ RSpec.describe Guard::HamlCoffee do
61
66
  expect { subject }.to_not raise_error
62
67
  end
63
68
  end
69
+
70
+ context 'with an input option' do
71
+ let(:options) { { input: 'foo' } }
72
+ it 'fails' do
73
+ expect { subject }.to_not raise_error
74
+ end
75
+ end
76
+
77
+ context 'with an output option' do
78
+ let(:options) { { output: 'foo' } }
79
+ it 'fails' do
80
+ expect { subject }.to_not raise_error
81
+ end
82
+ end
64
83
  end
65
84
 
66
85
  describe '#start' do
@@ -148,6 +167,25 @@ RSpec.describe Guard::HamlCoffee do
148
167
 
149
168
  before do
150
169
  allow(IO).to receive(:read).with('foo.js.hamlc').and_return('foo')
170
+ allow(IO).to receive(:write).with('./foo.js', 'js output')
171
+
172
+ allow(runtime).to receive(:call).and_return(output)
173
+ end
174
+
175
+ it 'works' do
176
+ subject.run_on_changes(files)
177
+ end
178
+ end
179
+
180
+ context 'with input/output options' do
181
+ let(:options) { { input: 'foo_dir', output: 'bar_dir' } }
182
+
183
+ let(:files) { %w(foo_dir/bar/foo.js.hamlc) }
184
+ let(:output) { 'js output' }
185
+
186
+ before do
187
+ allow(IO).to receive(:read).with('foo_dir/bar/foo.js.hamlc').and_return('foo')
188
+ allow(IO).to receive(:write).with('bar_dir/bar/foo.js', 'js output')
151
189
 
152
190
  allow(runtime).to receive(:call).and_return(output)
153
191
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-haml-coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ouvrages
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-compat