class SiteHook::Projects
Public Class Methods
length()
click to toggle source
# File lib/site_hook/config.rb, line 182 def self.length instance_variables.length end
new(config)
click to toggle source
# File lib/site_hook/config.rb, line 101 def initialize(config) config.each do |project, options| instance_variable_set(StrExt.mkatvar(StrExt.mkvar(project)), Project.new(project, options)) end end
Public Instance Methods
collect_public()
click to toggle source
Collect project names that meet certain criteria
# File lib/site_hook/config.rb, line 150 def collect_public public_vars = instance_variables.reject do |project_var| instance_variable_get(project_var).private end public_projects = [] public_vars.each do |var| public_projects << instance_variable_get(var) end public_projects end
each() { |instance_variable_get(instance_variables)| ... }
click to toggle source
# File lib/site_hook/config.rb, line 172 def each(&block) len1 = instance_variables.length x = 0 while x < len1 base = self yield instance_variable_get(instance_variables[x]) x += 1 end end
find_project(name)
click to toggle source
# File lib/site_hook/config.rb, line 115 def find_project(name) public_vars = instance_variables.reject do |project_var| instance_variable_get(project_var).private end project_obj = public_vars.select do |project| project == StrExt.mkatvar(StrExt.mkvar(name)) end project_obj = project_obj.join begin instance_variable_get(project_obj) rescue NameError nil end end
get(project)
click to toggle source
# File lib/site_hook/config.rb, line 130 def get(project) if instance_variables.empty? return :no_projects end vars = instance_variables.select do |name| name == StrExt.mkatvar(StrExt.mkvar(project)) end if vars.empty? return :not_found end obj = vars.join begin instance_variable_get(obj) rescue NameError => e return :not_found end end
inspect()
click to toggle source
# File lib/site_hook/config.rb, line 107 def inspect output = [] instance_variables.each do |project| output << "#{StrExt.rematvar(project)}=#{instance_variable_get(project).inspect}" end "#<SiteHook::Projects #{output.join(" ")}" end
to_h()
click to toggle source
# File lib/site_hook/config.rb, line 161 def to_h projects = {} each do |project| projects[project.name] = {} %i[src dst repo host private].each do |option| projects[project.name][option] = project.instance_variable_get(StrExt.mkatvar(option)) end end projects end