i18n-js-assets 1.1.0 → 1.2.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 (149) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/Rakefile +9 -0
  4. data/i18n-js-assets.gemspec +8 -2
  5. data/lib/i18n-js-assets.rb +17 -1
  6. data/lib/i18n-js-assets/entry.rb +58 -0
  7. data/lib/i18n-js-assets/i18njs_file.rb +47 -0
  8. data/lib/i18n-js-assets/manifest.rb +23 -0
  9. data/lib/i18n-js-assets/processor.rb +10 -4
  10. data/lib/i18n-js-assets/railtie.rb +23 -2
  11. data/lib/i18n-js-assets/version.rb +1 -1
  12. data/spec/app/assets/javascripts/application.js +1 -1
  13. data/spec/app/assets/javascripts/{i18n/translations.js.i18njs → translations/includable.js.i18njs} +0 -0
  14. data/spec/app/assets/javascripts/translations/language_specific.js.i18njs +3 -0
  15. data/spec/app/assets/javascripts/translations/precompilable.js.i18njs +1 -0
  16. data/spec/config/application.rb +10 -0
  17. data/spec/entry_spec.rb +44 -0
  18. data/spec/i18njs_file_spec.rb +62 -0
  19. data/spec/inline_spec.rb +17 -0
  20. data/spec/log/development.log +0 -0
  21. data/spec/log/test.log +110 -10
  22. data/spec/manifest_spec.rb +31 -0
  23. data/spec/precomp_spec.rb +38 -0
  24. data/spec/public/assets/application-32116ac999bceaf256827b79e929af35.js +3 -0
  25. data/spec/public/assets/application-32116ac999bceaf256827b79e929af35.js.gz +0 -0
  26. data/spec/public/assets/application.js +3 -0
  27. data/spec/public/assets/application.js.gz +0 -0
  28. data/spec/public/assets/manifest.yml +7 -0
  29. data/spec/public/assets/translations/precompilable-en-ae4c2761adea53027ecac38df3cba003.js +2 -0
  30. data/spec/public/assets/translations/precompilable-en-ae4c2761adea53027ecac38df3cba003.js.gz +0 -0
  31. data/spec/public/assets/translations/precompilable-en.js +2 -0
  32. data/spec/public/assets/translations/precompilable-en.js.gz +0 -0
  33. data/spec/public/assets/translations/precompilable-es-0d74aac120793e338c442e9474fcce3d.js +2 -0
  34. data/spec/public/assets/translations/precompilable-es-0d74aac120793e338c442e9474fcce3d.js.gz +0 -0
  35. data/spec/public/assets/translations/precompilable-es.js +2 -0
  36. data/spec/public/assets/translations/precompilable-es.js.gz +0 -0
  37. data/spec/spec_helper.rb +50 -12
  38. data/spec/tmp/cache/assets/C79/C70/sprockets%2F5d99787805ea7839fb86899402d8024f +0 -0
  39. data/spec/tmp/cache/assets/CB4/950/sprockets%2F501b8f2f906c6f3568786c390e3ba313 +0 -0
  40. data/spec/tmp/cache/assets/D32/080/sprockets%2F1bac68a17f3f321407d5b99df2601b5a +0 -0
  41. data/spec/tmp/cache/assets/D50/0C0/sprockets%2Fe11c0643ab40122ee9d776aca1e35b0a +0 -0
  42. data/spec/tmp/cache/assets/D73/A80/sprockets%2F9553e5d4b42d1e4b9fa4df58180cb85a +0 -0
  43. data/spec/tmp/cache/assets/D96/670/sprockets%2Fcb86e9ec4c1a3bd547ea310fdc737241 +0 -0
  44. metadata +63 -124
  45. data/spec/processor_spec.rb +0 -17
  46. data/spec/tmp/cache/assets/test/sprockets/v3.0/0TGG4strnS9VCrKg5IAPvdpqabFzfjJoxYSdYm5ihro.cache +0 -1
  47. data/spec/tmp/cache/assets/test/sprockets/v3.0/0eY8r3NjeD9fdoOShXKpsVpdH1jKQnwWx52C-B4Zdew.cache +0 -1
  48. data/spec/tmp/cache/assets/test/sprockets/v3.0/0riUBX-xAnCHYxQxiKuHgfQwr3fEdOjP_pU5T1J8l3c.cache +0 -2
  49. data/spec/tmp/cache/assets/test/sprockets/v3.0/1VEraULc9iuVPKnPp4rdF9d8U77SAGBt20GRx43YUdU.cache +0 -2
  50. data/spec/tmp/cache/assets/test/sprockets/v3.0/2AzkFeBliWpNOZqRYWdcgpn6qq2KQqQQhUsugTGTnAI.cache +0 -1
  51. data/spec/tmp/cache/assets/test/sprockets/v3.0/2CVcJp8utIPN_brzbVn2SeH5kRUrc-m-PCSKQcuLYFE.cache +0 -0
  52. data/spec/tmp/cache/assets/test/sprockets/v3.0/35f7ghn0_mSkJse_DDlsJXCH-aTRupAT38ebmrs-mOk.cache +0 -1
  53. data/spec/tmp/cache/assets/test/sprockets/v3.0/38l6-XpQ1nm9htHr0KD0cX1WFEVfu1GAQA8I_i81fBY.cache +0 -0
  54. data/spec/tmp/cache/assets/test/sprockets/v3.0/3WOA-jLgGTm5RG6xu5pQexhrfWnw_BXmSGl-QdIjdRE.cache +0 -1
  55. data/spec/tmp/cache/assets/test/sprockets/v3.0/4WQBXO4vTppErpRc5K1HM82jj5SJHracrEnk4jmQRCY.cache +0 -3
  56. data/spec/tmp/cache/assets/test/sprockets/v3.0/6ZRcOCLxuDpT3yENhV0aZMV_9gJI1TQwT77QMgIK37A.cache +0 -1
  57. data/spec/tmp/cache/assets/test/sprockets/v3.0/7a2W-xe7KVORjoLfqF5u7YLOvXiNUac9_wGnLl6Su0E.cache +0 -1
  58. data/spec/tmp/cache/assets/test/sprockets/v3.0/7boCXuGzdav81MPcjpSExjXwogaP70OGTjzM71PV3PQ.cache +0 -0
  59. data/spec/tmp/cache/assets/test/sprockets/v3.0/7sHVj7BzKNGoCFZ-kjevXptnptNgZyPNT5fLTp0FKWM.cache +0 -0
  60. data/spec/tmp/cache/assets/test/sprockets/v3.0/81rUcRAwllX3CIhsRXRBASug4DR0ab80NQn5gKVcrJQ.cache +0 -1
  61. data/spec/tmp/cache/assets/test/sprockets/v3.0/8tAhoU9B1TigzW0Xqag4FR3VemV2jgZE5lOCwtW2dn0.cache +0 -1
  62. data/spec/tmp/cache/assets/test/sprockets/v3.0/9-0DfGh6aoQkp2uOORK-KDzIjbVGG_tmfzBHiiDkJL0.cache +0 -1
  63. data/spec/tmp/cache/assets/test/sprockets/v3.0/9947MRIXBZZlIs2e2uu5e4JwuyoUz4FOZUPnPXHlUpU.cache +0 -1
  64. data/spec/tmp/cache/assets/test/sprockets/v3.0/ATw-HFCljNcwJ2-e_wTnROfZbnLCogiFZ5Fg5Yh8Sb4.cache +0 -1
  65. data/spec/tmp/cache/assets/test/sprockets/v3.0/ApElClNFEj6QTX7Ul2-O4qX3NIH2vaeK8noatReSmro.cache +0 -2
  66. data/spec/tmp/cache/assets/test/sprockets/v3.0/ApHoGQxwcRptNhfXJF_0QQYO79_9HKrWUR6Ms6HYyMw.cache +0 -1
  67. data/spec/tmp/cache/assets/test/sprockets/v3.0/BG9aDmUmSfTlg7NL30JXABxngL8-gIX9LAIo4x5vSts.cache +0 -1
  68. data/spec/tmp/cache/assets/test/sprockets/v3.0/BPBdHaZXRy26VkxJeR9bn6i9_nKLz-OXtKIwrlIGmps.cache +0 -1
  69. data/spec/tmp/cache/assets/test/sprockets/v3.0/CV1DkVWu2-JTjY2UN5j6oWBWj7Mq8sVhZ7Dh08TytWs.cache +0 -1
  70. data/spec/tmp/cache/assets/test/sprockets/v3.0/DURg9G5HZuC8CZOsiz_RSQyZNFHucTumI1JHNl7MQBI.cache +0 -0
  71. data/spec/tmp/cache/assets/test/sprockets/v3.0/EHAlDYDntn17_yishOhQPB3FtisCTAYrxAJ3yMU8nLY.cache +0 -1
  72. data/spec/tmp/cache/assets/test/sprockets/v3.0/EYsEe08MA8Uw1S-16OjCG7Ii1q3sXFWk8SBOuYUcPs8.cache +0 -1
  73. data/spec/tmp/cache/assets/test/sprockets/v3.0/FR_RX7YN2iO_0xHyzwewJw_tsrb-liCVvnkz8YvEnRk.cache +0 -1
  74. data/spec/tmp/cache/assets/test/sprockets/v3.0/F_Lqv3cyMXGH1AjfyMu442ztwqqdAN78jvw3D9Z_QMY.cache +0 -1
  75. data/spec/tmp/cache/assets/test/sprockets/v3.0/Gu_PnxeyLXW98LHpDxlE-OIKE1rQYJu5nZZiviI55dM.cache +0 -1
  76. data/spec/tmp/cache/assets/test/sprockets/v3.0/HaJSlzbPk33aLK4Reo0BpyqXGIvgIeSKgPNVlZyRhrs.cache +0 -0
  77. data/spec/tmp/cache/assets/test/sprockets/v3.0/HbDKDH2JN_XyXyaChQWJ5N7tASQXnuup3xEO03zZ4Hc.cache +0 -0
  78. data/spec/tmp/cache/assets/test/sprockets/v3.0/HjNvkqQ2OZcfhOwtYH7PJ8U410e9nJ6Z9z7gZPLsScU.cache +0 -1
  79. data/spec/tmp/cache/assets/test/sprockets/v3.0/HoXEYriyqTy50oFKUBnr727o_n0QAnuwuW45sAHNr50.cache +0 -1
  80. data/spec/tmp/cache/assets/test/sprockets/v3.0/IXYpi0Zz5dRF7Gx6fg37WshI0Y1J92wf3uEENugBpvA.cache +0 -0
  81. data/spec/tmp/cache/assets/test/sprockets/v3.0/JwO18_SZpJhx_6zRpzFrsqyXomH2tWnPbg_OQXV59Bo.cache +0 -0
  82. data/spec/tmp/cache/assets/test/sprockets/v3.0/KO3NfRq14AVG64OPOQSveHHDFAvxIw8efzqSy7RFxkU.cache +0 -0
  83. data/spec/tmp/cache/assets/test/sprockets/v3.0/KqHxVfNJuBW3gCmRrfJXyVttZZiJS6JwCoVfnzxXIe8.cache +0 -1
  84. data/spec/tmp/cache/assets/test/sprockets/v3.0/KxDS3J89t0kst_z-wBsMN1H7ePUqYAdRl4wMdsaBNSY.cache +0 -1
  85. data/spec/tmp/cache/assets/test/sprockets/v3.0/L1Ez-kjgZL-5Rz4g27reVbC8GJ7Hm4xbcPtTKumBzYw.cache +0 -2
  86. data/spec/tmp/cache/assets/test/sprockets/v3.0/L2vwbr0cwgm0qW1FuZ_VPzSvK1Vy4fGFvA2ZVYDc5Js.cache +0 -2
  87. data/spec/tmp/cache/assets/test/sprockets/v3.0/LEY95r7yjJ05--DGxpz2RO9mjpX6bfW__0LfspYgf54.cache +0 -0
  88. data/spec/tmp/cache/assets/test/sprockets/v3.0/LJwlYUVWX9A5d5F_1FwbWdn0N1VEv6CFzaRCau1ozVM.cache +0 -1
  89. data/spec/tmp/cache/assets/test/sprockets/v3.0/LUxJSgbE36LRmWl4Dp-FWAFDdk3gYEdMcV1vgBpfLrI.cache +0 -1
  90. data/spec/tmp/cache/assets/test/sprockets/v3.0/MIxcK-2b2D-GuW3sVkIZInt2-4viQ7-MvOTTwanZLn8.cache +0 -1
  91. data/spec/tmp/cache/assets/test/sprockets/v3.0/MKD5ATR0ZXGN21NCxZ_M5GiRMeo5oWbcu6kCDbyaMtc.cache +0 -0
  92. data/spec/tmp/cache/assets/test/sprockets/v3.0/MgT2Id3_-5Hdcw4TJvXALngfQa5I4h4jM7sIIjpw_Yo.cache +0 -0
  93. data/spec/tmp/cache/assets/test/sprockets/v3.0/No_dmRoPMIHiRkcPj1CEeVmynRfqX36-LPYeGxJ-gZc.cache +0 -0
  94. data/spec/tmp/cache/assets/test/sprockets/v3.0/NvGtE9n4Yk5sQUYKdNLyhQAHlawioR4hkjFzGA2N3_0.cache +0 -0
  95. data/spec/tmp/cache/assets/test/sprockets/v3.0/OOoGx4FoTR_WsHPZbQFRECX5ZF2zaEHPfE5MnW22Axc.cache +0 -1
  96. data/spec/tmp/cache/assets/test/sprockets/v3.0/OQ7O9QWx9JAPuQcrZWiDWkmwTR2FEKe3vi7NysnOJOs.cache +0 -1
  97. data/spec/tmp/cache/assets/test/sprockets/v3.0/Qo-0_hupmKRdmVjcpLB-iBD5ebhJu_VFPVnEITJXBws.cache +0 -0
  98. data/spec/tmp/cache/assets/test/sprockets/v3.0/TSBNHjSWXHIodyAgZYeqcmCMcdQ_xVnR4Op3XEbhQTw.cache +0 -0
  99. data/spec/tmp/cache/assets/test/sprockets/v3.0/TktEB5bYoXHKQSP5X7-RXRCvOByGLNWguC3wfljmHYg.cache +0 -1
  100. data/spec/tmp/cache/assets/test/sprockets/v3.0/UZ16yMTPWmwcDHYPYcdyzzvU_i6Qs2zSVY8RPFw4MpM.cache +0 -0
  101. data/spec/tmp/cache/assets/test/sprockets/v3.0/Xpeh2lygo1r2JCJeM4zoFpAZFFmoZocCdxr1x01ykpA.cache +0 -1
  102. data/spec/tmp/cache/assets/test/sprockets/v3.0/YgS78wW5O_M1BBIK1_ttlGXW9fYrbWW-c1lnbYAjXgs.cache +0 -0
  103. data/spec/tmp/cache/assets/test/sprockets/v3.0/_1mdRko1o9Uuyv1v7wd1NBrQJ_5fYKwLQ12W0WwBQUY.cache +0 -1
  104. data/spec/tmp/cache/assets/test/sprockets/v3.0/_fjUOVq7VdVTRIoEaHM8dc8kMbuZMKTd9puafDvhXAU.cache +0 -0
  105. data/spec/tmp/cache/assets/test/sprockets/v3.0/a6WLa8ZPC7LFh1IXxigNkXyJNSiJgmOBbdLpPIcCK2g.cache +0 -1
  106. data/spec/tmp/cache/assets/test/sprockets/v3.0/aE-uoFK0v9VMpvwk2AuMAYI6R-uFQIAlubEojUaA044.cache +0 -0
  107. data/spec/tmp/cache/assets/test/sprockets/v3.0/b5OiMehPg7TIbXFMKkHTHFpQ0gghPCJefZ-VacZcZL4.cache +0 -1
  108. data/spec/tmp/cache/assets/test/sprockets/v3.0/b9xLeljZA3ByNUGutTYgs1UoHPsJs95KNmCvBHQP9jw.cache +0 -0
  109. data/spec/tmp/cache/assets/test/sprockets/v3.0/dZAVBQBPnTeBqjXXfU-pfcGR2xnrWGykeKSGA0t3BJU.cache +0 -0
  110. data/spec/tmp/cache/assets/test/sprockets/v3.0/ePXdqTVn5BL-znKYqWS_qd6d4uzkogyvPJp0tVx_ioo.cache +0 -2
  111. data/spec/tmp/cache/assets/test/sprockets/v3.0/eQgWH5p4wKPuJ3F9N1nFpTpgAghBBTGXGID3hd_f5-I.cache +0 -0
  112. data/spec/tmp/cache/assets/test/sprockets/v3.0/gJGBNnb1dP4_aKOwLCD1hx2HH74XUfLb0E9u26YmpXs.cache +0 -0
  113. data/spec/tmp/cache/assets/test/sprockets/v3.0/gsvSWa0fFKgTjOstOXGrsgm3Pt_5gDs6Eggcn3OZZDE.cache +0 -1
  114. data/spec/tmp/cache/assets/test/sprockets/v3.0/hzWfzU_dvpBXKfIMNmknvVYVRN_xOKG8LgEate7K7ek.cache +0 -0
  115. data/spec/tmp/cache/assets/test/sprockets/v3.0/iE05xqTvW-S0qz7F23qKR3PhjaChA59dm8TuIcXT4bI.cache +0 -0
  116. data/spec/tmp/cache/assets/test/sprockets/v3.0/ifRrKzWfgw7qAq5S-MGGDPCs8RCuP8XEp9WVM8BmKz4.cache +0 -0
  117. data/spec/tmp/cache/assets/test/sprockets/v3.0/ijVKQkFNUMPubR5uraIc039Tq-42qWYwA7nv9NCuRfc.cache +0 -1
  118. data/spec/tmp/cache/assets/test/sprockets/v3.0/ir0DEh3GlJFGd8_SbLRZ0tssB0HRaMXAIZaXYR5y7ks.cache +0 -0
  119. data/spec/tmp/cache/assets/test/sprockets/v3.0/j00cx4gIBGrODOXarP6Qjy0xeZaO2Jp8rTjmjbD_bNg.cache +0 -0
  120. data/spec/tmp/cache/assets/test/sprockets/v3.0/jwwbsek2OuRlzomee3PcYA25JJSINlJjHU_6xBzeHh4.cache +0 -0
  121. data/spec/tmp/cache/assets/test/sprockets/v3.0/m1nR-_fLfDm6M9s2lyM9QmkUa86QkgtV0s0GlImWdr0.cache +0 -1
  122. data/spec/tmp/cache/assets/test/sprockets/v3.0/mDIj_9vsKlFrteU2_M1nWvDPMKstEUxfEkrOroMGMIk.cache +0 -2
  123. data/spec/tmp/cache/assets/test/sprockets/v3.0/mW4Y5AThUDjQcOPAUeELphUxCW4a7Yo4IpRsKZzkhoM.cache +0 -0
  124. data/spec/tmp/cache/assets/test/sprockets/v3.0/nYeoYQfWBXA_snnX8YVRdmp7AoOiQfbFD62LKROgjzY.cache +0 -0
  125. data/spec/tmp/cache/assets/test/sprockets/v3.0/naNJi1nxWlbEia063KrwvvLzdS0aVZHO4ikcY9Qxjbg.cache +0 -1
  126. data/spec/tmp/cache/assets/test/sprockets/v3.0/ne8IkfcDGMQFS6QivBzm12pM5uQ7_rOHSfI7gxIAYZg.cache +0 -1
  127. data/spec/tmp/cache/assets/test/sprockets/v3.0/no1ypM_IullykfbY0HxchYg1e0mpCNO3z7C5dOeRyfA.cache +0 -1
  128. data/spec/tmp/cache/assets/test/sprockets/v3.0/nxn04gmzcW7V_Rg2p-7KnHLSK1MbrtPKTWtCATvPHRY.cache +0 -1
  129. data/spec/tmp/cache/assets/test/sprockets/v3.0/p8d2hJs-GMXj3Pfb_SettPpUIL01kwlQtMXdPqzmsDk.cache +0 -0
  130. data/spec/tmp/cache/assets/test/sprockets/v3.0/pMcchoEpkVfbuFqcqV-QIsT2GriAlr_g05Xp_A4CtaU.cache +0 -0
  131. data/spec/tmp/cache/assets/test/sprockets/v3.0/pTk5o7gQWGjIyqtoFRug56We6pv9N6sItqBddq0rDu0.cache +0 -1
  132. data/spec/tmp/cache/assets/test/sprockets/v3.0/rNWmnhTEQLwZXspZ5r3b35mFbgCz4c-F3gR_HAdxLzI.cache +0 -0
  133. data/spec/tmp/cache/assets/test/sprockets/v3.0/rYacQdERuQhBtFOmHLjnJ7z45Ygr3nbm2HDo8BCr5bs.cache +0 -1
  134. data/spec/tmp/cache/assets/test/sprockets/v3.0/rz-DkBu0biGdgtOMAzLEI-aB3pgaCUKGb8bekTZ-9K0.cache +0 -1
  135. data/spec/tmp/cache/assets/test/sprockets/v3.0/s8HTRJcLNQhpqHMPuEYqX1y9O2-6v7upJVTEqAx1Dx4.cache +0 -1
  136. data/spec/tmp/cache/assets/test/sprockets/v3.0/sa6PtF84xfTeqJj0CHi3oAIThIFoPAO_QADROScybUs.cache +0 -0
  137. data/spec/tmp/cache/assets/test/sprockets/v3.0/snRmTZnmi4ryjP0wUE23wFd4fBuo1hxpjyonEOZh3-w.cache +0 -1
  138. data/spec/tmp/cache/assets/test/sprockets/v3.0/spYrgZJWT16U2ks857dDVa--ObngZZUF7aOhbhT5Bzo.cache +0 -0
  139. data/spec/tmp/cache/assets/test/sprockets/v3.0/t-yibBlcVmGwWuNS0pvEdfGyAxL2oaY8T5pSdT7Kbxs.cache +0 -1
  140. data/spec/tmp/cache/assets/test/sprockets/v3.0/uByORhDkfZw1i-QtsStGha4C4z3sYOz-B9mQ0tVMUOs.cache +0 -0
  141. data/spec/tmp/cache/assets/test/sprockets/v3.0/wDPT75aAPmkWMTxzeucffHw0mvHW-p4RfsfWRISMSv4.cache +0 -1
  142. data/spec/tmp/cache/assets/test/sprockets/v3.0/wLwiBaqts3mvXXj64NgQKvuOt5c5EFQbZ_gf5QPeCkk.cache +0 -1
  143. data/spec/tmp/cache/assets/test/sprockets/v3.0/wdtjFQCVbckEPM-Sm3OuOIQOQgyUHv53UPN_dyM42qw.cache +0 -1
  144. data/spec/tmp/cache/assets/test/sprockets/v3.0/x5iWQPToB48yLx3ZaFy7lGX2t_PbGXr4u_Ys5U9GP8o.cache +0 -1
  145. data/spec/tmp/cache/assets/test/sprockets/v3.0/xABx78Odel6ybIOMvX5E_OAVSgeyFtepOxzO-OHW3cI.cache +0 -1
  146. data/spec/tmp/cache/assets/test/sprockets/v3.0/z3G2bJgQGMbBCUAihZG36MFE56SibUs9Q9-y1qxKga0.cache +0 -0
  147. data/spec/tmp/cache/assets/test/sprockets/v3.0/zYA7lcYMc2JbrCxbVwEFcPCQRsz-mmxrrb-PxgRdycs.cache +0 -1
  148. data/spec/tmp/cache/assets/test/sprockets/v3.0/zacUSP_COvnw7zAmB4__BkcSG9ClG972-aaP6KPbm40.cache +0 -1
  149. data/spec/tmp/i18n-js.cache +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78c741d86f015320458cb78019e8f5a6ca44e2d7
4
- data.tar.gz: 90d676655f84726715c724edb2406d05f04548fa
3
+ metadata.gz: 2c6d712311554b9b92fe35729c5f85fb9fbc43c2
4
+ data.tar.gz: b5cee8412e9b9177c9921634011a18691e206b66
5
5
  SHA512:
6
- metadata.gz: 69dbcd6f49b5bfa248a4ebce6267b159356c1a8e068d9b6e9ca9c39c8ff9c9834605723206c6bc264138f211a1c6d21f7dc598beea24167c84900e0f46f1ef1e
7
- data.tar.gz: e07c7e212dfe1e39851b4b79261df1660aa703e07d766e15edca2cfb7d72f3091299ebb93f361cdf3a05f034ea03c7d7e730d547fccdbd5355bde25b7813f43f
6
+ metadata.gz: 4ef2178640e4efc982cfd8cd39e86a933f2e9c837dadb9f8d3656ea6a5dadd5fd810c7f0b3f914cf22cc32bfd5b75ace91262aa21c4468a49719f251e04e5c5a
7
+ data.tar.gz: e7815df62bc8b14f314f1bcd6f98b3165e47bfc2b13354515e360db95d32b9059939cd520686a93c5cd4a21f0e5f502fa1bf0a36a6e5f5f87b9266436d15bec5
data/README.md CHANGED
@@ -53,6 +53,10 @@ Require these files as you normally would. For example in your app's main `appli
53
53
 
54
54
  Voilà! The translations should now be available in your Javascript code just as if you'd used i18n-js and its rake tasks.
55
55
 
56
+ ## License
57
+
58
+ Licensed under the MIT license. See LICENSE for details.
59
+
56
60
  ## Authors
57
61
 
58
62
  * Cameron C. Dutro: http://github.com/camertron
data/Rakefile CHANGED
@@ -5,10 +5,12 @@ $:.unshift File.join(File.dirname(__FILE__), 'lib')
5
5
  require 'rubygems' unless ENV['NO_RUBYGEMS']
6
6
 
7
7
  require 'bundler'
8
+ require 'pry-nav'
8
9
  require 'rspec/core/rake_task'
9
10
  require 'rubygems/package_task'
10
11
 
11
12
  require 'rails'
13
+ require 'sprockets/railtie'
12
14
  require 'i18n-js-assets'
13
15
 
14
16
  Bundler::GemHelper.install_tasks
@@ -19,3 +21,10 @@ desc 'Run specs'
19
21
  RSpec::Core::RakeTask.new do |t|
20
22
  t.pattern = './spec/**/*_spec.rb'
21
23
  end
24
+
25
+ # for dummy app
26
+ Dir.chdir('spec') do
27
+ require File.expand_path('../spec/config/application', __FILE__)
28
+ I18nJsAssets::DummyApplication.initialize!
29
+ I18nJsAssets::DummyApplication.load_tasks
30
+ end
@@ -13,11 +13,17 @@ Gem::Specification.new do |s|
13
13
  s.platform = Gem::Platform::RUBY
14
14
  s.has_rdoc = true
15
15
 
16
+ if ENV['RAILS_VERSION']
17
+ s.add_dependency 'railties', "~> #{ENV['RAILS_VERSION']}"
18
+ else
19
+ s.add_dependency 'railties', '>= 3.2.0', '< 5'
20
+ end
21
+
22
+ s.add_dependency 'generated-assets', '~> 1.0'
16
23
  s.add_dependency 'i18n-js'
17
- s.add_dependency 'railties', ENV['RAILS_VERSION'] || '>= 3.2.0', '< 5'
18
- s.add_dependency 'tzinfo'
19
24
  s.add_dependency 'sprockets-rails'
20
25
  s.add_dependency 'tilt'
26
+ s.add_dependency 'tzinfo'
21
27
 
22
28
  s.require_path = 'lib'
23
29
  s.files = Dir["{lib,spec}/**/*", "Gemfile", "README.md", "Rakefile", "i18n-js-assets.gemspec"]
@@ -1,7 +1,23 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'generated-assets'
3
4
  require 'i18n-js-assets/railtie'
5
+ require 'fileutils'
6
+ require 'tmpdir'
4
7
 
5
8
  module I18nJsAssets
6
- autoload :Processor, 'i18n-js-assets/processor'
9
+ autoload :Entry, 'i18n-js-assets/entry'
10
+ autoload :I18nJsFile, 'i18n-js-assets/i18njs_file'
11
+ autoload :Manifest, 'i18n-js-assets/manifest'
12
+ autoload :Processor, 'i18n-js-assets/processor'
13
+
14
+ class << self
15
+ def asset_dir
16
+ @asset_dir ||= begin
17
+ dir = File.join(Dir.tmpdir, SecureRandom.hex)
18
+ FileUtils.mkdir_p(dir)
19
+ dir
20
+ end
21
+ end
22
+ end
7
23
  end
@@ -0,0 +1,58 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'fileutils'
4
+
5
+ module I18nJsAssets
6
+ class Entry
7
+ attr_reader :app, :source_path, :target_path, :options
8
+
9
+ def initialize(app, source_path, target_path, options)
10
+ @app = app
11
+ @source_path = source_path
12
+ @target_path = target_path
13
+ @options = options
14
+ end
15
+
16
+ def apply!
17
+ each_file do |locale, interpolated_target_path|
18
+ path = "#{interpolated_target_path}.i18njs"
19
+ app.config.assets.generated.add(path, options) do
20
+ source.overwrite('locales' => [locale]).dump
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def source
28
+ @source ||= I18nJsFile.load_file(absolute_source_path.to_s)
29
+ end
30
+
31
+ def each_file
32
+ if block_given?
33
+ locales.each do |locale|
34
+ interpolated_target_path = target_path % { locale: locale }
35
+ yield locale, interpolated_target_path
36
+ end
37
+ else
38
+ to_enum(__method__)
39
+ end
40
+ end
41
+
42
+ def absolute_source_path
43
+ app.assets.resolve(source_path)
44
+ end
45
+
46
+ def locales
47
+ if locs = options[:precompile]
48
+ locs.respond_to?(:call) ? locs.call : locs
49
+ else
50
+ if Kernel.const_defined?(:I18n)
51
+ I18n.available_locales
52
+ else
53
+ []
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'yaml'
4
+
5
+ module I18nJsAssets
6
+ class I18nJsFile
7
+ class << self
8
+ def load(contents)
9
+ from_hash(YAML.load(contents))
10
+ end
11
+
12
+ def load_file(file)
13
+ load(File.read(file))
14
+ end
15
+
16
+ def from_hash(hash)
17
+ new(hash)
18
+ end
19
+ end
20
+
21
+ attr_reader :attributes
22
+
23
+ def initialize(attributes)
24
+ @attributes = attributes
25
+ end
26
+
27
+ def only
28
+ attributes['only']
29
+ end
30
+
31
+ def locales
32
+ attributes['locales']
33
+ end
34
+
35
+ def overwrite(new_attributes)
36
+ self.class.from_hash(attributes.merge(new_attributes))
37
+ end
38
+
39
+ def write(path)
40
+ File.write(path, dump)
41
+ end
42
+
43
+ def dump
44
+ YAML.dump(attributes)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'yaml'
4
+
5
+ module I18nJsAssets
6
+ class Manifest
7
+ attr_reader :app, :entries
8
+
9
+ def initialize(app)
10
+ @app = app
11
+ @entries = []
12
+ end
13
+
14
+ def add(source_path, target_path, options = {})
15
+ entry = Entry.new(app, source_path, target_path, options)
16
+ entries << entry
17
+ end
18
+
19
+ def apply!
20
+ entries.each(&:apply!)
21
+ end
22
+ end
23
+ end
@@ -1,12 +1,15 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'tilt'
4
+ require 'i18n-js'
5
+
3
6
  module I18nJsAssets
4
7
  class Processor < ::Tilt::Template
5
8
  def prepare
6
9
  # noop
7
10
  end
8
11
 
9
- def evaluate(scope, locals, &block)
12
+ def evaluate(scope, locals)
10
13
  options = (YAML.load(data) || {}).with_indifferent_access
11
14
  only = options.fetch(:only, '*')
12
15
  exceptions = [options.fetch(:except, [])].flatten
@@ -18,14 +21,17 @@ module I18nJsAssets
18
21
  i18n_js.segment_for_scope(only)
19
22
  end
20
23
 
21
- construct_javascript_from(translations)
24
+ locales = options.fetch(:locales, translations.keys).map(&:to_sym)
25
+
26
+ construct_javascript_from(locales, translations)
22
27
  end
23
28
 
24
- protected
29
+ private
25
30
 
26
- def construct_javascript_from(translations)
31
+ def construct_javascript_from(locales, translations)
27
32
  %(I18n.translations || (I18n.translations = {});\n).tap do |result|
28
33
  translations.each_pair do |locale, locale_translations|
34
+ next unless locales.include?(locale)
29
35
  result << construct_javascript_for_locale(locale, locale_translations)
30
36
  end
31
37
  end
@@ -2,8 +2,29 @@
2
2
 
3
3
  module I18nJsAssets
4
4
  class Railtie < ::Rails::Railtie
5
- initializer :i18n_js_assets, group: :all do |app|
6
- app.assets.register_engine('.i18njs', I18nJsAssets::Processor)
5
+ config.before_configuration do |app|
6
+ app.config.assets.localized = I18nJsAssets::Manifest.new(app)
7
+ end
8
+
9
+ config.before_initialize do |app|
10
+ app.config.assets.generated.before_apply do
11
+ app.config.assets.localized.apply!
12
+ end
13
+ end
14
+
15
+ # this is for rails 3
16
+ config.after_initialize do |app|
17
+ begin
18
+ app.assets.register_engine('.i18njs', I18nJsAssets::Processor)
19
+ rescue TypeError
20
+ end
21
+ end
22
+
23
+ # this is for rails 4
24
+ initializer :i18n_js_assets, after: 'sprockets.environment' do |app|
25
+ if app.assets
26
+ app.assets.register_engine('.i18njs', I18nJsAssets::Processor)
27
+ end
7
28
  end
8
29
  end
9
30
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module I18nJsAssets
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -1 +1 @@
1
- //= require i18n/translations
1
+ //= require translations/includable
@@ -0,0 +1,3 @@
1
+ only: '*.my_app.*'
2
+ locales:
3
+ - es
@@ -0,0 +1 @@
1
+ only: '*.my_app.*'
@@ -0,0 +1,10 @@
1
+ module I18nJsAssets
2
+ class DummyApplication < ::Rails::Application
3
+ config.eager_load = false
4
+ config.assets.enabled = true
5
+ config.assets.compile = true
6
+ config.assets.allow_debugging = true
7
+ config.assets.digest = true
8
+ config.active_support.deprecation = :stderr
9
+ end
10
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ include I18nJsAssets
6
+
7
+ describe Entry do
8
+ let(:entry) do
9
+ Entry.new(
10
+ app, source_path, target_path, {
11
+ precompile: locales
12
+ }
13
+ )
14
+ end
15
+
16
+ let(:source_path) do
17
+ 'translations/precompilable.js'
18
+ end
19
+
20
+ let(:target_path) do
21
+ 'translations/precompilable-%{locale}.js'
22
+ end
23
+
24
+ let(:locales) do
25
+ [:en, :es]
26
+ end
27
+
28
+ describe '#apply!' do
29
+ it 'adds entries for each locale' do
30
+ entry.apply!
31
+
32
+ paths = app.config.assets
33
+ .generated.entries.map(&:logical_path)
34
+ .sort
35
+
36
+ expect(paths).to(
37
+ eq([
38
+ 'translations/precompilable-en.js.i18njs',
39
+ 'translations/precompilable-es.js.i18njs'
40
+ ])
41
+ )
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'fileutils'
5
+
6
+ include I18nJsAssets
7
+
8
+ describe I18nJsFile do
9
+ let(:file) do
10
+ I18nJsFile.load(contents)
11
+ end
12
+
13
+ let(:contents) do
14
+ YAML.dump(
15
+ 'only' => '*.my_app.*',
16
+ 'locales' => %w(en es)
17
+ )
18
+ end
19
+
20
+ describe '.load' do
21
+ it 'reads and creates a new file instance' do
22
+ expect(file).to be_a(I18nJsFile)
23
+ expect(file.attributes['locales']).to eq(%w(en es))
24
+ end
25
+ end
26
+
27
+ describe '#only' do
28
+ it 'retrieves the only filter' do
29
+ expect(file.only).to eq('*.my_app.*')
30
+ end
31
+ end
32
+
33
+ describe '#locales' do
34
+ it 'retrieves the list of locales' do
35
+ expect(file.locales).to eq(%w(en es))
36
+ end
37
+ end
38
+
39
+ describe '#overwrite' do
40
+ it 'replaces attributes and returns a new instance' do
41
+ new_file = file.overwrite('locales' => %w(ko ja))
42
+ expect(new_file.locales).to eq(%w(ko ja))
43
+ end
44
+ end
45
+
46
+ describe '#write' do
47
+ it 'serializes and writes the contents to the given path' do
48
+ # store the file in the asset path, which gets destroyed before
49
+ # every test
50
+ FileUtils.mkdir_p(asset_path)
51
+ path = asset_path.join('test.i18njs').to_s
52
+ file.write(path)
53
+ expect(File.read(path)).to eq(contents)
54
+ end
55
+ end
56
+
57
+ describe '#dump' do
58
+ it 'serializes the file contents' do
59
+ expect(file.dump).to eq(contents)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'inline' do
6
+ it 'requires javascript translations' do
7
+ asset = Rails.application.assets.find_asset('application.js')
8
+ expect(unescape_unicode(asset.source)).to include(en_source)
9
+ expect(unescape_unicode(asset.source)).to include(es_source)
10
+ end
11
+
12
+ it 'only includes translations for the requested locales' do
13
+ asset = Rails.application.assets.find_asset('translations/language_specific.js')
14
+ expect(unescape_unicode(asset.source)).to_not include(en_source)
15
+ expect(unescape_unicode(asset.source)).to include(es_source)
16
+ end
17
+ end