csv_plus_plus 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -63
- data/{CHANGELOG.md → docs/CHANGELOG.md} +17 -0
- data/lib/csv_plus_plus/benchmarked_compiler.rb +112 -0
- data/lib/csv_plus_plus/cell.rb +46 -24
- data/lib/csv_plus_plus/cli.rb +44 -17
- data/lib/csv_plus_plus/cli_flag.rb +1 -2
- data/lib/csv_plus_plus/color.rb +42 -11
- data/lib/csv_plus_plus/compiler.rb +178 -0
- data/lib/csv_plus_plus/entities/ast_builder.rb +50 -0
- data/lib/csv_plus_plus/entities/boolean.rb +40 -0
- data/lib/csv_plus_plus/entities/builtins.rb +58 -0
- data/lib/csv_plus_plus/entities/cell_reference.rb +231 -0
- data/lib/csv_plus_plus/entities/date.rb +63 -0
- data/lib/csv_plus_plus/entities/entity.rb +50 -0
- data/lib/csv_plus_plus/entities/entity_with_arguments.rb +57 -0
- data/lib/csv_plus_plus/entities/function.rb +45 -0
- data/lib/csv_plus_plus/entities/function_call.rb +50 -0
- data/lib/csv_plus_plus/entities/number.rb +48 -0
- data/lib/csv_plus_plus/entities/runtime_value.rb +43 -0
- data/lib/csv_plus_plus/entities/string.rb +42 -0
- data/lib/csv_plus_plus/entities/variable.rb +37 -0
- data/lib/csv_plus_plus/entities.rb +40 -0
- data/lib/csv_plus_plus/error/error.rb +20 -0
- data/lib/csv_plus_plus/error/formula_syntax_error.rb +37 -0
- data/lib/csv_plus_plus/error/modifier_syntax_error.rb +75 -0
- data/lib/csv_plus_plus/error/modifier_validation_error.rb +69 -0
- data/lib/csv_plus_plus/error/syntax_error.rb +71 -0
- data/lib/csv_plus_plus/error/writer_error.rb +17 -0
- data/lib/csv_plus_plus/error.rb +10 -2
- data/lib/csv_plus_plus/google_api_client.rb +11 -2
- data/lib/csv_plus_plus/google_options.rb +23 -18
- data/lib/csv_plus_plus/lexer/lexer.rb +17 -6
- data/lib/csv_plus_plus/lexer/tokenizer.rb +6 -1
- data/lib/csv_plus_plus/lexer.rb +24 -0
- data/lib/csv_plus_plus/modifier/conditional_formatting.rb +18 -0
- data/lib/csv_plus_plus/modifier/data_validation.rb +138 -0
- data/lib/csv_plus_plus/modifier/expand.rb +61 -0
- data/lib/csv_plus_plus/modifier/google_sheet_modifier.rb +133 -0
- data/lib/csv_plus_plus/modifier/modifier.rb +222 -0
- data/lib/csv_plus_plus/modifier/modifier_validator.rb +243 -0
- data/lib/csv_plus_plus/modifier/rubyxl_modifier.rb +84 -0
- data/lib/csv_plus_plus/modifier.rb +82 -150
- data/lib/csv_plus_plus/options.rb +64 -19
- data/lib/csv_plus_plus/{language → parser}/cell_value.tab.rb +25 -25
- data/lib/csv_plus_plus/{language → parser}/code_section.tab.rb +86 -95
- data/lib/csv_plus_plus/parser/modifier.tab.rb +478 -0
- data/lib/csv_plus_plus/row.rb +53 -15
- data/lib/csv_plus_plus/runtime/can_define_references.rb +87 -0
- data/lib/csv_plus_plus/runtime/can_resolve_references.rb +209 -0
- data/lib/csv_plus_plus/runtime/graph.rb +68 -0
- data/lib/csv_plus_plus/runtime/position_tracker.rb +231 -0
- data/lib/csv_plus_plus/runtime/references.rb +110 -0
- data/lib/csv_plus_plus/runtime/runtime.rb +126 -0
- data/lib/csv_plus_plus/runtime.rb +42 -0
- data/lib/csv_plus_plus/source_code.rb +66 -0
- data/lib/csv_plus_plus/template.rb +63 -36
- data/lib/csv_plus_plus/version.rb +2 -1
- data/lib/csv_plus_plus/writer/base_writer.rb +30 -5
- data/lib/csv_plus_plus/writer/csv.rb +11 -9
- data/lib/csv_plus_plus/writer/excel.rb +9 -2
- data/lib/csv_plus_plus/writer/file_backer_upper.rb +7 -4
- data/lib/csv_plus_plus/writer/google_sheet_builder.rb +88 -45
- data/lib/csv_plus_plus/writer/google_sheets.rb +79 -29
- data/lib/csv_plus_plus/writer/open_document.rb +6 -1
- data/lib/csv_plus_plus/writer/rubyxl_builder.rb +103 -33
- data/lib/csv_plus_plus/writer.rb +39 -9
- data/lib/csv_plus_plus.rb +41 -15
- metadata +44 -30
- data/lib/csv_plus_plus/code_section.rb +0 -101
- data/lib/csv_plus_plus/expand.rb +0 -18
- data/lib/csv_plus_plus/graph.rb +0 -62
- data/lib/csv_plus_plus/language/ast_builder.rb +0 -68
- data/lib/csv_plus_plus/language/benchmarked_compiler.rb +0 -65
- data/lib/csv_plus_plus/language/builtins.rb +0 -46
- data/lib/csv_plus_plus/language/compiler.rb +0 -152
- data/lib/csv_plus_plus/language/entities/boolean.rb +0 -33
- data/lib/csv_plus_plus/language/entities/cell_reference.rb +0 -33
- data/lib/csv_plus_plus/language/entities/entity.rb +0 -86
- data/lib/csv_plus_plus/language/entities/function.rb +0 -35
- data/lib/csv_plus_plus/language/entities/function_call.rb +0 -37
- data/lib/csv_plus_plus/language/entities/number.rb +0 -36
- data/lib/csv_plus_plus/language/entities/runtime_value.rb +0 -28
- data/lib/csv_plus_plus/language/entities/string.rb +0 -31
- data/lib/csv_plus_plus/language/entities/variable.rb +0 -25
- data/lib/csv_plus_plus/language/entities.rb +0 -28
- data/lib/csv_plus_plus/language/references.rb +0 -70
- data/lib/csv_plus_plus/language/runtime.rb +0 -205
- data/lib/csv_plus_plus/language/scope.rb +0 -192
- data/lib/csv_plus_plus/language/syntax_error.rb +0 -66
- data/lib/csv_plus_plus/modifier.tab.rb +0 -907
- data/lib/csv_plus_plus/writer/google_sheet_modifier.rb +0 -56
- data/lib/csv_plus_plus/writer/rubyxl_modifier.rb +0 -59
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CSVPlusPlus
|
4
|
-
module Writer
|
5
|
-
# Decorate a Modifier so it can be written to the Google Sheets API
|
6
|
-
class GoogleSheetModifier < ::SimpleDelegator
|
7
|
-
# Format the halign for Google Sheets
|
8
|
-
def halign
|
9
|
-
super&.upcase
|
10
|
-
end
|
11
|
-
|
12
|
-
# Format the valign for Google Sheets
|
13
|
-
def valign
|
14
|
-
super&.upcase
|
15
|
-
end
|
16
|
-
|
17
|
-
# Format the color for Google Sheets
|
18
|
-
def color
|
19
|
-
google_sheets_color(super) if super
|
20
|
-
end
|
21
|
-
|
22
|
-
# Format the fontcolor for Google Sheets
|
23
|
-
def fontcolor
|
24
|
-
google_sheets_color(super) if super
|
25
|
-
end
|
26
|
-
|
27
|
-
# Format the numberformat for Google Sheets
|
28
|
-
def numberformat
|
29
|
-
::Google::Apis::SheetsV4::NumberFormat.new(type: super) if super
|
30
|
-
end
|
31
|
-
|
32
|
-
# Builds a SheetsV4::TextFormat with the underlying Modifier
|
33
|
-
def text_format
|
34
|
-
::Google::Apis::SheetsV4::TextFormat.new(
|
35
|
-
bold: formatted?('bold') || nil,
|
36
|
-
italic: formatted?('italic') || nil,
|
37
|
-
strikethrough: formatted?('strikethrough') || nil,
|
38
|
-
underline: formatted?('underline') || nil,
|
39
|
-
font_family: fontfamily,
|
40
|
-
font_size: fontsize,
|
41
|
-
foreground_color: fontcolor
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def google_sheets_color(color)
|
48
|
-
::Google::Apis::SheetsV4::Color.new(
|
49
|
-
red: color.red_percent,
|
50
|
-
green: color.green_percent,
|
51
|
-
blue: color.blue_percent
|
52
|
-
)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CSVPlusPlus
|
4
|
-
module Writer
|
5
|
-
# Build a RubyXL-decorated Modifier class adds some support for Excel
|
6
|
-
class RubyXLModifier < ::SimpleDelegator
|
7
|
-
# https://www.rubydoc.info/gems/rubyXL/RubyXL/NumberFormats
|
8
|
-
# https://support.microsoft.com/en-us/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68
|
9
|
-
NUM_FMT_IDS = {
|
10
|
-
currency: 5,
|
11
|
-
date: 14,
|
12
|
-
date_time: 22,
|
13
|
-
number: 1,
|
14
|
-
percent: 9,
|
15
|
-
text: 49,
|
16
|
-
time: 21,
|
17
|
-
scientific: 48
|
18
|
-
}.freeze
|
19
|
-
private_constant :NUM_FMT_IDS
|
20
|
-
|
21
|
-
# https://www.rubydoc.info/gems/rubyXL/2.3.0/RubyXL
|
22
|
-
# ST_BorderStyle = %w{ none thin medium dashed dotted thick double hair mediumDashed dashDot mediumDashDot
|
23
|
-
# dashDotDot slantDashDot }
|
24
|
-
BORDER_STYLES = {
|
25
|
-
dashed: 'dashed',
|
26
|
-
dotted: 'dotted',
|
27
|
-
double: 'double',
|
28
|
-
solid: 'thin',
|
29
|
-
solid_medium: 'medium',
|
30
|
-
solid_thick: 'thick'
|
31
|
-
}.freeze
|
32
|
-
private_constant :BORDER_STYLES
|
33
|
-
|
34
|
-
# The excel-specific border weight
|
35
|
-
#
|
36
|
-
# @return [Integer]
|
37
|
-
def border_weight
|
38
|
-
return unless borderstyle
|
39
|
-
|
40
|
-
# rubocop:disable Lint/ConstantResolution
|
41
|
-
BORDER_STYLES[borderstyle.to_sym]
|
42
|
-
# rubocop:enable Lint/ConstantResolution
|
43
|
-
end
|
44
|
-
|
45
|
-
# The excel-specific number format code
|
46
|
-
#
|
47
|
-
# @return [String]
|
48
|
-
def number_format_code
|
49
|
-
return unless numberformat
|
50
|
-
|
51
|
-
::RubyXL::NumberFormats::DEFAULT_NUMBER_FORMATS.find_by_format_id(
|
52
|
-
# rubocop:disable Lint/ConstantResolution
|
53
|
-
NUM_FMT_IDS[numberformat.to_sym]
|
54
|
-
# rubocop:enable Lint/ConstantResolution
|
55
|
-
).format_code
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|