spreadsheet_architect 2.0.2 → 2.1.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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -26
  3. data/README.md +15 -15
  4. data/Rakefile +5 -3
  5. data/lib/spreadsheet_architect/class_methods/ods.rb +16 -2
  6. data/lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb +33 -3
  7. data/lib/spreadsheet_architect/utils/xlsx.rb +36 -18
  8. data/lib/spreadsheet_architect/version.rb +1 -1
  9. data/test/custom_assertions.rb +21 -0
  10. data/test/{rails_app → dummy_app}/Rakefile +3 -2
  11. data/test/{rails_app/public/apple-touch-icon-precomposed.png → dummy_app/app/assets/javascripts/application.js} +0 -0
  12. data/test/dummy_app/app/assets/stylesheets/application.css +3 -0
  13. data/test/{rails_app → dummy_app}/app/controllers/application_controller.rb +1 -1
  14. data/test/{rails_app → dummy_app}/app/controllers/spreadsheets_controller.rb +0 -0
  15. data/test/{rails_app → dummy_app}/app/models/active_model_object.rb +0 -0
  16. data/test/{rails_app → dummy_app}/app/models/application_record.rb +0 -0
  17. data/test/{rails_app → dummy_app}/app/models/bad_plain_ruby_object.rb +0 -0
  18. data/test/{rails_app → dummy_app}/app/models/custom_post.rb +2 -2
  19. data/test/{rails_app → dummy_app}/app/models/plain_ruby_object.rb +0 -0
  20. data/test/{rails_app → dummy_app}/app/models/post.rb +0 -0
  21. data/test/dummy_app/app/views/layouts/application.html.erb +14 -0
  22. data/test/dummy_app/app/views/reports/sample.html.erb +1 -0
  23. data/test/dummy_app/config.ru +4 -0
  24. data/test/dummy_app/config/application.rb +69 -0
  25. data/test/dummy_app/config/boot.rb +10 -0
  26. data/test/dummy_app/config/database.yml +25 -0
  27. data/test/dummy_app/config/environment.rb +5 -0
  28. data/test/dummy_app/config/environments/development.rb +30 -0
  29. data/test/dummy_app/config/environments/production.rb +60 -0
  30. data/test/dummy_app/config/environments/test.rb +41 -0
  31. data/test/{rails_app → dummy_app}/config/initializers/backtrace_silencers.rb +0 -0
  32. data/test/dummy_app/config/initializers/inflections.rb +10 -0
  33. data/test/{rails_app → dummy_app}/config/initializers/mime_types.rb +1 -0
  34. data/test/dummy_app/config/initializers/secret_token.rb +11 -0
  35. data/test/dummy_app/config/initializers/session_store.rb +8 -0
  36. data/test/dummy_app/config/initializers/spreadsheet_architect.rb +11 -0
  37. data/test/{rails_app → dummy_app}/config/initializers/wrap_parameters.rb +5 -5
  38. data/test/dummy_app/config/locales/en.yml +5 -0
  39. data/test/{rails_app → dummy_app}/config/routes.rb +1 -1
  40. data/test/{rails_app → dummy_app}/config/secrets.yml +4 -4
  41. data/test/{rails_app → dummy_app}/db/migrate/20170103234524_add_posts.rb +0 -0
  42. data/test/{rails_app → dummy_app}/db/schema.rb +4 -4
  43. data/test/{rails_app → dummy_app}/db/test.sqlite3 +0 -0
  44. data/test/dummy_app/log/development.log +28 -0
  45. data/test/dummy_app/log/test.log +24564 -0
  46. data/test/dummy_app/tmp/active_model_object/csv.csv +21 -0
  47. data/test/dummy_app/tmp/active_model_object/ods.ods +0 -0
  48. data/test/dummy_app/tmp/active_model_object/xlsx.xlsx +0 -0
  49. data/test/dummy_app/tmp/custom_posts/csv.csv +6 -0
  50. data/test/dummy_app/tmp/custom_posts/empty.xlsx +0 -0
  51. data/test/dummy_app/tmp/custom_posts/ods.ods +0 -0
  52. data/test/dummy_app/tmp/custom_posts/xlsx.xlsx +0 -0
  53. data/test/{rails_app → dummy_app}/tmp/empty_model.csv +0 -0
  54. data/test/dummy_app/tmp/empty_model.xlsx +0 -0
  55. data/test/{rails_app → dummy_app}/tmp/empty_sa.csv +0 -0
  56. data/test/dummy_app/tmp/empty_sa.xlsx +0 -0
  57. data/test/dummy_app/tmp/extreme.xlsx +0 -0
  58. data/test/dummy_app/tmp/integration_tests/alt_xlsx.xlsx +0 -0
  59. data/test/dummy_app/tmp/integration_tests/csv.csv +6 -0
  60. data/test/dummy_app/tmp/integration_tests/ods.ods +0 -0
  61. data/test/dummy_app/tmp/integration_tests/xlsx.xlsx +0 -0
  62. data/test/dummy_app/tmp/model.csv +6 -0
  63. data/test/dummy_app/tmp/model.xlsx +0 -0
  64. data/test/dummy_app/tmp/ods/empty_model.ods +0 -0
  65. data/test/{rails_app → dummy_app}/tmp/ods/empty_sa.ods +0 -0
  66. data/test/dummy_app/tmp/ods/model.ods +0 -0
  67. data/test/dummy_app/tmp/ods/model_options.ods +0 -0
  68. data/test/dummy_app/tmp/ods/sa.ods +0 -0
  69. data/test/dummy_app/tmp/options.csv +6 -0
  70. data/test/dummy_app/tmp/plain_ruby_object/csv.csv +4 -0
  71. data/test/dummy_app/tmp/plain_ruby_object/ods.ods +0 -0
  72. data/test/dummy_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
  73. data/test/dummy_app/tmp/posts/csv.csv +6 -0
  74. data/test/dummy_app/tmp/posts/empty.xlsx +0 -0
  75. data/test/dummy_app/tmp/posts/ods.ods +0 -0
  76. data/test/dummy_app/tmp/posts/xlsx.xlsx +0 -0
  77. data/test/{rails_app → dummy_app}/tmp/sa.csv +0 -0
  78. data/test/dummy_app/tmp/sa.xlsx +0 -0
  79. data/test/integration/application_test.rb +49 -0
  80. data/test/{rails_app/test/models → models}/active_model_object_test.rb +1 -4
  81. data/test/{rails_app/test/models → models}/bad_plain_ruby_object_test.rb +0 -2
  82. data/test/{rails_app/test/models → models}/csv_test.rb +5 -6
  83. data/test/{rails_app/test/models → models}/custom_post_test.rb +0 -3
  84. data/test/{rails_app/test/models → models}/ods_test.rb +6 -9
  85. data/test/{rails_app/test/models → models}/plain_ruby_object_test.rb +1 -4
  86. data/test/{rails_app/test/models → models}/post_test.rb +1 -4
  87. data/test/{rails_app/test/models → models}/spreadsheet_architect_utils_test.rb +0 -1
  88. data/test/{rails_app/test/models → models}/xlsx_test.rb +6 -7
  89. data/test/spreadsheet_architect_test.rb +11 -0
  90. data/test/test_helper.rb +35 -0
  91. metadata +186 -228
  92. data/test/rails_app/Gemfile +0 -17
  93. data/test/rails_app/Gemfile.lock +0 -176
  94. data/test/rails_app/README.md +0 -24
  95. data/test/rails_app/app/assets/config/manifest.js +0 -3
  96. data/test/rails_app/app/assets/javascripts/application.js +0 -16
  97. data/test/rails_app/app/assets/javascripts/cable.js +0 -13
  98. data/test/rails_app/app/assets/stylesheets/application.css +0 -15
  99. data/test/rails_app/app/channels/application_cable/channel.rb +0 -4
  100. data/test/rails_app/app/channels/application_cable/connection.rb +0 -4
  101. data/test/rails_app/app/helpers/application_helper.rb +0 -2
  102. data/test/rails_app/app/jobs/application_job.rb +0 -2
  103. data/test/rails_app/app/mailers/application_mailer.rb +0 -4
  104. data/test/rails_app/app/views/layouts/application.html.erb +0 -14
  105. data/test/rails_app/app/views/layouts/mailer.html.erb +0 -13
  106. data/test/rails_app/app/views/layouts/mailer.text.erb +0 -1
  107. data/test/rails_app/bin/bundle +0 -3
  108. data/test/rails_app/bin/rails +0 -9
  109. data/test/rails_app/bin/rake +0 -9
  110. data/test/rails_app/bin/setup +0 -34
  111. data/test/rails_app/bin/spring +0 -16
  112. data/test/rails_app/bin/update +0 -29
  113. data/test/rails_app/config.ru +0 -5
  114. data/test/rails_app/config/application.rb +0 -15
  115. data/test/rails_app/config/boot.rb +0 -3
  116. data/test/rails_app/config/cable.yml +0 -9
  117. data/test/rails_app/config/database.yml +0 -16
  118. data/test/rails_app/config/environment.rb +0 -5
  119. data/test/rails_app/config/environments/development.rb +0 -54
  120. data/test/rails_app/config/environments/production.rb +0 -86
  121. data/test/rails_app/config/environments/test.rb +0 -42
  122. data/test/rails_app/config/initializers/application_controller_renderer.rb +0 -6
  123. data/test/rails_app/config/initializers/assets.rb +0 -11
  124. data/test/rails_app/config/initializers/cookies_serializer.rb +0 -5
  125. data/test/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
  126. data/test/rails_app/config/initializers/inflections.rb +0 -16
  127. data/test/rails_app/config/initializers/new_framework_defaults.rb +0 -24
  128. data/test/rails_app/config/initializers/session_store.rb +0 -3
  129. data/test/rails_app/config/locales/en.yml +0 -23
  130. data/test/rails_app/db/development.sqlite3 +0 -0
  131. data/test/rails_app/db/seeds.rb +0 -7
  132. data/test/rails_app/log/development.log +0 -1195
  133. data/test/rails_app/log/test.log +0 -55339
  134. data/test/rails_app/public/404.html +0 -67
  135. data/test/rails_app/public/422.html +0 -67
  136. data/test/rails_app/public/500.html +0 -66
  137. data/test/rails_app/public/apple-touch-icon.png +0 -0
  138. data/test/rails_app/public/favicon.ico +0 -0
  139. data/test/rails_app/public/robots.txt +0 -5
  140. data/test/rails_app/test/controllers/spreadsheets_controller_test.rb +0 -46
  141. data/test/rails_app/test/test_helper.rb +0 -21
  142. data/test/rails_app/tmp/active_model_object/csv.csv +0 -21
  143. data/test/rails_app/tmp/active_model_object/ods.ods +0 -0
  144. data/test/rails_app/tmp/active_model_object/xlsx.xlsx +0 -0
  145. data/test/rails_app/tmp/controller_tests/alt_xlsx.xlsx +0 -0
  146. data/test/rails_app/tmp/controller_tests/csv.csv +0 -1
  147. data/test/rails_app/tmp/controller_tests/ods.ods +0 -0
  148. data/test/rails_app/tmp/controller_tests/xlsx.xlsx +0 -0
  149. data/test/rails_app/tmp/custom_posts/csv.csv +0 -1
  150. data/test/rails_app/tmp/custom_posts/empty.xlsx +0 -0
  151. data/test/rails_app/tmp/custom_posts/ods.ods +0 -0
  152. data/test/rails_app/tmp/custom_posts/xlsx.xlsx +0 -0
  153. data/test/rails_app/tmp/empty_model.xlsx +0 -0
  154. data/test/rails_app/tmp/empty_sa.xlsx +0 -0
  155. data/test/rails_app/tmp/extreme.xlsx +0 -0
  156. data/test/rails_app/tmp/model.csv +0 -1
  157. data/test/rails_app/tmp/model.xlsx +0 -0
  158. data/test/rails_app/tmp/ods/empty_model.ods +0 -0
  159. data/test/rails_app/tmp/ods/model.ods +0 -0
  160. data/test/rails_app/tmp/ods/model_options.ods +0 -0
  161. data/test/rails_app/tmp/ods/sa.ods +0 -0
  162. data/test/rails_app/tmp/options.csv +0 -1
  163. data/test/rails_app/tmp/plain_ruby_object/csv.csv +0 -4
  164. data/test/rails_app/tmp/plain_ruby_object/ods.ods +0 -0
  165. data/test/rails_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
  166. data/test/rails_app/tmp/posts/csv.csv +0 -1
  167. data/test/rails_app/tmp/posts/empty.xlsx +0 -0
  168. data/test/rails_app/tmp/posts/ods.ods +0 -0
  169. data/test/rails_app/tmp/posts/xlsx.xlsx +0 -0
  170. data/test/rails_app/tmp/sa.xlsx +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df0aa255d5445fd262b8f2244cf4ea0e4ab7558c
4
- data.tar.gz: 3c18faecb6e3453fa2f2fda45653ce500dcdc2d2
3
+ metadata.gz: 332a260a2197fc58114223a6c5be628144e45042
4
+ data.tar.gz: 26a2abd7e96fc28512215f5e17be5dd5f52db9c2
5
5
  SHA512:
6
- metadata.gz: 9687a9b89f283b77b643ce786fa3ebeb831fe995a4caa091b254a1c78776dfd796ec8b91d9889ff94b0f584c055994784d776c732948867f146ee259f3617c15
7
- data.tar.gz: 6c97b06aed2bb6ffb0de766bbce50f8bef0f5bf01b3dce862380be1f7ee24c5f50500aab198157df10a9f612697698bd3ed04d4910c05910e693859cdd0ed41e
6
+ metadata.gz: ecbf18abbf5a5e307040615570590588a45bc9e82d90a069df701c5daa485a6b2fd4bb4010e61437bc7d164d83a72631960d5562fd34ab449ef15b6df8cf0f63
7
+ data.tar.gz: 9dd2c71d8ac044c704f028b778f0368991129e33db3ac93c6004f91a2cf7d376e3e68baf4b2f2e0cad7ecdc3613e6aa8078c864d98259ae9aa0233b61ecf0814
@@ -1,14 +1,22 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
- - **July.14.2017**: 2.0.2
4
+ - **2.1.0** - June 20, 2018
5
+ - PR #15 - Improved the method symbolize_keys. This method did not work properly for nested objects.
6
+ - PR #15 - Added the ability to pass `:text_wrap` option within the `:alignment` style
7
+ - Make axlsx styles higher precendence over Spreadsheet Architect style aliases
8
+ - Use `prepend` monkey patches in Ruby 2+ to avoid annoying overwrite warnings when using old `define_method` monkey patches
9
+ - Due to [RODF bug](https://github.com/thiagoarrais/rodf/issues/19) convert all Date and Time cells to String in ODS spreadsheets
10
+ - Improve test suite
11
+ - Dont test against Ruby versions that Rails no longer supports. Gem code should remain compatible with Ruby 1.9.3.
12
+ - **2.0.2** - July 14 2017
5
13
  - Fix bug with range styles rows option not counting headers
6
14
  - Fix bug with range styles rows :all option
7
- - **February.16.2017**: 2.0.1
15
+ - **2.0.1** - February 16 2017
8
16
  - Fix bug where `SpreadsheetArchitect.default_options` and `SPREADSHEET_OPTIONS` were being overwritten
9
17
  - Fix bug where col_styles ignored previous styles on header when using `include_header` option
10
18
  - Errors now try to provide which value is the cause
11
- - **January.28.2017**: 2.0.0
19
+ - **2.0.0** - January 28 2017
12
20
  - Add to xlsx: `merges`, `column_styles`, `range_styles`, `borders`, `column_widths` multi-row headers, date/time default format_code
13
21
  - Add `column_types` option for xlsx and ods
14
22
  - Add ability to make multi-sheet spreadsheets in XLSX & ODS
@@ -16,52 +24,52 @@ CHANGELOG
16
24
  - Add Examples
17
25
  - Add Axlsx Style Reference
18
26
  - Refractor into smaller files
19
- - **December.6.2016**: 1.4.8
27
+ - **1.4.8** - December 6 2016
20
28
  - Lock `rodf` gem to v0.3.7 for last v1 version of this gem
21
- - **November.7.2016**: 1.4.7
29
+ - **1.4.7** - November 7 2016
22
30
  - Fix method arguments for `to_rodf_spreadsheet` method
23
- - **May.16.2016**: 1.4.6
31
+ - **1.4.6** - May 16 2016
24
32
  - Fix hash syntax for support of ruby v2.1 and below
25
- - **May.4.2016**: 1.4.5
33
+ - **1.4.5** - May 4 2016
26
34
  - Bug fixes
27
- - **May.3.2016**: 1.4.4
35
+ - **1.4.4** - May 3 2016
28
36
  - Add Ability to add format_code to all numbers body rows
29
- - **May.3.2016**: 1.4.3
37
+ - **1.4.3** - May 3 2016
30
38
  - Bug fixes
31
- - **May.3.2016**: 1.4.2
39
+ - **1.4.2** - May 3 2016
32
40
  - Add to_axlsx_package, to_rodf_spreadsheet methods for the item to be further manipulated. Ex. axlsx_styler
33
- - **May.2.2016**: 1.4.1
41
+ - **1.4.1** - May 2 2016
34
42
  - Add rails generator for project defaults initializer
35
- - **April.29.2016**: 1.4.0
43
+ - **1.4.0** - April 29 2016
36
44
  - Add to_xlsx, to_ods, & to_csv to SpreadsheetArchitect model for direct calling by passing in cell data
37
- - **April.21.2016**: 1.3.0
45
+ - **1.3.0** - April 21 2016
38
46
  - Add ability to create class/model and project option defaults
39
- - **March.25.2016**: 1.2.5
47
+ - **1.2.5** - March 25 2016
40
48
  - Fix each_with_index bug
41
- - **March.24.2016**: 1.2.4
49
+ - **1.2.4** - March 24 2016
42
50
  - Fix cell type logic for symbol methods
43
- - **March.20.2016**: 1.2.3
51
+ - **1.2.3** - March 20 2016
44
52
  - Fix cell type logic
45
- - **March.19.2016**: 1.2.2
53
+ - **1.2.2** - March 19 2016
46
54
  - Make cell type numeric if value is numeric
47
- - **March.13.2016**: 1.2.1
55
+ - **1.2.1** - March 13 2016
48
56
  - Better error reporting
49
57
  - Fix for Plain ruby models
50
- - **March.10.2016**: 1.2.0
58
+ - **1.2.0** - March 10 2016
51
59
  - Fix Bug: first row data repeated for all records on custom values
52
- - **March.3.2016**: 1.1.0 - Breaking Changes
53
- - Move spreadsheet_columns method from the class to the instance
60
+ - **1.1.0** - March 3 2016
61
+ - Breaking Change - Move spreadsheet_columns method from the class to the instance
54
62
  - Fix Bug: remove default underline on cells
55
- - **March.1.2016**: 1.0.4
63
+ - **1.0.4** - March 1 2016
56
64
  - Extract helper methods to seperate module
57
65
  - Improve readme
58
- - **March.1.2016**: 1.0.3
66
+ - **1.0.3** - March 1 2016
59
67
  - Fix/Improve renderers
60
68
  - Fix header default background color
61
69
  - Fix default columns
62
- - **February.26.2016**: 1.0.2
70
+ - **1.0.2** - February 26 2016
63
71
  - Enhance Style options
64
- - **February.26.2016**: 1.0.1
72
+ - **1.0.1** - February 26 2016
65
73
  - Fix bug in renderers
66
- - **February.26.2016**: 1.0.0
74
+ - **1.0.0** - February 26 2016
67
75
  - Gem Initial Release
data/README.md CHANGED
@@ -92,7 +92,7 @@ class PostsController < ActionController::Base
92
92
  respond_with @posts
93
93
  end
94
94
 
95
- # Using respond_with with custom options
95
+ # OR Using respond_with with custom options
96
96
  def index
97
97
  @posts = Post.order(published_at: :asc)
98
98
 
@@ -103,7 +103,7 @@ class PostsController < ActionController::Base
103
103
  end
104
104
  end
105
105
 
106
- # Using responders
106
+ # OR Using responders
107
107
  def index
108
108
  @posts = Post.order(published_at: :asc)
109
109
 
@@ -115,7 +115,7 @@ class PostsController < ActionController::Base
115
115
  end
116
116
  end
117
117
 
118
- # Using responders with custom options
118
+ # OR Using responders with custom options
119
119
  def index
120
120
  @posts = Post.order(published_at: :asc)
121
121
 
@@ -133,25 +133,25 @@ end
133
133
  ```ruby
134
134
  # Ex. with ActiveRecord relation
135
135
  File.open('path/to/file.xlsx', 'w+b') do |f|
136
- f.write{ Post.order(published_at: :asc).to_xlsx }
136
+ f.write Post.order(published_at: :asc).to_xlsx
137
137
  end
138
138
  File.open('path/to/file.ods', 'w+b') do |f|
139
- f.write{ Post.order(published_at: :asc).to_ods }
139
+ f.write Post.order(published_at: :asc).to_ods
140
140
  end
141
141
  File.open('path/to/file.csv', 'w+b') do |f|
142
- f.write{ Post.order(published_at: :asc).to_csv }
142
+ f.write Post.order(published_at: :asc).to_csv
143
143
  end
144
144
 
145
145
  # Ex. with plain ruby class
146
146
  File.open('path/to/file.xlsx', 'w+b') do |f|
147
- f.write{ Post.to_xlsx(instances: posts_array) }
147
+ f.write Post.to_xlsx(instances: posts_array)
148
148
  end
149
149
 
150
150
  # Ex. One time Usage
151
151
  File.open('path/to/file.xlsx', 'w+b') do |f|
152
152
  headers = ['Col 1','Col 2','Col 3']
153
153
  data = [[1,2,3], [4,5,6], [7,8,9]]
154
- f.write{ SpreadsheetArchitect::to_xlsx(data: data, headers: headers) }
154
+ f.write SpreadsheetArchitect::to_xlsx(data: data, headers: headers)
155
155
  end
156
156
  ```
157
157
  <br>
@@ -213,7 +213,7 @@ end
213
213
  |**range_styles**<br>*Array*||[See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
214
214
  |**merges**<br>*Array*||Merge cells. [See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
215
215
  |**borders**<br>*Array*||[See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
216
- |**column_types**<br>*Array*||Valid types for XLSX are :string, :integer, :float, :date, :time, :boolean, nil = auto determine|
216
+ |**column_types**<br>*Array*||Valid types for XLSX are :string, :integer, :float, :boolean, nil = auto determine.|
217
217
  |**column_widths**<br>*Array*||Sometimes you may want explicit column widths. Use nil if you want a column to autofit again.|
218
218
 
219
219
  <br>
@@ -227,7 +227,7 @@ end
227
227
  |**sheet_name**<br>*String*|`Sheet1`||
228
228
  |**header_style**<br>*Hash*|`{background_color: "AAAAAA", color: "FFFFFF", align: :center, font_size: 10, bold: true}`|Note: Currently ODS only supports these options|
229
229
  |**row_style**<br>*Hash*|`{background_color: nil, color: "000000", align: :left, font_size: 10, bold: false}`|Styles for non-header rows. Currently ODS only supports these options|
230
- |**column_types**<br>*Array*||Valid types for ODS are :string, :float, :date, :percent, :currency, nil = auto determine|
230
+ |**column_types**<br>*Array*||Valid types for ODS are :string, :float, :date, :time, :percent, :currency, nil = auto determine. Due to [RODF issue #19](https://github.com/thiagoarrais/rodf/issues/19), :date/:time will be converted to :string |
231
231
 
232
232
  <br>
233
233
 
@@ -272,7 +272,7 @@ end
272
272
  SpreadsheetArchitect.default_options = {
273
273
  headers: true,
274
274
  header_style: {background_color: 'AAAAAA', color: 'FFFFFF', align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
275
- row_style: {background_color: nil, color: 'FFFFFF', align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
275
+ row_style: {background_color: nil, color: '000000', align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
276
276
  sheet_name: 'My Project Export',
277
277
  column_styles: [],
278
278
  range_styles: [],
@@ -283,7 +283,7 @@ SpreadsheetArchitect.default_options = {
283
283
  ```
284
284
 
285
285
  # Complex XLSX Example with Styling
286
- See this example: (https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)
286
+ See this example: https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb
287
287
 
288
288
 
289
289
  # Multi Sheet XLSX or ODS spreadsheets
@@ -296,11 +296,11 @@ spreadsheet = SpreadsheetArchitect.to_rodf_spreadsheet({data: data, headers: hea
296
296
  SpreadsheetArchitect.to_rodf_spreadsheet({data: data, headers: headers}, spreadsheet) # to combine two sheets to one file
297
297
  ```
298
298
 
299
- See this example: (https://github.com/westonganger/spreadsheet_architect/blob/master/examples/multi_sheet_spreadsheets.rb)
299
+ See this example: https://github.com/westonganger/spreadsheet_architect/blob/master/examples/multi_sheet_spreadsheets.rb
300
300
 
301
301
 
302
302
  # Axlsx Style Reference
303
- I have compiled a list of all available style options for `axlsx` here: (https://github.com/westonganger/spreadsheet_architect/blob/master/docs/axlsx_style_reference.md)
303
+ I have compiled a list of all available style options for axlsx here: https://github.com/westonganger/spreadsheet_architect/blob/master/docs/axlsx_style_reference.md
304
304
 
305
305
 
306
306
  # Credits
@@ -308,4 +308,4 @@ Created by [@westonganger](https://github.com/westonganger)
308
308
 
309
309
  For any consulting or contract work please contact me via my company website: [Solid Foundation Web Development](https://solidfoundationwebdev.com)
310
310
 
311
- [![Solid Foundation Web Development Logo](https://solidfoundationwebdev.com/logo.png)](https://solidfoundationwebdev.com)
311
+ [![Solid Foundation Web Development Logo](https://solidfoundationwebdev.com/logo-sm.png)](https://solidfoundationwebdev.com)
data/Rakefile CHANGED
@@ -3,10 +3,12 @@ require 'bundler/gem_tasks'
3
3
 
4
4
  task :test do
5
5
  require 'rake/testtask'
6
- Rake::TestTask.new do |t|
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'lib'
7
9
  t.libs << 'test'
8
- t.test_files = FileList['test/**/*_test.rb']
9
- t.verbose = true
10
+ t.pattern = 'test/**/*_test.rb'
11
+ t.verbose = false
10
12
  end
11
13
  end
12
14
 
@@ -47,8 +47,22 @@ module SpreadsheetArchitect
47
47
 
48
48
  options[:data].each_with_index do |row_data, index|
49
49
  row do
50
- row_data.each_with_index do |y,i|
51
- cell y, style: :row_style, type: (options[:types][i] if options[:types])
50
+ row_data.each_with_index do |val, i|
51
+ if options[:types]
52
+ type = options[:types][i]
53
+ end
54
+
55
+ if type
56
+ if [:date, :time].include?(type)
57
+ type = :string
58
+ val = val.to_s
59
+ end
60
+ elsif val.respond_to?(:strftime)
61
+ type = :string
62
+ val = val.to_s
63
+ end
64
+
65
+ cell val, style: :row_style, type: (options[:types][i] if options[:types])
52
66
  end
53
67
  end
54
68
  end
@@ -1,4 +1,33 @@
1
- if defined? Axlsx
1
+ if RUBY_VERSION.to_f >= 2
2
+
3
+ module SpreadsheetArchitect
4
+ module AxlsxColumnWidthPatch
5
+ def initialize(*args)
6
+ @width = nil
7
+ super
8
+ end
9
+
10
+ def width=(v)
11
+ if v.nil?
12
+ @custom_width = false
13
+ @width = nil
14
+ elsif @width.nil? || @width < v+5
15
+ @custom_width = true
16
+ @best_fit = true
17
+ @width = v + 5
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ module Axlsx
24
+ class Col
25
+ prepend ::SpreadsheetArchitect::AxlsxColumnWidthPatch
26
+ end
27
+ end
28
+
29
+ else
30
+
2
31
  module Axlsx
3
32
  class Col
4
33
  original_initialize = instance_method(:initialize)
@@ -13,11 +42,12 @@ if defined? Axlsx
13
42
  @custom_width = false
14
43
  @width = nil
15
44
  elsif @width.nil? || @width < v+5
16
- @custom_width = @best_fit = v != nil
45
+ @custom_width = true
46
+ @best_fit = true
17
47
  @width = v + 5
18
48
  end
19
49
  end
20
-
21
50
  end
22
51
  end
52
+
23
53
  end
@@ -28,27 +28,48 @@ module SpreadsheetArchitect
28
28
  styles = {} unless styles.is_a?(Hash)
29
29
  styles = self.symbolize_keys(styles)
30
30
 
31
- if styles[:color].respond_to?(:sub) && !styles[:color].empty?
32
- styles[:fg_color] = styles.delete(:color).sub('#','')
31
+ if styles[:fg_color].nil?
32
+ if styles[:color].respond_to?(:sub) && !styles[:color].empty?
33
+ styles[:fg_color] = styles.delete(:color).sub('#','')
34
+ end
33
35
  end
34
36
 
35
- if styles[:background_color].respond_to?(:sub) && !styles[:background_color].empty?
36
- styles[:bg_color] = styles.delete(:background_color).sub('#','')
37
+ if styles[:bg_color].nil?
38
+ if styles[:background_color].respond_to?(:sub) && !styles[:background_color].empty?
39
+ styles[:bg_color] = styles.delete(:background_color).sub('#','')
40
+ end
37
41
  end
38
-
39
- if styles[:align]
42
+
43
+ if styles[:alignment].nil? && styles[:align]
40
44
  if styles[:align].is_a?(Hash)
41
- styles[:alignment] = {horizontal: styles[:align][:horizontal], vertical: styles[:align][:vertical]}
42
- styles.delete(:align)
45
+ styles[:alignment] = {
46
+ horizontal: styles[:align][:horizontal],
47
+ vertical: styles[:align][:vertical],
48
+ wrap_text: styles[:align][:wrap_text]
49
+ }
43
50
  else
44
51
  styles[:alignment] = {horizontal: styles.delete(:align)}
45
52
  end
53
+
54
+ styles.delete(:align)
55
+ end
56
+
57
+ if styles[:b].nil?
58
+ styles[:b] = styles.delete(:bold)
46
59
  end
47
- styles[:b] = styles.delete(:bold) || styles[:b]
48
- styles[:sz] = styles.delete(:font_size) || styles[:sz]
49
- styles[:i] = styles.delete(:italic) || styles[:i]
50
- styles[:u] = styles.delete(:underline) || styles[:u]
51
60
 
61
+ if styles[:sz].nil?
62
+ styles[:sz] = styles.delete(:font_size)
63
+ end
64
+
65
+ if styles[:i].nil?
66
+ styles[:i] = styles.delete(:italic)
67
+ end
68
+
69
+ if styles[:u].nil?
70
+ styles[:u] = styles.delete(:underline)
71
+ end
72
+
52
73
  styles.delete_if{|k,v| v.nil?}
53
74
  end
54
75
 
@@ -106,19 +127,16 @@ module SpreadsheetArchitect
106
127
 
107
128
  private
108
129
 
109
- # only converts the first 2 levels
110
130
  def self.symbolize_keys(hash={})
111
131
  new_hash = {}
112
- hash.each do |k,v|
132
+ hash.each do |k, v|
113
133
  if v.is_a?(Hash)
114
- v.each do |k2,v2|
115
- new_hash[k2.to_sym] = v2
116
- end
134
+ new_hash[k.to_sym] = self.symbolize_keys(v)
117
135
  else
118
136
  new_hash[k.to_sym] = v
119
137
  end
120
138
  end
121
- return new_hash
139
+ new_hash
122
140
  end
123
141
 
124
142
  end
@@ -1,3 +1,3 @@
1
1
  module SpreadsheetArchitect
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -0,0 +1,21 @@
1
+ def assert_changed(expression, &block)
2
+ if expression.respond_to?(:call)
3
+ e = expression
4
+ else
5
+ e = lambda{ eval(expression, block.binding) }
6
+ end
7
+ old = e.call
8
+ block.call
9
+ assert_not_equal old, e.call
10
+ end
11
+
12
+ def assert_not_changed(expression, &block)
13
+ if expression.respond_to?(:call)
14
+ e = expression
15
+ else
16
+ e = lambda{ eval(expression, block.binding) }
17
+ end
18
+ old = e.call
19
+ block.call
20
+ assert_equal old, e.call
21
+ end
@@ -1,6 +1,7 @@
1
+ #!/usr/bin/env rake
1
2
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
3
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
4
 
4
- require_relative 'config/application'
5
+ require File.expand_path('../config/application', __FILE__)
5
6
 
6
- Rails.application.load_tasks
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require_self
3
+ */
@@ -1,3 +1,3 @@
1
1
  class ApplicationController < ActionController::Base
2
- protect_from_forgery with: :exception
2
+ protect_from_forgery
3
3
  end