Class: Albacore::NugetsRestore::Config
- Inherits:
-
Object
- Object
- Albacore::NugetsRestore::Config
- Includes:
- CmdConfig, Logging, Albacore::NugetsAuthentication
- Defined in:
- lib/albacore/task_types/nugets_restore.rb
Overview
Public: Configure ‘nuget.exe install’ – nuget restore.
work_dir - optional exe - required NuGet.exe path out - required location of ‘packages’ folder
Constant Summary collapse
- OFFICIAL_REPO =
'https://nuget.org/api/v2/'
Instance Attribute Summary collapse
-
#include_official ⇒ Object
whether to include the official defaults to true.
-
#list_spec ⇒ Object
specifies the list specification to load ‘packages.config’ files from.
-
#out ⇒ Object
writeonly
the output directory passed to nuget when restoring the nugets.
Attributes included from Albacore::NugetsAuthentication
Instance Method Summary collapse
- #ensure_authentication! ⇒ Object
- #exclude_version ⇒ Object
- #has_credentials? ⇒ Boolean
-
#initialize ⇒ Config
constructor
Create a new Config object.
- #no_cache ⇒ Object
- #nuget_gem_exe ⇒ Object
- #opts_for_pkgcfg(pkg) ⇒ Object
- #packages ⇒ Object
-
#source ⇒ Object
nuget source, when other than MSFT source.
-
#source=(val) ⇒ Object
set the nuget source.
Methods included from Logging
#debug, #err, #error, #fatal, #info, #puts, #trace, #warn
Methods included from CmdConfig
Methods included from ConfigDSL
#attr_path, #attr_path_accessor
Constructor Details
#initialize ⇒ Config
Create a new Config object
76 77 78 79 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 76 def initialize @include_official = false @list_spec = File.join '**', 'packages.config' end |
Instance Attribute Details
#include_official ⇒ Object
whether to include the official defaults to true
118 119 120 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 118 def include_official @include_official end |
#list_spec ⇒ Object
specifies the list specification to load ‘packages.config’ files from.
e.g. ‘**/packages.config’ on *nix.
104 105 106 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 104 def list_spec @list_spec end |
#out=(value) ⇒ Object (writeonly)
the output directory passed to nuget when restoring the nugets
82 83 84 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 82 def out=(value) @out = value end |
Instance Method Details
#ensure_authentication! ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 132 def ensure_authentication! return unless has_credentials? remove = RemoveSourceCmd.new exe, source readd = AddSourceCmd.new exe, source, username, password remove.execute readd.execute end |
#exclude_version ⇒ Object
120 121 122 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 120 def exclude_version add_parameter "-ExcludeVersion" end |
#has_credentials? ⇒ Boolean
128 129 130 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 128 def has_credentials? username && password && source end |
#no_cache ⇒ Object
124 125 126 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 124 def no_cache add_parameter "-NoCache" end |
#nuget_gem_exe ⇒ Object
140 141 142 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 140 def nuget_gem_exe @exe = Albacore::Nugets::find_nuget_gem_exe end |
#opts_for_pkgcfg(pkg) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 144 def opts_for_pkgcfg pkg pars = parameters.to_a debug "include_official nuget repo: #{include_official}" pars << %W[-source #{OFFICIAL_REPO}] if include_official map = Map.new({ :pkgcfg => Albacore::Paths.normalise_slashes(pkg), :out => @out, :parameters => pars }) if has_credentials? map.set :username, username map.set :password, password map.set :source, source end map end |
#packages ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 106 def packages # it seems FileList doesn't care about the curr dir in_work_dir do FileList[ Dir.glob(list_spec, File::FNM_DOTMATCH). reject { |a| a =~ /^\.{1,2}$/ } ] end end |
#source ⇒ Object
nuget source, when other than MSFT source
85 86 87 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 85 def source @source end |
#source=(val) ⇒ Object
set the nuget source
90 91 92 93 94 95 96 97 98 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 90 def source= val if val.is_a? String debug { 'you used a plain string as source, naming it after its md5 digest' } md5 = Digest::MD5.hexdigest val @source = OpenStruct.new(:name => md5, :uri => val) else @source = val end end |