Class: HMap::HMapHeaders

Inherits:
Object
  • Object
show all
Defined in:
lib/hmap/helper/hmap_helper.rb

Overview

A collection of Each HMapHeaderEntry

Instance Method Summary collapse

Constructor Details

#initializeHMapHeaders

Returns a new instance of HMapHeaders.



52
53
54
55
56
57
58
# File 'lib/hmap/helper/hmap_helper.rb', line 52

def initialize
  @public_headers = HMapHeaderEntry.new(:i_headers)
  @public_headers_e = HMapHeaderEntry.new(:iextra_headers)
  @private_headers = HMapHeaderEntry.new(:iquote_headers)
  @private_headers_e = HMapHeaderEntry.new(:extra_headers)
  @unqi_headers = Set.new
end

Instance Method Details

#add_headers(type, headers, module_name, headers_sandbox) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/hmap/helper/hmap_helper.rb', line 101

def add_headers(type, headers, module_name, headers_sandbox)
  headers.each do |header|
    next unless @unqi_headers.add?(header)

    header_name = header.basename.to_s
    header_dir = "#{header.dirname}/"
    header_module_path = "#{module_name}/#{header_name}"
    header_module_name = "#{module_name}/"
    header_relative_path = header.relative_path_from(headers_sandbox).to_s
    header_last_dir_name = "#{header.dirname.basename}/#{header_name}"
    case type
    when :private_header_files, :public_header_files
      @public_headers.add_header([header_name, header_module_name, header_name]) if type == :public_header_files
      @public_headers_e.add_header([header_module_path, header_dir, header_name])
      @private_headers.add_header([header_name, header_module_name, header_name])
      unless header_relative_path == header_module_path || header_relative_path == header_name
        @private_headers_e.add_header([header_relative_path, header_dir, header_name])
      end
      unless header_last_dir_name == header_module_path
        @private_headers_e.add_header([header_last_dir_name, header_dir, header_name])
      end
    when :source_files
      @private_headers_e.add_header([header_name, header_dir, header_name])
      @private_headers_e.add_header([header_last_dir_name, header_dir, header_name])
      @private_headers_e.add_header([header_relative_path, header_dir, header_name])
    end
  end
end

#headersObject



60
61
62
# File 'lib/hmap/helper/hmap_helper.rb', line 60

def headers
  public_headers + private_headers
end

#headers_build_settings_for_options(headers, path, name, key = '') ⇒ Object



95
96
97
98
99
# File 'lib/hmap/helper/hmap_helper.rb', line 95

def headers_build_settings_for_options(headers, path, name, key = '')
  headers.each_with_object([]) do |header, setting|
    setting << header.build_setting(path, name).join(key)
  end
end

#headers_build_settings_for_reference(headers, path, name) ⇒ Object



88
89
90
91
92
93
# File 'lib/hmap/helper/hmap_helper.rb', line 88

def headers_build_settings_for_reference(headers, path, name)
  headers.each_with_object({}) do |header, setting|
    se = header.build_setting_xcconfig(path, name)
    setting.merge!(Hash[*se]) { |_, oldval, newval| [oldval, newval].join(' ') }
  end
end

#private_headersObject



68
69
70
# File 'lib/hmap/helper/hmap_helper.rb', line 68

def private_headers
  [@private_headers, @private_headers_e]
end

#private_setting_for_options(path, name) ⇒ Object



80
81
82
# File 'lib/hmap/helper/hmap_helper.rb', line 80

def private_setting_for_options(path, name)
  headers_build_settings_for_options(private_headers, path, name, ' ').join(' ')
end

#private_setting_for_reference(path, name) ⇒ Object



72
73
74
# File 'lib/hmap/helper/hmap_helper.rb', line 72

def private_setting_for_reference(path, name)
  headers_build_settings_for_reference(private_headers, path, name)
end

#public_headersObject



64
65
66
# File 'lib/hmap/helper/hmap_helper.rb', line 64

def public_headers
  [@public_headers, @public_headers_e]
end

#public_setting_for_options(path, name) ⇒ Object



84
85
86
# File 'lib/hmap/helper/hmap_helper.rb', line 84

def public_setting_for_options(path, name)
  headers_build_settings_for_options(public_headers, path, name).join(' ')
end

#public_setting_for_reference(path, name) ⇒ Object



76
77
78
# File 'lib/hmap/helper/hmap_helper.rb', line 76

def public_setting_for_reference(path, name)
  headers_build_settings_for_reference(public_headers, path, name)
end