source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/and.rb
Ruby
mit
228
master
633
module ExcelFunctions def excel_and(*args) # Flatten arrays args = args.flatten # If an argument is an error, return that error = args.find {|a| a.is_a?(Symbol)} return error if error # Replace 1 and 0 with true and false args.map! do |a| case a when 1; true ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/iferror.rb
Ruby
mit
228
master
220
module ExcelFunctions def iferror(value,value_if_error) value_if_error ||= 0 return value_if_error if value.is_a?(Symbol) return value_if_error if value.is_a?(Float) && value.nan? value end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/countifs.rb
Ruby
mit
228
master
219
module ExcelFunctions def countifs(*criteria) return 0 if criteria.empty? c = criteria[0].is_a?(Array) ? criteria[0] : [criteria[0]] count = c.map { 1 } return sumifs(count, *criteria) end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/log.rb
Ruby
mit
228
master
267
module ExcelFunctions def log(a, b = 10) a = number_argument(a) b = number_argument(b) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) return :num if a <= 0 return :num if b <= 0 Math.log(a) / Math.log(b) end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/index.rb
Ruby
mit
228
master
1,699
module ExcelFunctions def index(array, row_number, column_number = :not_specified) return array if array.is_a?(Symbol) return row_number if row_number.is_a?(Symbol) return column_number if column_number.is_a?(Symbol) && column_number != :not_specified array = [[array]] unless array.is_a?(Arra...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/large.rb
Ruby
mit
228
master
420
module ExcelFunctions def large(range, k) range = [range] unless range.is_a?(Array) range = range.flatten error = range.find {|a| a.is_a?(Symbol)} error ||= k if k.is_a?(Symbol) return error if error range.delete_if { |v| !v.is_a?(Numeric) } return :value unless k.is_a?(Numeric) ret...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/find.rb
Ruby
mit
228
master
1,141
module ExcelFunctions def find(find_text,within_text,start_number = 1) return find_text if find_text.is_a?(Symbol) return within_text if within_text.is_a?(Symbol) return start_number if start_number.is_a?(Symbol) # nils are treated as empty strings find_text ||= "" within_text ||= "" ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/substitute.rb
Ruby
mit
228
master
1,326
module ExcelFunctions def substitute(text, old_text, new_text, instance_num = :any) # Check for errors return text if text.is_a?(Symbol) return old_text if old_text.is_a?(Symbol) return new_text if new_text.is_a?(Symbol) # Nils get turned into blanks text ||= "" new_text ||= "" old_...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/roundup.rb
Ruby
mit
228
master
445
module ExcelFunctions def roundup(number,decimal_places) number = number_argument(number) decimal_places = number_argument(decimal_places) return number if number.is_a?(Symbol) return decimal_places if decimal_places.is_a?(Symbol) if number < 0 (number * 10**decimal_places).floo...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/pv.rb
Ruby
mit
228
master
971
module ExcelFunctions def pv(rate, nper, pmt, fv = nil, type = nil) # Turn the remainder into numbers rate = number_argument(rate) nper = number_argument(nper) pmt = number_argument(pmt) fv = number_argument(fv) type = number_argument(type) # Check for errors return rate if rate.is...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/mid.rb
Ruby
mit
228
master
467
module ExcelFunctions def mid(text, start_num, num_chars) start_num = number_argument(start_num) num_chars = number_argument(num_chars) return text if text.is_a?(Symbol) return start_num if start_num.is_a?(Symbol) return num_chars if num_chars.is_a?(Symbol) text = text.to_s return :v...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/fillgaps_in_array.rb
Ruby
mit
228
master
3,750
module ExcelFunctions def fillgaps_in_array(columns, rows, variable, years, endYear, extrapolateCurveType = "LS") return variable if variable.is_a?(Symbol) return years if years.is_a?(Symbol) return endYear if endYear.is_a?(Symbol) return :ref unless columns == 1 || rows == 1 size = max(column...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/address.rb
Ruby
mit
228
master
1,937
module ExcelFunctions # ADDRESS(row_num,column_num,abs_num,a1,sheet_text) # row_num # The row number to use in the cell reference. # column_num # The column number to use in the cell reference. # abs_num # Specifies the type of reference to return. # 1 or omitted returns the following type of reference...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/apply_to_range.rb
Ruby
mit
228
master
447
module ExcelFunctions def apply_to_range(a,b) a = Array.new(b.length,Array.new(b.first.length,a)) unless a.is_a?(Array) b = Array.new(a.length,Array.new(a.first.length,b)) unless b.is_a?(Array) return :value unless b.length == a.length return :value unless b.first.length == a.first.length ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/left.rb
Ruby
mit
228
master
367
module ExcelFunctions def left(string,characters = 1) return string if string.is_a?(Symbol) return characters if characters.is_a?(Symbol) return nil if string == nil || characters == nil return :value if characters < 0 string = "TRUE" if string == true string = "FALSE" if string == false ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/power.rb
Ruby
mit
228
master
438
require_relative 'number_argument' require_relative 'apply_to_range' module ExcelFunctions def power(a,b) a = number_argument(a) b = number_argument(b) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) return 1 if b ==0 # Special case so can do the following negative number check ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/more_than.rb
Ruby
mit
228
master
754
require_relative 'apply_to_range' module ExcelFunctions def more_than?(a,b) # return apply_to_range(a,b) { |a,b| more_than?(a,b) } if a.is_a?(Array) || b.is_a?(Array) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) a = 0 if a == nil b = 0 if b == nil case a when Stri...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/right.rb
Ruby
mit
228
master
478
module ExcelFunctions def right(string,characters = 1) return string if string.is_a?(Symbol) return characters if characters.is_a?(Symbol) return nil if string == nil || characters == nil return :value if characters < 0 string = "TRUE" if string == true string = "FALSE" if string == false ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/interpolate.rb
Ruby
mit
228
master
597
module ExcelFunctions def interpolate(r, i) return r if r.is_a?(Symbol) i = ensure_is_number(i) return i if i.is_a?(Symbol) r = [[r]] unless r.is_a?(Array) r.flatten! return :value if i < 1 return :value if i > r.size # -1 because Excel arrays are 1 indexed, but ruby arrays are 0...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/forecast.rb
Ruby
mit
228
master
1,728
module ExcelFunctions def forecast(required_x, known_y, known_x) required_x = number_argument(required_x) return required_x if required_x.is_a?(Symbol) fit = linest(known_y, known_x) return fit if fit.is_a?(Symbol) fit = fit.first slope = fit.first intercept = fit.last return interc...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/rounddown.rb
Ruby
mit
228
master
347
module ExcelFunctions def rounddown(number,decimal_places) number = number_argument(number) decimal_places = number_argument(decimal_places) return number if number.is_a?(Symbol) return decimal_places if decimal_places.is_a?(Symbol) (number * 10**decimal_places).truncate.to_f / 10**de...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/subtract.rb
Ruby
mit
228
master
418
require_relative 'number_argument' require_relative 'apply_to_range' module ExcelFunctions def subtract(a,b) # return apply_to_range(a,b) { |a,b| subtract(a,b) } if a.is_a?(Array) || b.is_a?(Array) a = number_argument(a) b = number_argument(b) return a if a.is_a?(Symbol) return b if b.is...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/min.rb
Ruby
mit
228
master
235
module ExcelFunctions def min(*args) args = args.flatten error = args.find {|a| a.is_a?(Symbol)} return error if error args.delete_if { |a| !a.is_a?(Numeric) } return 0 if args.empty? args.min end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/hlookup.rb
Ruby
mit
228
master
1,504
module ExcelFunctions def hlookup(lookup_value, lookup_table, row_number, match_type = true) return lookup_value if lookup_value.is_a?(Symbol) return lookup_table if lookup_table.is_a?(Symbol) return row_number if row_number.is_a?(Symbol) return match_type if match_type.is_a?(Symbol) r...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/excel_equal.rb
Ruby
mit
228
master
356
require_relative 'apply_to_range' module ExcelFunctions def excel_equal?(a,b) return apply_to_range(a,b) { |a,b| excel_equal?(a,b) } if a.is_a?(Array) || b.is_a?(Array) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) return a.downcase == b.downcase if a.is_a?(String) && b.is_a?(S...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/add.rb
Ruby
mit
228
master
404
require_relative 'number_argument' require_relative 'apply_to_range' module ExcelFunctions def add(a,b) # return apply_to_range(a,b) { |a,b| add(a,b) } if a.is_a?(Array) || b.is_a?(Array) a = number_argument(a) b = number_argument(b) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/vlookup.rb
Ruby
mit
228
master
1,559
module ExcelFunctions def vlookup(lookup_value,lookup_table,column_number, match_type = true) return lookup_value if lookup_value.is_a?(Symbol) return lookup_table if lookup_table.is_a?(Symbol) return column_number if column_number.is_a?(Symbol) return match_type if match_type.is_a?(Symbol) ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/cell.rb
Ruby
mit
228
master
282
module ExcelFunctions def cell(info_type, reference = nil) return info_type if info_type.is_a?(Symbol) return :value unless info_type.is_a?(String) case info_type.downcase when 'filename' original_excel_filename else :value end end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/string_argument.rb
Ruby
mit
228
master
762
module ExcelFunctions # This is a support function for mapping arguments that are not strings to their # Excel string equivalent. e.g., true = TRUE, :div0 = "DIV/0!" def string_argument(a) case a when Symbol return { :name => "#NAME?", :value => "#VALUE!", :div0 => "#DIV/0...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/scurve.rb
Ruby
mit
228
master
2,827
module ExcelFunctions def scurve(currentYear, startValue, endValue, duration, startYear = 2018.0) currentYear = number_argument(currentYear) startValue = number_argument(startValue) endValue = number_argument(endValue) duration = number_argument(duration) startYear = number_argument(startYear) ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/less_than.rb
Ruby
mit
228
master
722
require_relative 'apply_to_range' module ExcelFunctions def less_than?(a,b) # return apply_to_range(a,b) { |a,b| less_than?(a,b) } if a.is_a?(Array) || b.is_a?(Array) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) a = 0 if a == nil b = 0 if b == nil case a when Stri...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/floor.rb
Ruby
mit
228
master
368
module ExcelFunctions def floor(number, multiple) return number if number.is_a?(Symbol) return multiple if multiple.is_a?(Symbol) number ||= 0 return :value unless number.is_a?(Numeric) return :value unless multiple.is_a?(Numeric) return :div0 if multiple == 0 return :num if multiple < ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/number_argument.rb
Ruby
mit
228
master
602
module ExcelFunctions # This is a support function for mapping arguments that are numbers to numeric values # deals with the fact that in Excel "2.14" == 2.14, TRUE == 1, FALSE == 0 and nil == 0 def number_argument(a) case a when Symbol return a when String begin return Float(a)...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/average.rb
Ruby
mit
228
master
289
module ExcelFunctions def average(*args) args = args.flatten error = args.find {|a| a.is_a?(Symbol)} return error if error args.delete_if { |a| !a.is_a?(Numeric) } return :div0 if args.empty? args.inject(0.0) { |m,i| m + i.to_f } / args.size.to_f end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/project.rb
Ruby
mit
228
master
311
module ExcelFunctions def project_in_array(variable, years, endValue, duration, curveType = "S", startYear = 0, extrapolateCurveType = "LS", relativeEndValue = false) project_in_array(1, 1, variable, years, endValue, duration, curveType, startYear, extrapolateCurveType, relativeEndValue) end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/project_in_array.rb
Ruby
mit
228
master
2,551
module ExcelFunctions def project_in_array(columns, rows, variable, years, endValue, duration, curveType = "S", startYear = 0, extrapolateCurveType = "LS", relativeEndValue = false) return variable if variable.is_a?(Symbol) return years if years.is_a?(Symbol) return endValue if endValue.is_a?(Symbol) ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/not.rb
Ruby
mit
228
master
252
module ExcelFunctions def excel_not(a) return a if a.is_a?(Symbol) return :value if a.is_a?(String) return :value if a.is_a?(Array) a = false if a == nil a = false if a == 0 a = true if a.is_a?(Numeric) !a end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/replace.rb
Ruby
mit
228
master
448
module ExcelFunctions def replace(string, start, length, replacement) return string if string.is_a?(Symbol) return start if start.is_a?(Symbol) return length if length.is_a?(Symbol) return replacement if replacement.is_a?(Symbol) string = string.to_s return string + replacement if start >= ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/not_equal.rb
Ruby
mit
228
master
244
require_relative 'apply_to_range' module ExcelFunctions def not_equal?(a,b) return a if a.is_a?(Symbol) return b if b.is_a?(Symbol) return a.downcase != b.downcase if a.is_a?(String) && b.is_a?(String) a != b end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/ceiling.rb
Ruby
mit
228
master
741
module ExcelFunctions def ceiling(number, multiple, mode = 0) return number if number.is_a?(Symbol) return multiple if multiple.is_a?(Symbol) return mode if mode.is_a?(Symbol) number = number_argument(number) multiple = number_argument(multiple) mode = number_argument(mode) return :valu...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/round.rb
Ruby
mit
228
master
306
module ExcelFunctions def round(number,decimal_places) number = number_argument(number) decimal_places = number_argument(decimal_places) return number if number.is_a?(Symbol) return decimal_places if decimal_places.is_a?(Symbol) number.round(decimal_places) end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/pmt.rb
Ruby
mit
228
master
1,010
module ExcelFunctions def pmt(rate,number_of_periods,present_value, final_value = 0, type = 0) rate = number_argument(rate) number_of_periods = number_argument(number_of_periods) present_value = number_argument(present_value) final_value = number_argument(final_value) type = number_argumen...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/rank.rb
Ruby
mit
228
master
666
module ExcelFunctions def rank(number, list, order = 0) number = number_argument(number) order = number_argument(order) list = [[list]] unless list.is_a?(Array) return number if number.is_a?(Symbol) return order if order.is_a?(Symbol) return list if list.is_a?(Symbol) ranked = 1 ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/mmult.rb
Ruby
mit
228
master
892
module ExcelFunctions def mmult(array_a, array_b) return array_a if array_a.is_a?(Symbol) return array_b if array_b.is_a?(Symbol) return :value unless array_a.is_a?(Array) return :value unless array_b.is_a?(Array) columns = array_a.first.length rows = array_b.length error = Array.new([...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/abs.rb
Ruby
mit
228
master
223
module ExcelFunctions def abs(a) case a when Numeric; return a.abs when Symbol; return a when nil; return 0 when true; return 1 when false; return 0 else; return :value end end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/lower.rb
Ruby
mit
228
master
363
module ExcelFunctions def lower(string) return string if string.is_a?(Symbol) case string when nil; "" when String; string.downcase when Numeric if string.round == string string.to_i.to_s else string.to_s end when true; "true" when false; "false" e...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/char.rb
Ruby
mit
228
master
228
module ExcelFunctions def char(a) a = number_argument(a) return a if a.is_a?(Symbol) return :value if a <= 0 return :value if a >= 256 a = a.floor "".force_encoding("Windows-1252") << a end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/excel_if.rb
Ruby
mit
228
master
225
module ExcelFunctions def excel_if(condition,true_value,false_value = false) return condition if condition.is_a?(Symbol) return false_value if condition == 0 condition ? true_value : false_value end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/max.rb
Ruby
mit
228
master
235
module ExcelFunctions def max(*args) args = args.flatten error = args.find {|a| a.is_a?(Symbol)} return error if error args.delete_if { |a| !a.is_a?(Numeric) } return 0 if args.empty? args.max end end
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/excel/excel_functions/or.rb
Ruby
mit
228
master
631
module ExcelFunctions def excel_or(*args) # Flatten arrays args = args.flatten # If an argument is an error, return that error = args.find {|a| a.is_a?(Symbol)} return error if error # Replace 1 and 0 with true and false args.map! do |a| case a when 1; true w...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c.rb
Ruby
mit
228
master
265
require_relative 'c/compile_to_c' require_relative 'c/compile_to_c_header' require_relative 'c/map_sheet_names_to_c_names' require_relative "c/compile_to_c_unit_test" require_relative "c/map_values_to_c_structs" require_relative "c/compile_named_reference_setters"
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/go/map_formulae_to_go.rb
Ruby
mit
228
master
945
# frozen_string_literal: true require_relative 'map_values_to_go' class MapFormulaeToGo < MapValuesToGo attr_accessor :sheet_names attr_accessor :getter_method_name FUNCTIONS = { :'+' => 'add' }.freeze def prefix(symbol, ast) return map(ast) if symbol == '+' function('-', ast) end def br...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/go/map_values_to_go.rb
Ruby
mit
228
master
1,233
# frozen_string_literal: true require_relative '../../util/not_supported_exception' class MapValuesToGo def map(ast) raise NotSupportedException, "#{ast} not supported" unless ast.is_a?(Array) operator = ast[0] raise NotSupportedException, "#{operator} in #{ast} not supported" unless respond_to?(opera...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/go/compile_to_go_test.rb
Ruby
mit
228
master
1,392
# frozen_string_literal: true # Turns the data structure into a series of tests written in golang class CompileToGoTest include CompileToGoCommon attr_accessor :settable attr_accessor :gettable attr_accessor :sheet_names def rewrite(formulae, values, sheet_names, output) setup_instance_vars(sheet_names...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/go/compile_to_go.rb
Ruby
mit
228
master
2,968
# frozen_string_literal: true # CombileToGoCommon includes coe shared between CompileToGo and CompileToGoTest module CompileToGoCommon def struct_type 'spreadsheet' end def self.rewrite(*args) new.rewrite(*args) end def setup_instance_vars(sheet_names:) self.settable ||= ->(_ref) { false } ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/ruby/map_sheet_names_to_ruby_names.rb
Ruby
mit
228
master
643
class MapSheetNamesToRubyNames def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input,output) ruby_names_assigned = {} input.lines do |line| excel_worksheet_name = line.split("\t").first ruby_name = excel_worksheet_name.downcase.gsub(/[^a-z0-9]+/,'_') ruby_name =...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/ruby/map_formulae_to_ruby.rb
Ruby
mit
228
master
4,387
require_relative 'map_values_to_ruby' class MapFormulaeToRuby < MapValuesToRuby attr_accessor :sheet_names attr_accessor :worksheet FUNCTIONS = { :'*' => 'multiply', :'+' => 'add', :'-' => 'subtract', :'/' => 'divide', :'<' => 'less_than?', :'<=' => 'less_than_or_equal?', :'<>' => '...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/ruby/compile_to_ruby.rb
Ruby
mit
228
master
1,097
require_relative 'map_formulae_to_ruby' class CompileToRuby attr_accessor :settable attr_accessor :worksheet attr_accessor :defaults def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input, sheet_names, output) self.settable ||= lambda { |ref| false } self.defaults ||= []...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/ruby/map_values_to_ruby.rb
Ruby
mit
228
master
1,516
require_relative '../../util/not_supported_exception' class MapValuesToRuby attr_accessor :constants attr_accessor :leave_inline_blank_as_nil # otherwise will turn into 0.0 def map(ast) if ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator,*ast[1..-1]) else ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/ruby/compile_to_ruby_unit_test.rb
Ruby
mit
228
master
2,013
require_relative "map_values_to_ruby" class CompileToRubyUnitTest attr_accessor :epsilon attr_accessor :delta def initialize @epsilon = 0.002 @delta = 0.002 end def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input, sloppy, sheet_names, constants, o) mapper = Map...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/compile_named_reference_setters.rb
Ruby
mit
228
master
2,406
class MapNamedReferenceToCSetter attr_accessor :sheet_names attr_accessor :cells_that_can_be_set_at_runtime def initialize reset end def reset @new_value_name = "newValue" end def map(ast) if ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator,*ast...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/map_sheet_names_to_c_names.rb
Ruby
mit
228
master
599
class MapSheetNamesToCNames def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input,output) c_names_assigned = {} input.each_line do |line| excel_worksheet_name = line.split("\t").first c_name = excel_worksheet_name.downcase.gsub(/[^a-z0-9]+/,'_') c_name = "s"+c_n...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/map_values_to_c.rb
Ruby
mit
228
master
1,722
require_relative '../../util/not_supported_exception' class MapValuesToC def map(ast) if ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator,*ast[1..-1]) else raise NotSupportedException.new("#{operator} in #{ast.inspect} not supported") end else...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/compile_to_c_header.rb
Ruby
mit
228
master
780
class CompileToCHeader attr_accessor :gettable attr_accessor :settable def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(formulae, c_name_for_worksheet_name, output) self.gettable ||= lambda { |ref| true } self.settable ||= lambda { |ref| false } formulae.each do |ref, a...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/map_formulae_to_c.rb
Ruby
mit
228
master
8,977
require_relative 'map_values_to_c' class MapFormulaeToC < MapValuesToC attr_accessor :sheet_names attr_accessor :worksheet attr_reader :initializers attr_reader :counter attr_accessor :allow_unknown_functions def initialize reset end def reset @initializers = [] @counter = 0 end FUN...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/compile_to_c_unit_test.rb
Ruby
mit
228
master
681
require_relative "map_values_to_c" class CompileToCUnitTest def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input, sloppy, sheet_names, constants, o) mapper = MapValuesToC.new input.each do |ref, ast| worksheet_c_name = sheet_names[ref.first.to_s] || ref.first.to_s #FIXME: ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/map_values_to_c_structs.rb
Ruby
mit
228
master
795
require_relative '../../util/not_supported_exception' class MapValuesToCStructs def map(ast) if ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator,*ast[1..-1]) else raise NotSupportedException.new("#{operator} in #{ast.inspect} not supported") end ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/compile/c/compile_to_c.rb
Ruby
mit
228
master
3,127
require_relative 'map_formulae_to_c' class CompileToC attr_accessor :settable attr_accessor :gettable attr_accessor :variable_set_counter attr_accessor :allow_unknown_functions def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(formulae, sheet_names, output) self.settable ||...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/ast_copy_formula.rb
Ruby
mit
228
master
1,238
require_relative '../excel' require_relative '../util/not_supported_exception' class AstCopyFormula attr_accessor :rows_to_move attr_accessor :columns_to_move def initialize self.rows_to_move = 0 self.columns_to_move = 0 end DO_NOT_MAP = {:number => true, :string => true, :blank => true, :null ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_merge_formulae_and_values.rb
Ruby
mit
228
master
947
class RewriteMergeFormulaeAndValues def self.rewrite(*args) new.rewrite(*args) end attr_accessor :references_to_add_if_they_are_not_already_present def rewrite(values,shared_formulae,array_formula,simple_formulae,output) @references_to_add_if_they_are_not_already_present ||= [] shared_for...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_array_formulae.rb
Ruby
mit
228
master
2,526
class ExtractArrayFormulaForCell attr_accessor :row_offset, :column_offset, :array_range def initialize @fc = CachingFormulaParser.instance end def map(ast) case ast.first when :array; map_array(ast) when :function; map_function(ast) else return ast end end def map_array(as...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_shared_formulae.rb
Ruby
mit
228
master
1,482
require_relative 'ast_copy_formula' class RewriteSharedFormulae def self.rewrite(*args) new.rewrite(*args) end def rewrite(formula_shared, formula_shared_targets) @output = {} @formula_shared_targets = formula_shared_targets formula_shared.each do |ref, a| copy_range = a[0] shared...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_cell_references_to_include_sheet.rb
Ruby
mit
228
master
1,874
require_relative '../excel' class RewriteCellReferencesToIncludeSheetAst attr_accessor :worksheet def initialize @fp = CachingFormulaParser.instance end # FIXME: UGh. def map(ast) r = do_map(ast) ast.replace(r) unless r.object_id == ast.object_id ast end def do_map(ast) ret...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/caching_formula_parser.rb
Ruby
mit
228
master
4,488
require 'singleton' class ExternalReferenceException < ExcelToCodeException attr_accessor :reference_ast attr_accessor :full_ast attr_accessor :formula_text attr_accessor :ref def initialize(reference_ast, full_ast, formula_text) @reference_ast, @full_ast, @formula_text = reference_ast, full_ast, formu...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/ast_expand_array_formulae.rb
Ruby
mit
228
master
7,414
require_relative '../excel' class AstExpandArrayFormulae attr_accessor :array_range def map(ast) return ast unless ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator, ast) else ast.each {|a| map(a) } end ast end # Format [:arithmetic, left, ope...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_whole_row_column_references_to_areas.rb
Ruby
mit
228
master
2,622
require_relative '../excel' class WorksheetDimension attr_reader :first_column, :last_column, :first_row, :last_row def initialize(area) @area = Area.for(area) @area.calculate_excel_variables @first_column = @area.excel_start.excel_column @last_column = @area.excel_finish.excel_column @f...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_array_formulae_to_arrays.rb
Ruby
mit
228
master
394
require_relative "ast_expand_array_formulae" class RewriteArrayFormulaeToArrays def self.rewrite(*args) new.rewrite(*args) end def rewrite(input,output) mapper = AstExpandArrayFormulae.new input.each_line do |line| content = line.split("\t") ast = eval(content.pop) output.puts...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_relationship_id_to_filename.rb
Ruby
mit
228
master
722
class RewriteRelationshipIdToFilename def self.rewrite(*args) self.new.rewrite(*args) end def rewrite(input, relationships_file, output) relationships_file.rewind relationships = Hash[relationships_file.readlines.map { |line| line.split("\t")}] input.each_line do |line| parts = line.sp...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_named_reference_names.rb
Ruby
mit
228
master
1,272
class RewriteNamedReferenceNames def self.rewrite(*args) self.new.rewrite(*args) end # Expects named reference in the form: # sheet_name_or_blank_for_global\tnamed_reference_name\treference\n # Outputs named references in the form: # name\treference\n # where name incorporates the sheet name and h...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_values_to_ast.rb
Ruby
mit
228
master
965
require_relative '../excel/formula_peg' #FIXME: NOT NEEDED class RewriteValuesToAst def self.rewrite(input,output) self.new.rewrite(input,output) end # input should be in the form: 'thing\tthing\tformula\n' where the last field is always a forumla # output will be in the form 'thing\tthing\tast\n' ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_formulae_to_ast.rb
Ruby
mit
228
master
665
require_relative '../excel/formula_peg' class RewriteFormulaeToAst def self.rewrite(input,output) self.new.rewrite(input,output) end # input should be in the form: 'thing\tthing\tformula\n' where the last field is always a forumla # output will be in the form 'thing\tthing\tast\n' def rewrite(input...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
src/rewrite/rewrite_worksheet_names.rb
Ruby
mit
228
master
789
class RewriteWorksheetNames def self.rewrite(worksheet_names,relationships,output) self.new.rewrite(worksheet_names,relationships,output) end # Expects worksheet names in the form: # name\trelationship_id\n # Expects relationships in the form: # relationship_id\tfilename\n # Outputs worksheet na...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/spec_helper.rb
Ruby
mit
228
master
713
require 'rspec' require 'stringio' require 'tmpdir' # Allow both old and new syntax RSpec.configure do |config| config.example_status_persistence_file_path = File.join(File.dirname(__FILE__), "results.txt") config.run_all_when_everything_filtered = true config.expect_with :rspec do |c| c.syntax = [:should, ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/reference_spec.rb
Ruby
mit
228
master
1,270
require_relative '../spec_helper' describe Reference do it "should have a Reference#for method that takes a reference string" do Reference.for("A1").should == "A1" Reference.for("AAA$305").should == "AAA$305" end it "should be a subclass of String" do Reference.for("A1").should be_kind_of(String) ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/formula_peg_spec.rb
Ruby
mit
228
master
2,045
require_relative '../spec_helper' require 'textpeg2rubypeg' describe Formula do # The parser is written as formula_peg.txt and then compiled into formula_peg.rb # This method checks whether formula_peg.txt has been updated, and if so, updated # formula_peg.rb before(:all) do text_peg = File.join(File.dir...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/table_spec.rb
Ruby
mit
228
master
6,506
require_relative '../spec_helper' describe Table do before(:all) do @table = Table.new("FirstTable",:sheet1,"B3:D7","1","ColA","ColB","ColC") end it 'should be able to return a reference for [:table_reference, "FirstTable", "ColA"]]' do @table.reference_for("FirstTable", "ColA",:sheet1,"A1").shou...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/area_spec.rb
Ruby
mit
228
master
2,926
require_relative '../spec_helper' describe Area do it "should have a Area#for method that takes a reference string" do Area.for("A1:B10").should == "A1:B10" Area.for("AAA$305:$BBB1035").should == "AAA$305:$BBB1035" end it "should cope with single cell areas (e.g., A1 is treated as A1:A1)" do Area....
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/counta_spec.rb
Ruby
mit
228
master
550
require_relative '../../spec_helper.rb' describe "ExcelFunctions: COUNTA(arg1,[arg2],..)" do it "should count the number of non blank arguments" do FunctionTest.counta(1,"two",[[10],[100],[:error],[nil]]).should == 5 end it "should not count nil" do FunctionTest.counta(nil).should == 0 end ...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/rank_spec.rb
Ruby
mit
228
master
1,505
require_relative '../../spec_helper.rb' describe "ExcelFunctions: RANK" do it "should return the rank of the first argument in the list given as the second argument assuming the order specified in the third argument" do FunctionTest.rank(2,[[3,2],[1,8]]).should == 3 FunctionTest.rank(2,[[3,2],[1,8]],0).sh...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/address_spec.rb
Ruby
mit
228
master
1,911
require_relative '../../spec_helper.rb' # ADDRESS(row_num,column_num,abs_num,a1,sheet_text) # row_num # The row number to use in the cell reference. # column_num # The column number to use in the cell reference. # abs_num # Specifies the type of reference to return. # 1 or omitted returns the following type of referen...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/subtotal_spec.rb
Ruby
mit
228
master
1,692
require_relative '../../spec_helper.rb' describe "ExcelFunctions: SUBTOTAL" do it "should calculate averages, counts, countas, sums depending on first argument" do FunctionTest.subtotal(1.0,1,"two",[[10],[100],[nil]]).should == 111.0/3.0 # Average FunctionTest.subtotal(2.0,1,"two",[[10],[100],[nil]]).shou...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/string_join_spec.rb
Ruby
mit
228
master
969
require_relative '../../spec_helper.rb' describe "ExcelFunctions: string_join(string,string)" do it "should return a string by combining its arguments" do FunctionTest.string_join("Hello ","world").should == "Hello world" end it "should cope with an arbitrary number of arguments" do FunctionTest.st...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/averageifs_spec.rb
Ruby
mit
228
master
1,656
require_relative '../../spec_helper.rb' describe "ExcelFunctions: AVERAGEIFS" do it "should only average values that meet all of the criteria" do FunctionTest.averageifs([[10],[100],[nil]],[[10],[100],[nil]],10.0,[["pear"],["bear"],["apple"]],'Bear').should == :div0 FunctionTest.averageifs([[10],[100],[ni...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/ifna_spec.rb
Ruby
mit
228
master
718
require_relative '../../spec_helper.rb' describe "ExcelFunctions: IFNA" do it "should return its first argument if it is not an NA" do FunctionTest.ifna(1, 2).should == 1 end it "should return its second argument if the first is an NA error" do FunctionTest.ifna(:na, 2).should == 2 end it "shoul...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/large_spec.rb
Ruby
mit
228
master
869
require_relative '../../spec_helper.rb' describe "ExcelFunctions: LARGE(range, k)" do it "should return the kth largest value in the range number" do FunctionTest.large([[10],[100],[500],[nil]],1).should == 500 FunctionTest.large([[10],[100],[500],[nil]],2).should == 100 FunctionTest.large([[10],[100]...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/hlookup_spec.rb
Ruby
mit
228
master
1,640
require_relative '../../spec_helper.rb' describe "ExcelFunctions: HLOOKUP" do it "should match the first argument against the first row of the table in the second argument, returning the value in the row specified by the third argument" do test = [[1,2,3],['a','b','c']] FunctionTest.hlookup(2.0,test,2).sh...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/rate_spec.rb
Ruby
mit
228
master
366
require_relative '../../spec_helper.rb' describe "ExcelFunctions: RATE" do it "should return the cagr when second argument is zero" do (FunctionTest.rate(12,0,-69999,64786) * 1000.0).round.should == -6 end it "should be in the list of functions that can be mapped to ruby" do MapFormulaeToRuby::FUN...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/npv_spec.rb
Ruby
mit
228
master
965
require_relative '../../spec_helper.rb' describe "ExcelFunctions: NPV" do it "should return something when given appropriate arguments" do FunctionTest.npv(0.1, 110).should == 99.99999999999999 FunctionTest.npv(0.1, 110, 121).should == 199.99999999999997 FunctionTest.npv(0.1, [[110], [121]]).should ==...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/iserror_spec.rb
Ruby
mit
228
master
837
require_relative '../../spec_helper.rb' describe "ExcelFunctions: iserrorOR" do it "should return true if passed any other sort of error" do FunctionTest.iserror(:na).should == true FunctionTest.iserror(:div0).should == true FunctionTest.iserror(:ref).should == true FunctionTest.iserror(:value).sh...
github
tamc/excel_to_code
https://github.com/tamc/excel_to_code
spec/excel/excel_functions/not_equal_spec.rb
Ruby
mit
228
master
1,213
require_relative '../../spec_helper.rb' describe "ExcelFunctions: = not_equal?()" do it "should check the equality of numbers" do FunctionTest.not_equal?(1,1).should == false FunctionTest.not_equal?(1,0).should == true FunctionTest.not_equal?(1.0,1).should == false end it "should check the equa...