Class: Steep::Server::TargetGroupFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/server/target_group_files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ TargetGroupFiles

Returns a new instance of TargetGroupFiles.



10
11
12
13
14
15
# File 'lib/steep/server/target_group_files.rb', line 10

def initialize(project)
  @project = project
  @source_paths = {}
  @signature_paths = {}
  @library_paths = {}
end

Instance Attribute Details

#library_pathsObject (readonly)

Returns the value of attribute library_paths.



8
9
10
# File 'lib/steep/server/target_group_files.rb', line 8

def library_paths
  @library_paths
end

#projectObject (readonly)

Returns the value of attribute project.



4
5
6
# File 'lib/steep/server/target_group_files.rb', line 4

def project
  @project
end

#signature_pathsObject (readonly)

Returns the value of attribute signature_paths.



6
7
8
# File 'lib/steep/server/target_group_files.rb', line 6

def signature_paths
  @signature_paths
end

#source_pathsObject (readonly)

Returns the value of attribute source_paths.



6
7
8
# File 'lib/steep/server/target_group_files.rb', line 6

def source_paths
  @source_paths
end

Instance Method Details

#add_library_path(target, *paths) ⇒ Object



30
31
32
# File 'lib/steep/server/target_group_files.rb', line 30

def add_library_path(target, *paths)
  (library_paths[target.name] ||= Set[]).merge(paths)
end

#add_path(path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/steep/server/target_group_files.rb', line 17

def add_path(path)
  if target_group = project.group_for_signature_path(path)
    signature_paths[path] = target_group
    return true
  end
  if target_group = project.group_for_source_path(path)
    source_paths[path] = target_group
    return true
  end

  false
end

#each_group_signature_path(target, no_group = false, &block) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/steep/server/target_group_files.rb', line 84

def each_group_signature_path(target, no_group = false, &block)
  if block
    signature_paths.each_key do |path|
      t, g = target_group_for_signature_path(path)

      if target.is_a?(Project::Target)
        if no_group
          yield path if t == target && g == nil
        else
          yield path if t == target
        end
      else
        yield path if g == target
      end
    end
  else
    enum_for(_ = __method__, target, no_group)
  end
end

#each_group_source_path(target, no_group = false, &block) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/steep/server/target_group_files.rb', line 144

def each_group_source_path(target, no_group = false, &block)
  if block
    source_paths.each_key do |path|
      t, g = target_group_for_source_path(path)

      if target.is_a?(Project::Target)
        if no_group
          yield path if t == target && g == nil
        else
          yield path if t == target
        end
      else
        yield path if g == target
      end
    end
  else
    enum_for(_ = __method__, target, no_group)
  end
end

#each_library_path(target, &block) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/steep/server/target_group_files.rb', line 34

def each_library_path(target, &block)
  if block
    library_paths.fetch(target.name).each(&block)
  else
    enum_for(_ = __method__, target)
  end
end

#each_project_signature_path(target, &block) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/steep/server/target_group_files.rb', line 121

def each_project_signature_path(target, &block)
  if block
    signature_paths.each do |path, target_group|
      t =
        case target_group
        when Project::Target
          target_group
        when Project::Group
          target_group.target
        end

      if target
        next if t.unreferenced
        next if t == target
      end

      yield path
    end
  else
    enum_for(_ = __method__, target)
  end
end

#each_project_source_path(target, &block) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/steep/server/target_group_files.rb', line 181

def each_project_source_path(target, &block)
  if block
    source_paths.each do |path, target_group|
      t =
        case target_group
        when Project::Target
          target_group
        when Project::Group
          target_group.target
        end

      if target
        next if t.unreferenced
        next if t == target
      end

      yield path
    end
  else
    enum_for(_ = __method__, target)
  end
end

#each_target_signature_path(target, group, &block) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/steep/server/target_group_files.rb', line 104

def each_target_signature_path(target, group, &block)
  raise unless group.target == target if group

  if block
    signature_paths.each_key do |path|
      t, g = target_group_for_signature_path(path)

      next unless target == t
      next if group && group == g

      yield path
    end
  else
    enum_for(_ = __method__, target, group)
  end
end

#each_target_source_path(target, group, &block) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/steep/server/target_group_files.rb', line 164

def each_target_source_path(target, group, &block)
  raise unless group.target == target if group

  if block
    source_paths.each_key do |path|
      t, g = target_group_for_source_path(path)

      next unless target == t
      next if group && group == g

      yield path
    end
  else
    enum_for(_ = __method__, target, group)
  end
end

#library_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/steep/server/target_group_files.rb', line 42

def library_path?(path)
  library_paths.each_value.any? { _1.include?(path) }
end

#signature_path_target(path) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/steep/server/target_group_files.rb', line 46

def signature_path_target(path)
  case target_group = signature_paths.fetch(path, nil)
  when Project::Target
    target_group
  when Project::Group
    target_group.target
  end
end

#source_path_target(path) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/steep/server/target_group_files.rb', line 55

def source_path_target(path)
  case target_group = source_paths.fetch(path, nil)
  when Project::Target
    target_group
  when Project::Group
    target_group.target
  end
end

#target_group_for_signature_path(path) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/steep/server/target_group_files.rb', line 74

def target_group_for_signature_path(path)
  ret = signature_paths.fetch(path, nil)
  case ret
  when Project::Group
    [ret.target, ret]
  when Project::Target
    [ret, nil]
  end
end

#target_group_for_source_path(path) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/steep/server/target_group_files.rb', line 64

def target_group_for_source_path(path)
  ret = source_paths.fetch(path, nil)
  case ret
  when Project::Group
    [ret.target, ret]
  when Project::Target
    [ret, nil]
  end
end