rake-funnel 0.4.0.pre → 0.5.0.pre
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/lib/rake/funnel/support/specs_remover.rb +35 -20
- data/lib/rake/funnel/support/version_info.rb +2 -5
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +15 -1
- data/lib/rake/funnel/version.rb +1 -1
- data/spec/rake/funnel/support/specs_remover/paket.references +4 -0
- data/spec/rake/funnel/support/specs_remover/subdir/foo.paket.references +4 -0
- data/spec/rake/funnel/support/specs_remover_spec.rb +87 -25
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +10 -6
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b802578d7663c71e143eeb59c653e9007c5e68a1
|
4
|
+
data.tar.gz: 4fdb2bd0f6685e3796b65e9d28231126bd611860
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4498c0b46d7ec90ecd91af78cb3a674f16490433253dd43181cfd64de3b559bd1228b9c371cffdafe0d03a3d0e77643217df6563fc3a0d14394b60ccf78a958b
|
7
|
+
data.tar.gz: d37bb5fdc8ff28b5351087deb011bf66f039e62d813a02851b67297093074efac7d4cdb44477d060e9ceb8604b95a021860c14d3c3f637d143f82bfb932b4259
|
@@ -5,45 +5,49 @@ module Rake
|
|
5
5
|
module Support
|
6
6
|
class SpecsRemover
|
7
7
|
class << self
|
8
|
-
DEFAULTS = {
|
9
|
-
projects: [],
|
10
|
-
references: [],
|
11
|
-
specs: []
|
12
|
-
}
|
13
|
-
|
14
8
|
def remove(args = {})
|
15
|
-
|
9
|
+
remove_specs_from_projects(args)
|
10
|
+
delete_test_files(args)
|
11
|
+
remove_paket_references(args)
|
12
|
+
end
|
16
13
|
|
14
|
+
private
|
15
|
+
def remove_specs_from_projects(args)
|
17
16
|
projects(args).each do |project|
|
18
|
-
xml = REXML::Document.new(File.read(project),
|
19
|
-
|
17
|
+
xml = REXML::Document.new(File.read(project), attribute_quote: :quote)
|
20
18
|
removed = remove_references(args, xml) + remove_specs(args, xml)
|
21
19
|
|
22
20
|
write_xml(project, xml) if removed.flatten.any?
|
23
21
|
end
|
24
|
-
|
25
|
-
delete_specs(args)
|
26
22
|
end
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def remove_paket_references(args)
|
25
|
+
paket_references(args).each do |references|
|
26
|
+
text = File.read(references)
|
27
|
+
removed = remove_packages(text, args)
|
28
|
+
|
29
|
+
File.write(references, removed) if removed != text
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
def
|
36
|
-
Dir[*args[:specs]].uniq.each do |spec|
|
33
|
+
def delete_test_files(args)
|
34
|
+
Dir[*list(args[:specs])].uniq.each do |spec|
|
37
35
|
RakeFileUtils.rm(spec)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
39
|
+
def list(args)
|
40
|
+
([] << args).flatten.compact
|
41
|
+
end
|
42
|
+
|
41
43
|
def projects(args)
|
42
|
-
Dir[*args[:projects]]
|
44
|
+
Dir[*list(args[:projects])]
|
43
45
|
end
|
44
46
|
|
45
|
-
def
|
46
|
-
(
|
47
|
+
def write_xml(project, xml)
|
48
|
+
File.open(project, 'w+') do |file|
|
49
|
+
xml.write(output: file, ie_hack: true)
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
def remove_references(args, xml)
|
@@ -59,6 +63,17 @@ module Rake
|
|
59
63
|
xml.elements.delete_all(query)
|
60
64
|
end
|
61
65
|
end
|
66
|
+
|
67
|
+
def paket_references(args)
|
68
|
+
Dir[*list(args[:paket_references])]
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove_packages(text, args)
|
72
|
+
list(args[:packages]).each do |package|
|
73
|
+
text = text.gsub(/^#{package}.*\n?/i, '')
|
74
|
+
end
|
75
|
+
text
|
76
|
+
end
|
62
77
|
end
|
63
78
|
end
|
64
79
|
end
|
@@ -67,7 +67,7 @@ module Rake
|
|
67
67
|
semver = [
|
68
68
|
numeric_version,
|
69
69
|
alpha_version,
|
70
|
-
pre(context)
|
70
|
+
pre(context)
|
71
71
|
].join
|
72
72
|
|
73
73
|
[
|
@@ -78,10 +78,7 @@ module Rake
|
|
78
78
|
|
79
79
|
def pre(context)
|
80
80
|
pre = context.fetch(:metadata, {})[:pre]
|
81
|
-
|
82
|
-
if pre && pre.to_s !~ /^-/
|
83
|
-
pre = "-#{pre}"
|
84
|
-
end
|
81
|
+
pre = "-#{pre}" if pre && pre.to_s !~ /^-/
|
85
82
|
|
86
83
|
pre
|
87
84
|
end
|
@@ -7,6 +7,7 @@ module Rake
|
|
7
7
|
include Rake::Funnel::Support
|
8
8
|
|
9
9
|
attr_accessor :name, :projects, :references, :specs, :enabled
|
10
|
+
attr_accessor :paket_references, :packages
|
10
11
|
|
11
12
|
def initialize(*args, &task_block)
|
12
13
|
setup_ivars(args)
|
@@ -22,6 +23,8 @@ module Rake
|
|
22
23
|
@references = []
|
23
24
|
@specs = %w(*Specs.cs **/*Specs.cs *Tests.cs **/*Tests.cs)
|
24
25
|
@enabled = false
|
26
|
+
@paket_references = %w(**/*paket.references)
|
27
|
+
@packages = []
|
25
28
|
end
|
26
29
|
|
27
30
|
def define(args, &task_block)
|
@@ -30,11 +33,22 @@ module Rake
|
|
30
33
|
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
31
34
|
|
32
35
|
next unless enabled
|
33
|
-
|
36
|
+
|
37
|
+
SpecsRemover.remove(remove_args)
|
34
38
|
end
|
35
39
|
|
36
40
|
self
|
37
41
|
end
|
42
|
+
|
43
|
+
def remove_args
|
44
|
+
{
|
45
|
+
projects: projects,
|
46
|
+
references: references,
|
47
|
+
specs: specs,
|
48
|
+
paket_references: paket_references,
|
49
|
+
packages: packages
|
50
|
+
}
|
51
|
+
end
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
data/lib/rake/funnel/version.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
describe Rake::Funnel::Support::SpecsRemover do
|
2
2
|
describe 'removal' do
|
3
|
-
let(:projects) {
|
4
|
-
let(:references) {
|
5
|
-
let(:specs) {
|
3
|
+
let(:projects) {}
|
4
|
+
let(:references) {}
|
5
|
+
let(:specs) {}
|
6
|
+
let(:paket_references) {}
|
7
|
+
let(:packages) {}
|
6
8
|
|
7
9
|
before {
|
8
|
-
allow(Dir).to receive(:[]).and_return(%w(project.proj))
|
9
|
-
allow(File).to receive(:read).and_return('<root></root>')
|
10
10
|
allow(File).to receive(:open)
|
11
|
+
allow(File).to receive(:write)
|
11
12
|
allow(RakeFileUtils).to receive(:rm)
|
12
13
|
}
|
13
14
|
|
14
|
-
before {
|
15
|
-
described_class.remove({
|
16
|
-
projects: projects,
|
17
|
-
references: references,
|
18
|
-
specs: specs
|
19
|
-
})
|
20
|
-
}
|
21
|
-
|
22
15
|
describe 'arguments' do
|
16
|
+
before {
|
17
|
+
described_class.remove(projects: projects,
|
18
|
+
references: references,
|
19
|
+
specs: specs,
|
20
|
+
paket_references: paket_references,
|
21
|
+
packages: packages)
|
22
|
+
}
|
23
|
+
|
23
24
|
context 'string projects' do
|
24
25
|
let(:projects) { '**/*.??proj' }
|
25
26
|
|
@@ -47,13 +48,48 @@ describe Rake::Funnel::Support::SpecsRemover do
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
let(:
|
52
|
-
let(:
|
53
|
-
|
51
|
+
describe 'unchanged files' do
|
52
|
+
let(:project_file) {}
|
53
|
+
let(:paket_references_file) {}
|
54
|
+
|
55
|
+
before {
|
56
|
+
allow(Dir).to receive(:[]).and_return([])
|
57
|
+
}
|
58
|
+
|
59
|
+
before {
|
60
|
+
allow(Dir).to receive(:[]).with(projects).and_return([project_file])
|
61
|
+
allow(File).to receive(:read).with(project_file).and_return('<root></root>')
|
62
|
+
}
|
63
|
+
|
64
|
+
before {
|
65
|
+
allow(Dir).to receive(:[]).with(paket_references).and_return([paket_references_file])
|
66
|
+
allow(File).to receive(:read).with(paket_references_file).and_return('SomePackage')
|
67
|
+
}
|
68
|
+
|
69
|
+
before {
|
70
|
+
described_class.remove(projects: projects,
|
71
|
+
references: references,
|
72
|
+
specs: specs,
|
73
|
+
paket_references: paket_references,
|
74
|
+
packages: packages)
|
75
|
+
}
|
76
|
+
|
77
|
+
context 'project unchanged' do
|
78
|
+
let(:projects) { '**/*.??proj' }
|
79
|
+
let(:project_file) { 'project.proj' }
|
80
|
+
|
81
|
+
it 'should not write the project file' do
|
82
|
+
expect(File).not_to have_received(:open)
|
83
|
+
end
|
84
|
+
end
|
54
85
|
|
55
|
-
|
56
|
-
|
86
|
+
context 'paket references unchanged' do
|
87
|
+
let(:paket_references) { '*paket.references' }
|
88
|
+
let(:paket_references_file) { 'paket.references' }
|
89
|
+
|
90
|
+
it 'should not write the references file' do
|
91
|
+
expect(File).not_to have_received(:write)
|
92
|
+
end
|
57
93
|
end
|
58
94
|
end
|
59
95
|
end
|
@@ -62,6 +98,8 @@ describe Rake::Funnel::Support::SpecsRemover do
|
|
62
98
|
let(:projects) { %w(**/*.??proj) }
|
63
99
|
let(:references) { %w(Sample-Ref-1 Sample-Ref-2 Sample-Ref-3) }
|
64
100
|
let(:specs) { %w(*Specs.cs **/*Specs.cs) }
|
101
|
+
let(:paket_references) { %w(**/*paket.references) }
|
102
|
+
let(:packages) { references }
|
65
103
|
|
66
104
|
let(:temp_dir) { Dir.mktmpdir }
|
67
105
|
|
@@ -75,11 +113,11 @@ describe Rake::Funnel::Support::SpecsRemover do
|
|
75
113
|
|
76
114
|
before {
|
77
115
|
Dir.chdir(temp_dir) do
|
78
|
-
described_class.remove(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
116
|
+
described_class.remove(projects: projects,
|
117
|
+
references: references,
|
118
|
+
specs: specs,
|
119
|
+
paket_references: paket_references,
|
120
|
+
packages: packages)
|
83
121
|
end
|
84
122
|
}
|
85
123
|
|
@@ -105,12 +143,36 @@ describe Rake::Funnel::Support::SpecsRemover do
|
|
105
143
|
end
|
106
144
|
|
107
145
|
it 'should remove references' do
|
108
|
-
expect(project_xml).not_to include(
|
146
|
+
expect(project_xml).not_to include(*references)
|
109
147
|
end
|
110
148
|
|
111
149
|
it 'should remove spec files' do
|
112
150
|
expect(project_xml).not_to include('Specs.cs', 'SampleSpecs.cs')
|
113
151
|
end
|
114
152
|
end
|
153
|
+
|
154
|
+
describe 'paket references' do
|
155
|
+
def content(file)
|
156
|
+
File.read(File.join(temp_dir, file))
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should remove packages' do
|
160
|
+
[
|
161
|
+
content('paket.references'),
|
162
|
+
content('subdir/foo.paket.references')
|
163
|
+
].each do |content|
|
164
|
+
expect(content).not_to include(*packages)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should keep other packages' do
|
169
|
+
[
|
170
|
+
content('paket.references'),
|
171
|
+
content('subdir/foo.paket.references')
|
172
|
+
].each do |content|
|
173
|
+
expect(content).to include('Untouched')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
115
177
|
end
|
116
178
|
end
|
@@ -14,15 +14,19 @@ describe Rake::Funnel::Tasks::SideBySideSpecs do
|
|
14
14
|
its(:references) { should == [] }
|
15
15
|
its(:specs) { should == %w(*Specs.cs **/*Specs.cs *Tests.cs **/*Tests.cs) }
|
16
16
|
its(:enabled) { should == false }
|
17
|
+
its(:paket_references) { should == %w(**/*paket.references) }
|
18
|
+
its(:packages) { should == [] }
|
17
19
|
end
|
18
20
|
|
19
21
|
describe 'execution' do
|
20
22
|
subject {
|
21
23
|
described_class.new do |t|
|
22
24
|
t.projects = %w(**/*.??proj)
|
23
|
-
t.references = %w(Ref
|
25
|
+
t.references = %w(Ref)
|
24
26
|
t.specs = %w(*Specs.cs **/*Specs.cs)
|
25
27
|
t.enabled = enabled
|
28
|
+
t.paket_references = %w(paket.references)
|
29
|
+
t.packages = %w(Package)
|
26
30
|
end
|
27
31
|
}
|
28
32
|
|
@@ -39,11 +43,11 @@ describe Rake::Funnel::Tasks::SideBySideSpecs do
|
|
39
43
|
|
40
44
|
it 'should use remover' do
|
41
45
|
expect(SpecsRemover).to have_received(:remove)
|
42
|
-
.with(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
.with(projects: subject.projects,
|
47
|
+
references: subject.references,
|
48
|
+
specs: subject.specs,
|
49
|
+
paket_references: subject.paket_references,
|
50
|
+
packages: subject.packages)
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
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.
|
4
|
+
version: 0.5.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Groß
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -176,8 +176,10 @@ files:
|
|
176
176
|
- spec/rake/funnel/support/specs_remover/FooSpecs.cs
|
177
177
|
- spec/rake/funnel/support/specs_remover/Sample.csproj
|
178
178
|
- spec/rake/funnel/support/specs_remover/Specs.cs
|
179
|
+
- spec/rake/funnel/support/specs_remover/paket.references
|
179
180
|
- spec/rake/funnel/support/specs_remover/subdir/BarCode.cs
|
180
181
|
- spec/rake/funnel/support/specs_remover/subdir/BarSpecs.cs
|
182
|
+
- spec/rake/funnel/support/specs_remover/subdir/foo.paket.references
|
181
183
|
- spec/rake/funnel/support/specs_remover_spec.rb
|
182
184
|
- spec/rake/funnel/support/template_engine_spec.rb
|
183
185
|
- spec/rake/funnel/support/timing/report_spec.rb
|
@@ -255,8 +257,10 @@ test_files:
|
|
255
257
|
- spec/rake/funnel/support/specs_remover/FooSpecs.cs
|
256
258
|
- spec/rake/funnel/support/specs_remover/Sample.csproj
|
257
259
|
- spec/rake/funnel/support/specs_remover/Specs.cs
|
260
|
+
- spec/rake/funnel/support/specs_remover/paket.references
|
258
261
|
- spec/rake/funnel/support/specs_remover/subdir/BarCode.cs
|
259
262
|
- spec/rake/funnel/support/specs_remover/subdir/BarSpecs.cs
|
263
|
+
- spec/rake/funnel/support/specs_remover/subdir/foo.paket.references
|
260
264
|
- spec/rake/funnel/support/specs_remover_spec.rb
|
261
265
|
- spec/rake/funnel/support/template_engine_spec.rb
|
262
266
|
- spec/rake/funnel/support/timing/report_spec.rb
|