albacore 2.1.2 → 2.2.0.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- module Albacore
4
- class UnfilledPropertyError < StandardError
5
- attr_accessor :property
6
- def initialize property, message
7
- super(message)
8
- @property = property
9
- end
10
- def message
11
- %Q{The property "#{property}"; #{message}}
12
- end
13
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Albacore
4
+ class UnfilledPropertyError < StandardError
5
+ attr_accessor :property
6
+ def initialize property, message
7
+ super(message)
8
+ @property = property
9
+ end
10
+ def message
11
+ %Q{The property "#{property}"; #{message}}
12
+ end
13
+ end
14
14
  end
@@ -1,4 +1,6 @@
1
1
  require 'albacore'
2
+ require 'net/http'
3
+ require 'uri'
2
4
 
3
5
  module Albacore
4
6
  module Ext
@@ -47,6 +49,17 @@ module Albacore
47
49
  # tell teamcity of our progress
48
50
  finish_progress p.message
49
51
  end
52
+ Albacore.subscribe :release do |r|
53
+ ::Albacore.puts 'Pinning build'
54
+ # https://stackoverflow.com/questions/12681908/is-it-possible-to-automate-the-teamcity-pin-functionality-on-a-run-custom-build
55
+ uri = URI.parse("%teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%/pin -u 'TCuser:TCpass'")
56
+ # curl -v -H "Content-Type:text/plain" -d "Deliverable" %teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%/tags -u "TCuser:TCpass"
57
+ http = Net::HTTP.new uri.host, uri.port
58
+ put = Net::HTTP::Put.new uri.request_uri
59
+ #request["Content-Type"] = "application/json"
60
+ response = http.request put
61
+ ::Albacore.puts "Done, server replied #{response.code}"
62
+ end
50
63
  end
51
64
 
52
65
  private
@@ -1,25 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- module Albacore
4
- module Facts
5
-
6
- def self.processor_count
7
- case RbConfig::CONFIG['host_os']
8
- when /darwin9/
9
- `hwprefs cpu_count`.to_i
10
- when /darwin/
11
- ((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
12
- when /linux/
13
- `cat /proc/cpuinfo | grep processor | wc -l`.to_i
14
- when /freebsd/
15
- `sysctl -n hw.ncpu`.to_i
16
- when /mswin|mingw/
17
- require 'win32ole'
18
- # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373%28v=vs.85%29.aspx
19
- wmi = WIN32OLE.connect("winmgmts://")
20
- cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
21
- cpu.to_enum.first.NumberOfLogicalProcessors
22
- end
23
- end
24
- end
25
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Albacore
4
+ module Facts
5
+ def self.processor_count
6
+ case RbConfig::CONFIG['host_os']
7
+ when /darwin9/
8
+ `hwprefs cpu_count`.to_i
9
+ when /darwin/
10
+ ((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
11
+ when /linux/
12
+ `cat /proc/cpuinfo | grep processor | wc -l`.to_i
13
+ when /freebsd/
14
+ `sysctl -n hw.ncpu`.to_i
15
+ when /mswin|mingw/
16
+ require 'win32ole'
17
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373%28v=vs.85%29.aspx
18
+ wmi = WIN32OLE.connect("winmgmts://")
19
+ cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
20
+ cpu.to_enum.first.NumberOfLogicalProcessors
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,33 +1,33 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'logger'
4
- require 'albacore/albacore_module'
5
-
6
- module Albacore
7
- module Logging
8
- def trace *str, &block
9
- ::Albacore.application.logger.debug *str, &block
10
- end
11
- def debug *str, &block
12
- ::Albacore.application.logger.debug *str, &block
13
- end
14
- def info *str, &block
15
- ::Albacore.application.logger.info *str, &block
16
- end
17
- def warn *str, &block
18
- ::Albacore.application.logger.warn *str, &block
19
- end
20
- def error *str, &block
21
- ::Albacore.application.logger.error *str, &block
22
- end
23
- def fatal *str, &block
24
- ::Albacore.application.logger.fatal *str, &block
25
- end
26
- def puts *str
27
- ::Albacore.application.puts *str
28
- end
29
- def err str
30
- ::Albacore.application.err str
31
- end
32
- end
33
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'logger'
4
+ require 'albacore/albacore_module'
5
+
6
+ module Albacore
7
+ module Logging
8
+ def trace *str, &block
9
+ ::Albacore.application.logger.debug *str, &block
10
+ end
11
+ def debug *str, &block
12
+ ::Albacore.application.logger.debug *str, &block
13
+ end
14
+ def info *str, &block
15
+ ::Albacore.application.logger.info *str, &block
16
+ end
17
+ def warn *str, &block
18
+ ::Albacore.application.logger.warn *str, &block
19
+ end
20
+ def error *str, &block
21
+ ::Albacore.application.logger.error *str, &block
22
+ end
23
+ def fatal *str, &block
24
+ ::Albacore.application.logger.fatal *str, &block
25
+ end
26
+ def puts *str
27
+ ::Albacore.application.puts *str
28
+ end
29
+ def err str
30
+ ::Albacore.application.err str
31
+ end
32
+ end
33
+ end
@@ -1,114 +1,114 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'rake'
4
- require 'pathname'
5
-
6
- require 'albacore/albacore_module'
7
- require 'albacore/logging'
8
-
9
- # module methods for handling paths
10
- module Paths
11
- extend self
12
-
13
- # returns the operating system separator character as a string
14
- def separator
15
- ::Albacore.windows? ? '\\' : '/'
16
- end
17
-
18
- # normalize the slashes of the path to what the operating system prefers
19
- def normalise_slashes path
20
- return path unless path.respond_to? :gsub
21
- raise ArgumentError, "path is nil" if path.nil?
22
- ::Rake::Win32.windows? ? path.gsub('/', '\\') : path.gsub('\\', '/')
23
- end
24
-
25
- # make a single string-command from a given executable string, by quoting each parameter
26
- # individually. You can also use Albacore::CrossPlatformCmd#system given an array
27
- # of 'stringly' things.
28
- def make_command executable, parameters
29
- raise ArgumentError, "executable is nil" if executable.nil?
30
- params = parameters.collect{|p| '"' + p + '"'}.join ' '
31
- exe = normalise_slashes executable
32
- %Q{"#{exe}" #{params}}
33
- end
34
-
35
- # normalise slashes in an executable/parameters combo
36
- def normalise executable, parameters
37
- raise ArgumentError, "executable is nil" if executable.nil?
38
- parameters = parameters.collect{ |p| (p === String) ? p : p.to_s }
39
- exe = normalise_slashes executable
40
- ["#{exe}", parameters]
41
- end
42
-
43
- # join an Enumerable of paths by normalising slashes on each of the segments, then
44
- # joining them
45
- def join *paths
46
- raise ArgumentError, 'no paths given' if paths.nil?
47
-
48
- joined = paths[1..-1].inject(PathnameWrap.new(normalise_slashes(paths[0]))) do |s, t|
49
- s + normalise_slashes(t)
50
- end
51
-
52
- PathnameWrap.new joined
53
- end
54
-
55
- # join an Enumerable of paths by normalising slashes on each of the segments, then
56
- # joining them, returning a string
57
- def join_str *paths
58
- join(*paths).to_s
59
- end
60
-
61
- class PathnameWrap
62
- include ::Albacore::Logging
63
-
64
- # inner pathname
65
- attr_reader :inner
66
-
67
- # string pathname
68
- attr_reader :p
69
-
70
- def initialize p
71
- raise ArgumentError, 'p is nil' if p.nil?
72
- @p = (p.is_a?(String) ? p : p.to_s)
73
- @inner = Pathname.new @p
74
- end
75
-
76
- def parent
77
- PathnameWrap.new(inner.parent)
78
- end
79
-
80
- def +(other)
81
- join other
82
- end
83
-
84
- def join *other
85
- args = other.collect { |x| x.is_a?(PathnameWrap) ? x.p : x }
86
- PathnameWrap.new(inner.join(*args))
87
- end
88
-
89
- def to_s
90
- ::Albacore::Paths.normalise_slashes p
91
- end
92
-
93
- def ==(o)
94
- trace { "#{self} ==( #{o} )" }
95
- (o.respond_to? :p) && o.p == p
96
- end
97
-
98
- alias_method :eql?, :==
99
-
100
- def hash
101
- p.hash
102
- end
103
-
104
- # unwraps the pathname; defaults all return forward slashes
105
- def as_unix
106
- to_s.gsub /\\/, '/'
107
- end
108
- end
109
- end
110
-
111
- # Paths should be accessible if you require this file
112
- module Albacore::Paths
113
- self.extend ::Paths
114
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'rake'
4
+ require 'pathname'
5
+
6
+ require 'albacore/albacore_module'
7
+ require 'albacore/logging'
8
+
9
+ # module methods for handling paths
10
+ module Paths
11
+ extend self
12
+
13
+ # returns the operating system separator character as a string
14
+ def separator
15
+ ::Albacore.windows? ? '\\' : '/'
16
+ end
17
+
18
+ # normalize the slashes of the path to what the operating system prefers
19
+ def normalise_slashes path
20
+ return path unless path.respond_to? :gsub
21
+ raise ArgumentError, "path is nil" if path.nil?
22
+ ::Rake::Win32.windows? ? path.gsub('/', '\\') : path.gsub('\\', '/')
23
+ end
24
+
25
+ # make a single string-command from a given executable string, by quoting each parameter
26
+ # individually. You can also use Albacore::CrossPlatformCmd#system given an array
27
+ # of 'stringly' things.
28
+ def make_command executable, parameters
29
+ raise ArgumentError, "executable is nil" if executable.nil?
30
+ params = parameters.collect{|p| '"' + p + '"'}.join ' '
31
+ exe = normalise_slashes executable
32
+ %Q{"#{exe}" #{params}}
33
+ end
34
+
35
+ # normalise slashes in an executable/parameters combo
36
+ def normalise executable, parameters
37
+ raise ArgumentError, "executable is nil" if executable.nil?
38
+ parameters = parameters.collect{ |p| (p === String) ? p : p.to_s }
39
+ exe = normalise_slashes executable
40
+ ["#{exe}", parameters]
41
+ end
42
+
43
+ # join an Enumerable of paths by normalising slashes on each of the segments, then
44
+ # joining them
45
+ def join *paths
46
+ raise ArgumentError, 'no paths given' if paths.nil?
47
+
48
+ joined = paths[1..-1].inject(PathnameWrap.new(normalise_slashes(paths[0]))) do |s, t|
49
+ s + normalise_slashes(t)
50
+ end
51
+
52
+ PathnameWrap.new joined
53
+ end
54
+
55
+ # join an Enumerable of paths by normalising slashes on each of the segments, then
56
+ # joining them, returning a string
57
+ def join_str *paths
58
+ join(*paths).to_s
59
+ end
60
+
61
+ class PathnameWrap
62
+ include ::Albacore::Logging
63
+
64
+ # inner pathname
65
+ attr_reader :inner
66
+
67
+ # string pathname
68
+ attr_reader :p
69
+
70
+ def initialize p
71
+ raise ArgumentError, 'p is nil' if p.nil?
72
+ @p = (p.is_a?(String) ? p : p.to_s)
73
+ @inner = Pathname.new @p
74
+ end
75
+
76
+ def parent
77
+ PathnameWrap.new(inner.parent)
78
+ end
79
+
80
+ def +(other)
81
+ join other
82
+ end
83
+
84
+ def join *other
85
+ args = other.collect { |x| x.is_a?(PathnameWrap) ? x.p : x }
86
+ PathnameWrap.new(inner.join(*args))
87
+ end
88
+
89
+ def to_s
90
+ ::Albacore::Paths.normalise_slashes p
91
+ end
92
+
93
+ def ==(o)
94
+ trace { "#{self} ==( #{o} )" }
95
+ (o.respond_to? :p) && o.p == p
96
+ end
97
+
98
+ alias_method :eql?, :==
99
+
100
+ def hash
101
+ p.hash
102
+ end
103
+
104
+ # unwraps the pathname; defaults all return forward slashes
105
+ def as_unix
106
+ to_s.gsub /\\/, '/'
107
+ end
108
+ end
109
+ end
110
+
111
+ # Paths should be accessible if you require this file
112
+ module Albacore::Paths
113
+ self.extend ::Paths
114
+ end
@@ -15,7 +15,7 @@ module Albacore
15
15
  include Logging
16
16
 
17
17
  attr_reader :proj_path_base, :proj_filename, :proj_xml_node
18
-
18
+
19
19
  def initialize proj_path
20
20
  raise ArgumentError, 'project path does not exist' unless File.exists? proj_path.to_s
21
21
  proj_path = proj_path.to_s unless proj_path.is_a? String
@@ -23,7 +23,7 @@ module Albacore
23
23
  @proj_path_base, @proj_filename = File.split proj_path
24
24
  sanity_checks
25
25
  end
26
-
26
+
27
27
  # get the project name specified in the project file
28
28
  def name
29
29
  prop = read_property 'Name' || asmname
@@ -58,7 +58,7 @@ module Albacore
58
58
  system @executable, @parameters, :work_dir => @work_dir, :output => false
59
59
  end
60
60
  end
61
-
61
+
62
62
  # Public: Configure 'nuget.exe install' -- nuget restore.
63
63
  #
64
64
  # work_dir - optional
@@ -71,6 +71,7 @@ module Albacore
71
71
 
72
72
  OFFICIAL_REPO = 'https://nuget.org/api/v2/'
73
73
 
74
+ # Create a new Config object
74
75
  def initialize
75
76
  @include_official = false
76
77
  @list_spec = File.join '**', 'packages.config'
@@ -78,9 +79,22 @@ module Albacore
78
79
 
79
80
  # the output directory passed to nuget when restoring the nugets
80
81
  attr_writer :out
81
-
82
+
82
83
  # nuget source, when other than MSFT source
83
- attr_accessor :source
84
+ def source
85
+ @source
86
+ end
87
+
88
+ # set the nuget source
89
+ def source= val
90
+ if val.is_a? String
91
+ debug { 'you used a plain string as source, naming it after its md5 digest' }
92
+ md5 = Digest::MD5.hexdigest val
93
+ @source = OpenStruct.new(:name => md5, :uri => val)
94
+ else
95
+ @source = val
96
+ end
97
+ end
84
98
 
85
99
  # specifies the list specification to load 'packages.config' files
86
100
  # from.
@@ -105,7 +119,7 @@ module Albacore
105
119
  def exclude_version
106
120
  add_parameter "-ExcludeVersion"
107
121
  end
108
-
122
+
109
123
  def has_credentials?
110
124
  username && password && source
111
125
  end