From 3ef45ccfcfb69e546b0c0c35d14237ad8e57430f Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Tue, 4 Oct 2022 18:06:31 +0100 Subject: [PATCH 1/7] JSON finished not reviewed --- web/thesauruses/ruby/3/strings.json | 416 ++++++++++++++++++++++++++++ 1 file changed, 416 insertions(+) create mode 100644 web/thesauruses/ruby/3/strings.json diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json new file mode 100644 index 000000000..0afb77ab8 --- /dev/null +++ b/web/thesauruses/ruby/3/strings.json @@ -0,0 +1,416 @@ +{ + "meta": { + "language": "ruby", + "language_name": "Ruby", + "structure": "strings", + "language_version": "3" + }, + "concepts": { + "is_primitive_or_not": { + "name": "Is this a built-in type in this language?", + "code": [ + "Yes" + ] + }, + "import": { + "name": "Import the string class", + "code": [ + "No need?" + ] + }, + "default_string_byte_encoding": { + "name": "Default byte encoding (ex: ASCII UTF-8, UTF-16, etc.)", + "code": [ + "UTF-8" + ] + }, + "create_new_string": { + "name": "Create new string", + "code": [ + "1. varName = \"Hello World\"", + "2. varName = 'This also works'", + "3. anotherVar = %{another way to do it}\n", + "1. & 2. Enclosing a set of characters between quotes/double quotes.", + "3. Using the %char-style quoting mechanism generates either a single or doubled quoted string.", + "You can preceed the % by a character option and a delimiter", + "The most common delimiter is {} like the example, but you can use any non alpha-numerical delimiter." + ] + }, + "create_multiline_string": { + "name": "Create new multi-line string", + "code": [ + "1. text = <' %>" + ] + }, + "decode_html_entities": { + "name": "Decode HTML entitles into characters", + "code": [ + "Ruby does not implement this, although you can use the cgi library to do it.", + "In Rails you can use the raw method, as shown in the example bellow:", + "<%= raw '' %>" + ] + }, + "encode_url_percent": { + "name": "Encode URL percent encoding into string (ex: ' ' to %20)", + "code": [ + "Ruby does not implement this, although you can use the cgi library to do it." + ] + }, + "decode_url_percent": { + "name": "Decode URL percent encoding", + "code": [ + "Ruby does not implement this, although you can use the cgi library to do it." + ] + }, + "encode_to_base64": { + "name": "Encode string into Base64 format", + "code": [ + "Base64.encode64(string)" + ] + }, + "decode_from_base64": { + "name": "Decode string from Base64 format", + "code": [ + "Base64.decode64(encodedString)" + ] + }, + "format_string_function": { + "name": "Function to format a string", + "code": [ + "\"Hello %d\" % 4 # you can use more formats ex: [%c, %x; etc]", + "\"Hello %x %s\" % [2, \"you\"]", + "\"This is a #{variable} string\"" + ] + }, + "parameter_format_in_order": { + "name": "Parameter used in format function if they're used in order", + "code": [ + "Not Implemented in Ruby" + ] + }, + "parameter_format_numerical": { + "name": "Parameter used in format function if they're numerically numbered", + "code": [ + "Not Implemented in Ruby" + ] + }, + "parameter_format_by_name": { + "name": "Paramater used in format function if they're named variables", + "code": [ + "Not Implemented in Ruby" + ] + }, + "format_as_integer": { + "name": "Format parameter as an integer", + "code": [ + "%d or %i" + ] + }, + "format_as_decimal": { + "name": "Format parameter as a decimal number", + "code": [ + "%f" + ] + }, + "format_as_fixed_decimal": { + "name": "Format parameter as a fixed-point decimal number", + "code": [ + "%.nf # where n is the fixed-point number" + ] + }, + "format_as_currency": { + "name": "Format parameter as a currency number", + "code": [ + "\"%s%s\" % [currency, string.reverse.scan(/.{1,3}/).join(',').reverse]" + ] + }, + "format_as_percentage": { + "name": "Format parameter as a percentage number", + "code": [ + "\"%s%%\" % string.reverse.scan(/.{1,3}/).join(',').reverse" + ] + }, + "format_number_with_separators": { + "name": "Format number with thousand separators", + "code": [ + "\"%s\" % string.reverse.scan(/.{1,3}/).join(',').reverse" + ] + }, + "format_number_with_positive_negative_sign": { + "name": "Format number with positive/negative signs", + "code": [ + "\"+%d\" % number", + "\"-%d\" % number", + "\"+#{number}\"", + "\"-#{number}\"" + ] + }, + "format_number_in_scientific_notation_little_e": { + "name": "Format number with scientific notation with 'e'", + "code": [ + "\"%e\" % number" + ] + }, + "format_number_in_scientific_notation_big_e": { + "name": "Format number with scientific notation with 'E'", + "code": [ + "\"%E\" % number" + ] + }, + "format_number_in_binary": { + "name": "Format number into binary", + "code": [ + "\"%s\" % number.to_s(2)" + ] + }, + "format_number_in_octal": { + "name": "Format number into octal", + "code": [ + "\"%o\" % number" + ] + }, + "format_number_in_hexadecimal": { + "name": "Format number into hexadecimal", + "code": [ + "\"%x\" % number # use X for uppercase format" + ] + } + } +} \ No newline at end of file From 21e33bd8bba2e1127da69580d8e2e90ab7581316 Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Tue, 4 Oct 2022 18:41:40 +0100 Subject: [PATCH 2/7] Resolved question 2 about strings --- web/thesauruses/ruby/3/strings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json index 0afb77ab8..433551991 100644 --- a/web/thesauruses/ruby/3/strings.json +++ b/web/thesauruses/ruby/3/strings.json @@ -15,7 +15,7 @@ "import": { "name": "Import the string class", "code": [ - "No need?" + "Built-in included in the default Modules" ] }, "default_string_byte_encoding": { From 9d501fcedb025b552b4931441a5e39040183787a Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Tue, 4 Oct 2022 18:42:44 +0100 Subject: [PATCH 3/7] Fixed small typo to show the newline char explicitly --- web/thesauruses/java/11/strings.json | 2 +- web/thesauruses/java/15/strings.json | 2 +- web/thesauruses/java/17/strings.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/thesauruses/java/11/strings.json b/web/thesauruses/java/11/strings.json index d1100d49f..10f2c025b 100644 --- a/web/thesauruses/java/11/strings.json +++ b/web/thesauruses/java/11/strings.json @@ -170,7 +170,7 @@ }, "split_at_newlines": { "name": "Split string into a list of strings at every new line character", - "code": "List stringList = strings.split(\"\\\n\");" + "code": "List stringList = strings.split(\"\\n\");" }, "split_at_substring": { "name": "Split string by locating all substrings", diff --git a/web/thesauruses/java/15/strings.json b/web/thesauruses/java/15/strings.json index 5e36d824b..c84007469 100644 --- a/web/thesauruses/java/15/strings.json +++ b/web/thesauruses/java/15/strings.json @@ -170,7 +170,7 @@ }, "split_at_newlines": { "name": "Split string into a list of strings at every new line character", - "code": "List stringList = strings.split(\"\\\n\");" + "code": "List stringList = strings.split(\"\\n\");" }, "split_at_substring": { "name": "Split string by locating all substrings", diff --git a/web/thesauruses/java/17/strings.json b/web/thesauruses/java/17/strings.json index ebdc6383e..f73fab1bb 100644 --- a/web/thesauruses/java/17/strings.json +++ b/web/thesauruses/java/17/strings.json @@ -170,7 +170,7 @@ }, "split_at_newlines": { "name": "Split string into a list of strings at every new line character", - "code": "List stringList = strings.split(\"\\\n\");" + "code": "List stringList = strings.split(\"\\n\");" }, "split_at_substring": { "name": "Split string by locating all substrings", From 9cb9a76e6a4073973de206756eecdd20bd6d319f Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Tue, 4 Oct 2022 19:06:12 +0100 Subject: [PATCH 4/7] Fixed missplaced string concatenation answer --- web/thesauruses/ruby/3/strings.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json index 433551991..d29c3ec8c 100644 --- a/web/thesauruses/ruby/3/strings.json +++ b/web/thesauruses/ruby/3/strings.json @@ -87,7 +87,10 @@ "concatenate_two_strings": { "name": "Concatenate/join two strings", "code": [ - "" + "a = \"String\"", + "b = a + \"2\"", + "c = a + b", + "puts c # Returns \"StringString2\"" ] }, "concatenate_many_strings": { @@ -95,17 +98,14 @@ "code": [ "a = \"String\"", "b = a + \"2\"", - "c = a + b", - "puts c # Returns \"StringString2\"" + "c = a + \" \" + b", + "puts c # Returns \"String String2\"" ] }, "is_all_alphabetical": { "name": "Is string all alphabetical characters?", "code": [ - "a = \"String\"", - "b = a + \"2\"", - "c = a + \" \" + b", - "puts c # Returns \"String String2\"" + "!string.match(/\\A[a-zA-Z]*\\z/).nil?" ] }, "is_all_numerical": { From 3cc9399d03987b583d115f2edb6884e32a23d790 Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Wed, 5 Oct 2022 15:21:41 +0100 Subject: [PATCH 5/7] Implement the 'comment' JSON variable when it's necessary --- web/thesauruses/ruby/3/strings.json | 79 +++++++++-------------------- 1 file changed, 25 insertions(+), 54 deletions(-) diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json index d29c3ec8c..d21bea3a6 100644 --- a/web/thesauruses/ruby/3/strings.json +++ b/web/thesauruses/ruby/3/strings.json @@ -8,56 +8,44 @@ "concepts": { "is_primitive_or_not": { "name": "Is this a built-in type in this language?", - "code": [ - "Yes" - ] + "comment": "Yes" }, "import": { "name": "Import the string class", - "code": [ + "comment": "Built-in included in the default Modules" - ] }, "default_string_byte_encoding": { "name": "Default byte encoding (ex: ASCII UTF-8, UTF-16, etc.)", - "code": [ - "UTF-8" - ] + "comment": "UTF-8" }, "create_new_string": { "name": "Create new string", "code": [ - "1. varName = \"Hello World\"", - "2. varName = 'This also works'", - "3. anotherVar = %{another way to do it}\n", - "1. & 2. Enclosing a set of characters between quotes/double quotes.", - "3. Using the %char-style quoting mechanism generates either a single or doubled quoted string.", - "You can preceed the % by a character option and a delimiter", - "The most common delimiter is {} like the example, but you can use any non alpha-numerical delimiter." - ] + "varName = \"Hello World\"", + "varName = 'This also works'", + "anotherVar = %{another way to do it}\n" + ], + "comment": "Using the %char-style quoting mechanism generates either a single or doubled quoted string.\nYou can preceed the % by a character option and a delimiter.\nThe most common delimiter is {} like the example, but you can use any non alpha-numerical delimiter." }, "create_multiline_string": { "name": "Create new multi-line string", "code": [ - "1. text = <' %>" - ] + "code": ["<%= h 'escaping ' %>"], + "comment": + "Ruby does not implement this, although you can use the cgi library to do it.\nIn Rails you can use the h method, as shown in the example above." }, "decode_html_entities": { "name": "Decode HTML entitles into characters", - "code": [ - "Ruby does not implement this, although you can use the cgi library to do it.", - "In Rails you can use the raw method, as shown in the example bellow:", - "<%= raw '' %>" - ] + "code": ["<%= raw '' %>"], + "comment": "Ruby does not implement this, although you can use the cgi library to do it.\nIn Rails you can use the raw method, as shown in the example above." }, "encode_url_percent": { "name": "Encode URL percent encoding into string (ex: ' ' to %20)", - "code": [ - "Ruby does not implement this, although you can use the cgi library to do it." - ] + "not-implemented": true }, "decode_url_percent": { "name": "Decode URL percent encoding", - "code": [ - "Ruby does not implement this, although you can use the cgi library to do it." - ] + "not-implemented": true }, "encode_to_base64": { "name": "Encode string into Base64 format", @@ -321,21 +298,15 @@ }, "parameter_format_in_order": { "name": "Parameter used in format function if they're used in order", - "code": [ - "Not Implemented in Ruby" - ] + "not-implemented": true }, "parameter_format_numerical": { "name": "Parameter used in format function if they're numerically numbered", - "code": [ - "Not Implemented in Ruby" - ] + "not-implemented": true }, "parameter_format_by_name": { "name": "Paramater used in format function if they're named variables", - "code": [ - "Not Implemented in Ruby" - ] + "not-implemented": true }, "format_as_integer": { "name": "Format parameter as an integer", From e677fe96b515f8664e5cf0d72782891059c4bccd Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Wed, 5 Oct 2022 16:11:41 +0100 Subject: [PATCH 6/7] Remove name field from the JSON file --- web/thesauruses/ruby/3/strings.json | 63 ----------------------------- 1 file changed, 63 deletions(-) diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json index d21bea3a6..9b3e6839e 100644 --- a/web/thesauruses/ruby/3/strings.json +++ b/web/thesauruses/ruby/3/strings.json @@ -7,20 +7,16 @@ }, "concepts": { "is_primitive_or_not": { - "name": "Is this a built-in type in this language?", "comment": "Yes" }, "import": { - "name": "Import the string class", "comment": "Built-in included in the default Modules" }, "default_string_byte_encoding": { - "name": "Default byte encoding (ex: ASCII UTF-8, UTF-16, etc.)", "comment": "UTF-8" }, "create_new_string": { - "name": "Create new string", "code": [ "varName = \"Hello World\"", "varName = 'This also works'", @@ -29,7 +25,6 @@ "comment": "Using the %char-style quoting mechanism generates either a single or doubled quoted string.\nYou can preceed the % by a character option and a delimiter.\nThe most common delimiter is {} like the example, but you can use any non alpha-numerical delimiter." }, "create_multiline_string": { - "name": "Create new multi-line string", "code": [ "text = <' %>"], "comment": "Ruby does not implement this, although you can use the cgi library to do it.\nIn Rails you can use the h method, as shown in the example above." }, "decode_html_entities": { - "name": "Decode HTML entitles into characters", "code": ["<%= raw '' %>"], "comment": "Ruby does not implement this, although you can use the cgi library to do it.\nIn Rails you can use the raw method, as shown in the example above." }, "encode_url_percent": { - "name": "Encode URL percent encoding into string (ex: ' ' to %20)", "not-implemented": true }, "decode_url_percent": { - "name": "Decode URL percent encoding", "not-implemented": true }, "encode_to_base64": { - "name": "Encode string into Base64 format", "code": [ "Base64.encode64(string)" ] }, "decode_from_base64": { - "name": "Decode string from Base64 format", "code": [ "Base64.decode64(encodedString)" ] }, "format_string_function": { - "name": "Function to format a string", "code": [ "\"Hello %d\" % 4 # you can use more formats ex: [%c, %x; etc]", "\"Hello %x %s\" % [2, \"you\"]", @@ -297,55 +249,45 @@ ] }, "parameter_format_in_order": { - "name": "Parameter used in format function if they're used in order", "not-implemented": true }, "parameter_format_numerical": { - "name": "Parameter used in format function if they're numerically numbered", "not-implemented": true }, "parameter_format_by_name": { - "name": "Paramater used in format function if they're named variables", "not-implemented": true }, "format_as_integer": { - "name": "Format parameter as an integer", "code": [ "%d or %i" ] }, "format_as_decimal": { - "name": "Format parameter as a decimal number", "code": [ "%f" ] }, "format_as_fixed_decimal": { - "name": "Format parameter as a fixed-point decimal number", "code": [ "%.nf # where n is the fixed-point number" ] }, "format_as_currency": { - "name": "Format parameter as a currency number", "code": [ "\"%s%s\" % [currency, string.reverse.scan(/.{1,3}/).join(',').reverse]" ] }, "format_as_percentage": { - "name": "Format parameter as a percentage number", "code": [ "\"%s%%\" % string.reverse.scan(/.{1,3}/).join(',').reverse" ] }, "format_number_with_separators": { - "name": "Format number with thousand separators", "code": [ "\"%s\" % string.reverse.scan(/.{1,3}/).join(',').reverse" ] }, "format_number_with_positive_negative_sign": { - "name": "Format number with positive/negative signs", "code": [ "\"+%d\" % number", "\"-%d\" % number", @@ -354,31 +296,26 @@ ] }, "format_number_in_scientific_notation_little_e": { - "name": "Format number with scientific notation with 'e'", "code": [ "\"%e\" % number" ] }, "format_number_in_scientific_notation_big_e": { - "name": "Format number with scientific notation with 'E'", "code": [ "\"%E\" % number" ] }, "format_number_in_binary": { - "name": "Format number into binary", "code": [ "\"%s\" % number.to_s(2)" ] }, "format_number_in_octal": { - "name": "Format number into octal", "code": [ "\"%o\" % number" ] }, "format_number_in_hexadecimal": { - "name": "Format number into hexadecimal", "code": [ "\"%x\" % number # use X for uppercase format" ] From 591c17567b331e342430068d7f7ed30a9e029bb2 Mon Sep 17 00:00:00 2001 From: pulgamecanica Date: Sat, 8 Oct 2022 05:53:53 +0100 Subject: [PATCH 7/7] prevent Unkown meassage --- web/thesauruses/ruby/3/strings.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/thesauruses/ruby/3/strings.json b/web/thesauruses/ruby/3/strings.json index 9b3e6839e..9b2a89621 100644 --- a/web/thesauruses/ruby/3/strings.json +++ b/web/thesauruses/ruby/3/strings.json @@ -7,14 +7,14 @@ }, "concepts": { "is_primitive_or_not": { - "comment": "Yes" + "code": "Yes" }, "import": { - "comment": + "code": "Built-in included in the default Modules" }, "default_string_byte_encoding": { - "comment": "UTF-8" + "code": "UTF-8" }, "create_new_string": { "code": [ @@ -47,7 +47,7 @@ ] }, "max_length_of_string": { - "comment": "65,535 characters." + "code": "65,535 characters." }, "clear_string": { "code": [