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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +17 -2
- data/README.md +149 -129
- data/lib/spreadsheet_architect/class_methods/csv.rb +2 -2
- data/lib/spreadsheet_architect/class_methods/ods.rb +2 -2
- data/lib/spreadsheet_architect/class_methods/xlsx.rb +26 -30
- data/lib/spreadsheet_architect/exceptions.rb +32 -30
- data/lib/spreadsheet_architect/utils/xlsx.rb +46 -25
- data/lib/spreadsheet_architect/utils.rb +116 -121
- data/lib/spreadsheet_architect/version.rb +1 -1
- data/lib/spreadsheet_architect.rb +5 -1
- data/test/dummy_app/app/models/active_model_object.rb +1 -0
- data/test/dummy_app/app/models/custom_post.rb +1 -0
- data/test/dummy_app/app/models/legacy_plain_ruby_object.rb +14 -0
- data/test/dummy_app/app/models/plain_ruby_object.rb +2 -9
- data/test/dummy_app/app/models/post.rb +3 -0
- data/test/dummy_app/config/routes.rb +4 -5
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +26911 -21739
- data/test/dummy_app/tmp/2.0.1/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/integration/csv.csv +6 -0
- data/test/dummy_app/tmp/2.0.1/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/{empty_sa.csv → 2.0.1/models/ActiveModelObject/empty.csv} +0 -0
- data/test/dummy_app/tmp/{ods/empty_model.ods → 2.0.1/models/ActiveModelObject/empty.ods} +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.csv +6 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.csv +1 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.csv +6 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.csv +1 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.csv +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.csv +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.csv +3 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.csv +0 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/SpreadsheetArchitect/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/multi_sheet.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/csv.csv +6 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.csv +6 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.csv +1 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.csv +6 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.csv +1 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.csv +3 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/SpreadsheetArchitect/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/csv.csv +6 -0
- data/test/dummy_app/tmp/axlsx-master/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.csv +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.csv +6 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.csv +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.csv +6 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.csv +1 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.csv +1 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.csv +6 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.csv +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.csv +3 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.csv +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/SpreadsheetArchitect/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/multi_sheet.xlsx +0 -0
- data/test/integration/application_test.rb +8 -11
- data/test/models/all_models_test.rb +107 -0
- data/test/test_helper.rb +13 -4
- data/test/unit/exceptions_test.rb +168 -0
- data/test/unit/formats_test.rb +15 -0
- data/test/unit/general_test.rb +15 -0
- data/test/unit/kitchen_sink_test.rb +87 -0
- data/test/unit/multi_sheet_test.rb +29 -0
- data/test/unit/utils_test.rb +179 -0
- data/test/unit/xlsx_utils_test.rb +143 -0
- metadata +409 -116
- data/lib/generators/spreadsheet_architect/add_project_defaults_generator.rb +0 -20
- data/test/dummy_app/app/models/bad_plain_ruby_object.rb +0 -3
- data/test/dummy_app/app/views/reports/sample.html.erb +0 -1
- data/test/dummy_app/log/development.log +0 -28
- data/test/dummy_app/tmp/active_model_object/csv.csv +0 -21
- data/test/dummy_app/tmp/active_model_object/ods.ods +0 -0
- data/test/dummy_app/tmp/active_model_object/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/custom_posts/csv.csv +0 -6
- data/test/dummy_app/tmp/custom_posts/empty.xlsx +0 -0
- data/test/dummy_app/tmp/custom_posts/ods.ods +0 -0
- data/test/dummy_app/tmp/custom_posts/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/empty_model.csv +0 -1
- data/test/dummy_app/tmp/empty_model.xlsx +0 -0
- data/test/dummy_app/tmp/empty_sa.xlsx +0 -0
- data/test/dummy_app/tmp/extreme.xlsx +0 -0
- data/test/dummy_app/tmp/integration_tests/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/integration_tests/csv.csv +0 -6
- data/test/dummy_app/tmp/integration_tests/ods.ods +0 -0
- data/test/dummy_app/tmp/integration_tests/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/model.csv +0 -6
- data/test/dummy_app/tmp/model.xlsx +0 -0
- data/test/dummy_app/tmp/ods/empty_sa.ods +0 -0
- data/test/dummy_app/tmp/ods/model.ods +0 -0
- data/test/dummy_app/tmp/ods/model_options.ods +0 -0
- data/test/dummy_app/tmp/ods/sa.ods +0 -0
- data/test/dummy_app/tmp/options.csv +0 -6
- data/test/dummy_app/tmp/plain_ruby_object/csv.csv +0 -4
- data/test/dummy_app/tmp/plain_ruby_object/ods.ods +0 -0
- data/test/dummy_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/posts/csv.csv +0 -6
- data/test/dummy_app/tmp/posts/empty.xlsx +0 -0
- data/test/dummy_app/tmp/posts/ods.ods +0 -0
- data/test/dummy_app/tmp/posts/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/sa.csv +0 -4
- data/test/dummy_app/tmp/sa.xlsx +0 -0
- data/test/models/active_model_object_test.rb +0 -51
- data/test/models/bad_plain_ruby_object_test.rb +0 -28
- data/test/models/csv_test.rb +0 -59
- data/test/models/custom_post_test.rb +0 -51
- data/test/models/ods_test.rb +0 -65
- data/test/models/plain_ruby_object_test.rb +0 -51
- data/test/models/post_test.rb +0 -44
- data/test/models/spreadsheet_architect_utils_test.rb +0 -73
- data/test/models/xlsx_test.rb +0 -98
- 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
|