rake-funnel 0.16.1 → 0.17.0

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: 15c93cd453fd3a4cb44ff99fecb8b9e12501bab0
4
- data.tar.gz: 2b6ccf54a20198fb9b1c05cdb8c6ae9425b53040
3
+ metadata.gz: af6a3384beef14d765b3deeb68f46bc6e9075753
4
+ data.tar.gz: 56a85fbb32a083c02f329c2c379a46b91fd312b7
5
5
  SHA512:
6
- metadata.gz: 4cabea259d82d608fdf27acfdc6e24f2ff085805abf698dbb5b58c15d2281857d56fff1af83c7b463967f9f0478caff3732436fc436fecf18546ee5dd68cf45b
7
- data.tar.gz: 6d3f30c6d8570a6c4f501d00c998add9dc75142aa50b933f38891a0dfa4f2a5131885a0b46b4dc8a9dd97c888b8ae0cbd2619648a85239688cdf9602b2eaf262
6
+ metadata.gz: fcf794c4853b54485436d3d102d2edc58e61840de0e72965af8d6ef2d395c6afe49110b97a04c94ebab5d222f8f1ddcb6c46f251b63098a49a4e9b46494fd2db
7
+ data.tar.gz: e3ae2368bd27d0c25b78eb46ba4d2ebf1c216623041629e93e91ce98dc34b10e937459c12e45338dbaf3a26d0e7617971da94b4d2dc2f9e5e268ecc4f058f9d6
@@ -4,7 +4,7 @@ module Rake
4
4
  module Funnel
5
5
  module Tasks
6
6
  class BinPath < Rake::TaskLib
7
- attr_accessor :name, :search_pattern
7
+ attr_accessor :name, :search_pattern, :path_modifier
8
8
 
9
9
  def initialize(*args, &task_block)
10
10
  setup_ivars(args)
@@ -16,6 +16,7 @@ module Rake
16
16
  def setup_ivars(args)
17
17
  @name = args.shift || :bin_path
18
18
  @search_pattern = %w(tools/* tools/*/bin packages/**/tools)
19
+ @path_modifier = proc { |paths| paths }
19
20
  end
20
21
 
21
22
  def define(args, &task_block)
@@ -26,7 +27,7 @@ module Rake
26
27
 
27
28
  next unless paths.any?
28
29
 
29
- add_pattern_to_path_environment(paths)
30
+ prepend_pattern_to_path_environment(paths)
30
31
  Rake.rake_output_message 'Added the following paths to the PATH environment variable:'
31
32
  paths.each do |p|
32
33
  Rake.rake_output_message " - #{p}"
@@ -37,10 +38,12 @@ module Rake
37
38
  end
38
39
 
39
40
  def paths
40
- @paths ||= Dir[*search_pattern].map { |path| File.expand_path(path) }.sort
41
+ @paths ||= @path_modifier.call(Dir[*search_pattern])
42
+ .map { |path| File.expand_path(path) }
43
+ .sort
41
44
  end
42
45
 
43
- def add_pattern_to_path_environment(paths)
46
+ def prepend_pattern_to_path_environment(paths)
44
47
  ENV['PATH'] = ([] << paths << ENV['PATH']).flatten.join(File::PATH_SEPARATOR)
45
48
  paths
46
49
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.16.1'
3
+ VERSION = '0.17.0'.freeze
4
4
  end
5
5
  end
@@ -13,6 +13,7 @@ describe Rake::Funnel::Tasks::BinPath do
13
13
  describe 'execution' do
14
14
  let(:default_path) { 'default PATH contents' }
15
15
  let(:search_pattern) { %w(foo bar) }
16
+ let(:path_modifier) { nil }
16
17
 
17
18
  before {
18
19
  allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
@@ -23,6 +24,7 @@ describe Rake::Funnel::Tasks::BinPath do
23
24
  subject {
24
25
  described_class.new do |t|
25
26
  t.search_pattern = search_pattern
27
+ t.path_modifier = path_modifier unless path_modifier.nil?
26
28
  end
27
29
  }
28
30
 
@@ -49,6 +51,33 @@ describe Rake::Funnel::Tasks::BinPath do
49
51
  expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
50
52
  expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
51
53
  end
54
+
55
+ describe 'path modifier' do
56
+ context 'adding paths' do
57
+ let(:path_modifier) { proc { |paths| paths.push('added path') } }
58
+
59
+ it 'adds extra paths' do
60
+ expect(ENV).to have_received(:[]=).with('PATH',/added path/)
61
+ end
62
+
63
+ it 'retains other paths' do
64
+ expect(ENV).to have_received(:[]=).with('PATH', /foo/)
65
+ expect(ENV).to have_received(:[]=).with('PATH', /bar/)
66
+ end
67
+ end
68
+
69
+ context 'rejecting paths' do
70
+ let(:path_modifier) { proc { |paths| paths.reject { |p| p =~ /foo/ } } }
71
+
72
+ it 'removes matching paths' do
73
+ expect(ENV).not_to have_received(:[]=).with('PATH', /foo/)
74
+ end
75
+
76
+ it 'retains non-matching paths' do
77
+ expect(ENV).to have_received(:[]=).with('PATH', /bar/)
78
+ end
79
+ end
80
+ end
52
81
  end
53
82
 
54
83
  context 'no paths to add' do
@@ -63,6 +92,10 @@ describe Rake::Funnel::Tasks::BinPath do
63
92
  it 'should not print message' do
64
93
  expect(Rake).not_to have_received(:rake_output_message)
65
94
  end
95
+
96
+ it 'should not set environment variable' do
97
+ expect(ENV).not_to have_received(:[]=).with('PATH')
98
+ end
66
99
  end
67
100
  end
68
101
  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.1
4
+ version: 0.17.0
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-04-06 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake