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.
- #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
75 76 77 78 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 75 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
117 118 119 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 117 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.
103 104 105 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 103 def list_spec @list_spec end |
#out=(value) ⇒ Object (writeonly)
the output directory passed to nuget when restoring the nugets
81 82 83 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 81 def out=(value) @out = value end |
Instance Method Details
#ensure_authentication! ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 127 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
119 120 121 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 119 def exclude_version add_parameter "-ExcludeVersion" end |
#has_credentials? ⇒ Boolean
123 124 125 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 123 def has_credentials? username && password && source end |
#opts_for_pkgcfg(pkg) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 135 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
105 106 107 108 109 110 111 112 113 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 105 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
84 85 86 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 84 def source @source end |
#source=(val) ⇒ Object
set the nuget source
89 90 91 92 93 94 95 96 97 |
# File 'lib/albacore/task_types/nugets_restore.rb', line 89 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 |