albacore 2.1.2 → 2.2.0.pre.beta

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.
@@ -1,82 +1,82 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'nokogiri'
4
- require 'pathname'
5
- require 'rake'
6
- require 'albacore/logging'
7
- require 'albacore/project'
8
- require 'albacore/package'
9
- require 'albacore/package_repo'
10
-
11
- module Albacore::Tools
12
-
13
- # a tuple of a package and a ref
14
- class MatchedRef
15
- attr_accessor :package, :ref
16
- def initialize package, ref
17
- @package, @ref = package, ref
18
- end
19
- end
20
-
21
- module RestoreHintPaths
22
- class Config
23
- attr_accessor :asmname_to_package
24
- attr_accessor :lang
25
- attr_accessor :projs, :dry_run
26
- def initialize
27
- @asmname_to_package = {}
28
- @lang = 'fs'
29
- end
30
- end
31
- class Task
32
- include Logging
33
- def initialize config
34
- @config = config
35
- end
36
- def execute
37
- ps = map_file_list(@config.projs) || find_projs_in_need(@config.lang)
38
- ps.each do |proj|
39
- info "fixing #{proj}"
40
- fix_refs proj, @config.asmname_to_package
41
- info "saving #{proj}"
42
- proj.save unless @config.dry_run
43
- end
44
- end
45
-
46
- private
47
- def find_projs_in_need ext
48
- map_file_list FileList["./src/**/*.#{ext}proj"]
49
- end
50
- def map_file_list fl
51
- return nil if fl.nil?
52
- fl.collect{ |path| Project.new(path) }.
53
- keep_if{ |fp| fp.has_faulty_refs? && fp.has_packages_config? }
54
- end
55
- def matched_refs refs, packages, asmname_to_package = {}
56
- refs.collect { |ref|
57
- ref_include_id = asmname_to_package.fetch(ref['Include'].split(',')[0]) { |k| k }
58
- found_pkg = packages[ref_include_id]
59
- debug "ref[Include] = #{ref_include_id}, package: #{found_pkg}" unless found_pkg.nil?
60
- debug "NOMATCH: #{ref_include_id}" if found_pkg.nil?
61
- found_pkg.nil? ? nil : MatchedRef.new(found_pkg, ref)
62
- }.keep_if { |match| not match.nil? }
63
- end
64
-
65
- def fix_refs p, asmname_to_package = {}
66
- packages = Hash[p.find_packages.collect { |v| [v.id, v] }]
67
- trace "packages: #{packages}"
68
- matches = matched_refs p.faulty_refs, packages, asmname_to_package
69
- trace "matches: #{matches}"
70
- matches.each{ |match|
71
- dll_path = Pathname.new match.package.path
72
- proj_path = Pathname.new p.proj_path_base
73
- hint_path = Nokogiri::XML::Node.new "HintPath", p.proj_xml_node
74
- hint_path.content = dll_path.relative_path_from proj_path
75
- match.ref << hint_path
76
- debug "For #{p.asmname} => hint_path: #{hint_path}"
77
- }
78
- trace p.proj_xml_node
79
- end
80
- end
81
- end
82
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'nokogiri'
4
+ require 'pathname'
5
+ require 'rake'
6
+ require 'albacore/logging'
7
+ require 'albacore/project'
8
+ require 'albacore/package'
9
+ require 'albacore/package_repo'
10
+
11
+ module Albacore::Tools
12
+
13
+ # a tuple of a package and a ref
14
+ class MatchedRef
15
+ attr_accessor :package, :ref
16
+ def initialize package, ref
17
+ @package, @ref = package, ref
18
+ end
19
+ end
20
+
21
+ module RestoreHintPaths
22
+ class Config
23
+ attr_accessor :asmname_to_package
24
+ attr_accessor :lang
25
+ attr_accessor :projs, :dry_run
26
+ def initialize
27
+ @asmname_to_package = {}
28
+ @lang = 'fs'
29
+ end
30
+ end
31
+ class Task
32
+ include Logging
33
+ def initialize config
34
+ @config = config
35
+ end
36
+ def execute
37
+ ps = map_file_list(@config.projs) || find_projs_in_need(@config.lang)
38
+ ps.each do |proj|
39
+ info "fixing #{proj}"
40
+ fix_refs proj, @config.asmname_to_package
41
+ info "saving #{proj}"
42
+ proj.save unless @config.dry_run
43
+ end
44
+ end
45
+
46
+ private
47
+ def find_projs_in_need ext
48
+ map_file_list FileList["./src/**/*.#{ext}proj"]
49
+ end
50
+ def map_file_list fl
51
+ return nil if fl.nil?
52
+ fl.collect{ |path| Project.new(path) }.
53
+ keep_if{ |fp| fp.has_faulty_refs? && fp.has_packages_config? }
54
+ end
55
+ def matched_refs refs, packages, asmname_to_package = {}
56
+ refs.collect { |ref|
57
+ ref_include_id = asmname_to_package.fetch(ref['Include'].split(',')[0]) { |k| k }
58
+ found_pkg = packages[ref_include_id]
59
+ debug "ref[Include] = #{ref_include_id}, package: #{found_pkg}" unless found_pkg.nil?
60
+ debug "NOMATCH: #{ref_include_id}" if found_pkg.nil?
61
+ found_pkg.nil? ? nil : MatchedRef.new(found_pkg, ref)
62
+ }.keep_if { |match| not match.nil? }
63
+ end
64
+
65
+ def fix_refs p, asmname_to_package = {}
66
+ packages = Hash[p.find_packages.collect { |v| [v.id, v] }]
67
+ trace "packages: #{packages}"
68
+ matches = matched_refs p.faulty_refs, packages, asmname_to_package
69
+ trace "matches: #{matches}"
70
+ matches.each{ |match|
71
+ dll_path = Pathname.new match.package.path
72
+ proj_path = Pathname.new p.proj_path_base
73
+ hint_path = Nokogiri::XML::Node.new "HintPath", p.proj_xml_node
74
+ hint_path.content = dll_path.relative_path_from proj_path
75
+ match.ref << hint_path
76
+ debug "For #{p.asmname} => hint_path: #{hint_path}"
77
+ }
78
+ trace p.proj_xml_node
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,61 +1,61 @@
1
- # encoding: utf-8
2
- require 'zip'
3
- require "albacore"
4
-
5
- # https://github.com/aussiegeek/rubyzip/blob/master/samples/example_recursive.rb
6
- # This is a simple example which uses rubyzip to
7
- # recursively generate a zip file from the contents of
8
- # a specified directory. The directory itself is not
9
- # included in the archive, rather just its contents.
10
- #
11
- # Usage:
12
- # dir_to_zip = "/tmp/input"
13
- # out_file = "/tmp/out.zip"
14
- # zf = Zippy.new dir_to_zip, out_file
15
- # zf.write
16
- #
17
- # Or:
18
- # z = Zippy.new(directory_to_zip, output_file) { |f| f.include? 'html' }
19
- # z.write
20
- class Zippy
21
-
22
- # Initialize with the directory to zip and the location of the output archive.
23
- #
24
- # @param [String] input_dir The location to zip as a file system relative or
25
- # absolute path
26
- #
27
- # @param [String] out_file The path of the output zip file that is generated.
28
- # @param [Block] filter An optional block with a filter that is to return true
29
- # if the file is to be added.
30
- def initialize input_dir, out_file, &filter
31
- @input_dir = input_dir.
32
- gsub(/[\/\\]$/, '').
33
- gsub(/\\/, '/')
34
- @out_file = out_file
35
- @filter = block_given? ? filter : lambda { |f| true }
36
- end
37
-
38
- # Zips the input directory.
39
- def write
40
- FileUtils.rm @out_file if File.exists? @out_file
41
- in_progress "Writing archive #{@out_file} from #{@input_dir}" do
42
- Zip::File.open @out_file, Zip::File::CREATE do |zipfile|
43
- Dir["#{@input_dir}/**/**"].reject{ |f| f == @out_file || !@filter.call(f) }.each do |file|
44
- progress "deflating #{file}"
45
- zipfile.add(file.sub(@input_dir + '/', ''), file)
46
- end
47
- end
48
- end
49
- end
50
-
51
- private
52
- def in_progress msg, &block
53
- Albacore.publish :start_progress, OpenStruct.new(:message => msg)
54
- yield
55
- Albacore.publish :finish_progress, OpenStruct.new(:message => msg)
56
- end
57
-
58
- def progress msg
59
- Albacore.publish :progress, OpenStruct.new(:message => msg)
60
- end
61
- end
1
+ # encoding: utf-8
2
+ require 'zip'
3
+ require "albacore"
4
+
5
+ # https://github.com/aussiegeek/rubyzip/blob/master/samples/example_recursive.rb
6
+ # This is a simple example which uses rubyzip to
7
+ # recursively generate a zip file from the contents of
8
+ # a specified directory. The directory itself is not
9
+ # included in the archive, rather just its contents.
10
+ #
11
+ # Usage:
12
+ # dir_to_zip = "/tmp/input"
13
+ # out_file = "/tmp/out.zip"
14
+ # zf = Zippy.new dir_to_zip, out_file
15
+ # zf.write
16
+ #
17
+ # Or:
18
+ # z = Zippy.new(directory_to_zip, output_file) { |f| f.include? 'html' }
19
+ # z.write
20
+ class Zippy
21
+
22
+ # Initialize with the directory to zip and the location of the output archive.
23
+ #
24
+ # @param [String] input_dir The location to zip as a file system relative or
25
+ # absolute path
26
+ #
27
+ # @param [String] out_file The path of the output zip file that is generated.
28
+ # @param [Block] filter An optional block with a filter that is to return true
29
+ # if the file is to be added.
30
+ def initialize input_dir, out_file, &filter
31
+ @input_dir = input_dir.
32
+ gsub(/[\/\\]$/, '').
33
+ gsub(/\\/, '/')
34
+ @out_file = out_file
35
+ @filter = block_given? ? filter : lambda { |f| true }
36
+ end
37
+
38
+ # Zips the input directory.
39
+ def write
40
+ FileUtils.rm @out_file if File.exists? @out_file
41
+ in_progress "Writing archive #{@out_file} from #{@input_dir}" do
42
+ Zip::File.open @out_file, Zip::File::CREATE do |zipfile|
43
+ Dir["#{@input_dir}/**/**"].reject{ |f| f == @out_file || !@filter.call(f) }.each do |file|
44
+ progress "deflating #{file}"
45
+ zipfile.add(file.sub(@input_dir + '/', ''), file)
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ private
52
+ def in_progress msg, &block
53
+ Albacore.publish :start_progress, OpenStruct.new(:message => msg)
54
+ yield
55
+ Albacore.publish :finish_progress, OpenStruct.new(:message => msg)
56
+ end
57
+
58
+ def progress msg
59
+ Albacore.publish :progress, OpenStruct.new(:message => msg)
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module Albacore
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2.0-beta"
3
3
  end
@@ -14,6 +14,21 @@ shared_context 'cmd context' do
14
14
  subject { cmd.execute ; cmd.mono_parameters }
15
15
  end
16
16
 
17
+ describe Albacore::NugetsRestore::Config, 'when setting #source' do
18
+ it 'should allow setting a string' do
19
+ subject.source = 'hello'
20
+ expect(subject.source).not_to be_a String
21
+ expect(subject.source).to be_a OpenStruct
22
+ expect(subject.source.name).to eq(Digest::MD5.hexdigest('hello'))
23
+ end
24
+ it 'should allow setting an OpenStruct' do
25
+ subject.source = OpenStruct.new :name => 'a', :uri => 'https://example.com/nugetfeed.svc'
26
+ expect(subject.source).not_to be_a String
27
+ expect(subject.source).to be_a OpenStruct
28
+ expect(subject.source.name).to eq 'a'
29
+ expect(subject.source.uri).to eq 'https://example.com/nugetfeed.svc'
30
+ end
31
+ end
17
32
 
18
33
  describe Albacore::NugetsRestore::RemoveSourceCmd, 'when calling #execute should remove source' do
19
34
  let(:cmd) { Albacore::NugetsRestore::RemoveSourceCmd.new 'nuget.exe', hafsrc }
@@ -32,19 +47,18 @@ describe Albacore::NugetsRestore::AddSourceCmd, 'when calling #execute should re
32
47
  end
33
48
 
34
49
  describe Albacore::NugetsRestore::Cmd, 'when calling #execute with specific source' do
35
-
36
- let (:cmd) {
50
+ let (:cmd) do
37
51
  cfg = Albacore::NugetsRestore::Config.new
38
52
  cfg.out = 'src/packages'
39
53
  cfg.add_parameter '-Source'
40
54
  cfg.add_parameter 'http://localhost:8081'
41
55
 
42
56
  cmd = Albacore::NugetsRestore::Cmd.new nil, 'NuGet.exe', cfg.opts_for_pkgcfg('src/Proj/packages.config')
43
- }
57
+ end
44
58
 
45
- let (:path) {
59
+ let (:path) do
46
60
  Albacore::Paths.normalise_slashes('src/Proj/packages.config')
47
- }
61
+ end
48
62
 
49
63
  include_context 'cmd context'
50
64
 
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.1.2
4
+ version: 2.2.0.pre.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Feldt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-08 00:00:00.000000000 Z
12
+ date: 2014-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -162,6 +162,7 @@ files:
162
162
  - lib/albacore/tasks/README.md
163
163
  - lib/albacore/tasks/albasemver.rb
164
164
  - lib/albacore/tasks/projectlint.rb
165
+ - lib/albacore/tasks/release.rb
165
166
  - lib/albacore/tasks/versionizer.rb
166
167
  - lib/albacore/tools.rb
167
168
  - lib/albacore/tools/fluent_migrator.rb
@@ -382,9 +383,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
382
383
  version: '0'
383
384
  required_rubygems_version: !ruby/object:Gem::Requirement
384
385
  requirements:
385
- - - ">="
386
+ - - ">"
386
387
  - !ruby/object:Gem::Version
387
- version: '0'
388
+ version: 1.3.1
388
389
  requirements: []
389
390
  rubyforge_project: albacore
390
391
  rubygems_version: 2.2.2