Class: Travis::Yaml::Nodes::DeployEntry::Setting

Inherits:
OpenMapping show all
Defined in:
lib/travis/yaml/nodes/deploy_entry.rb

Constant Summary collapse

KEY =
''

Instance Attribute Summary

Attributes inherited from Mapping

#mapping

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from OpenMapping

#accept_key?, default_type, subnode_for

Methods inherited from Mapping

#[], #[]=, #accept_key?, aliases, auto_prefix, #deep_verify, define_map_accessor, drop_empty, #drop_empty?, #each_scalar, #empty?, experimental, #include?, map, #mapped_key, mapping, #nested_warnings, prefix_scalar, prefix_sequence, #prepare, required, subnode_for, #subnode_for, #verify, #verify_empty, #verify_errors, #verify_experimental, #verify_required, #visit_key_value, #visit_mapping, #visit_pair, #with_value!

Methods inherited from Node

#decrypt, #decrypted?, #deep_verify, #dup, #encrypt, #encrypted?, #error, #errors, #errors?, has_default?, #initialize, #method_missing, #nested_warning, #nested_warnings, #prepare, #respond_to_missing?, #serialize, #to_json, #to_legacy_ruby, #to_ruby, #to_s, #to_yaml, #verify, #verify_language, #visit_child, #visit_mapping, #visit_pair, #visit_scalar, #visit_sequence, #visit_unexpected, #warngings?, #warning, #warnings, #with_value

Constructor Details

This class inherits a constructor from Travis::Yaml::Nodes::Node

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Travis::Yaml::Nodes::Node

Instance Method Details

#==(other) ⇒ Object



9
10
11
12
13
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 9

def ==(other)
  return true if super
  return false unless branch_specific?
  generic == other
end

#__getobj__Object



15
16
17
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 15

def __getobj__
  branch_specific? ? generic : super
end

#branch_specific?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 23

def branch_specific?
  @mapping.size == 1 and @mapping.include? KEY
end

#branchesObject



27
28
29
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 27

def branches
  @mapping.keys - [KEY]
end

#genericObject



31
32
33
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 31

def generic
  @mapping[KEY]
end

#inspectObject



19
20
21
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 19

def inspect
  branch_specific? ? generic.inspect : super
end

#verify_branch(name) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/travis/yaml/nodes/deploy_entry.rb', line 35

def verify_branch(name)
  branches.each do |branch|
    next if branch.to_s == name.to_s
    warning "branch %p not permitted by deploy condition, dropping", branch
    @mapping.delete(branch)
  end
end