csv_plus_plus 0.1.1 → 0.1.3
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.
- 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,171 +1,103 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# @attr expand [Expand] Whether this row expands into multiple rows
|
|
8
|
-
# @attr fontfamily [String] The font family
|
|
9
|
-
# @attr fontsize [Number] The font size
|
|
10
|
-
# @attr halign ['left', 'center', 'right'] Horizontal alignment
|
|
11
|
-
# @attr note [String] A note/comment on the cell
|
|
12
|
-
# @attr numberformat [String] A number format to apply to the value in the cell
|
|
13
|
-
# @attr row_level [Boolean] Is this a row modifier? If so it's values will apply to all cells in the row
|
|
14
|
-
# (unless overridden by the cell modifier)
|
|
15
|
-
# @attr validation [Object]
|
|
16
|
-
# @attr valign ['top', 'center', 'bottom'] Vertical alignment
|
|
17
|
-
#
|
|
18
|
-
# @attr_writer borderstyle ['dashed', 'dotted', 'double', 'solid', 'solid_medium', 'solid_thick']
|
|
19
|
-
# The style of border on the cell
|
|
20
|
-
#
|
|
21
|
-
# @attr_reader bordercolor [String]
|
|
22
|
-
# @attr_reader borders [Array<String>]
|
|
23
|
-
# @attr_reader color [Color] The background color of the cell
|
|
24
|
-
# @attr_reader fontcolor [Color] The font color of the cell
|
|
25
|
-
# @attr_reader formats [Array<String>] Bold/italics/underline/strikethrough formatting
|
|
26
|
-
class Modifier
|
|
27
|
-
attr_reader :bordercolor, :borders, :color, :fontcolor, :formats
|
|
28
|
-
attr_writer :borderstyle
|
|
29
|
-
attr_accessor :expand, :fontfamily, :fontsize, :halign, :valign, :note, :numberformat, :row_level, :validation
|
|
30
|
-
|
|
31
|
-
# @param row_level [Boolean] Whether or not this modifier applies to the entire row
|
|
32
|
-
def initialize(row_level: false)
|
|
33
|
-
@row_level = row_level
|
|
34
|
-
@freeze = false
|
|
35
|
-
@borders = ::Set.new
|
|
36
|
-
@formats = ::Set.new
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Set the color
|
|
40
|
-
#
|
|
41
|
-
# @param hex_value [String]
|
|
42
|
-
#
|
|
43
|
-
# @return [Color]
|
|
44
|
-
def color=(hex_value)
|
|
45
|
-
@color = ::CSVPlusPlus::Color.new(hex_value)
|
|
46
|
-
end
|
|
4
|
+
require_relative './modifier/conditional_formatting'
|
|
5
|
+
require_relative './modifier/data_validation'
|
|
6
|
+
require_relative './modifier/expand'
|
|
7
|
+
require_relative './modifier/modifier'
|
|
47
8
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Does this have a border along all sides?
|
|
65
|
-
#
|
|
66
|
-
# @return [Boolean]
|
|
67
|
-
def border_all?
|
|
68
|
-
@borders.include?('all') \
|
|
69
|
-
|| (border_along?('top') && border_along?('bottom') && border_along?('left') && border_along?('right'))
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Set the bordercolor
|
|
73
|
-
#
|
|
74
|
-
# @param hex_value [String] formatted as '#000000', '#000' or '000000'
|
|
75
|
-
def bordercolor=(hex_value)
|
|
76
|
-
@bordercolor = ::CSVPlusPlus::Color.new(hex_value)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Are there any borders set?
|
|
80
|
-
#
|
|
81
|
-
# @return [Boolean]
|
|
82
|
-
def any_border?
|
|
83
|
-
!@borders.empty?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Set the fontcolor
|
|
87
|
-
#
|
|
88
|
-
# @param hex_value [String] formatted as '#000000', '#000' or '000000'
|
|
89
|
-
def fontcolor=(hex_value)
|
|
90
|
-
@fontcolor = ::CSVPlusPlus::Color.new(hex_value)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Set a text format (bolid, italic, underline or strikethrough)
|
|
94
|
-
#
|
|
95
|
-
# @param value ['bold', 'italic', 'underline', 'strikethrough']
|
|
96
|
-
def format=(value)
|
|
97
|
-
@formats << value
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Is the given format set?
|
|
101
|
-
#
|
|
102
|
-
# @param type ['bold', 'italic', 'underline', 'strikethrough']
|
|
103
|
-
#
|
|
104
|
-
# @return [Boolean]
|
|
105
|
-
def formatted?(type)
|
|
106
|
-
@formats.include?(type)
|
|
9
|
+
module CSVPlusPlus
|
|
10
|
+
# All modifier-specific logic is hidden in this module and callers should just call +#new+ on this module.
|
|
11
|
+
module Modifier
|
|
12
|
+
extend ::T::Sig
|
|
13
|
+
|
|
14
|
+
# The sides that a border can be on
|
|
15
|
+
class BorderSide < ::T::Enum
|
|
16
|
+
enums do
|
|
17
|
+
All = new
|
|
18
|
+
Top = new
|
|
19
|
+
Bottom = new
|
|
20
|
+
Left = new
|
|
21
|
+
Right = new
|
|
22
|
+
end
|
|
107
23
|
end
|
|
108
24
|
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
25
|
+
# The various border styles
|
|
26
|
+
class BorderStyle < ::T::Enum
|
|
27
|
+
enums do
|
|
28
|
+
Dashed = new
|
|
29
|
+
Dotted = new
|
|
30
|
+
Double = new
|
|
31
|
+
Solid = new
|
|
32
|
+
SolidMedium = new
|
|
33
|
+
SolidThick = new
|
|
34
|
+
end
|
|
114
35
|
end
|
|
115
36
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
37
|
+
# The possible values for a horizontal alignment
|
|
38
|
+
class HorizontalAlign < ::T::Enum
|
|
39
|
+
enums do
|
|
40
|
+
Left = new
|
|
41
|
+
Right = new
|
|
42
|
+
Center = new
|
|
43
|
+
end
|
|
121
44
|
end
|
|
122
45
|
|
|
123
|
-
#
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
46
|
+
# The allowed number formats
|
|
47
|
+
class NumberFormat < ::T::Enum
|
|
48
|
+
enums do
|
|
49
|
+
Currency = new
|
|
50
|
+
Date = new
|
|
51
|
+
DateTime = new
|
|
52
|
+
Number = new
|
|
53
|
+
Percent = new
|
|
54
|
+
Text = new
|
|
55
|
+
Time = new
|
|
56
|
+
Scientific = new
|
|
57
|
+
end
|
|
128
58
|
end
|
|
129
59
|
|
|
130
|
-
#
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
60
|
+
# The types of formats that can be applied to text.
|
|
61
|
+
class TextFormat < ::T::Enum
|
|
62
|
+
enums do
|
|
63
|
+
Bold = new
|
|
64
|
+
Italic = new
|
|
65
|
+
Strikethrough = new
|
|
66
|
+
Underline = new
|
|
67
|
+
end
|
|
135
68
|
end
|
|
136
69
|
|
|
137
|
-
#
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
70
|
+
# The possible values for a horizontal alignment
|
|
71
|
+
class VerticalAlign < ::T::Enum
|
|
72
|
+
enums do
|
|
73
|
+
Top = new
|
|
74
|
+
Bottom = new
|
|
75
|
+
Center = new
|
|
76
|
+
end
|
|
142
77
|
end
|
|
143
78
|
|
|
144
|
-
|
|
79
|
+
sig { params(options: ::CSVPlusPlus::Options, row_level: ::T::Boolean).returns(::CSVPlusPlus::Modifier::Modifier) }
|
|
80
|
+
# Return a +Modifier+ with the proper validation and helper functions attached for the given output
|
|
145
81
|
#
|
|
146
|
-
# @
|
|
147
|
-
|
|
148
|
-
@borderstyle || 'solid'
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
# @return [String]
|
|
152
|
-
def to_s
|
|
153
|
-
# TODO... I dunno, not sure how to manage this
|
|
154
|
-
"Modifier(row_level: #{@row_level} halign: #{@halign} valign: #{@valign} format: #{@formats} " \
|
|
155
|
-
"font_size: #{@font_size})"
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# Create a new modifier instance, with all values defaulted from +other+
|
|
82
|
+
# @param options [boolean] is this a row level modifier? (otherwise cell-level)
|
|
83
|
+
# @param row_level [boolean] is this a row level modifier? (otherwise cell-level)
|
|
159
84
|
#
|
|
160
|
-
# @
|
|
161
|
-
def
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
85
|
+
# @return [ValidatedModifier]
|
|
86
|
+
def self.new(options, row_level: false)
|
|
87
|
+
output_format = options.output_format
|
|
88
|
+
case output_format
|
|
89
|
+
when ::CSVPlusPlus::Options::OutputFormat::CSV, ::CSVPlusPlus::Options::OutputFormat::OpenDocument
|
|
90
|
+
::CSVPlusPlus::Modifier::Modifier.new(row_level:)
|
|
91
|
+
when ::CSVPlusPlus::Options::OutputFormat::Excel
|
|
92
|
+
::CSVPlusPlus::Modifier::RubyXLModifier.new(row_level:)
|
|
93
|
+
when ::CSVPlusPlus::Options::OutputFormat::GoogleSheets
|
|
94
|
+
::CSVPlusPlus::Modifier::GoogleSheetModifier.new(row_level:)
|
|
95
|
+
else ::T.absurd(output_format)
|
|
168
96
|
end
|
|
169
97
|
end
|
|
170
98
|
end
|
|
171
99
|
end
|
|
100
|
+
|
|
101
|
+
require_relative './modifier/google_sheet_modifier'
|
|
102
|
+
require_relative './modifier/modifier_validator'
|
|
103
|
+
require_relative './modifier/rubyxl_modifier'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require_relative './cli_flag'
|
|
4
|
-
require_relative './google_options'
|
|
5
|
-
|
|
6
4
|
module CSVPlusPlus
|
|
7
5
|
# The options a user can supply (via CLI flags)
|
|
8
6
|
#
|
|
@@ -15,28 +13,80 @@ module CSVPlusPlus
|
|
|
15
13
|
# @attr verbose [boolean] Include extra verbose output?
|
|
16
14
|
# @attr_reader google [GoogleOptions] Options that are specific to the Google Sheets writer
|
|
17
15
|
class Options
|
|
18
|
-
|
|
16
|
+
extend ::T::Sig
|
|
17
|
+
|
|
18
|
+
# The supported output formats. We use this to dispatch flow in several places
|
|
19
|
+
class OutputFormat < ::T::Enum
|
|
20
|
+
enums do
|
|
21
|
+
CSV = new
|
|
22
|
+
Excel = new
|
|
23
|
+
GoogleSheets = new
|
|
24
|
+
OpenDocument = new
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
sig { returns(::T::Boolean) }
|
|
29
|
+
attr_accessor :backup
|
|
30
|
+
|
|
31
|
+
sig { returns(::T::Boolean) }
|
|
32
|
+
attr_accessor :create_if_not_exists
|
|
33
|
+
|
|
34
|
+
sig { returns(::T::Hash[::Symbol, ::String]) }
|
|
35
|
+
attr_accessor :key_values
|
|
36
|
+
|
|
37
|
+
sig { returns(::T::Array[::Integer]) }
|
|
38
|
+
attr_accessor :offset
|
|
39
|
+
|
|
40
|
+
sig { returns(::T.nilable(::String)) }
|
|
41
|
+
attr_accessor :output_filename
|
|
42
|
+
|
|
43
|
+
sig { returns(::T.nilable(::String)) }
|
|
44
|
+
attr_accessor :sheet_name
|
|
45
|
+
|
|
46
|
+
sig { returns(::T::Boolean) }
|
|
47
|
+
attr_accessor :verbose
|
|
48
|
+
|
|
49
|
+
sig { returns(::T.nilable(::CSVPlusPlus::GoogleOptions)) }
|
|
19
50
|
attr_reader :google
|
|
20
51
|
|
|
21
|
-
|
|
52
|
+
sig { void }
|
|
53
|
+
# Initialize a default +Options+ object
|
|
22
54
|
def initialize
|
|
23
|
-
@offset = [0, 0]
|
|
24
|
-
@create_if_not_exists = false
|
|
25
|
-
@key_values = {}
|
|
26
|
-
@verbose = false
|
|
27
|
-
@backup = false
|
|
55
|
+
@offset = ::T.let([0, 0], ::T::Array[::Integer])
|
|
56
|
+
@create_if_not_exists = ::T.let(false, ::T::Boolean)
|
|
57
|
+
@key_values = ::T.let({}, ::T::Hash[::Symbol, ::String])
|
|
58
|
+
@verbose = ::T.let(false, ::T::Boolean)
|
|
59
|
+
@backup = ::T.let(false, ::T::Boolean)
|
|
60
|
+
@google = ::T.let(nil, ::T.nilable(::CSVPlusPlus::GoogleOptions))
|
|
28
61
|
end
|
|
29
62
|
|
|
63
|
+
sig { params(sheet_id: ::String).returns(::CSVPlusPlus::GoogleOptions) }
|
|
30
64
|
# Set the Google Sheet ID
|
|
31
65
|
#
|
|
32
|
-
# @param sheet_id [String] The identifier used by Google's API to reference the sheet. You can find it in the URL
|
|
66
|
+
# @param sheet_id [::String] The identifier used by Google's API to reference the sheet. You can find it in the URL
|
|
33
67
|
# for the sheet
|
|
34
68
|
#
|
|
35
|
-
# @return [String]
|
|
69
|
+
# @return [::String]
|
|
36
70
|
def google_sheet_id=(sheet_id)
|
|
37
71
|
@google = ::CSVPlusPlus::GoogleOptions.new(sheet_id)
|
|
38
72
|
end
|
|
39
73
|
|
|
74
|
+
sig { returns(::CSVPlusPlus::Options::OutputFormat) }
|
|
75
|
+
# Given the options, figure out which type of +OutputFormat+ we'll be writing to
|
|
76
|
+
#
|
|
77
|
+
# @return [Options::OutputFormat]
|
|
78
|
+
def output_format
|
|
79
|
+
return ::CSVPlusPlus::Options::OutputFormat::GoogleSheets if @google
|
|
80
|
+
|
|
81
|
+
case @output_filename
|
|
82
|
+
when /\.csv$/ then ::CSVPlusPlus::Options::OutputFormat::CSV
|
|
83
|
+
when /\.ods$/ then ::CSVPlusPlus::Options::OutputFormat::OpenDocument
|
|
84
|
+
when /\.xl(sx|sm|tx|tm)$/ then ::CSVPlusPlus::Options::OutputFormat::Excel
|
|
85
|
+
else raise(::CSVPlusPlus::Error::Error, "Unsupported file extension: #{@output_filename}")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
sig { returns(::T.nilable(::String)) }
|
|
40
90
|
# Returns an error string or nil if there are no validation problems
|
|
41
91
|
#
|
|
42
92
|
# @return [String, nil]
|
|
@@ -46,6 +96,7 @@ module CSVPlusPlus
|
|
|
46
96
|
'You must supply either a Google Sheet ID or an output file'
|
|
47
97
|
end
|
|
48
98
|
|
|
99
|
+
sig { returns(::String) }
|
|
49
100
|
# Return a string with a verbose description of what we're doing with the options
|
|
50
101
|
#
|
|
51
102
|
# @return [String]
|
|
@@ -55,7 +106,6 @@ module CSVPlusPlus
|
|
|
55
106
|
|
|
56
107
|
# csv++ Command Options
|
|
57
108
|
|
|
58
|
-
> Input filename | #{@filename}
|
|
59
109
|
> Sheet name | #{@sheet_name}
|
|
60
110
|
> Create sheet if it does not exist? | #{@create_if_not_exists}
|
|
61
111
|
> Spreadsheet row-offset | #{@offset[0]}
|
|
@@ -73,14 +123,9 @@ module CSVPlusPlus
|
|
|
73
123
|
SUMMARY
|
|
74
124
|
end
|
|
75
125
|
|
|
76
|
-
# @return [String]
|
|
77
|
-
def to_s
|
|
78
|
-
"Options(create_if_not_exists: #{@create_if_not_exists}, google: #{@google}, key_values: #{@key_values}, " \
|
|
79
|
-
"offset: #{@offset}, sheet_name: #{@sheet_name}, verbose: #{@verbose})"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
126
|
private
|
|
83
127
|
|
|
128
|
+
sig { returns(::String) }
|
|
84
129
|
def summary_divider
|
|
85
130
|
'========================================================================='
|
|
86
131
|
end
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
require 'racc/parser.rb'
|
|
8
8
|
|
|
9
9
|
require_relative '../lexer'
|
|
10
|
-
require_relative '../
|
|
10
|
+
require_relative '../entities/ast_builder'
|
|
11
11
|
|
|
12
12
|
module CSVPlusPlus
|
|
13
|
-
module
|
|
14
|
-
class
|
|
13
|
+
module Parser
|
|
14
|
+
class CellValue < Racc::Parser
|
|
15
15
|
|
|
16
|
-
module_eval(<<'...end cell_value.y/module_eval...', 'cell_value.y',
|
|
17
|
-
include ::CSVPlusPlus::
|
|
16
|
+
module_eval(<<'...end cell_value.y/module_eval...', 'cell_value.y', 49)
|
|
17
|
+
include ::CSVPlusPlus::Entities::ASTBuilder
|
|
18
18
|
include ::CSVPlusPlus::Lexer
|
|
19
19
|
|
|
20
20
|
protected
|
|
@@ -201,7 +201,7 @@ Racc_debug_parser = false
|
|
|
201
201
|
|
|
202
202
|
# reduce 0 omitted
|
|
203
203
|
|
|
204
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
204
|
+
module_eval(<<'.,.,', 'cell_value.y', 21)
|
|
205
205
|
def _reduce_1(val, _values, result)
|
|
206
206
|
@ast = val[1]
|
|
207
207
|
result
|
|
@@ -212,86 +212,86 @@ module_eval(<<'.,.,', 'cell_value.y', 20)
|
|
|
212
212
|
|
|
213
213
|
# reduce 3 omitted
|
|
214
214
|
|
|
215
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
215
|
+
module_eval(<<'.,.,', 'cell_value.y', 25)
|
|
216
216
|
def _reduce_4(val, _values, result)
|
|
217
217
|
result = val[1]
|
|
218
218
|
result
|
|
219
219
|
end
|
|
220
220
|
.,.,
|
|
221
221
|
|
|
222
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
222
|
+
module_eval(<<'.,.,', 'cell_value.y', 26)
|
|
223
223
|
def _reduce_5(val, _values, result)
|
|
224
|
-
result = variable(val[1])
|
|
224
|
+
result = variable(val[1].to_sym)
|
|
225
225
|
result
|
|
226
226
|
end
|
|
227
227
|
.,.,
|
|
228
228
|
|
|
229
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
229
|
+
module_eval(<<'.,.,', 'cell_value.y', 27)
|
|
230
230
|
def _reduce_6(val, _values, result)
|
|
231
231
|
result = string(val[0])
|
|
232
232
|
result
|
|
233
233
|
end
|
|
234
234
|
.,.,
|
|
235
235
|
|
|
236
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
236
|
+
module_eval(<<'.,.,', 'cell_value.y', 28)
|
|
237
237
|
def _reduce_7(val, _values, result)
|
|
238
238
|
result = number(val[0])
|
|
239
239
|
result
|
|
240
240
|
end
|
|
241
241
|
.,.,
|
|
242
242
|
|
|
243
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
243
|
+
module_eval(<<'.,.,', 'cell_value.y', 29)
|
|
244
244
|
def _reduce_8(val, _values, result)
|
|
245
245
|
result = boolean(true)
|
|
246
246
|
result
|
|
247
247
|
end
|
|
248
248
|
.,.,
|
|
249
249
|
|
|
250
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
250
|
+
module_eval(<<'.,.,', 'cell_value.y', 30)
|
|
251
251
|
def _reduce_9(val, _values, result)
|
|
252
252
|
result = boolean(false)
|
|
253
253
|
result
|
|
254
254
|
end
|
|
255
255
|
.,.,
|
|
256
256
|
|
|
257
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
257
|
+
module_eval(<<'.,.,', 'cell_value.y', 31)
|
|
258
258
|
def _reduce_10(val, _values, result)
|
|
259
|
-
result = cell_reference(val[0])
|
|
259
|
+
result = cell_reference(ref: val[0])
|
|
260
260
|
result
|
|
261
261
|
end
|
|
262
262
|
.,.,
|
|
263
263
|
|
|
264
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
264
|
+
module_eval(<<'.,.,', 'cell_value.y', 33)
|
|
265
265
|
def _reduce_11(val, _values, result)
|
|
266
|
-
result = function_call(val[0], val[2])
|
|
266
|
+
result = function_call(val[0].to_sym, val[2])
|
|
267
267
|
result
|
|
268
268
|
end
|
|
269
269
|
.,.,
|
|
270
270
|
|
|
271
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
271
|
+
module_eval(<<'.,.,', 'cell_value.y', 34)
|
|
272
272
|
def _reduce_12(val, _values, result)
|
|
273
|
-
result = function_call(val[0], [])
|
|
273
|
+
result = function_call(val[0].to_sym, [])
|
|
274
274
|
result
|
|
275
275
|
end
|
|
276
276
|
.,.,
|
|
277
277
|
|
|
278
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
278
|
+
module_eval(<<'.,.,', 'cell_value.y', 36)
|
|
279
279
|
def _reduce_13(val, _values, result)
|
|
280
280
|
result = val[0] << val[2]
|
|
281
281
|
result
|
|
282
282
|
end
|
|
283
283
|
.,.,
|
|
284
284
|
|
|
285
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
285
|
+
module_eval(<<'.,.,', 'cell_value.y', 37)
|
|
286
286
|
def _reduce_14(val, _values, result)
|
|
287
287
|
result = [val[0]]
|
|
288
288
|
result
|
|
289
289
|
end
|
|
290
290
|
.,.,
|
|
291
291
|
|
|
292
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
|
292
|
+
module_eval(<<'.,.,', 'cell_value.y', 39)
|
|
293
293
|
def _reduce_15(val, _values, result)
|
|
294
|
-
result = function_call(val[1], [val[0], val[2]], infix: true)
|
|
294
|
+
result = function_call(val[1].to_sym, [val[0], val[2]], infix: true)
|
|
295
295
|
result
|
|
296
296
|
end
|
|
297
297
|
.,.,
|
|
@@ -300,6 +300,6 @@ def _reduce_none(val, _values, result)
|
|
|
300
300
|
val[0]
|
|
301
301
|
end
|
|
302
302
|
|
|
303
|
-
end # class
|
|
304
|
-
end # module
|
|
303
|
+
end # class CellValue
|
|
304
|
+
end # module Parser
|
|
305
305
|
end # module CSVPlusPlus
|