excel_to_code 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cceb19713580157a6d4911e093de7847739c09a
4
- data.tar.gz: 40e33dc2ae747d31f1f13c91dfcc290d8b0ca2b1
3
+ metadata.gz: 7be4eb5782ad34fe1d4a42bf50083440afcc72e2
4
+ data.tar.gz: ac3bbda110cc0d9ce8dcbc504fce982e79c849d0
5
5
  SHA512:
6
- metadata.gz: fb562768c44cf4c27a06e1a754a30e0a766c7d35e0169f29adc2882f87b119f79a8311d5b7ad3969645af1ed1abc21ee807341dcbaa68c7b6cee8f5b23dbb90d
7
- data.tar.gz: 0a326c177bcc2e1749a406f364f7ccd7c90f7ce542455c6af55773943f5aa81c719c183feb041539fe2071fe3f1f77cdc44728c8758391faa93e162f54da83d1
6
+ metadata.gz: 2ca73c4cac5b6acef852961b40cd495e91793b5424ef1833b9bdfbf4614c012bcb7c058eda8139b877e2fa8496d4b74014bd9e6066650e2852e6cf8e68bf7456
7
+ data.tar.gz: df4a7cc607b058104cabd6f03f1fe2675d352a90d1c63fc5591f22e2ba76450c46cfd076f70ca2ef9d7bf29b98ddb1b82ca4657b35bdb064a189b6126241ef12
@@ -231,7 +231,13 @@ class ExcelToX
231
231
  unless self.log
232
232
  self.log = Logger.new(STDOUT)
233
233
  log.formatter = proc do |severity, datetime, progname, msg|
234
- "#{datetime.strftime("%H:%M")}\t#{msg}\n"
234
+ case severity
235
+ when "FATAL"; "\033[41m#{datetime.strftime("%H:%M")}\t#{msg}\033[0m\n"
236
+ when "ERROR"; "\033[41m#{datetime.strftime("%H:%M")}\t#{msg}\033[0m\n"
237
+ when "WARN"; "\033[31m#{datetime.strftime("%H:%M")}\t#{msg}\033[0m\n"
238
+ when "INFO"; "\033[34m#{datetime.strftime("%H:%M")}\t#{msg}\033[0m\n"
239
+ else; "#{datetime.strftime("%H:%M")}\t#{msg}\n"
240
+ end
235
241
  end
236
242
  end
237
243
 
Binary file
@@ -58,6 +58,7 @@ static ExcelValue less_than(ExcelValue a_v, ExcelValue b_v);
58
58
  static ExcelValue less_than_or_equal(ExcelValue a_v, ExcelValue b_v);
59
59
  static ExcelValue average(int array_size, ExcelValue *array);
60
60
  static ExcelValue averageifs(ExcelValue average_range_v, int number_of_arguments, ExcelValue *arguments);
61
+ static ExcelValue excel_char(ExcelValue number_v);
61
62
  static ExcelValue ensure_is_number(ExcelValue maybe_number_v);
62
63
  static ExcelValue find_2(ExcelValue string_to_look_for_v, ExcelValue string_to_look_in_v);
63
64
  static ExcelValue find(ExcelValue string_to_look_for_v, ExcelValue string_to_look_in_v, ExcelValue position_to_start_at_v);
@@ -300,6 +301,23 @@ static ExcelValue excel_abs(ExcelValue a_v) {
300
301
  }
301
302
  }
302
303
 
304
+ static ExcelValue excel_char(ExcelValue a_v) {
305
+ CHECK_FOR_PASSED_ERROR(a_v)
306
+ NUMBER(a_v, a)
307
+ CHECK_FOR_CONVERSION_ERROR
308
+ if(a <= 0) { return VALUE; }
309
+ if(a >= 256) { return VALUE; }
310
+ a = floor(a);
311
+ char *string = malloc(1); // Freed later
312
+ if(string == 0) {
313
+ printf("Out of memory in char");
314
+ exit(-1);
315
+ }
316
+ string[0] = a;
317
+ free_later(string);
318
+ return EXCEL_STRING(string);
319
+ }
320
+
303
321
  static ExcelValue add(ExcelValue a_v, ExcelValue b_v) {
304
322
  CHECK_FOR_PASSED_ERROR(a_v)
305
323
  CHECK_FOR_PASSED_ERROR(b_v)
@@ -1012,6 +1012,16 @@ int test_functions() {
1012
1012
  ExcelValue npv_array5[] = { BLANK };
1013
1013
  assert(npv(EXCEL_NUMBER(0.1), 1, npv_array5).number == 0);
1014
1014
 
1015
+ // CHAR
1016
+ assert_equal(VALUE, excel_char(ZERO), "excel_char(0) == VALUE");
1017
+ assert_equal(VALUE, excel_char(EXCEL_NUMBER(256)), "excel_char(256) == VALUE");
1018
+ assert_equal(VALUE, excel_char(BLANK), "excel_char() == VALUE");
1019
+ assert_equal(VALUE, excel_char(EXCEL_STRING("adsfa")), "excel_char('nonsense') == VALUE");
1020
+ assert_equal(DIV0, excel_char(DIV0), "excel_char(DIV0) == DIV0");
1021
+ assert_equal(EXCEL_STRING("\x01"), excel_char(ONE), "excel_char(1) == '\x01'");
1022
+ assert_equal(EXCEL_STRING("a"), excel_char(EXCEL_NUMBER(97)), "excel_char(97) == 'a'");
1023
+ assert_equal(EXCEL_STRING("a"), excel_char(EXCEL_NUMBER(97.5)), "excel_char(97.5) == 'a'");
1024
+
1015
1025
  // Release memory
1016
1026
  free_all_allocated_memory();
1017
1027
 
@@ -31,6 +31,7 @@ class MapFormulaeToC < MapValuesToC
31
31
  :'AND' => 'excel_and',
32
32
  :'AVERAGE' => 'average',
33
33
  :'AVERAGEIFS' => 'averageifs',
34
+ :'CHAR' => 'excel_char',
34
35
  :'CHOOSE' => 'choose',
35
36
  :'CONCATENATE' => 'string_join',
36
37
  :'COSH' => 'cosh',
@@ -21,6 +21,7 @@ class MapFormulaeToRuby < MapValuesToRuby
21
21
  :'AVERAGE' => 'average',
22
22
  :'AVERAGEIFS' => 'averageifs',
23
23
  :'CELL' => 'cell',
24
+ :'CHAR' => 'char',
24
25
  :'CHOOSE' => 'choose',
25
26
  :'CONCATENATE' => 'string_join',
26
27
  :'COSH' => 'cosh',
@@ -117,3 +117,5 @@ require_relative 'excel_functions/iserr'
117
117
  require_relative 'excel_functions/npv'
118
118
 
119
119
  require_relative 'excel_functions/iserror'
120
+
121
+ require_relative 'excel_functions/char'
@@ -0,0 +1,12 @@
1
+ module ExcelFunctions
2
+
3
+ def char(a)
4
+ a = number_argument(a)
5
+ return a if a.is_a?(Symbol)
6
+ return :value if a <= 0
7
+ return :value if a >= 256
8
+ a = a.floor
9
+ "".force_encoding("Windows-1252") << a
10
+ end
11
+
12
+ end
@@ -1,5 +1,5 @@
1
1
  class ExcelToCode
2
- def self.version() "0.3.10" end
2
+ def self.version() "0.3.11" end
3
3
  end
4
4
 
5
5
  require_relative 'commands'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excel_to_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Counsell, Green on Black Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubypeg
@@ -155,6 +155,7 @@ files:
155
155
  - src/excel/excel_functions/average.rb
156
156
  - src/excel/excel_functions/averageifs.rb
157
157
  - src/excel/excel_functions/cell.rb
158
+ - src/excel/excel_functions/char.rb
158
159
  - src/excel/excel_functions/choose.rb
159
160
  - src/excel/excel_functions/cosh.rb
160
161
  - src/excel/excel_functions/count.rb