Class: Steep::Server::TargetGroupFiles::PathEnumerator
- Defined in:
- lib/steep/server/target_group_files.rb
Instance Method Summary collapse
- #[](path) ⇒ Object
- #[]=(path, target_group) ⇒ Object
- #each(&block) ⇒ Object
- #each_group_path(target_group, include_sub_groups: false, &block) ⇒ Object
- #each_project_path(except: nil, &block) ⇒ Object
- #each_target_path(target, except: nil, &block) ⇒ Object
- #empty? ⇒ Boolean
- #group_of(target_group) ⇒ Object
-
#initialize ⇒ PathEnumerator
constructor
A new instance of PathEnumerator.
- #paths ⇒ Object
- #registered_path?(path) ⇒ Boolean
- #target(path) ⇒ Object
- #target_group(path) ⇒ Object
- #target_of(target_group) ⇒ Object
Constructor Details
#initialize ⇒ PathEnumerator
Returns a new instance of PathEnumerator.
5 6 7 |
# File 'lib/steep/server/target_group_files.rb', line 5 def initialize @paths = {} end |
Instance Method Details
#[](path) ⇒ Object
25 26 27 |
# File 'lib/steep/server/target_group_files.rb', line 25 def [](path) @paths[path] end |
#[]=(path, target_group) ⇒ Object
21 22 23 |
# File 'lib/steep/server/target_group_files.rb', line 21 def []=(path, target_group) @paths[path] = target_group end |
#each(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/steep/server/target_group_files.rb', line 29 def each(&block) if block @paths.each do |path, target_group| target = target_of(target_group) group = group_of(target_group) yield [path, target, group] end else enum_for(_ = __method__) end end |
#each_group_path(target_group, include_sub_groups: false, &block) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/steep/server/target_group_files.rb', line 89 def each_group_path(target_group, include_sub_groups: false, &block) if block if include_sub_groups target_group.is_a?(Project::Target) or raise "target_group must be a target if `include_sub_groups:` is given. (#{target_group.name})" each_target_path(target_group, &block) else @paths.each do |path, tg| if tg == target_group t, g = target_group(path) || raise yield [path, t, g, g || t] end end end else enum_for(_ = __method__, target_group, include_sub_groups: include_sub_groups) end end |
#each_project_path(except: nil, &block) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/steep/server/target_group_files.rb', line 57 def each_project_path(except: nil, &block) if block @paths.each_key do |path| target, group = target_group(path) || raise next if target == except yield [path, target, group, group || target] end else enum_for(_ = __method__, except: except) end end |
#each_target_path(target, except: nil, &block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/steep/server/target_group_files.rb', line 71 def each_target_path(target, except: nil, &block) if block @paths.each_key do |path| t, g = target_group(path) || raise if except next if g == except end next unless t == target yield [path, t, g, g || t] end else enum_for(_ = __method__, target, except: except) end end |
#empty? ⇒ Boolean
9 10 11 |
# File 'lib/steep/server/target_group_files.rb', line 9 def empty? @paths.empty? end |
#group_of(target_group) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/steep/server/target_group_files.rb', line 116 def group_of(target_group) case target_group when Project::Group target_group end end |
#paths ⇒ Object
13 14 15 |
# File 'lib/steep/server/target_group_files.rb', line 13 def paths @paths.keys end |
#registered_path?(path) ⇒ Boolean
17 18 19 |
# File 'lib/steep/server/target_group_files.rb', line 17 def registered_path?(path) @paths.key?(path) end |
#target(path) ⇒ Object
42 43 44 45 46 |
# File 'lib/steep/server/target_group_files.rb', line 42 def target(path) if target_group = @paths.fetch(path, nil) target_of(target_group) end end |
#target_group(path) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/steep/server/target_group_files.rb', line 48 def target_group(path) if target_group = @paths.fetch(path, nil) target = target_of(target_group) group = group_of(target_group) [target, group] end end |