Class: Albacore::Asmver::Config

Inherits:
Object
  • Object
show all
Extended by:
ConfigDSL
Includes:
CmdConfig
Defined in:
lib/albacore/task_types/asmver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigDSL

attr_path, attr_path_accessor

Methods included from CmdConfig

#add_parameter, #parameters

Methods included from Logging

#debug, #err, #error, #fatal, #info, #puts, #trace, #warn

Constructor Details

#initialize(file_path = nil, namespace = nil, attributes = nil) ⇒ Config

creates a new config with some pre-existing data



81
82
83
84
# File 'lib/albacore/task_types/asmver.rb', line 81

def initialize file_path = nil, namespace = nil, attributes = nil
  @file_path, @namespace, @attributes = file_path, namespace, attributes
  @usings = []
end

Instance Attribute Details

#namespaceObject

the namespace to output into the version file



72
73
74
# File 'lib/albacore/task_types/asmver.rb', line 72

def namespace
  @namespace
end

#outObject

(optional) output stream



75
76
77
# File 'lib/albacore/task_types/asmver.rb', line 75

def out
  @out
end

#usingsObject

the array-like thing of using namespaces



78
79
80
# File 'lib/albacore/task_types/asmver.rb', line 78

def usings
  @usings
end

Instance Method Details

#attributes(attrs) ⇒ Object

Give the hash of attributes to write to the assembly info file



92
93
94
# File 'lib/albacore/task_types/asmver.rb', line 92

def attributes attrs
  @attributes = attrs
end

#change_attributes {|@attributes| ... } ⇒ Object

Call with to get the opportunity to change the attributes hash

Yields:



87
88
89
# File 'lib/albacore/task_types/asmver.rb', line 87

def change_attributes &block
  yield @attributes if block
end

#optsObject

Raises:



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/albacore/task_types/asmver.rb', line 101

def opts
  raise MissingOutputError, "#file_path or #out is not set" unless (file_path or out)
  ns   = @namespace || '' # defaults to empty namespace if not set.
  lang = lang_for file_path
  m = Map.new attributes: @attributes,
              namespace: ns,
              file_path: @file_path,
              language:  lang,
              usings: usings
  m[:out] = out if out
  m
end

#to_sObject



114
115
116
# File 'lib/albacore/task_types/asmver.rb', line 114

def to_s
  "AsmVer::Config[#{file_path}]"
end

#using(ns) ⇒ Object



96
97
98
99
# File 'lib/albacore/task_types/asmver.rb', line 96

def using ns
  debug { "adding namespace #{ns} [Asmver::Config using]" }
  usings << ns
end