Class: ProjectHeaderMap::HmapGenerator
- Inherits:
-
Object
- Object
- ProjectHeaderMap::HmapGenerator
- Defined in:
- lib/cocoapods-project-hmap/hmap_generator.rb
Constant Summary collapse
- QUOTE =
001
1
- ANGLE_BRACKET =
010
2
- BOTH =
011
3
Instance Method Summary collapse
-
#add_hmap_with_header_mapping(header_mapping, type, target_name = nil, module_name = nil) ⇒ Object
header_mapping : [Hash=> Hash] Hash of file accessors by header mappings.
- #empty? ⇒ Boolean
-
#initialize ⇒ HmapGenerator
constructor
A new instance of HmapGenerator.
-
#save_to(path) ⇒ Object
: succeed.
Constructor Details
#initialize ⇒ HmapGenerator
Returns a new instance of HmapGenerator.
8 9 10 |
# File 'lib/cocoapods-project-hmap/hmap_generator.rb', line 8 def initialize @hmap = Hash.new end |
Instance Method Details
#add_hmap_with_header_mapping(header_mapping, type, target_name = nil, module_name = nil) ⇒ Object
header_mapping : [Hash=> Hash] Hash of file accessors by header mappings.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods-project-hmap/hmap_generator.rb', line 12 def add_hmap_with_header_mapping(header_mapping, type, target_name=nil, module_name=nil) header_mapping.each do |facc, headers| headers.each do |key, value| value.each do |path| pn = Pathname.new(path) name = pn.basename.to_s dirname = pn.dirname.to_s + '/' # construct hmap hash info path_info = Hash['suffix' => name, 'prefix' => dirname] if type & QUOTE > 0 # import with quote @hmap[name] = path_info end if type & ANGLE_BRACKET > 0 if target_name != nil # import with angle bracket @hmap["#{target_name}/#{name}"] = path_info end if module_name != nil && module_name != target_name @hmap["#{module_name}/#{name}"] = path_info end end end end end end |
#empty? ⇒ Boolean
55 56 57 |
# File 'lib/cocoapods-project-hmap/hmap_generator.rb', line 55 def empty? @hmap.empty? end |
#save_to(path) ⇒ Object
Returns : succeed.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cocoapods-project-hmap/hmap_generator.rb', line 40 def save_to(path) if path != nil && @hmap.empty? == false pn=Pathname(path) json_path=pn.dirname.to_s + '/' + 'temp.json' # write hmap json to file File.open(json_path, 'w') { |file| file << @hmap.to_json } # json to hmap suc=system("hmap convert #{json_path} #{path}") # delete json file File.delete(json_path) suc else false end end |