albacore 2.3.10 → 2.3.11

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: 17edbc6d61873f582e9d6444f4756371625b3d58
4
- data.tar.gz: ee2a86b4312bfdded0b1d34c199877069e2d7544
3
+ metadata.gz: a5477545e0039f685becc960210d322ca80f7533
4
+ data.tar.gz: b84c0d215e55a4186da09026a78864c2c3ced25a
5
5
  SHA512:
6
- metadata.gz: f7a9b1c50ddb9265d1111d6d4fc5796cc50836b747ffc831a55dd3260dfc19e5743c3a6bc5327ef6493b4f09a9d7a340e99579c6f162fecfbb9adfb8d5f50c4f
7
- data.tar.gz: 076826fc099708ab887ea1bb01ac1722bacbcf7cf2229026ed5d7707276b411654082a506555a4e9272fca3719c1af27bee11ef1043e15193d50e9278008b08e
6
+ metadata.gz: e2a7b9b32e5e1c3dfe12fc624245e325871b26f5d0231387db4d08d97651bb1c64a0875409555dcff861950553ce8492d206064fcd2e6e650a8fd87776ca1275
7
+ data.tar.gz: a80530c23639b263f1a5ec5e0257e12492305bd6d55275439a2cb4668d350fe1bef058707ec1b6bd48a46cc0d6f759b578aaad80ccbacf68a9d2d815adad5409
@@ -54,6 +54,11 @@ module Albacore
54
54
  read_property 'AssemblyName'
55
55
  end
56
56
 
57
+ # Get the root namespace of the project
58
+ def namespace
59
+ read_property 'RootNamespace'
60
+ end
61
+
57
62
  # gets the version from the project file
58
63
  def version
59
64
  read_property 'Version'
@@ -18,10 +18,19 @@ module Albacore
18
18
  # list of xxproj files to iterate over
19
19
  attr_writer :files
20
20
 
21
+ def initialize
22
+ @usings = []
23
+ end
24
+
21
25
  def attributes attrs
22
26
  @attributes = attrs
23
27
  end
24
28
 
29
+ def using ns
30
+ debug { "adding namespace #{ns} [Asmver::MultipleFilesConfig using]" }
31
+ @usings << ns
32
+ end
33
+
25
34
  # block should have signature: Project -> AsmVer::Config -> AsmVer::Config
26
35
  # because you can use this block to change the configuration generated
27
36
  def handle_config &block
@@ -42,11 +51,16 @@ module Albacore
42
51
  file_path = "#{proj.proj_path_base}/AssemblyVersionInfo.#{ext}"
43
52
  cfg = Albacore::Asmver::Config.new file_path, proj.asmname, attrs
44
53
  cfg = @handle_config.call(proj, cfg) if @handle_config
54
+ cfg.usings = @usings.clone
45
55
  cfg
46
56
  }
47
57
  end
48
58
  end
49
59
 
60
+ # Raised when the configuration is missing where to write the file.
61
+ class MissingOutputError < StandardError
62
+ end
63
+
50
64
  class Config
51
65
  include CmdConfig
52
66
  self.extend ConfigDSL
@@ -58,11 +72,15 @@ module Albacore
58
72
  attr_accessor :namespace
59
73
 
60
74
  # (optional) output stream
61
- attr_writer :out
75
+ attr_accessor :out
76
+
77
+ # the array-like thing of using namespaces
78
+ attr_accessor :usings
62
79
 
63
80
  # creates a new config with some pre-existing data
64
81
  def initialize file_path = nil, namespace = nil, attributes = nil
65
82
  @file_path, @namespace, @attributes = file_path, namespace, attributes
83
+ @usings = []
66
84
  end
67
85
 
68
86
  # Call with to get the opportunity to change the attributes hash
@@ -75,15 +93,21 @@ module Albacore
75
93
  @attributes = attrs
76
94
  end
77
95
 
96
+ def using ns
97
+ debug { "adding namespace #{ns} [Asmver::Config using]" }
98
+ usings << ns
99
+ end
100
+
78
101
  def opts
79
- raise Error, "#file_path is not set" unless (file_path or out)
102
+ raise MissingOutputError, "#file_path or #out is not set" unless (file_path or out)
80
103
  ns = @namespace || '' # defaults to empty namespace if not set.
81
104
  lang = lang_for file_path
82
105
  m = Map.new attributes: @attributes,
83
106
  namespace: ns,
84
107
  file_path: @file_path,
85
- language: lang
86
- m[:out] = @out if @out
108
+ language: lang,
109
+ usings: usings
110
+ m[:out] = out if out
87
111
  m
88
112
  end
89
113
 
@@ -30,8 +30,8 @@ System.Runtime.InteropServices|
30
30
  # after namespace My.Ns.Here
31
31
  out << "\n"
32
32
 
33
- # open all namespaces to use .Net attributes
34
- @opts.get(:usings) { DEFAULT_USINGS }.each do |ns|
33
+ # open all namespaces to use .Net attributes, concat with your custom attrs
34
+ [ DEFAULT_USINGS, (@opts.get(:usings) || [])].flatten.each do |ns|
35
35
  out << @engine.build_using_statement(ns)
36
36
  out << "\n"
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module Albacore
2
- VERSION = "2.3.10"
2
+ VERSION = "2.3.11"
3
3
  end
@@ -1,8 +1,36 @@
1
+ require 'albacore/task_types/asmver'
1
2
  require 'albacore/task_types/asmver/engine'
2
3
  require 'albacore/task_types/asmver/file_generator'
3
4
 
4
5
  include Albacore::Asmver
5
6
 
7
+ describe Albacore::Asmver::Config, 'when misconfigured' do
8
+ subject do
9
+ Albacore::Asmver::Config.new
10
+ end
11
+ it 'should throw MissingOutputError by default' do
12
+ expect(lambda { subject.opts }).to raise_error MissingOutputError
13
+ end
14
+ end
15
+
16
+ describe Albacore::Asmver::Config do
17
+ subject do
18
+ Albacore::Asmver::Config.new 'A.fs'
19
+ end
20
+
21
+ it 'should have a namespace that\' RW' do
22
+ subject.namespace = 'smirk'
23
+ subject.namespace = subject.namespace + 'smirk'
24
+ expect(subject.namespace).to eq 'smirksmirk'
25
+ end
26
+
27
+ it 'can add a #using' do
28
+ subject.out = StringIO.new
29
+ subject.using 'System'
30
+ expect(subject.opts.get(:usings)).to include('System')
31
+ end
32
+ end
33
+
6
34
  %w|Fs Vb Cpp Cs|.each do |lang|
7
35
  require "albacore/task_types/asmver/#{lang.downcase}"
8
36
 
@@ -152,42 +180,82 @@ describe FileGenerator, 'when generating F# file' do
152
180
  let :generated do
153
181
  @out.string
154
182
  end
183
+
155
184
  it 'should include namespace' do
156
- generated.should =~ /namespace My\.Fs\.Ns(\r\n?|\n)/
185
+ expect(generated).to match /namespace My\.Fs\.Ns(\r\n?|\n)/
157
186
  end
187
+
158
188
  it 'should open System.Reflection' do
159
- generated.should =~ /open System\.Reflection/
189
+ expect(generated).to match /open System\.Reflection/
160
190
  end
191
+
161
192
  it 'should open System.Runtime.CompilerServices' do
162
- generated.should =~ /open System\.Runtime\.CompilerServices/
193
+ expect(generated).to match /open System\.Runtime\.CompilerServices/
163
194
  end
195
+
164
196
  it 'should open System.Runtime.InteropServices' do
165
- generated.should =~ /open System\.Runtime\.InteropServices/
197
+ expect(generated).to match /open System\.Runtime\.InteropServices/
166
198
  end
199
+
167
200
  it 'should generate the ComVisible attribute' do
168
- generated.should include('[<assembly: ComVisible(false)>]')
201
+ expect(generated).to include('[<assembly: ComVisible(false)>]')
169
202
  end
203
+
170
204
  it 'should generate the AssemblyTitle attribute' do
171
- generated.should include('[<assembly: AssemblyTitle("My.Ns")>]')
205
+ expect(generated).to include('[<assembly: AssemblyTitle("My.Ns")>]')
172
206
  end
207
+
173
208
  it 'should generate the AssemblyVersion attribute' do
174
- generated.should include('[<assembly: AssemblyVersion("0.1.2")>]')
209
+ expect(generated).to include('[<assembly: AssemblyVersion("0.1.2")>]')
175
210
  end
211
+
176
212
  it 'should generate the CustomThing attribute' do
177
- generated.should include('[<assembly: CustomThing("a", "b", "c")>]')
213
+ expect(generated).to include('[<assembly: CustomThing("a", "b", "c")>]')
178
214
  end
215
+
179
216
  it 'should generate the NamedThing attribute' do
180
- generated.should include('[<assembly: NamedThing(b = 3, c = "hi")>]')
217
+ expect(generated).to include('[<assembly: NamedThing(b = 3, c = "hi")>]')
181
218
  end
219
+
182
220
  it 'should generate the CLSCompliant attribute' do
183
- generated.should include('[<assembly: CLSCompliant(true)>]')
221
+ expect(generated).to include('[<assembly: CLSCompliant(true)>]')
184
222
  end
223
+
185
224
  it 'should end with ()\n' do
186
- generated.should =~ /\(\)(\r\n?|\n)$/m
225
+ expect(generated).to match /\(\)(\r\n?|\n)$/m
187
226
  end
188
227
  end
189
228
 
190
- describe FileGenerator do
229
+ describe FileGenerator, 'when given extra "usings"' do
230
+ before :all do
231
+ @out = StringIO.new
232
+ subject = FileGenerator.new Fs.new, '', usings: ['System']
233
+ subject.generate @out, assembly_title: 'My.Asm'
234
+ end
235
+
236
+ let :generated do
237
+ @out.string
238
+ end
239
+
240
+ it 'should open System' do
241
+ expect(generated).to match /open System/
242
+ end
243
+
244
+ it 'should open System.Reflection' do
245
+ expect(generated).to match /open System\.Reflection/
246
+ end
247
+
248
+ it 'should open System.Runtime.CompilerServices' do
249
+ expect(generated).to match /open System\.Runtime\.CompilerServices/
250
+ end
251
+
252
+ it 'should open System.Runtime.InteropServices' do
253
+ expect(generated).to match /open System\.Runtime\.InteropServices/
254
+ end
255
+
256
+ end
257
+
258
+ describe FileGenerator, 'when it should generate NO NAMESPACE' do
191
259
  before :all do
192
260
  @out = StringIO.new
193
261
  subject = FileGenerator.new(Cs.new, '', {})
@@ -202,6 +270,6 @@ describe FileGenerator do
202
270
  @out.string
203
271
  end
204
272
  it 'should not include \'namespace\'' do
205
- generated.should_not include('namespace')
273
+ expect(generated).to_not include('namespace')
206
274
  end
207
275
  end
@@ -70,25 +70,28 @@ describe Albacore::Project, "when reading project file" do
70
70
 
71
71
  describe 'public API' do
72
72
  it do
73
- subject.should respond_to(:name)
73
+ expect(subject).to respond_to :name
74
74
  end
75
75
  it do
76
- subject.should respond_to(:asmname)
76
+ expect(subject).to respond_to :asmname
77
77
  end
78
78
  it do
79
- subject.should respond_to(:version)
79
+ expect(subject).to respond_to :namespace
80
80
  end
81
81
  it do
82
- subject.should respond_to(:authors)
82
+ expect(subject).to respond_to :version
83
+ end
84
+ it do
85
+ expect(subject).to respond_to :authors
83
86
  end
84
87
  it 'should have five referenced assemblies' do
85
- subject.find_refs.length.should eq(5)
88
+ expect(subject.find_refs.length).to eq 5
86
89
  end
87
90
  it 'knows about referenced packages' do
88
- subject.should respond_to(:declared_packages)
91
+ expect(subject).to respond_to :declared_packages
89
92
  end
90
93
  it 'knows about referenced projects' do
91
- subject.should respond_to(:declared_projects)
94
+ expect(subject).to respond_to :declared_projects
92
95
  end
93
96
  it 'should have three referenced packages' do
94
97
  expected = %w|Intelliplan.Util Newtonsoft.Json NLog|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: albacore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.10
4
+ version: 2.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Feldt