xcres 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.travis.yml +18 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +85 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +181 -0
  8. data/Rakefile +58 -0
  9. data/bin/xcres +12 -0
  10. data/lib/xcres/analyzer/aggregate_analyzer.rb +48 -0
  11. data/lib/xcres/analyzer/analyzer.rb +141 -0
  12. data/lib/xcres/analyzer/resources_aggregate_analyzer.rb +27 -0
  13. data/lib/xcres/analyzer/resources_analyzer/base_resources_analyzer.rb +133 -0
  14. data/lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb +68 -0
  15. data/lib/xcres/analyzer/resources_analyzer/loose_resources_analyzer.rb +39 -0
  16. data/lib/xcres/analyzer/resources_analyzer/xcassets_analyzer.rb +62 -0
  17. data/lib/xcres/analyzer/strings_analyzer.rb +255 -0
  18. data/lib/xcres/builder/file_builder.rb +61 -0
  19. data/lib/xcres/builder/resources_builder.rb +184 -0
  20. data/lib/xcres/builder/string_builder.rb +31 -0
  21. data/lib/xcres/command/build_command.rb +83 -0
  22. data/lib/xcres/command/command.rb +58 -0
  23. data/lib/xcres/command/install_command.rb +173 -0
  24. data/lib/xcres/command/main_command.rb +14 -0
  25. data/lib/xcres/command/project_command.rb +111 -0
  26. data/lib/xcres/command/version_command.rb +12 -0
  27. data/lib/xcres/helper/file_helper.rb +16 -0
  28. data/lib/xcres/logger.rb +148 -0
  29. data/lib/xcres/model/section.rb +43 -0
  30. data/lib/xcres/model/xcassets/bundle.rb +55 -0
  31. data/lib/xcres/model/xcassets/resource.rb +141 -0
  32. data/lib/xcres/model/xcassets/resource_image.rb +134 -0
  33. data/lib/xcres/version.rb +9 -0
  34. data/lib/xcres.rb +9 -0
  35. data/spec/fixtures/Example/Example/AppDelegate.h +15 -0
  36. data/spec/fixtures/Example/Example/AppDelegate.m +49 -0
  37. data/spec/fixtures/Example/Example/Example-Info.plist +38 -0
  38. data/spec/fixtures/Example/Example/Example-Prefix.pch +16 -0
  39. data/spec/fixtures/Example/Example/Images/doge.jpeg +0 -0
  40. data/spec/fixtures/Example/Example/Images/nyanCat.png +0 -0
  41. data/spec/fixtures/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  42. data/spec/fixtures/Example/Example/Images.xcassets/Doge.imageset/Contents.json +18 -0
  43. data/spec/fixtures/Example/Example/Images.xcassets/Doge.imageset/doge.png +0 -0
  44. data/spec/fixtures/Example/Example/Images.xcassets/Doge.imageset/doge@2x.png +0 -0
  45. data/spec/fixtures/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  46. data/spec/fixtures/Example/Example/de.lproj/Localizable.strings +12 -0
  47. data/spec/fixtures/Example/Example/en.lproj/InfoPlist.strings +2 -0
  48. data/spec/fixtures/Example/Example/en.lproj/Localizable.strings +15 -0
  49. data/spec/fixtures/Example/Example/main.m +18 -0
  50. data/spec/fixtures/Example/Example.xcodeproj/project.pbxproj +449 -0
  51. data/spec/fixtures/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  52. data/spec/fixtures/ExampleOSX/ExampleOSX/AppDelegate.h +15 -0
  53. data/spec/fixtures/ExampleOSX/ExampleOSX/AppDelegate.m +18 -0
  54. data/spec/fixtures/ExampleOSX/ExampleOSX/Base.lproj/MainMenu.xib +680 -0
  55. data/spec/fixtures/ExampleOSX/ExampleOSX/ExampleOSX-Info.plist +34 -0
  56. data/spec/fixtures/ExampleOSX/ExampleOSX/ExampleOSX-Prefix.pch +9 -0
  57. data/spec/fixtures/ExampleOSX/ExampleOSX/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
  58. data/spec/fixtures/ExampleOSX/ExampleOSX/en.lproj/Credits.rtf +29 -0
  59. data/spec/fixtures/ExampleOSX/ExampleOSX/en.lproj/InfoPlist.strings +2 -0
  60. data/spec/fixtures/ExampleOSX/ExampleOSX/main.m +14 -0
  61. data/spec/fixtures/ExampleOSX/ExampleOSX.xcodeproj/project.pbxproj +481 -0
  62. data/spec/fixtures/ExampleOSX/ExampleOSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  63. data/spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests-Info.plist +22 -0
  64. data/spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests.m +34 -0
  65. data/spec/fixtures/ExampleOSX/ExampleOSXTests/en.lproj/InfoPlist.strings +2 -0
  66. data/spec/integration/build/after/Example/Example/AppDelegate.h +15 -0
  67. data/spec/integration/build/after/Example/Example/AppDelegate.m +49 -0
  68. data/spec/integration/build/after/Example/Example/Example-Info.plist +38 -0
  69. data/spec/integration/build/after/Example/Example/Example-Prefix.pch +16 -0
  70. data/spec/integration/build/after/Example/Example/Icons.bundle/tab_bar/tabbar_list.png +0 -0
  71. data/spec/integration/build/after/Example/Example/Icons.bundle/tab_bar/tabbar_list@2x.png +0 -0
  72. data/spec/integration/build/after/Example/Example/Icons.bundle/tab_bar/tabbar_map.png +0 -0
  73. data/spec/integration/build/after/Example/Example/Icons.bundle/tab_bar/tabbar_map@2x.png +0 -0
  74. data/spec/integration/build/after/Example/Example/Images/doge.jpeg +0 -0
  75. data/spec/integration/build/after/Example/Example/Images/nyanCat.png +0 -0
  76. data/spec/integration/build/after/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  77. data/spec/integration/build/after/Example/Example/Images.xcassets/Doge.imageset/Contents.json +18 -0
  78. data/spec/integration/build/after/Example/Example/Images.xcassets/Doge.imageset/doge.png +0 -0
  79. data/spec/integration/build/after/Example/Example/Images.xcassets/Doge.imageset/doge@2x.png +0 -0
  80. data/spec/integration/build/after/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  81. data/spec/integration/build/after/Example/Example/de.lproj/Localizable.strings +12 -0
  82. data/spec/integration/build/after/Example/Example/en.lproj/InfoPlist.strings +2 -0
  83. data/spec/integration/build/after/Example/Example/en.lproj/Localizable.strings +15 -0
  84. data/spec/integration/build/after/Example/Example/main.m +18 -0
  85. data/spec/integration/build/after/Example/Example.xcodeproj.yaml +168 -0
  86. data/spec/integration/build/after/R.h +39 -0
  87. data/spec/integration/build/after/R.m +29 -0
  88. data/spec/integration/build/after/execution_output.txt +19 -0
  89. data/spec/integration/build/before/Example/Example/AppDelegate.h +15 -0
  90. data/spec/integration/build/before/Example/Example/AppDelegate.m +49 -0
  91. data/spec/integration/build/before/Example/Example/Example-Info.plist +38 -0
  92. data/spec/integration/build/before/Example/Example/Example-Prefix.pch +16 -0
  93. data/spec/integration/build/before/Example/Example/Icons.bundle/tab_bar/tabbar_list.png +0 -0
  94. data/spec/integration/build/before/Example/Example/Icons.bundle/tab_bar/tabbar_list@2x.png +0 -0
  95. data/spec/integration/build/before/Example/Example/Icons.bundle/tab_bar/tabbar_map.png +0 -0
  96. data/spec/integration/build/before/Example/Example/Icons.bundle/tab_bar/tabbar_map@2x.png +0 -0
  97. data/spec/integration/build/before/Example/Example/Images/doge.jpeg +0 -0
  98. data/spec/integration/build/before/Example/Example/Images/nyanCat.png +0 -0
  99. data/spec/integration/build/before/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  100. data/spec/integration/build/before/Example/Example/Images.xcassets/Doge.imageset/Contents.json +18 -0
  101. data/spec/integration/build/before/Example/Example/Images.xcassets/Doge.imageset/doge.png +0 -0
  102. data/spec/integration/build/before/Example/Example/Images.xcassets/Doge.imageset/doge@2x.png +0 -0
  103. data/spec/integration/build/before/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  104. data/spec/integration/build/before/Example/Example/de.lproj/Localizable.strings +12 -0
  105. data/spec/integration/build/before/Example/Example/en.lproj/InfoPlist.strings +2 -0
  106. data/spec/integration/build/before/Example/Example/en.lproj/Localizable.strings +15 -0
  107. data/spec/integration/build/before/Example/Example/main.m +18 -0
  108. data/spec/integration/build/before/Example/Example.xcodeproj/project.pbxproj +453 -0
  109. data/spec/integration/build/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  110. data/spec/integration/build-keyword-clash/after/Example/Example/AppDelegate.h +15 -0
  111. data/spec/integration/build-keyword-clash/after/Example/Example/AppDelegate.m +49 -0
  112. data/spec/integration/build-keyword-clash/after/Example/Example/Default-568h@2x.png +0 -0
  113. data/spec/integration/build-keyword-clash/after/Example/Example/Default.png +0 -0
  114. data/spec/integration/build-keyword-clash/after/Example/Example/Default@2x.png +0 -0
  115. data/spec/integration/build-keyword-clash/after/Example/Example/Example-Info.plist +38 -0
  116. data/spec/integration/build-keyword-clash/after/Example/Example/Example-Prefix.pch +16 -0
  117. data/spec/integration/build-keyword-clash/after/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  118. data/spec/integration/build-keyword-clash/after/Example/Example/en.lproj/InfoPlist.strings +2 -0
  119. data/spec/integration/build-keyword-clash/after/Example/Example/main.m +18 -0
  120. data/spec/integration/build-keyword-clash/after/Example/Example.xcodeproj.yaml +160 -0
  121. data/spec/integration/build-keyword-clash/after/R.h +15 -0
  122. data/spec/integration/build-keyword-clash/after/R.m +15 -0
  123. data/spec/integration/build-keyword-clash/after/execution_output.txt +14 -0
  124. data/spec/integration/build-keyword-clash/before/Example/Example/AppDelegate.h +15 -0
  125. data/spec/integration/build-keyword-clash/before/Example/Example/AppDelegate.m +49 -0
  126. data/spec/integration/build-keyword-clash/before/Example/Example/Default-568h@2x.png +0 -0
  127. data/spec/integration/build-keyword-clash/before/Example/Example/Default.png +0 -0
  128. data/spec/integration/build-keyword-clash/before/Example/Example/Default@2x.png +0 -0
  129. data/spec/integration/build-keyword-clash/before/Example/Example/Example-Info.plist +38 -0
  130. data/spec/integration/build-keyword-clash/before/Example/Example/Example-Prefix.pch +16 -0
  131. data/spec/integration/build-keyword-clash/before/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  132. data/spec/integration/build-keyword-clash/before/Example/Example/en.lproj/InfoPlist.strings +2 -0
  133. data/spec/integration/build-keyword-clash/before/Example/Example/main.m +18 -0
  134. data/spec/integration/build-keyword-clash/before/Example/Example.xcodeproj/project.pbxproj +427 -0
  135. data/spec/integration/build-keyword-clash/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  136. data/spec/integration/build-var-infoplist/after/Example/Example/AppDelegate.h +15 -0
  137. data/spec/integration/build-var-infoplist/after/Example/Example/AppDelegate.m +49 -0
  138. data/spec/integration/build-var-infoplist/after/Example/Example/Example-Info.plist +38 -0
  139. data/spec/integration/build-var-infoplist/after/Example/Example/Example-Prefix.pch +16 -0
  140. data/spec/integration/build-var-infoplist/after/Example/Example/Icons.bundle/tab_bar/tabbar_list.png +0 -0
  141. data/spec/integration/build-var-infoplist/after/Example/Example/Icons.bundle/tab_bar/tabbar_list@2x.png +0 -0
  142. data/spec/integration/build-var-infoplist/after/Example/Example/Icons.bundle/tab_bar/tabbar_map.png +0 -0
  143. data/spec/integration/build-var-infoplist/after/Example/Example/Icons.bundle/tab_bar/tabbar_map@2x.png +0 -0
  144. data/spec/integration/build-var-infoplist/after/Example/Example/Images/doge.jpeg +0 -0
  145. data/spec/integration/build-var-infoplist/after/Example/Example/Images/nyanCat.png +0 -0
  146. data/spec/integration/build-var-infoplist/after/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  147. data/spec/integration/build-var-infoplist/after/Example/Example/Images.xcassets/Doge.imageset/Contents.json +18 -0
  148. data/spec/integration/build-var-infoplist/after/Example/Example/Images.xcassets/Doge.imageset/doge.png +0 -0
  149. data/spec/integration/build-var-infoplist/after/Example/Example/Images.xcassets/Doge.imageset/doge@2x.png +0 -0
  150. data/spec/integration/build-var-infoplist/after/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  151. data/spec/integration/build-var-infoplist/after/Example/Example/de.lproj/Localizable.strings +12 -0
  152. data/spec/integration/build-var-infoplist/after/Example/Example/en.lproj/InfoPlist.strings +2 -0
  153. data/spec/integration/build-var-infoplist/after/Example/Example/en.lproj/Localizable.strings +15 -0
  154. data/spec/integration/build-var-infoplist/after/Example/Example/main.m +18 -0
  155. data/spec/integration/build-var-infoplist/after/Example/Example.xcodeproj.yaml +168 -0
  156. data/spec/integration/build-var-infoplist/after/R.h +39 -0
  157. data/spec/integration/build-var-infoplist/after/R.m +29 -0
  158. data/spec/integration/build-var-infoplist/after/execution_output.txt +19 -0
  159. data/spec/integration/build-var-infoplist/before/Example/Example/AppDelegate.h +15 -0
  160. data/spec/integration/build-var-infoplist/before/Example/Example/AppDelegate.m +49 -0
  161. data/spec/integration/build-var-infoplist/before/Example/Example/Example-Info.plist +38 -0
  162. data/spec/integration/build-var-infoplist/before/Example/Example/Example-Prefix.pch +16 -0
  163. data/spec/integration/build-var-infoplist/before/Example/Example/Icons.bundle/tab_bar/tabbar_list.png +0 -0
  164. data/spec/integration/build-var-infoplist/before/Example/Example/Icons.bundle/tab_bar/tabbar_list@2x.png +0 -0
  165. data/spec/integration/build-var-infoplist/before/Example/Example/Icons.bundle/tab_bar/tabbar_map.png +0 -0
  166. data/spec/integration/build-var-infoplist/before/Example/Example/Icons.bundle/tab_bar/tabbar_map@2x.png +0 -0
  167. data/spec/integration/build-var-infoplist/before/Example/Example/Images/doge.jpeg +0 -0
  168. data/spec/integration/build-var-infoplist/before/Example/Example/Images/nyanCat.png +0 -0
  169. data/spec/integration/build-var-infoplist/before/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  170. data/spec/integration/build-var-infoplist/before/Example/Example/Images.xcassets/Doge.imageset/Contents.json +18 -0
  171. data/spec/integration/build-var-infoplist/before/Example/Example/Images.xcassets/Doge.imageset/doge.png +0 -0
  172. data/spec/integration/build-var-infoplist/before/Example/Example/Images.xcassets/Doge.imageset/doge@2x.png +0 -0
  173. data/spec/integration/build-var-infoplist/before/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  174. data/spec/integration/build-var-infoplist/before/Example/Example/de.lproj/Localizable.strings +12 -0
  175. data/spec/integration/build-var-infoplist/before/Example/Example/en.lproj/InfoPlist.strings +2 -0
  176. data/spec/integration/build-var-infoplist/before/Example/Example/en.lproj/Localizable.strings +15 -0
  177. data/spec/integration/build-var-infoplist/before/Example/Example/main.m +18 -0
  178. data/spec/integration/build-var-infoplist/before/Example/Example.xcodeproj/project.pbxproj +453 -0
  179. data/spec/integration/build-var-infoplist/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  180. data/spec/integration/help/after/execution_output.txt +18 -0
  181. data/spec/integration/help/before/.gitkeep +0 -0
  182. data/spec/integration/install/after/Example/Example/AppDelegate.h +15 -0
  183. data/spec/integration/install/after/Example/Example/AppDelegate.m +49 -0
  184. data/spec/integration/install/after/Example/Example/Example-Info.plist +38 -0
  185. data/spec/integration/install/after/Example/Example/Example-Prefix.pch +18 -0
  186. data/spec/integration/install/after/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  187. data/spec/integration/install/after/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  188. data/spec/integration/install/after/Example/Example/Resources/R.h +19 -0
  189. data/spec/integration/install/after/Example/Example/Resources/R.m +17 -0
  190. data/spec/integration/install/after/Example/Example/en.lproj/InfoPlist.strings +2 -0
  191. data/spec/integration/install/after/Example/Example/main.m +18 -0
  192. data/spec/integration/install/after/Example/Example.xcodeproj/project.pbxproj +898 -0
  193. data/spec/integration/install/after/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  194. data/spec/integration/install/after/Example/Example.xcodeproj.yaml +172 -0
  195. data/spec/integration/install/after/execution_output.txt +22 -0
  196. data/spec/integration/install/before/Example/Example/AppDelegate.h +15 -0
  197. data/spec/integration/install/before/Example/Example/AppDelegate.m +49 -0
  198. data/spec/integration/install/before/Example/Example/Example-Info.plist +38 -0
  199. data/spec/integration/install/before/Example/Example/Example-Prefix.pch +16 -0
  200. data/spec/integration/install/before/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  201. data/spec/integration/install/before/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  202. data/spec/integration/install/before/Example/Example/en.lproj/InfoPlist.strings +2 -0
  203. data/spec/integration/install/before/Example/Example/main.m +18 -0
  204. data/spec/integration/install/before/Example/Example.xcodeproj/project.pbxproj +421 -0
  205. data/spec/integration/install/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  206. data/spec/integration/install-again/after/Example/Example/AppDelegate.h +15 -0
  207. data/spec/integration/install-again/after/Example/Example/AppDelegate.m +49 -0
  208. data/spec/integration/install-again/after/Example/Example/Example-Info.plist +38 -0
  209. data/spec/integration/install-again/after/Example/Example/Example-Prefix.pch +18 -0
  210. data/spec/integration/install-again/after/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  211. data/spec/integration/install-again/after/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  212. data/spec/integration/install-again/after/Example/Example/Resources/R.h +19 -0
  213. data/spec/integration/install-again/after/Example/Example/Resources/R.m +17 -0
  214. data/spec/integration/install-again/after/Example/Example/en.lproj/InfoPlist.strings +2 -0
  215. data/spec/integration/install-again/after/Example/Example/main.m +18 -0
  216. data/spec/integration/install-again/after/Example/Example.xcodeproj.yaml +172 -0
  217. data/spec/integration/install-again/after/execution_output.txt +23 -0
  218. data/spec/integration/install-again/before/Example/Example/AppDelegate.h +15 -0
  219. data/spec/integration/install-again/before/Example/Example/AppDelegate.m +49 -0
  220. data/spec/integration/install-again/before/Example/Example/Example-Info.plist +38 -0
  221. data/spec/integration/install-again/before/Example/Example/Example-Prefix.pch +18 -0
  222. data/spec/integration/install-again/before/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  223. data/spec/integration/install-again/before/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  224. data/spec/integration/install-again/before/Example/Example/Resources/R.h +19 -0
  225. data/spec/integration/install-again/before/Example/Example/Resources/R.m +17 -0
  226. data/spec/integration/install-again/before/Example/Example/en.lproj/InfoPlist.strings +2 -0
  227. data/spec/integration/install-again/before/Example/Example/main.m +18 -0
  228. data/spec/integration/install-again/before/Example/Example.xcodeproj/project.pbxproj +898 -0
  229. data/spec/integration/install-again/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  230. data/spec/integration/install-moved-supporting-files/after/Example/Example.xcodeproj.yaml +173 -0
  231. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/Example-Info.plist +38 -0
  232. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/Example-Prefix.pch +18 -0
  233. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/Resources/R.h +19 -0
  234. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/Resources/R.m +17 -0
  235. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/en.lproj/InfoPlist.strings +2 -0
  236. data/spec/integration/install-moved-supporting-files/after/Example/Supporting_Files/main.m +18 -0
  237. data/spec/integration/install-moved-supporting-files/after/Example/res/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  238. data/spec/integration/install-moved-supporting-files/after/Example/res/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  239. data/spec/integration/install-moved-supporting-files/after/Example/src/AppDelegate.h +15 -0
  240. data/spec/integration/install-moved-supporting-files/after/Example/src/AppDelegate.m +49 -0
  241. data/spec/integration/install-moved-supporting-files/after/execution_output.txt +22 -0
  242. data/spec/integration/install-moved-supporting-files/before/Example/Example.xcodeproj/project.pbxproj +431 -0
  243. data/spec/integration/install-moved-supporting-files/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  244. data/spec/integration/install-moved-supporting-files/before/Example/Supporting_Files/Example-Info.plist +38 -0
  245. data/spec/integration/install-moved-supporting-files/before/Example/Supporting_Files/Example-Prefix.pch +16 -0
  246. data/spec/integration/install-moved-supporting-files/before/Example/Supporting_Files/en.lproj/InfoPlist.strings +2 -0
  247. data/spec/integration/install-moved-supporting-files/before/Example/Supporting_Files/main.m +18 -0
  248. data/spec/integration/install-moved-supporting-files/before/Example/res/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  249. data/spec/integration/install-moved-supporting-files/before/Example/res/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  250. data/spec/integration/install-moved-supporting-files/before/Example/src/AppDelegate.h +15 -0
  251. data/spec/integration/install-moved-supporting-files/before/Example/src/AppDelegate.m +49 -0
  252. data/spec/integration/install-no-supporting-files/after/Example/Example.xcodeproj.yaml +173 -0
  253. data/spec/integration/install-no-supporting-files/after/Example/Resources/R.h +19 -0
  254. data/spec/integration/install-no-supporting-files/after/Example/Resources/R.m +17 -0
  255. data/spec/integration/install-no-supporting-files/after/Example/Supporting_Files/Example-Info.plist +38 -0
  256. data/spec/integration/install-no-supporting-files/after/Example/Supporting_Files/Example-Prefix.pch +18 -0
  257. data/spec/integration/install-no-supporting-files/after/Example/Supporting_Files/en.lproj/InfoPlist.strings +2 -0
  258. data/spec/integration/install-no-supporting-files/after/Example/Supporting_Files/main.m +18 -0
  259. data/spec/integration/install-no-supporting-files/after/Example/res/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  260. data/spec/integration/install-no-supporting-files/after/Example/res/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  261. data/spec/integration/install-no-supporting-files/after/Example/src/AppDelegate.h +15 -0
  262. data/spec/integration/install-no-supporting-files/after/Example/src/AppDelegate.m +49 -0
  263. data/spec/integration/install-no-supporting-files/after/execution_output.txt +23 -0
  264. data/spec/integration/install-no-supporting-files/before/Example/Example.xcodeproj/project.pbxproj +430 -0
  265. data/spec/integration/install-no-supporting-files/before/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  266. data/spec/integration/install-no-supporting-files/before/Example/Supporting_Files/Example-Info.plist +38 -0
  267. data/spec/integration/install-no-supporting-files/before/Example/Supporting_Files/Example-Prefix.pch +16 -0
  268. data/spec/integration/install-no-supporting-files/before/Example/Supporting_Files/en.lproj/InfoPlist.strings +2 -0
  269. data/spec/integration/install-no-supporting-files/before/Example/Supporting_Files/main.m +18 -0
  270. data/spec/integration/install-no-supporting-files/before/Example/res/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  271. data/spec/integration/install-no-supporting-files/before/Example/res/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  272. data/spec/integration/install-no-supporting-files/before/Example/src/AppDelegate.h +15 -0
  273. data/spec/integration/install-no-supporting-files/before/Example/src/AppDelegate.m +49 -0
  274. data/spec/integration/version/after/execution_output.txt +3 -0
  275. data/spec/integration/version/before/.gitkeep +0 -0
  276. data/spec/integration.rb +86 -0
  277. data/spec/spec_helper/xcodeproj_project_yaml.rb +26 -0
  278. data/spec/unit/analyzer/aggregate_analyzer_spec.rb +61 -0
  279. data/spec/unit/analyzer/analyzer_spec.rb +123 -0
  280. data/spec/unit/analyzer/resources_aggregate_analyzer_spec.rb +46 -0
  281. data/spec/unit/analyzer/resources_analyzer/base_resources_analyzer_spec.rb +126 -0
  282. data/spec/unit/analyzer/resources_analyzer/bundle_resources_analyzer_spec.rb +57 -0
  283. data/spec/unit/analyzer/resources_analyzer/loose_resources_analyzer_spec.rb +22 -0
  284. data/spec/unit/analyzer/strings_analyzer_spec.rb +99 -0
  285. data/spec/unit/builder/file_builder_spec.rb +46 -0
  286. data/spec/unit/builder/resources_builder_spec.rb +50 -0
  287. data/spec/unit/builder/string_builder_spec.rb +76 -0
  288. data/spec/unit/command/main_command_spec.rb +5 -0
  289. data/spec/unit/command/project_command_spec.rb +23 -0
  290. data/spec/unit/helper/file_helper_spec.rb +24 -0
  291. data/spec/unit/logger_spec.rb +142 -0
  292. data/spec/unit/model/section_spec.rb +47 -0
  293. data/spec/unit/model/xcassets/bundle_spec.rb +154 -0
  294. data/spec/unit/model/xcassets/resource_image_spec.rb +141 -0
  295. data/spec/unit/model/xcassets/resource_spec.rb +174 -0
  296. data/spec/unit/model/xcassets/spec_helper.rb +31 -0
  297. data/spec/unit/spec_helper.rb +17 -0
  298. data/xcres.gemspec +42 -0
  299. metadata +811 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a076ffc4975feacb4afd297104c8814613c542eb
4
+ data.tar.gz: 211c8641f12dd550e4e43d8f39e2b8c24efa938c
5
+ SHA512:
6
+ metadata.gz: 3bd3346d7bbcd259fa698bba2dfad0c2081db342ba9d3fc7f85ced88717fa1d0775b3090f9d98800d705294cad8b44b1692cd2d7ffb586382b82a055eff6c52f
7
+ data.tar.gz: aa0d427e7b7d5f86174728b84e4f987a8bf635b80be0a5a98a28a114d347e348754312c47eb762d185096ab9fa2a52b3a1e08fd9e06528687edc750c12703865
data/.gitignore ADDED
@@ -0,0 +1,33 @@
1
+ # General
2
+ *.rbc
3
+ *.gem
4
+ .DS_Store
5
+
6
+ # Yardoc
7
+ .yardoc
8
+ /doc
9
+
10
+ # Specs
11
+ tmp
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+
16
+ # Examples
17
+ DerivedData
18
+
19
+ # IDEs
20
+ xcuserdata
21
+ *.xccheckout
22
+ .idea/
23
+
24
+ # RVM files
25
+ /.rvmrc
26
+ /.ruby-version
27
+ /.ruby-gemset
28
+
29
+ # RBENV files
30
+ /.rbenv-version
31
+
32
+ # Bundler files
33
+ /.bundle
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ # Sets Travis to run the Ruby specs on OS X machines which are required to
2
+ # use the native tools to read plists.
3
+ #
4
+ language: objective-c
5
+
6
+ env:
7
+ - RVM_RUBY_VERSION=system
8
+
9
+ before_install:
10
+ - source ~/.rvm/scripts/rvm
11
+ - if [[ $RVM_RUBY_VERSION != 'system' ]]; then rvm install $RVM_RUBY_VERSION; fi
12
+ - rvm use $RVM_RUBY_VERSION
13
+ - if [[ $RVM_RUBY_VERSION == 'system' ]]; then sudo gem install bundler --no-ri --no-rdoc; else gem install bundler --no-ri --no-rdoc; fi
14
+
15
+ install:
16
+ - bundle install --without=documentation
17
+
18
+ script: rake spec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xcres.gemspec
4
+ gemspec
5
+
6
+ group 'development' do
7
+ gem 'clintegracon'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xcres (0.4.0)
5
+ activesupport (>= 3.2.15, < 4)
6
+ clamp (~> 0.6.3)
7
+ colored (~> 1.2)
8
+ libxml-ruby
9
+ xcodeproj (~> 0.18)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ CFPropertyList (2.2.8)
15
+ activesupport (3.2.19)
16
+ i18n (~> 0.6, >= 0.6.4)
17
+ multi_json (~> 1.0)
18
+ ast (2.0.0)
19
+ bacon (1.2.0)
20
+ clamp (0.6.3)
21
+ clintegracon (0.5.2)
22
+ colored (~> 1.2)
23
+ diffy
24
+ coderay (1.1.0)
25
+ colored (1.2)
26
+ diffy (3.0.6)
27
+ i18n (0.6.11)
28
+ inch (0.4.10)
29
+ pry
30
+ sparkr (>= 0.2.0)
31
+ term-ansicolor
32
+ yard (~> 0.8.7)
33
+ libxml-ruby (2.7.0)
34
+ metaclass (0.0.4)
35
+ method_source (0.8.2)
36
+ mocha (1.1.0)
37
+ metaclass (~> 0.0.1)
38
+ mocha-on-bacon (0.2.2)
39
+ mocha (>= 0.13.0)
40
+ multi_json (1.10.1)
41
+ parser (2.2.0.pre.4)
42
+ ast (>= 1.1, < 3.0)
43
+ slop (~> 3.4, >= 3.4.5)
44
+ powerpack (0.0.9)
45
+ prettybacon (0.0.2)
46
+ bacon (~> 1.2)
47
+ pry (0.10.1)
48
+ coderay (~> 1.1.0)
49
+ method_source (~> 0.8.1)
50
+ slop (~> 3.4)
51
+ psych (2.0.5)
52
+ rainbow (2.0.0)
53
+ rake (10.3.2)
54
+ rubocop (0.25.0)
55
+ parser (>= 2.2.0.pre.4, < 3.0)
56
+ powerpack (~> 0.0.6)
57
+ rainbow (>= 1.99.1, < 3.0)
58
+ ruby-progressbar (~> 1.4)
59
+ ruby-progressbar (1.5.1)
60
+ slop (3.6.0)
61
+ sparkr (0.4.1)
62
+ term-ansicolor (1.3.0)
63
+ tins (~> 1.0)
64
+ tins (1.3.2)
65
+ xcodeproj (0.18.0)
66
+ CFPropertyList (~> 2.2)
67
+ activesupport (~> 3.0)
68
+ colored (~> 1.2)
69
+ yard (0.8.7.4)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ bacon (~> 1.1)
76
+ bundler (~> 1.3)
77
+ clintegracon
78
+ inch
79
+ mocha
80
+ mocha-on-bacon
81
+ prettybacon
82
+ psych
83
+ rake
84
+ rubocop
85
+ xcres!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Marius Rackwitz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # xcres
2
+
3
+ [![Twitter: @mrackwitz](https://img.shields.io/badge/contact-@mrackwitz-blue.svg?style=flat)](https://twitter.com/mrackwitz)
4
+ [![Gem](https://img.shields.io/gem/v/xcres.svg?style=flat)](http://rubygems.org/gems/xcres)
5
+ [![Build Status](https://img.shields.io/travis/mrackwitz/xcres/master.svg?style=flat)](https://travis-ci.org/mrackwitz/xcres)
6
+ [![Inline Docs](http://inch-ci.org/github/mrackwitz/xcres.svg?branch=master&style=flat)](http://inch-ci.org/github/mrackwitz/xcres)
7
+
8
+ `xcres` searches your Xcode project for resources and generates an index
9
+ as struct constants. So you will never have to reference a resource, without
10
+ knowing already at compile time if it exists or not.
11
+
12
+ It includes **loose images**, **.bundles**, **asset catalogs** (.xcasset)
13
+ and even **.strings** in the index.
14
+
15
+ It gives you **code autocompletion** for resources and localized string keys,
16
+ without the need of an Xcode plugin.
17
+
18
+ Especially if your app is a bit more complex, this will greatly improve your
19
+ workflow. It ensures a better quality and gives you more safety.
20
+ You will see directly when a resource is missing, when you renamed it,
21
+ or you moved it around.
22
+
23
+ Furthermore it won't even bother you for trivial name changes like change
24
+ capitalization or converting name scheme from *train-case* or *snake_case* to
25
+ *camelCase* and vice versa.
26
+
27
+ It will warn you in Xcode on build, if certain resources or string keys can't be
28
+ references, because their name contain invalid chars, duplicates in the
29
+ *camelCase* variant with another key, or would be equal to a protected compiler
30
+ keyword.
31
+
32
+ The generated index could look like below.
33
+
34
+ While this is still **Objective-C**, `xcres` is compatible with **Swift**.
35
+ All you need to do is to add an import to the generated header to your
36
+ project's bridging header.
37
+
38
+ ```objc
39
+ const struct R {
40
+ struct Images {
41
+ /// doge.jpeg
42
+ __unsafe_unretained NSString *doge;
43
+ } Images;
44
+ struct ImagesAssets {
45
+ /// AppIcon
46
+ __unsafe_unretained NSString *app;
47
+ /// LaunchImage
48
+ __unsafe_unretained NSString *launch;
49
+ /// DefaultAvatar
50
+ __unsafe_unretained NSString *defaultAvatar;
51
+ } ImagesAssets;
52
+ struct Strings {
53
+ /// Password wrong!
54
+ __unsafe_unretained NSString *errorTitleWrongPassword;
55
+ /// Please enter the correct password.
56
+ __unsafe_unretained NSString *errorMessageWrongPassword;
57
+ } Strings;
58
+ } R;
59
+ ```
60
+
61
+
62
+ ## Installation
63
+
64
+ `xcres` is built with Ruby and it will be installable with the default
65
+ Ruby available on OS X. You can use a Ruby Version manager, if you know
66
+ what you're doing.
67
+ Using the default Ruby install will require you to use sudo when
68
+ installing gems. (This is only an issue for the duration of the gem
69
+ installation, though.)
70
+
71
+ Install the gem on your machine:
72
+
73
+ ```bash
74
+ $ [sudo] gem install xcres
75
+ ```
76
+
77
+ Use the automatic integration to add a build phase to your project,
78
+ by executing the following command:
79
+
80
+ ```bash
81
+ $ xcres install
82
+ ```
83
+
84
+
85
+ ## Usage
86
+
87
+ Reference your resources safely with the generated constants.
88
+
89
+ ### Asset Catalogs
90
+
91
+ Assuming your asset catalog is named `Images.xcassets`.
92
+ `xcres` supports multiple bundles in one project.
93
+
94
+ Instead of:
95
+
96
+ ```objc
97
+ [UIImage imageNamed:@"PersonDefaultAvatar"]
98
+ ```
99
+
100
+ Just write:
101
+
102
+ ```objc
103
+ [UIImage imageNamed:R.ImagesAssets.personDefaultAvatar]
104
+ ```
105
+
106
+ ##### How to Add a New Resource
107
+
108
+ 1. Add it to your asset catalog.
109
+ - Trigger a build. (**⌘ + B**)
110
+ - The new key will be available under
111
+ `R.${catalogName}Assets.${keyName:camelCase}`
112
+ and is ready for use in your code now.
113
+
114
+
115
+ ### Loose Images
116
+
117
+ Instead of:
118
+
119
+ ```objc
120
+ [UIImage imageNamed:@"table_header_background_image"]
121
+ ```
122
+
123
+ Just write:
124
+
125
+ ```objc
126
+ [UIImage imageNamed:R.Images.tableHeaderBackgroundImage]
127
+ ```
128
+
129
+ ##### How to Add a New Loose Image
130
+
131
+ 1. Drop the image in your project.
132
+ - Trigger a build. (**⌘ + B**)
133
+ - The new key will be available under `R.Images.${keyName:camelCase}`
134
+ and is ready for use in your code now.
135
+
136
+
137
+ ### Strings
138
+
139
+ Instead of:
140
+
141
+ ```objc
142
+ NSLocalizedString(@"error_message_wrong_password", @"Message shown if a wrong password was entered.")
143
+ ```
144
+
145
+ Just write:
146
+
147
+ ```objc
148
+ NSLocalizedString(R.Strings.errorMessageWrongPassword, @"Message shown if a wrong password was entered.")
149
+ ```
150
+
151
+
152
+ ##### How to Add a New String
153
+
154
+ With xcres your workflow for adding new strings will change slightly.
155
+
156
+ 1. Create a new string (at least) in your project's native development
157
+ language in one of the strings files included in your target.
158
+ (By default this will be `en.lproj/Localizable.strings`)
159
+ - Trigger a build. (**⌘ + B**)
160
+ - The new key will be available under `R.Strings.${keyName:camelCase}`
161
+ and is ready for use in your code now.
162
+
163
+
164
+ ## Known Issues & Tips
165
+
166
+ One minor drawback is that `genstrings` will not be helpful anymore.
167
+ But this tool is mostly useful in the first step, when bootstrapping
168
+ your project, until you care about internationalization and want to
169
+ provide translations.
170
+
171
+ xcres generally assumes that you don't use natural language for keys,
172
+ as this will led very fast to ambiguities. It will filter out unwanted
173
+ chars when transforming your keys to camel case notation, but it will
174
+ also warn you about those. It can be a help, if you want to migrate
175
+ your project to non-natural language keys.
176
+
177
+
178
+ ## License
179
+
180
+ xcres is available under MIT License.
181
+ See the LICENSE file for more info.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ #encoding: utf-8
2
+
3
+ begin
4
+ require 'bundler/gem_tasks'
5
+ require 'rubocop/rake_task'
6
+
7
+ namespace :install do
8
+ desc 'Install the gem as current user (NOT RECOMMENDED)'
9
+ task :user => ['build'] do
10
+ sh "gem install #{Dir['pkg/*.gem'].sort.last} --user-install"
11
+ end
12
+ end
13
+
14
+ namespace :lint do
15
+ RuboCop::RakeTask.new do |task|
16
+ task.patterns = ['lib/**/*.rb']
17
+ end
18
+
19
+ desc 'Run inch to see documentation coverage'
20
+ task :doc do
21
+ sh 'bundle exec inch'
22
+ end
23
+ end
24
+
25
+ namespace :spec do
26
+
27
+ task :prepare do
28
+ verbose false
29
+ puts 'Prepare …'
30
+ sh 'mkdir -p tmp'
31
+ rm_rf 'tmp/*'
32
+ end
33
+
34
+ desc 'Run all integration specs'
35
+ task :integration => [:prepare] do
36
+ sh 'bundle exec bacon spec/integration.rb'
37
+ end
38
+
39
+ desc 'Run all unit specs'
40
+ task :unit, [:spec] do |t, args|
41
+ sh "bundle exec bacon #{specs(args[:spec] || '**/*')}"
42
+ end
43
+
44
+ def specs(dir)
45
+ FileList["spec/unit/#{dir}_spec.rb"].shuffle.join(' ')
46
+ end
47
+
48
+ desc 'Run all specs'
49
+ task :all => [
50
+ :unit,
51
+ :integration
52
+ ]
53
+
54
+ end
55
+
56
+ desc 'Run all specs'
57
+ task :spec => 'spec:all'
58
+ end
data/bin/xcres ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $PROGRAM_NAME == __FILE__
4
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
+ end
9
+
10
+ require 'xcres'
11
+
12
+ XCRes::MainCommand.run
@@ -0,0 +1,48 @@
1
+ require 'xcres/analyzer/analyzer'
2
+
3
+ module XCRes
4
+
5
+ # A +AggregateAnalyzer+ runs multiple +Analyzer+.
6
+ #
7
+ class AggregateAnalyzer < Analyzer
8
+
9
+ # @return [Array<Analyzer>]
10
+ # an array of +Analyzer+.
11
+ attr_accessor :analyzers
12
+
13
+ def initialize(project=nil, options={})
14
+ super
15
+ self.analyzers = []
16
+ end
17
+
18
+ # Run all aggregated analyzers
19
+ #
20
+ # @return [Array<Hash>]
21
+ # the built sections
22
+ #
23
+ def analyze
24
+ @sections = analyzers.map(&:analyze).flatten.compact
25
+ end
26
+
27
+ # Instantiate and add an analyzer by its class.
28
+ # All properties will be copied to the child analyzer.
29
+ #
30
+ # @param [Class] analyzer_class
31
+ # the class of the analyzer to instantiate and add
32
+ #
33
+ # @param [Hash] options
34
+ # options which will be passed on initialization
35
+ #
36
+ # @return [Analyzer]
37
+ #
38
+ def add_with_class(analyzer_class, options={})
39
+ analyzer = analyzer_class.new(target, self.options.merge(options))
40
+ analyzer.exclude_file_patterns = exclude_file_patterns
41
+ analyzer.logger = logger
42
+ self.analyzers << analyzer
43
+ analyzer
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,141 @@
1
+ require 'xcodeproj'
2
+ require 'xcres/helper/file_helper'
3
+ require 'xcres/model/section'
4
+
5
+ module XCRes
6
+
7
+ # An +Analyzer+ scans the project for references,
8
+ # which should be included in the output file.
9
+ #
10
+ class Analyzer
11
+ include XCRes::FileHelper
12
+
13
+ # @return [PBXNativeTarget]
14
+ # the application target of the #project to analyze.
15
+ attr_reader :target
16
+
17
+ # @return [Array<Section>]
18
+ # the built sections
19
+ attr_reader :sections
20
+
21
+ # @return [Hash]
22
+ # the options passed to the sections
23
+ attr_accessor :options
24
+
25
+ # @return [Array<String>]
26
+ # the exclude file patterns
27
+ attr_accessor :exclude_file_patterns
28
+
29
+ # @return [Logger]
30
+ # the logger
31
+ attr_accessor :logger
32
+
33
+ delegate :inform, :log, :success, :warn, :fail, to: :logger
34
+
35
+ # Initialize a new analyzer
36
+ #
37
+ # @param [PBXNativeTarget] target
38
+ # see +target+.
39
+ #
40
+ # @param [Hash] options
41
+ # see subclasses.
42
+ #
43
+ def initialize(target=nil, options={})
44
+ @target = target
45
+ @sections = []
46
+ @exclude_file_patterns = []
47
+ @options = options
48
+ end
49
+
50
+ # Analyze the project
51
+ #
52
+ # @return [Array<Section>]
53
+ # the built sections
54
+ #
55
+ def analyze
56
+ # Empty stub implementation
57
+ end
58
+
59
+ # Return the Xcode project to analyze
60
+ #
61
+ # @return [Xcodeproj::Project]
62
+ #
63
+ def project
64
+ target.project
65
+ end
66
+
67
+ # Create a new +Section+.
68
+ #
69
+ # @param [String] name
70
+ # see Section#name
71
+ #
72
+ # @param [Hash] items
73
+ # see Section#items
74
+ #
75
+ # @param [Hash] options
76
+ # see Section#options
77
+ #
78
+ # @return [XCRes::Section]
79
+ #
80
+ def new_section(name, data, options={})
81
+ XCRes::Section.new(name, data, self.options.merge(options))
82
+ end
83
+
84
+ # Apply the configured exclude file patterns to a list of files
85
+ #
86
+ # @param [Array<Pathname>] file_paths
87
+ # the list of files to filter
88
+ #
89
+ # @param [Array<Pathname>]
90
+ # the filtered list of files
91
+ #
92
+ def filter_exclusions file_paths
93
+ file_paths.reject do |path|
94
+ exclude_file_patterns.any? { |pattern| File.fnmatch("#{pattern}", path) || File.fnmatch("**/#{pattern}", path) }
95
+ end
96
+ end
97
+
98
+ # Discover all references to files with a specific extension in project,
99
+ # which belong to a resources build phase of an application target.
100
+ #
101
+ # @param [String] extname
102
+ # the extname, which contains a leading dot
103
+ # e.g.: '.bundle', '.strings'
104
+ #
105
+ # @return [Array<PBXFileReference>]
106
+ #
107
+ def find_file_refs_by_extname(extname)
108
+ project.files.select do |file_ref|
109
+ File.extname(file_ref.path) == extname \
110
+ && is_file_ref_included_in_application_target?(file_ref)
111
+ end
112
+ end
113
+
114
+ # Checks if a file ref is included in any resources build phase of any
115
+ # of the application targets of the #project.
116
+ #
117
+ # @param [PBXFileReference] file_ref
118
+ # the file to search for
119
+ #
120
+ # @return [Bool]
121
+ #
122
+ def is_file_ref_included_in_application_target?(file_ref)
123
+ resources_files.include?(file_ref)
124
+ end
125
+
126
+ # Find files in resources build phases of application targets
127
+ #
128
+ # @return [Array<PBXFileReference>]
129
+ #
130
+ def resources_files
131
+ target.resources_build_phase.files.map do |build_file|
132
+ if build_file.file_ref.is_a?(Xcodeproj::Project::Object::PBXGroup)
133
+ build_file.file_ref.recursive_children
134
+ else
135
+ [build_file.file_ref]
136
+ end
137
+ end.flatten.compact
138
+ end
139
+
140
+ end
141
+ end
@@ -0,0 +1,27 @@
1
+ require 'xcres/analyzer/aggregate_analyzer'
2
+ require 'xcres/analyzer/resources_analyzer/bundle_resources_analyzer'
3
+ require 'xcres/analyzer/resources_analyzer/loose_resources_analyzer'
4
+ require 'xcres/analyzer/resources_analyzer/xcassets_analyzer'
5
+
6
+ module XCRes
7
+
8
+ # A +ResourcesAnalyzer+ scans the project for resources,
9
+ # which should be included in the output file.
10
+ #
11
+ # It is a +AggregateAnalyzer+, which uses the following child analyzers:
12
+ # * +XCRes::ResourcesAnalyzer::BundleResourcesAnalyzer+
13
+ # * +XCRes::ResourcesAnalyzer::LooseResourcesAnalyzer+
14
+ #
15
+ class ResourcesAggregateAnalyzer < AggregateAnalyzer
16
+
17
+ def analyze
18
+ self.analyzers = []
19
+ add_with_class ResourcesAnalyzer::BundleResourcesAnalyzer
20
+ add_with_class ResourcesAnalyzer::LooseResourcesAnalyzer
21
+ add_with_class ResourcesAnalyzer::XCAssetsAnalyzer
22
+ super
23
+ end
24
+
25
+ end
26
+
27
+ end