Class: Vendorificator::Vendor

Inherits:
Object
  • Object
show all
Defined in:
lib/vendorificator/vendor.rb

Direct Known Subclasses

Archive, Download, Git, Tool

Defined Under Namespace

Classes: Archive, ChefCookbook, Download, Git, Tool

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, name, args = {}, &block) ⇒ Vendor

Returns a new instance of Vendor.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vendorificator/vendor.rb', line 26

def initialize(environment, name, args = {}, &block)
  @environment = environment
  @name = name
  @block = block
  @metadata = {
    :unparsed_args => args.clone
  }
  @metadata[:parsed_args] = @args = parse_initialize_args(args)
  @metadata[:module_annotations] = @args[:annotate] if @args[:annotate]

  @segment = Segment::Vendor.new(vendor: self, overlay: config.overlay_instance)
  if config.overlay_instance
    config.overlay_instance.segments << @segment
  else
    @environment.segments << @segment
  end
end

Class Attribute Details

.groupObject

Returns the value of attribute group.



11
12
13
# File 'lib/vendorificator/vendor.rb', line 11

def group
  @group
end

.method_nameObject

Returns the value of attribute method_name.



11
12
13
# File 'lib/vendorificator/vendor.rb', line 11

def method_name
  @method_name
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



22
23
24
# File 'lib/vendorificator/vendor.rb', line 22

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



22
23
24
# File 'lib/vendorificator/vendor.rb', line 22

def block
  @block
end

#environmentObject (readonly)

Returns the value of attribute environment.



22
23
24
# File 'lib/vendorificator/vendor.rb', line 22

def environment
  @environment
end

#git=(value) ⇒ Object

Sets the attribute git

Parameters:

  • value

    the value to set the attribute git to.



23
24
25
# File 'lib/vendorificator/vendor.rb', line 23

def git=(value)
  @git = value
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/vendorificator/vendor.rb', line 22

def name
  @name
end

#segmentObject (readonly)

Returns the value of attribute segment.



22
23
24
# File 'lib/vendorificator/vendor.rb', line 22

def segment
  @segment
end

Class Method Details

.arg_reader(*names) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/vendorificator/vendor.rb', line 13

def arg_reader(*names)
  names.each do |name|
    define_method(name) do
      args[name]
    end
  end
end

Instance Method Details

#===(other) ⇒ Object



44
45
46
# File 'lib/vendorificator/vendor.rb', line 44

def ===(other)
  other === name || File.expand_path(other.to_s) == work_dir
end

#before_conjure!Object



68
# File 'lib/vendorificator/vendor.rb', line 68

def before_conjure! ; end

#compute_dependencies!Object



69
# File 'lib/vendorificator/vendor.rb', line 69

def compute_dependencies! ; end

#conjure!Object



62
63
64
# File 'lib/vendorificator/vendor.rb', line 62

def conjure!
  block.call(self) if block
end

#conjure_commit_messageObject



81
82
83
# File 'lib/vendorificator/vendor.rb', line 81

def conjure_commit_message
  "Conjured vendor module #{name} version #{version}"
end

#git_add_extra_pathsObject

Hook points



67
# File 'lib/vendorificator/vendor.rb', line 67

def git_add_extra_paths ; [] ; end

#groupObject



48
49
50
# File 'lib/vendorificator/vendor.rb', line 48

def group
  defined?(@group) ? @group : self.class.group
end

#inspectObject



52
53
54
# File 'lib/vendorificator/vendor.rb', line 52

def inspect
  "#<#{self.class} #{self}>"
end

#metadataObject



72
73
74
75
76
77
78
79
# File 'lib/vendorificator/vendor.rb', line 72

def 
  default = {
    :module_name => @name,
    :module_version => version,
    :module_group => @group,
  }
  default.merge @metadata
end

#upstream_versionObject



70
# File 'lib/vendorificator/vendor.rb', line 70

def upstream_version ; end

#versionObject



56
57
58
59
60
# File 'lib/vendorificator/vendor.rb', line 56

def version
  @args[:version] ||
    (!config[:use_upstream_version] && segment.merged_version) ||
    upstream_version
end