Class: Avm::EacGitlabBase0::Api::NodesSet
- Inherits:
-
Object
- Object
- Avm::EacGitlabBase0::Api::NodesSet
show all
- Defined in:
- lib/avm/eac_gitlab_base0/api/nodes_set.rb,
lib/avm/eac_gitlab_base0/api/nodes_set/add_by_group_projects_id.rb
Defined Under Namespace
Classes: AddByGroupProjectsId
Constant Summary
collapse
- IDS_PREFIXES =
{
'@@' => :group_and_projects, '@-' => :group_projects, '@' => :group
}.freeze
- GROUP_AND_PROJECTS_ID_PARSER =
/\A@@(.*)\z/.to_parser { |m| m[1] }
- GROUP_ID_PARSER =
/\A@(.*)\z/.to_parser { |m| m[1] }
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(rest_api, *ids) ⇒ NodesSet
Returns a new instance of NodesSet.
34
35
36
37
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 34
def initialize(rest_api, *ids)
self.rest_api = rest_api
ids.each { |id| add(id) }
end
|
Instance Attribute Details
#no_groups=(value) ⇒ Object
Sets the attribute no_groups
32
33
34
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 32
def no_groups=(value)
@no_groups = value
end
|
#rest_api ⇒ Object
Returns the value of attribute rest_api.
31
32
33
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 31
def rest_api
@rest_api
end
|
Class Method Details
.parse_id(id) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 20
def parse_id(id)
IDS_PREFIXES.each do |prefix, type|
/\A#{::Regexp.quote(prefix)}(.*)\z/.if_match(id, false) do |m|
return [m[1], type]
end
end
[id, :project]
end
|
Instance Method Details
#add(id) ⇒ Object
39
40
41
42
43
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 39
def add(id)
parsed_id, type = self.class.parse_id(id)
send("add_by_#{type}_id", parsed_id)
end
|
46
47
48
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 46
def add_all_projects
rest_api.root.projects.each { |project| add_node(project) }
end
|
51
52
53
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 51
def groups
nodes.select { |node| node.is_a?(::Avm::EacGitlabBase0::Api::Group) }
end
|
#no_groups? ⇒ Boolean
67
68
69
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 67
def no_groups?
@no_groups ? true : false
end
|
61
62
63
64
65
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 61
def nodes
r = nodes_set
r = r.reject { |g| g.is_a?(::Avm::EacGitlabBase0::Api::Group) } if no_groups?
r.sort_by { |p| [p.full_path] }
end
|
56
57
58
|
# File 'lib/avm/eac_gitlab_base0/api/nodes_set.rb', line 56
def projects
nodes.select { |node| node.is_a?(::Avm::EacGitlabBase0::Api::Project) }
end
|