rake-funnel 0.16.0 → 0.16.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0765d968f496d9b2d6fc6e9987522f44b3b68414
4
- data.tar.gz: 6402693233bbd64577af3fa8ac33b7254e68ff1f
3
+ metadata.gz: 15c93cd453fd3a4cb44ff99fecb8b9e12501bab0
4
+ data.tar.gz: 2b6ccf54a20198fb9b1c05cdb8c6ae9425b53040
5
5
  SHA512:
6
- metadata.gz: 6ea5d6e5819f386a9e0ee18919c60a597419df112afd02bfd28165cf073b88f0e84ab6a8ad99120b7d08dad047256077925e9475b7d181fa3957fc0ab6095188
7
- data.tar.gz: 9eed51507993fdf63ead454fd9653455c232f7e25163260d96c54e62cc02b46de54119ccf7e464ba857411b66cbf848360b2019e360565bbabc4744d23394175
6
+ metadata.gz: 4cabea259d82d608fdf27acfdc6e24f2ff085805abf698dbb5b58c15d2281857d56fff1af83c7b463967f9f0478caff3732436fc436fecf18546ee5dd68cf45b
7
+ data.tar.gz: 6d3f30c6d8570a6c4f501d00c998add9dc75142aa50b933f38891a0dfa4f2a5131885a0b46b4dc8a9dd97c888b8ae0cbd2619648a85239688cdf9602b2eaf262
@@ -24,8 +24,11 @@ module Rake
24
24
  task(name, *args) do |_, task_args|
25
25
  task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
26
26
 
27
+ next unless paths.any?
28
+
29
+ add_pattern_to_path_environment(paths)
27
30
  Rake.rake_output_message 'Added the following paths to the PATH environment variable:'
28
- add_pattern_to_path_environment.each do |p|
31
+ paths.each do |p|
29
32
  Rake.rake_output_message " - #{p}"
30
33
  end
31
34
  end
@@ -33,9 +36,11 @@ module Rake
33
36
  self
34
37
  end
35
38
 
36
- def add_pattern_to_path_environment
37
- paths = Dir[*search_pattern].map { |path| File.expand_path(path) }.sort
39
+ def paths
40
+ @paths ||= Dir[*search_pattern].map { |path| File.expand_path(path) }.sort
41
+ end
38
42
 
43
+ def add_pattern_to_path_environment(paths)
39
44
  ENV['PATH'] = ([] << paths << ENV['PATH']).flatten.join(File::PATH_SEPARATOR)
40
45
  paths
41
46
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.16.0'
3
+ VERSION = '0.16.1'
4
4
  end
5
5
  end
@@ -20,33 +20,49 @@ describe Rake::Funnel::Tasks::BinPath do
20
20
  allow(Rake).to receive(:rake_output_message)
21
21
  }
22
22
 
23
- before {
24
- allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
25
- }
26
-
27
23
  subject {
28
24
  described_class.new do |t|
29
25
  t.search_pattern = search_pattern
30
26
  end
31
27
  }
32
28
 
33
- before {
34
- Task[subject.name].invoke
35
- }
29
+ context 'paths to add' do
30
+ before {
31
+ allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
32
+ }
36
33
 
37
- it 'should prepend sorted matching folders to the PATH environment variable' do
38
- paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)
34
+ before {
35
+ Task[subject.name].invoke
36
+ }
39
37
 
40
- expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
41
- end
38
+ it 'should prepend sorted matching folders to the PATH environment variable' do
39
+ paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)
40
+
41
+ expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
42
+ end
43
+
44
+ it 'should append original PATH environment variable' do
45
+ expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
46
+ end
42
47
 
43
- it 'should append original PATH environment variable' do
44
- expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
48
+ it 'should report added paths' do
49
+ expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
50
+ expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
51
+ end
45
52
  end
46
53
 
47
- it 'should report added paths' do
48
- expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
49
- expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
54
+ context 'no paths to add' do
55
+ before {
56
+ allow(Dir).to receive(:[]).with(*search_pattern).and_return([])
57
+ }
58
+
59
+ before {
60
+ Task[subject.name].invoke
61
+ }
62
+
63
+ it 'should not print message' do
64
+ expect(Rake).not_to have_received(:rake_output_message)
65
+ end
50
66
  end
51
67
  end
52
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-funnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Groß
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -301,3 +301,4 @@ test_files:
301
301
  - spec/rake/funnel/tasks/timing_spec.rb
302
302
  - spec/rake/funnel/tasks/zip_spec.rb
303
303
  - spec/spec_helper.rb
304
+ has_rdoc: