spreadsheet_architect 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +17 -2
  3. data/README.md +149 -129
  4. data/lib/spreadsheet_architect/class_methods/csv.rb +2 -2
  5. data/lib/spreadsheet_architect/class_methods/ods.rb +2 -2
  6. data/lib/spreadsheet_architect/class_methods/xlsx.rb +26 -30
  7. data/lib/spreadsheet_architect/exceptions.rb +32 -30
  8. data/lib/spreadsheet_architect/utils/xlsx.rb +46 -25
  9. data/lib/spreadsheet_architect/utils.rb +116 -121
  10. data/lib/spreadsheet_architect/version.rb +1 -1
  11. data/lib/spreadsheet_architect.rb +5 -1
  12. data/test/dummy_app/app/models/active_model_object.rb +1 -0
  13. data/test/dummy_app/app/models/custom_post.rb +1 -0
  14. data/test/dummy_app/app/models/legacy_plain_ruby_object.rb +14 -0
  15. data/test/dummy_app/app/models/plain_ruby_object.rb +2 -9
  16. data/test/dummy_app/app/models/post.rb +3 -0
  17. data/test/dummy_app/config/routes.rb +4 -5
  18. data/test/dummy_app/db/test.sqlite3 +0 -0
  19. data/test/dummy_app/log/test.log +26911 -21739
  20. data/test/dummy_app/tmp/2.0.1/integration/alt_xlsx.xlsx +0 -0
  21. data/test/dummy_app/tmp/2.0.1/integration/csv.csv +6 -0
  22. data/test/dummy_app/tmp/2.0.1/integration/ods.ods +0 -0
  23. data/test/dummy_app/tmp/2.0.1/integration/xlsx.xlsx +0 -0
  24. data/test/dummy_app/tmp/2.0.1/kitchen_sink.ods +0 -0
  25. data/test/dummy_app/tmp/2.0.1/kitchen_sink.xlsx +0 -0
  26. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.csv +3 -0
  27. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.ods +0 -0
  28. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.xlsx +0 -0
  29. data/test/dummy_app/tmp/{empty_sa.csv → 2.0.1/models/ActiveModelObject/empty.csv} +0 -0
  30. data/test/dummy_app/tmp/{ods/empty_model.ods → 2.0.1/models/ActiveModelObject/empty.ods} +0 -0
  31. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/empty.xlsx +0 -0
  32. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.csv +6 -0
  33. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.ods +0 -0
  34. data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.xlsx +0 -0
  35. data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.csv +3 -0
  36. data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.ods +0 -0
  37. data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.xlsx +0 -0
  38. data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.csv +1 -0
  39. data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.ods +0 -0
  40. data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.xlsx +0 -0
  41. data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.csv +6 -0
  42. data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.ods +0 -0
  43. data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.xlsx +0 -0
  44. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.csv +3 -0
  45. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.ods +0 -0
  46. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.xlsx +0 -0
  47. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.csv +1 -0
  48. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.ods +0 -0
  49. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.xlsx +0 -0
  50. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.csv +6 -0
  51. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.ods +0 -0
  52. data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.xlsx +0 -0
  53. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.csv +3 -0
  54. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.ods +0 -0
  55. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.xlsx +0 -0
  56. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.csv +0 -0
  57. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.ods +0 -0
  58. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.xlsx +0 -0
  59. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.csv +6 -0
  60. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.ods +0 -0
  61. data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.xlsx +0 -0
  62. data/test/dummy_app/tmp/2.0.1/models/Post/data.csv +3 -0
  63. data/test/dummy_app/tmp/2.0.1/models/Post/data.ods +0 -0
  64. data/test/dummy_app/tmp/2.0.1/models/Post/data.xlsx +0 -0
  65. data/test/dummy_app/tmp/2.0.1/models/Post/empty.csv +0 -0
  66. data/test/dummy_app/tmp/2.0.1/models/Post/empty.ods +0 -0
  67. data/test/dummy_app/tmp/2.0.1/models/Post/empty.xlsx +0 -0
  68. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.csv +3 -0
  69. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.ods +0 -0
  70. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.xlsx +0 -0
  71. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.csv +0 -0
  72. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.ods +0 -0
  73. data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.xlsx +0 -0
  74. data/test/dummy_app/tmp/2.0.1/multi_sheet.ods +0 -0
  75. data/test/dummy_app/tmp/2.0.1/multi_sheet.xlsx +0 -0
  76. data/test/dummy_app/tmp/3.0.0.pre/integration/alt_xlsx.xlsx +0 -0
  77. data/test/dummy_app/tmp/3.0.0.pre/integration/csv.csv +6 -0
  78. data/test/dummy_app/tmp/3.0.0.pre/integration/ods.ods +0 -0
  79. data/test/dummy_app/tmp/3.0.0.pre/integration/xlsx.xlsx +0 -0
  80. data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.ods +0 -0
  81. data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.xlsx +0 -0
  82. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.csv +3 -0
  83. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.ods +0 -0
  84. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.xlsx +0 -0
  85. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.csv +0 -0
  86. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.ods +0 -0
  87. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.xlsx +0 -0
  88. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.csv +6 -0
  89. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.ods +0 -0
  90. data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.xlsx +0 -0
  91. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.csv +3 -0
  92. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.ods +0 -0
  93. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.xlsx +0 -0
  94. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.csv +1 -0
  95. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.ods +0 -0
  96. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.xlsx +0 -0
  97. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.csv +6 -0
  98. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.ods +0 -0
  99. data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.xlsx +0 -0
  100. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.csv +3 -0
  101. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.ods +0 -0
  102. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.xlsx +0 -0
  103. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.csv +0 -0
  104. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.ods +0 -0
  105. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.xlsx +0 -0
  106. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.csv +6 -0
  107. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.ods +0 -0
  108. data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.xlsx +0 -0
  109. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.csv +3 -0
  110. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.ods +0 -0
  111. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.xlsx +0 -0
  112. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.csv +1 -0
  113. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.ods +0 -0
  114. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.xlsx +0 -0
  115. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.csv +6 -0
  116. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.ods +0 -0
  117. data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.xlsx +0 -0
  118. data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.csv +3 -0
  119. data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.ods +0 -0
  120. data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.xlsx +0 -0
  121. data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.csv +0 -0
  122. data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.ods +0 -0
  123. data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.xlsx +0 -0
  124. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.csv +3 -0
  125. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.ods +0 -0
  126. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.xlsx +0 -0
  127. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.csv +0 -0
  128. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.ods +0 -0
  129. data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.xlsx +0 -0
  130. data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.ods +0 -0
  131. data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.xlsx +0 -0
  132. data/test/dummy_app/tmp/axlsx-master/integration/alt_xlsx.xlsx +0 -0
  133. data/test/dummy_app/tmp/axlsx-master/integration/csv.csv +6 -0
  134. data/test/dummy_app/tmp/axlsx-master/integration/ods.ods +0 -0
  135. data/test/dummy_app/tmp/axlsx-master/integration/xlsx.xlsx +0 -0
  136. data/test/dummy_app/tmp/axlsx-master/kitchen_sink.ods +0 -0
  137. data/test/dummy_app/tmp/axlsx-master/kitchen_sink.xlsx +0 -0
  138. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.csv +3 -0
  139. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.ods +0 -0
  140. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.xlsx +0 -0
  141. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.csv +0 -0
  142. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.ods +0 -0
  143. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.xlsx +0 -0
  144. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.csv +6 -0
  145. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.ods +0 -0
  146. data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.xlsx +0 -0
  147. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.csv +3 -0
  148. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.ods +0 -0
  149. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.xlsx +0 -0
  150. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.csv +0 -0
  151. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.ods +0 -0
  152. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.xlsx +0 -0
  153. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.csv +6 -0
  154. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.ods +0 -0
  155. data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.xlsx +0 -0
  156. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.csv +3 -0
  157. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.ods +0 -0
  158. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.xlsx +0 -0
  159. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.csv +1 -0
  160. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.ods +0 -0
  161. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.xlsx +0 -0
  162. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.csv +6 -0
  163. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.ods +0 -0
  164. data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.xlsx +0 -0
  165. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.csv +3 -0
  166. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.ods +0 -0
  167. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.xlsx +0 -0
  168. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.csv +1 -0
  169. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.ods +0 -0
  170. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.xlsx +0 -0
  171. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.csv +6 -0
  172. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.ods +0 -0
  173. data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.xlsx +0 -0
  174. data/test/dummy_app/tmp/axlsx-master/models/Post/data.csv +3 -0
  175. data/test/dummy_app/tmp/axlsx-master/models/Post/data.ods +0 -0
  176. data/test/dummy_app/tmp/axlsx-master/models/Post/data.xlsx +0 -0
  177. data/test/dummy_app/tmp/axlsx-master/models/Post/empty.csv +0 -0
  178. data/test/dummy_app/tmp/axlsx-master/models/Post/empty.ods +0 -0
  179. data/test/dummy_app/tmp/axlsx-master/models/Post/empty.xlsx +0 -0
  180. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.csv +3 -0
  181. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.ods +0 -0
  182. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.xlsx +0 -0
  183. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.csv +0 -0
  184. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.ods +0 -0
  185. data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.xlsx +0 -0
  186. data/test/dummy_app/tmp/axlsx-master/multi_sheet.ods +0 -0
  187. data/test/dummy_app/tmp/axlsx-master/multi_sheet.xlsx +0 -0
  188. data/test/integration/application_test.rb +8 -11
  189. data/test/models/all_models_test.rb +107 -0
  190. data/test/test_helper.rb +13 -4
  191. data/test/unit/exceptions_test.rb +168 -0
  192. data/test/unit/formats_test.rb +15 -0
  193. data/test/unit/general_test.rb +15 -0
  194. data/test/unit/kitchen_sink_test.rb +87 -0
  195. data/test/unit/multi_sheet_test.rb +29 -0
  196. data/test/unit/utils_test.rb +179 -0
  197. data/test/unit/xlsx_utils_test.rb +143 -0
  198. metadata +409 -116
  199. data/lib/generators/spreadsheet_architect/add_project_defaults_generator.rb +0 -20
  200. data/test/dummy_app/app/models/bad_plain_ruby_object.rb +0 -3
  201. data/test/dummy_app/app/views/reports/sample.html.erb +0 -1
  202. data/test/dummy_app/log/development.log +0 -28
  203. data/test/dummy_app/tmp/active_model_object/csv.csv +0 -21
  204. data/test/dummy_app/tmp/active_model_object/ods.ods +0 -0
  205. data/test/dummy_app/tmp/active_model_object/xlsx.xlsx +0 -0
  206. data/test/dummy_app/tmp/custom_posts/csv.csv +0 -6
  207. data/test/dummy_app/tmp/custom_posts/empty.xlsx +0 -0
  208. data/test/dummy_app/tmp/custom_posts/ods.ods +0 -0
  209. data/test/dummy_app/tmp/custom_posts/xlsx.xlsx +0 -0
  210. data/test/dummy_app/tmp/empty_model.csv +0 -1
  211. data/test/dummy_app/tmp/empty_model.xlsx +0 -0
  212. data/test/dummy_app/tmp/empty_sa.xlsx +0 -0
  213. data/test/dummy_app/tmp/extreme.xlsx +0 -0
  214. data/test/dummy_app/tmp/integration_tests/alt_xlsx.xlsx +0 -0
  215. data/test/dummy_app/tmp/integration_tests/csv.csv +0 -6
  216. data/test/dummy_app/tmp/integration_tests/ods.ods +0 -0
  217. data/test/dummy_app/tmp/integration_tests/xlsx.xlsx +0 -0
  218. data/test/dummy_app/tmp/model.csv +0 -6
  219. data/test/dummy_app/tmp/model.xlsx +0 -0
  220. data/test/dummy_app/tmp/ods/empty_sa.ods +0 -0
  221. data/test/dummy_app/tmp/ods/model.ods +0 -0
  222. data/test/dummy_app/tmp/ods/model_options.ods +0 -0
  223. data/test/dummy_app/tmp/ods/sa.ods +0 -0
  224. data/test/dummy_app/tmp/options.csv +0 -6
  225. data/test/dummy_app/tmp/plain_ruby_object/csv.csv +0 -4
  226. data/test/dummy_app/tmp/plain_ruby_object/ods.ods +0 -0
  227. data/test/dummy_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
  228. data/test/dummy_app/tmp/posts/csv.csv +0 -6
  229. data/test/dummy_app/tmp/posts/empty.xlsx +0 -0
  230. data/test/dummy_app/tmp/posts/ods.ods +0 -0
  231. data/test/dummy_app/tmp/posts/xlsx.xlsx +0 -0
  232. data/test/dummy_app/tmp/sa.csv +0 -4
  233. data/test/dummy_app/tmp/sa.xlsx +0 -0
  234. data/test/models/active_model_object_test.rb +0 -51
  235. data/test/models/bad_plain_ruby_object_test.rb +0 -28
  236. data/test/models/csv_test.rb +0 -59
  237. data/test/models/custom_post_test.rb +0 -51
  238. data/test/models/ods_test.rb +0 -65
  239. data/test/models/plain_ruby_object_test.rb +0 -51
  240. data/test/models/post_test.rb +0 -44
  241. data/test/models/spreadsheet_architect_utils_test.rb +0 -73
  242. data/test/models/xlsx_test.rb +0 -98
  243. data/test/spreadsheet_architect_test.rb +0 -11
@@ -0,0 +1,143 @@
1
+ require 'test_helper'
2
+
3
+ class XlsxUtilsTest < ActiveSupport::TestCase
4
+ klass = SpreadsheetArchitect::Utils::XLSX
5
+
6
+ def setup
7
+ end
8
+
9
+ def teardown
10
+ end
11
+
12
+ test "convert_styles_to_axlsx" do
13
+ xlsx_styles = klass.convert_styles_to_axlsx({background_color: '333333', color: '000000', align: true, bold: true, font_size: 14, italic: true, underline: true, test: true})
14
+
15
+ assert_equal(xlsx_styles, {bg_color: '333333', fg_color: '000000', alignment: {horizontal: true}, b: true, sz: 14, i: true, u: true, test: true})
16
+ end
17
+
18
+ test "get_type" do
19
+ assert_equal(klass.get_type('string'), :string)
20
+ assert_equal(klass.get_type(123.01), :float)
21
+ assert_equal(klass.get_type(BigDecimal('123.01')), :float)
22
+ assert_equal(klass.get_type(10), :integer)
23
+ assert_equal(klass.get_type(:test), :string)
24
+ assert_equal(klass.get_type(Time.now.to_date), :date)
25
+ assert_equal(klass.get_type(DateTime.now), :time)
26
+ assert_equal(klass.get_type(Time.now), :time)
27
+ end
28
+
29
+ test "range_hash_to_str" do
30
+ num_columns = 26
31
+ num_rows = 10
32
+
33
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError do
34
+ klass.range_hash_to_str({}, num_columns, num_rows)
35
+ end
36
+
37
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError do
38
+ klass.range_hash_to_str({columns: 1}, num_columns, num_rows)
39
+ end
40
+
41
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError do
42
+ klass.range_hash_to_str({rows: 1}, num_columns, num_rows)
43
+ end
44
+
45
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError do
46
+ klass.range_hash_to_str({columns: [1,2,3], rows: 1}, num_columns, num_rows)
47
+ end
48
+
49
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError do
50
+ klass.range_hash_to_str({columns: 1, rows: [1,2,3]}, num_columns, num_rows)
51
+ end
52
+
53
+ assert_equal klass.range_hash_to_str({columns: 0, rows: 1}, num_columns, num_rows), "A1:A1"
54
+
55
+ assert_equal klass.range_hash_to_str({columns: (0..2), rows: (1..3)}, num_columns, num_rows), "A1:C3"
56
+
57
+ assert_equal klass.range_hash_to_str({columns: ('A'..'C'), rows: (1..3)}, num_columns, num_rows), "A1:C3"
58
+
59
+ assert_equal klass.range_hash_to_str({columns: :all, rows: :all}, num_columns, num_rows), "A1:Z10"
60
+
61
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
62
+ assert_equal klass.range_hash_to_str({columns: ('foobar'..'asd'), rows: (1..3)}, num_columns, num_rows), "foobar1:asd3"
63
+ end
64
+ end
65
+
66
+ test "verify_range" do
67
+ num_rows = 10
68
+
69
+ klass.verify_range("A1:Z10", num_rows)
70
+
71
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
72
+ klass.verify_range(:foo, num_rows)
73
+ end
74
+
75
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
76
+ klass.verify_range("A1Z10", num_rows)
77
+ end
78
+
79
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
80
+ klass.verify_range("A1:A11", num_rows)
81
+ end
82
+
83
+ #assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
84
+ klass.verify_range("A1:AAA1", num_rows)
85
+ #end
86
+ end
87
+
88
+ test "verify_column" do
89
+ num_columns = 26
90
+
91
+ klass.verify_column(1, num_columns)
92
+
93
+ klass.verify_column("A", num_columns)
94
+
95
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
96
+ klass.verify_column(-1, num_columns)
97
+ end
98
+
99
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
100
+ klass.verify_column(99, num_columns)
101
+ end
102
+
103
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
104
+ klass.verify_column("foobar", num_columns)
105
+ end
106
+
107
+ assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
108
+ klass.verify_column([], num_columns)
109
+ end
110
+
111
+ #assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
112
+ klass.verify_column("ZZ", num_columns)
113
+ #end
114
+ end
115
+
116
+ test "symbolize_keys" do
117
+ hash = klass.symbolize_keys
118
+ assert_empty hash
119
+
120
+ hash = klass.symbolize_keys({'foo' => :bar})
121
+ assert_nil hash['foo']
122
+ assert_equal hash[:foo], :bar
123
+
124
+ hash = klass.symbolize_keys({'foo' => :bar, bar: :foo})
125
+ assert_nil hash['foo']
126
+ assert_equal hash[:foo], :bar
127
+
128
+ hash = klass.symbolize_keys({'foo' => {'foo' => :bar}})
129
+ assert_nil hash['foo']
130
+ assert_equal hash[:foo][:foo], :bar
131
+
132
+ hash = klass.symbolize_keys({'foo' => {'foo' => {'foo' => :bar}}})
133
+ assert_nil hash['foo']
134
+ assert_equal hash[:foo][:foo][:foo], :bar
135
+ end
136
+
137
+ test "constants" do
138
+ assert_equal klass::COL_NAMES.count, 16384
139
+ assert_equal klass::COL_NAMES.first, 'A'
140
+ assert_equal klass::COL_NAMES.last, 'XFD'
141
+ end
142
+
143
+ end