csv_plus_plus 0.0.5 → 0.1.1
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/CHANGELOG.md +14 -0
- data/README.md +1 -0
- data/lib/csv_plus_plus/cell.rb +24 -8
- data/lib/csv_plus_plus/cli.rb +29 -16
- data/lib/csv_plus_plus/cli_flag.rb +10 -2
- data/lib/csv_plus_plus/code_section.rb +55 -3
- data/lib/csv_plus_plus/color.rb +19 -5
- data/lib/csv_plus_plus/google_options.rb +6 -2
- data/lib/csv_plus_plus/graph.rb +0 -1
- data/lib/csv_plus_plus/language/ast_builder.rb +68 -0
- data/lib/csv_plus_plus/language/benchmarked_compiler.rb +65 -0
- data/lib/csv_plus_plus/language/builtins.rb +46 -0
- data/lib/csv_plus_plus/language/cell_value.tab.rb +106 -134
- data/lib/csv_plus_plus/language/code_section.tab.rb +163 -192
- data/lib/csv_plus_plus/language/compiler.rb +75 -92
- data/lib/csv_plus_plus/language/entities/boolean.rb +3 -2
- data/lib/csv_plus_plus/language/entities/cell_reference.rb +10 -3
- data/lib/csv_plus_plus/language/entities/entity.rb +20 -8
- data/lib/csv_plus_plus/language/entities/function.rb +6 -4
- data/lib/csv_plus_plus/language/entities/function_call.rb +17 -5
- data/lib/csv_plus_plus/language/entities/number.rb +6 -4
- data/lib/csv_plus_plus/language/entities/runtime_value.rb +9 -8
- data/lib/csv_plus_plus/language/entities/string.rb +6 -4
- data/lib/csv_plus_plus/language/references.rb +22 -5
- data/lib/csv_plus_plus/language/runtime.rb +80 -22
- data/lib/csv_plus_plus/language/scope.rb +34 -39
- data/lib/csv_plus_plus/language/syntax_error.rb +10 -5
- data/lib/csv_plus_plus/lexer/lexer.rb +27 -13
- data/lib/csv_plus_plus/lexer/tokenizer.rb +35 -11
- data/lib/csv_plus_plus/modifier.rb +38 -18
- data/lib/csv_plus_plus/modifier.tab.rb +2 -2
- data/lib/csv_plus_plus/options.rb +20 -2
- data/lib/csv_plus_plus/row.rb +15 -4
- data/lib/csv_plus_plus/template.rb +26 -6
- data/lib/csv_plus_plus/version.rb +1 -1
- data/lib/csv_plus_plus/writer/excel.rb +2 -9
- data/lib/csv_plus_plus/writer/file_backer_upper.rb +22 -20
- data/lib/csv_plus_plus/writer/google_sheet_builder.rb +8 -10
- data/lib/csv_plus_plus/writer/google_sheets.rb +4 -10
- data/lib/csv_plus_plus/writer/rubyxl_builder.rb +23 -15
- data/lib/csv_plus_plus/writer/rubyxl_modifier.rb +15 -8
- data/lib/csv_plus_plus.rb +42 -8
- metadata +5 -2
data/lib/csv_plus_plus.rb
CHANGED
@@ -1,25 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'google/apis/drive_v3'
|
4
|
+
require 'google/apis/sheets_v4'
|
5
|
+
require 'googleauth'
|
6
|
+
require 'rubyXL'
|
7
|
+
require 'rubyXL/convenience_methods'
|
8
|
+
require 'set'
|
9
|
+
|
10
|
+
require_relative 'csv_plus_plus/cell'
|
3
11
|
require_relative 'csv_plus_plus/cli'
|
12
|
+
require_relative 'csv_plus_plus/code_section'
|
13
|
+
require_relative 'csv_plus_plus/color'
|
4
14
|
require_relative 'csv_plus_plus/error'
|
15
|
+
require_relative 'csv_plus_plus/language/builtins'
|
5
16
|
require_relative 'csv_plus_plus/language/compiler'
|
17
|
+
require_relative 'csv_plus_plus/language/runtime'
|
18
|
+
require_relative 'csv_plus_plus/language/syntax_error'
|
19
|
+
require_relative 'csv_plus_plus/modifier'
|
20
|
+
require_relative 'csv_plus_plus/modifier.tab'
|
6
21
|
require_relative 'csv_plus_plus/options'
|
22
|
+
require_relative 'csv_plus_plus/row'
|
23
|
+
require_relative 'csv_plus_plus/template'
|
7
24
|
require_relative 'csv_plus_plus/writer'
|
8
25
|
|
9
|
-
# A language for writing rich CSV
|
26
|
+
# A programming language for writing rich CSV files
|
10
27
|
module CSVPlusPlus
|
11
28
|
# Parse the input into a +Template+ and write it to the desired format
|
29
|
+
#
|
30
|
+
# @param input [String] The csvpp input to compile
|
31
|
+
# @param filename [String, nil] The filename the input was read from. +nil+ if it is read from stdin.
|
32
|
+
# @param options [Options] The various options to compile with
|
12
33
|
def self.apply_template_to_sheet!(input, filename, options)
|
13
34
|
warn(options.verbose_summary) if options.verbose
|
14
35
|
|
15
|
-
::CSVPlusPlus::Language::
|
16
|
-
|
36
|
+
runtime = ::CSVPlusPlus::Language::Runtime.new(input:, filename:)
|
37
|
+
|
38
|
+
::CSVPlusPlus::Language::Compiler.with_compiler(options:, runtime:) do |compiler|
|
39
|
+
template = compiler.compile_template
|
40
|
+
|
41
|
+
warn(template.verbose_summary) if options.verbose
|
42
|
+
|
43
|
+
write_template(template, compiler, options)
|
44
|
+
end
|
45
|
+
end
|
17
46
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
47
|
+
# Write the results (and possibly make a backup) of a compiled +template+
|
48
|
+
#
|
49
|
+
# @param template [Template] The compiled template
|
50
|
+
# @param compiler [Compiler] The compiler currently in use
|
51
|
+
# @param options [Options] The options we're running with
|
52
|
+
def self.write_template(template, compiler, options)
|
53
|
+
output = ::CSVPlusPlus::Writer.writer(options)
|
54
|
+
compiler.outputting! do
|
55
|
+
output.write_backup if options.backup
|
56
|
+
output.write(template)
|
23
57
|
end
|
24
58
|
end
|
25
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_plus_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Carroll
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-apis-drive_v3
|
@@ -133,6 +133,9 @@ files:
|
|
133
133
|
- lib/csv_plus_plus/google_api_client.rb
|
134
134
|
- lib/csv_plus_plus/google_options.rb
|
135
135
|
- lib/csv_plus_plus/graph.rb
|
136
|
+
- lib/csv_plus_plus/language/ast_builder.rb
|
137
|
+
- lib/csv_plus_plus/language/benchmarked_compiler.rb
|
138
|
+
- lib/csv_plus_plus/language/builtins.rb
|
136
139
|
- lib/csv_plus_plus/language/cell_value.tab.rb
|
137
140
|
- lib/csv_plus_plus/language/code_section.tab.rb
|
138
141
|
- lib/csv_plus_plus/language/compiler.rb
|