xcres 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,46 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::FileBuilder' do
4
+
5
+ def subject
6
+ XCRes::FileBuilder
7
+ end
8
+
9
+ before do
10
+ @builder = subject.new
11
+ @builder.logger = stub('Logger')
12
+ end
13
+
14
+ describe "#prepare_output_path!" do
15
+ # TODO: Mock fs
16
+ end
17
+
18
+ describe "#build" do
19
+ it 'should prepare output path' do
20
+ @builder.expects(:prepare_output_path!)
21
+ @builder.build
22
+ end
23
+ end
24
+
25
+ describe "#build_contents" do
26
+ it 'should call the given block' do
27
+ proc = Proc.new {}
28
+ proc.expects(:call)
29
+ @builder.build_contents &proc
30
+ end
31
+
32
+ it 'should pass a StringBuilder as first argument to the given block' do
33
+ @builder.build_contents do |builder|
34
+ builder.should.be.an.instance_of?(XCRes::StringBuilder)
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#write_file_eventually" do
40
+ # TODO: Mock fs
41
+ end
42
+
43
+ describe "#write_file" do
44
+ # TODO: Mock fs
45
+ end
46
+ end
@@ -0,0 +1,50 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::ResourcesBuilder' do
4
+
5
+ def subject
6
+ XCRes::ResourcesBuilder
7
+ end
8
+
9
+ before do
10
+ @builder = subject.new
11
+ @builder.logger = stub('Logger')
12
+ end
13
+
14
+ describe "#initialize" do
15
+ it 'should set attribute documented to true' do
16
+ @builder.documented.should.be.true?
17
+ end
18
+ end
19
+
20
+ describe "#resources_constant_name" do
21
+ it 'should use the configured resources constant name' do
22
+ @builder.resources_constant_name = 'test'
23
+ @builder.resources_constant_name.should.be.eql?('test')
24
+ end
25
+
26
+ it 'should fallback to the basename of the output path' do
27
+ @builder.output_path = 'test/R.m'
28
+ @builder.resources_constant_name.should.be.eql?('R')
29
+ end
30
+ end
31
+
32
+ describe '#add_section' do
33
+ it 'should raise if no items are given' do
34
+ -> {
35
+ @builder.add_section 'Test', nil
36
+ }.should.raise?(ArgumentError, 'No items are given!')
37
+ end
38
+
39
+ it 'should not add keys, which are protected keywords' do
40
+ @builder.logger.expects(:warn).twice
41
+ @builder.add_section 'Test', {
42
+ 'default' => 'Default.png',
43
+ 'cat' => 'cat.gif',
44
+ 'auto' => 'auto.jpg'
45
+ }
46
+ @builder.sections.should.be.eql?('Test' => { 'cat' => 'cat.gif' })
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,76 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::StringBuilder' do
4
+
5
+ def subject
6
+ XCRes::StringBuilder
7
+ end
8
+
9
+ before do
10
+ @builder = subject.new
11
+ end
12
+
13
+ describe '#initialize' do
14
+ it 'should set indentation string' do
15
+ @builder.indentation_string.should.be.eql?(' ')
16
+ end
17
+
18
+ it 'should set an empty result' do
19
+ @builder.result.should.be.not.nil?
20
+ @builder.result.should.be.empty?
21
+ end
22
+ end
23
+
24
+ describe '#write' do
25
+ it 'should add input to result' do
26
+ @builder.write 'test'
27
+ @builder.result.should.be.eql?('test')
28
+ end
29
+
30
+ it 'should not add any separation' do
31
+ @builder.write 'foo'
32
+ @builder.write 'bar'
33
+ @builder.result.should.be.eql?('foobar')
34
+ end
35
+ end
36
+
37
+ describe '#writeln' do
38
+ it 'should write a new line' do
39
+ @builder.write '{'
40
+ @builder.writeln 'foo'
41
+ @builder.write '}'
42
+ @builder.result.should.be.eql?("{foo\n}")
43
+ end
44
+
45
+ it 'should write just a new line' do
46
+ @builder.writeln
47
+ @builder.result.should.be.eql?("\n")
48
+ end
49
+ end
50
+
51
+ describe '#section' do
52
+ it 'should write a section with increased indentation' do
53
+ @builder.writeln '{'
54
+ @builder.section do |b|
55
+ b.writeln 'c'
56
+ end
57
+ @builder.writeln '}'
58
+ @builder.result.should.be.eql?("{\n c\n}\n")
59
+ end
60
+
61
+ it 'should write a sub section with increased indentation' do
62
+ @builder.indentation_string = ' '
63
+ @builder.writeln 'a{'
64
+ @builder.section do |b|
65
+ b.writeln 'b{'
66
+ b.section do |b|
67
+ b.writeln 'c'
68
+ end
69
+ b.writeln '}b'
70
+ end
71
+ @builder.writeln '}a'
72
+ @builder.result.should.be.eql?("a{\n b{\n c\n }b\n}a\n")
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::MainCommand' do
4
+
5
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::ProjectCommand' do
4
+
5
+ def subject
6
+ XCRes::ProjectCommand
7
+ end
8
+
9
+ before do
10
+ @cmd = subject.new('xcres', [], {})
11
+ @cmd.stubs(:project).returns(xcodeproj)
12
+ end
13
+
14
+ describe '#application_targets' do
15
+ it 'should return the expected application target' do
16
+ @cmd.application_targets.count.should.eql? 1
17
+ target = @cmd.application_targets.first
18
+ target.should.be.an.instance_of?(Xcodeproj::Project::Object::PBXNativeTarget)
19
+ target.name.should.eql?('Example')
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::FileHelper' do
4
+
5
+ def subject
6
+ Class.new.class_eval { include XCRes::FileHelper }.new
7
+ end
8
+
9
+ describe '#basename_without_ext' do
10
+ it 'should raise if the name is not given' do
11
+ -> { subject.basename_without_ext(nil) }.should.raise?(TypeError)
12
+ end
13
+
14
+ it 'should return the name itself if there is not extension' do
15
+ subject.basename_without_ext('dir/base').should.be.eql?('base')
16
+ end
17
+
18
+ it 'should return the name without extension' do
19
+ subject.basename_without_ext('b/a.gif').should.be.eql?('a')
20
+ subject.basename_without_ext('b/A.bundle').should.be.eql?('A')
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,142 @@
1
+ #encoding: utf-8
2
+
3
+ require File.expand_path('../spec_helper', __FILE__)
4
+
5
+ describe 'XCRes::LoggerSpec' do
6
+
7
+ def subject
8
+ XCRes::Logger
9
+ end
10
+
11
+ before do
12
+ @logger = subject.new
13
+
14
+ # Capture the STDOUT
15
+ @out = StringIO.new("")
16
+ $stdout = @out
17
+ def out
18
+ @out.string.chomp
19
+ end
20
+ end
21
+
22
+ after do
23
+ $stdout = STDOUT
24
+ end
25
+
26
+ describe '#initialize' do
27
+ it 'should set attribute colored to true by default' do
28
+ @logger.colored.should.be.true?
29
+ end
30
+
31
+ it 'should set attribute verbose to false by default' do
32
+ @logger.verbose.should.be.false?
33
+ end
34
+
35
+ it 'should set attribute silent to false by default' do
36
+ @logger.silent.should.be.false?
37
+ end
38
+
39
+ it 'should set attribute indentation to an empty string by default' do
40
+ @logger.indentation.should.be.eql?('')
41
+ end
42
+ end
43
+
44
+ describe '#inform' do
45
+ it 'prints the message' do
46
+ @logger.inform '%s %s %s', 'a', 'b', 'c'
47
+ out.should.be.eql? 'a b c'
48
+ end
49
+
50
+ it 'prints the message with indentation if set' do
51
+ @logger.indentation = ' '
52
+ @logger.inform 'attention'
53
+ out.should.be.eql? ' attention'
54
+ end
55
+ end
56
+
57
+ describe '#inform_colored' do
58
+ it 'works with string placeholders' do
59
+ @logger.inform_colored 'a %s c', :red, 'b'
60
+ out.should.be.eql? "\e[31ma \e[0m\e[31m\e[1mb\e[0m\e[0m\e[31m c\e[0m"
61
+ end
62
+
63
+ it 'works with multiple placeholders' do
64
+ @logger.inform_colored 'a %s c %s e', :red, 'b', 'd'
65
+ out.should.be.eql? "\e[31ma \e[0m\e[31m\e[1mb\e[0m\e[0m\e[31m c \e[0m\e[31m\e[1md\e[0m\e[0m\e[31m e\e[0m"
66
+ end
67
+
68
+ it 'works with integer number placeholders' do
69
+ @logger.inform_colored '%d', :red, 2
70
+ out.should.be.eql? "\e[31m\e[1m2\e[0m\e[0m"
71
+ end
72
+
73
+ it 'works with floating point number placeholders' do
74
+ @logger.inform_colored '%.5f', :red, 3.14159265359
75
+ out.should.be.eql? "\e[31m\e[1m3.14159\e[0m\e[0m"
76
+ end
77
+
78
+ it 'works with more complex placeholders' do
79
+ @logger.inform_colored '%1$#+10.d', :red, 1234
80
+ out.should.be.eql? "\e[31m\e[1m +1234\e[0m\e[0m"
81
+ end
82
+
83
+ it 'works with escaped percents' do
84
+ @logger.inform_colored '%%', :red
85
+ out.should.be.eql? "\e[31m%\e[0m"
86
+ end
87
+
88
+ it 'doesn\'t fail because of unescaped percents' do
89
+ -> {
90
+ @logger.inform_colored '%s', :red, '%'
91
+ }.should.not.raise?(ArgumentError)
92
+ end
93
+ end
94
+
95
+ describe '#log' do
96
+ it 'prints nothing by default' do
97
+ @logger.log 'test'
98
+ out.should.be.empty?
99
+ end
100
+
101
+ it 'prints the message in verbose mode' do
102
+ @logger.verbose = true
103
+ @logger.log 'test'
104
+ out.should.be.eql? "\e[35mⓋ test\e[0m"
105
+ end
106
+ end
107
+
108
+ describe '#success' do
109
+ it 'prints the message' do
110
+ @logger.success 'test'
111
+ out.should.be.eql? "\e[32m✓ test\e[0m"
112
+ end
113
+ end
114
+
115
+ describe '#warn' do
116
+ it 'prints the message' do
117
+ @logger.warn 'test'
118
+ out.should.be.eql? "\e[33m⚠ test\e[0m"
119
+ end
120
+ end
121
+
122
+ describe '#fail' do
123
+ it 'accepts a String as message' do
124
+ @logger.fail 'test'
125
+ out.should.be.eql? "\e[31m✗ test\e[0m"
126
+ end
127
+
128
+ it 'accepts an Exception as message' do
129
+ @logger.fail StandardError.new('test')
130
+ out.should.be.eql? "\e[31m✗ test\e[0m"
131
+ end
132
+
133
+ it 'prints the backtrace in verbose mode' do
134
+ @logger.verbose = true
135
+ exception = StandardError.new 'test'
136
+ exception.expects(backtrace: %w[a b])
137
+ @logger.fail exception
138
+ out.should.be.eql? "\e[31m✗ test\e[0m\n\e[35mⓋ Backtrace:\na\nb\e[0m"
139
+ end
140
+ end
141
+
142
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe 'XCRes::Section' do
4
+
5
+ def subject
6
+ XCRes::Section
7
+ end
8
+
9
+ describe '#initialize' do
10
+ it 'should initialize a new section without options' do
11
+ section = subject.new('Name', { 'a' => 'a.gif' })
12
+ section.name.should.be.eql?('Name')
13
+ section.items.should.be.eql?({ 'a' => 'a.gif' })
14
+ section.options.should.be.eql?({})
15
+ end
16
+
17
+ it 'should initialize a new section with options' do
18
+ section = subject.new('Name', { 'a' => 'a.gif' }, { custom_flag: true })
19
+ section.name.should.be.eql?('Name')
20
+ section.items.should.be.eql?({ 'a' => 'a.gif' })
21
+ section.options.should.be.eql?({ custom_flag: true })
22
+ end
23
+ end
24
+
25
+ describe '#==' do
26
+ before do
27
+ @left = subject.new('Cats', 'cat' => 'cat.gif')
28
+ end
29
+
30
+ it 'should be true for equal sections' do
31
+ (@left == subject.new('Cats', 'cat' => 'cat.gif')).should.be.true?
32
+ end
33
+
34
+ it 'should be false if name is different' do
35
+ (@left == subject.new('Dog', 'cat' => 'cat.gif')).should.be.false?
36
+ end
37
+
38
+ it 'should be false if items are different' do
39
+ (@left == subject.new('Cat', 'dog' => 'dog.gif')).should.be.false?
40
+ end
41
+
42
+ it 'should be false if options are different' do
43
+ (@left == subject.new('Cat', { 'cat' => 'cat.gif' }, custom_flag: true)).should.be.false?
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,154 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module XCAssetsSpec
4
+ describe 'XCRes::XCAssets::Bundle' do
5
+
6
+ def subject
7
+ Bundle
8
+ end
9
+
10
+ describe "::open" do
11
+ it 'should read the bundle at given path' do
12
+ subject.any_instance.expects(:read)
13
+ subject.open('.')
14
+ end
15
+ end
16
+
17
+ describe "#initialize" do
18
+ it 'should not require any arguments' do
19
+ -> { subject.new }.should.not.raise?
20
+ end
21
+
22
+ describe 'first argument' do
23
+ it 'should box it in Pathname and set it as attribute path' do
24
+ subject.new('.').path.should.be.eql?(Pathname('.'))
25
+ end
26
+
27
+ it 'should set it as attribute path' do
28
+ subject.new(Pathname('.')).path.should.be.eql?(Pathname('.'))
29
+ end
30
+ end
31
+
32
+ it 'should initialize attribute resources with an empty array' do
33
+ subject.new.resources.should.be.eql?([])
34
+ end
35
+ end
36
+
37
+ describe "#read" do
38
+ before do
39
+ @bundle = subject.new(xcassets_fixture_path)
40
+ @bundle.read
41
+ end
42
+
43
+ it 'should set the resource paths' do
44
+ @bundle.resource_paths.should.be.eql? [
45
+ Pathname('AppIcon.appiconset'),
46
+ Pathname('Doge.imageset'),
47
+ Pathname('LaunchImage.launchimage'),
48
+ ]
49
+ end
50
+
51
+ shared 'XCAssets resource' do
52
+ it 'should match the info' do
53
+ @res.info.should.be.eql?({ "version" => 1, "author" => "xcode" })
54
+ end
55
+ end
56
+
57
+ describe 'resources' do
58
+ describe 'AppIcon.appiconset' do
59
+ before { @res = @bundle.resources[0] }
60
+
61
+ behaves_like 'XCAssets resource'
62
+
63
+ it 'should match the path' do
64
+ @res.path.should.be.eql? Pathname('AppIcon.appiconset')
65
+ end
66
+
67
+ it 'should match the name' do
68
+ @res.name.should.be.eql? 'AppIcon'
69
+ end
70
+
71
+ it 'should match the type' do
72
+ @res.type.should.be.eql? 'appiconset'
73
+ end
74
+
75
+ it 'should match the images' do
76
+ @res.images.should.be.eql? [
77
+ ResourceImage.new(idiom: 'iphone', scale: 2, size: '29x29'),
78
+ ResourceImage.new(idiom: 'iphone', scale: 2, size: '40x40'),
79
+ ResourceImage.new(idiom: 'iphone', scale: 2, size: '60x60'),
80
+ ]
81
+ end
82
+ end
83
+
84
+ describe 'Doge.imageset' do
85
+ before { @res = @bundle.resources[1] }
86
+
87
+ behaves_like 'XCAssets resource'
88
+
89
+ it 'should match the path' do
90
+ @res.path.should.be.eql? Pathname('Doge.imageset')
91
+ end
92
+
93
+ it 'should match the name' do
94
+ @res.name.should.be.eql? 'Doge'
95
+ end
96
+
97
+ it 'should match the type' do
98
+ @res.type.should.be.eql? 'imageset'
99
+ end
100
+
101
+ it 'should match the info' do
102
+ @res.info.should.be.eql?({ "version" => 1, "author" => "xcode" })
103
+ end
104
+
105
+ it 'should match the images' do
106
+ @res.images.should.be.eql? [
107
+ ResourceImage.new(idiom: 'universal', scale: 1, filename: 'doge.png'),
108
+ ResourceImage.new(idiom: 'universal', scale: 2, filename: 'doge@2x.png'),
109
+ ]
110
+ end
111
+ end
112
+
113
+ describe 'LaunchImage.launchimage' do
114
+ before { @res = @bundle.resources[2] }
115
+
116
+ behaves_like 'XCAssets resource'
117
+
118
+ it 'should match the path' do
119
+ @res.path.should.be.eql? Pathname('LaunchImage.launchimage')
120
+ end
121
+
122
+ it 'should match the name' do
123
+ @res.name.should.be.eql? 'LaunchImage'
124
+ end
125
+
126
+ it 'should match the type' do
127
+ @res.type.should.be.eql? 'launchimage'
128
+ end
129
+
130
+ it 'should match the images' do
131
+ @res.images.should.be.eql? [
132
+ ResourceImage.new({
133
+ orientation: 'portrait',
134
+ idiom: 'iphone',
135
+ extent: 'full-screen',
136
+ minimum_system_version: '7.0',
137
+ scale: 2,
138
+ }),
139
+ ResourceImage.new({
140
+ orientation: 'portrait',
141
+ idiom: 'iphone',
142
+ extent: 'full-screen',
143
+ minimum_system_version: '7.0',
144
+ scale: 2,
145
+ subtype: 'retina4',
146
+ }),
147
+ ]
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ end
154
+ end