{"id":17832415,"url":"https://github.com/rubycocos/core","last_synced_at":"2025-03-19T10:30:54.747Z","repository":{"id":6918277,"uuid":"8168989","full_name":"rubycocos/core","owner":"rubycocos","description":"core tools, libraries \u0026 scripts - logger, config, dates, alphabets, shell \u0026 more","archived":false,"fork":false,"pushed_at":"2024-06-14T17:24:55.000Z","size":253,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T23:17:53.429Z","etag":null,"topics":["alphabets","dates","gems","logger","props","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubycocos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-12T22:45:32.000Z","updated_at":"2024-06-14T17:24:59.000Z","dependencies_parsed_at":"2024-06-14T18:56:15.492Z","dependency_job_id":null,"html_url":"https://github.com/rubycocos/core","commit_stats":{"total_commits":60,"total_committers":1,"mean_commits":60.0,"dds":0.0,"last_synced_commit":"fb097dbe4d9fe0ea2c6c66319e751e1c8c34423f"},"previous_names":["rubylibs/logutils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubycocos","download_url":"https://codeload.github.com/rubycocos/core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982182,"owners_count":20378605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alphabets","dates","gems","logger","props","ruby"],"created_at":"2024-10-27T19:56:48.943Z","updated_at":"2025-03-19T10:30:54.394Z","avatar_url":"https://github.com/rubycocos.png","language":"Ruby","readme":"# core tools, libraries \u0026 scripts\r\n\r\nGems:\r\n\r\n- [**hexutils**](hexutils) - hex(adecimal) encode/decode helpers 'n' more for String, NilClass, Kernel and more\r\n- [**bytes**](bytes) - bits 'n' bytes made easy/easier incl. new buffer helper / wrapper class to help with the string byte vs character dichotomy\r\n- [**enums**](enums) - safe enum / enumeration types - a set of symbolic keys bound to unique integer numbers (incl. bit flags option)\r\n- [**safebool**](safebool) - safe bool / boolean type adds `Bool()`, `to_b`, `parse_bool` / `to_bool`, `bool?`, `false?`, `true?`, `true.is_a?(Bool)==true`, `false.is_a?(Bool)==true`, and more\r\n\r\n\r\n\u003c!-- break --\u003e\r\n\r\n\r\n- [**logutils**](logutils)  - (lite) logger library\r\n- [logutils-activerecord](logutils-activerecord) - addon for database support (e.g. LogDb, log model etc.)\r\n- [logutils-admin](logutils-admin) - addon for browsing logs in database (e.g. LogDb, log model etc.)\r\n\r\n\r\n\u003c!-- break --\u003e\r\n- [**props**](props)  - manage settings hierarchies (commandline, user, home, defaults, etc.)\r\n- [props-activerecord](props-activerecord) - addon for database support (ConfDb, props model, etc.)\r\n\r\n\r\n\u003c!-- break --\u003e\r\n- [iniparser](iniparser) - read / parse INI configuration, settings and data files into a hash (incl. named subsections)\r\n\r\n\u003c!-- break --\u003e\r\n- [alphabets](alphabets) - alphabet (a-z) helpers incl. unaccent, downcase, variants, and more\r\n- [date-formats](date-formats) - read / parse and print dates (and times) from around the world\r\n- [date-formatter](date-formatter) - date formatter by example; auto-builds the strftime format string from an example date\r\n\r\n\r\n\u003c!-- break --\u003e\r\n- [records](records) -  frozen / immutable structs with copy on updates\r\n- [safedata](safedata) - safe (algebraic) union data types with (enumerated) variants\r\n\r\n\r\n\r\n\u003c!-- break --\u003e\r\n- [shell-lite](shell-lite) - run / execute shell commands\r\n\r\n\r\n\r\n\r\n## If I Were ~~King~~ Matz (aka Yukihiro Matsumoto) - Ideas For Ruby 4.0   - What's Broken \u0026 Missing in Ruby 3.x and How To Fix It\r\n\r\nAfter programming in ruby for more than 10+ years and [sharing / publishing 200+ gems](https://rubygems.org/profiles/geraldbauer)\r\nand - yes, believe it or not - getting perma-banned (\"cancel-cultured\" ) for life twice (thanks to Richard Schneeman, Brandon Weaver, et al)\r\non r/reddit and ruby-talk - see the [public service announcement](https://old.reddit.com/r/planetruby/comments/swzz2h/public_service_announcement_this_reddit_here_is/) for some background  -\r\nI ([Gerald Bauer](https://github.com/geraldb)) will try to keep a public log on how to make\r\nruby even more fun by collecting ideas  (mostly backed-up by \"real-world\" code \u0026 monkey patches) right here on this page.   Your questions and comments are more than welcome.\r\n\r\n\r\n\r\n### Core Language \u0026 Types\r\n\r\nAbout Strings\r\n\r\nDid you know? In rubyland a string (like a character) started\r\nas a series of bytes. In the old days a character was a byte (that is, an unsigned integer number in the range of 0-255).\r\n\r\nBackground Reading\r\n-  [Programming Bits, Bytes 'n' Blocks Step-by-Step Book / Guide](bytes) -\r\n   _Let's start with the three types of strings, that is, bytes, string buffers, and frozen strings, ..._\r\n\r\n\r\nThat all changed with wide-chars, unicode, \u0026 friends.\r\nIn 2024 does ruby need a (Binary) Buffer class?\r\nWhy? Why Not? Discuss.\r\n\r\n\r\nWorking with binary and hex(adecimal) strings in ruby\r\n\r\nIn 2024 the \"classic\" way\r\nto convert a binary string to a hex(adecimal) string\r\nand vice versa in ruby is like:\r\n\r\n``` ruby\r\ndef hex_to_bin( hex )\r\n    raise TypeError, \"hex_to_bin - non-hexadecimal digit found in \u003e#{hex}\u003c\" unless hex =~ /\\A(?:0x)?[0-9a-f]*\\z/i\r\n\r\n    ## note: assume pack always returns string with BINARY/ASCII-8BIT encoding!!!\r\n    if ['0x', '0X'].include?( hex[0,2] )   ## cut-of leading 0x or 0X if present\r\n      [hex[2..-1]].pack('H*')\r\n    else\r\n      [hex].pack('H*')\r\n    end\r\nend\r\n\r\ndef bin_to_hex( bin )\r\n  # note: unpack returns string with \u003cEncoding:US-ASCII\u003e\r\n  # convert to default encoding\r\n  hex = bin.unpack('H*').first\r\n  hex.encode!( Encoding::UTF_8 )\r\n  hex\r\nend\r\n```\r\n\r\nThe idea is to add new hex helpers to `String#hex` and `Kernel#hex`.\r\n\r\nThat let's you use convert hex strings to bin(ary) string via `Kernel#hex`\r\ne.g.\r\n\r\n``` ruby\r\nbin = hex\"00000000000000000000000000000000000000000000000000000000000004d2\"\r\n```\r\n\r\nand vice versa via `String#hex`:\r\n\r\n``` ruby\r\nbin.hex\r\n#=\u003e \"00000000000000000000000000000000000000000000000000000000000004d2\"\r\n```\r\n\r\n\r\nDid you know? In rubyland `String#hex`  like `String#oct`\r\nis already defined\r\nand is an alias for `String#to_i(16)`  or `String#to_i(8)`.\r\n\r\n``` ruby\r\n\"41\".to_i(16)          #=\u003e 65\r\n\"0x41\".to_i(16)        #=\u003e 65 - same as \"41\" - 0x hex prefix gets skipped\r\n\"41\".hex          #=\u003e 65\r\n\"0x41\".hex        #=\u003e 65 - same as \"41\" - 0x hex prefix gets\r\n```\r\n\r\nThe idea for ruby 4.0 is to redefine `String#hex`  to return a hex string.\r\nAnother idea is to use a different name (and aliases)\r\nsuch as `String#hexdump` or `String#hexdigest` and so on.\r\nBut somehow the matching symetry  of `String#hex` and `Kernel#hex`\r\nand principle of least surprise gets lost.\r\nAnyone ever used the old `String#hex`?  Let's find real-world code snippets / references.\r\n\r\n\r\n\r\n\r\n#### The Missing Bool Class\r\n\r\nDid you know? In rubyland there is no `Bool` class only `TrueClass` and `FalseClass`.\r\n\r\nThis can easily monkey-patched - why not make it official?\r\nSee the [safebool gem](safebool) for a start.\r\n\r\nBackground Reading:\r\n-  [The State of Bool - Everything You Never Wanted to Know](https://github.com/geraldb/talks/blob/master/bool.md) @ Vienna Ruby Meetup, April 2019\r\n\r\n\r\n#### The Missing Enum Class?\r\n\r\nDid you know? In rubyland there is no `Enum` class.\r\nThe official party line is that\r\nthere's no class needed, just use symbols :-) or use constants. Example:\r\n\r\n``` ruby\r\nColor = [:red, :blue, :green]\r\nColor[0]  #=\u003e :red\r\nColor[1]  #=\u003e :blue\r\n\r\n# -or-\r\n\r\nColor = {red: 0, blue: 1, green: 2}\r\nColor[:red]   #=\u003e 0\r\nColor[:blue]  #=\u003e 1\r\nColor.keys    #=\u003e [:red, :blue, :green]\r\nColor.values  #=\u003e [0, 1, 2]\r\n\r\n# -or-\r\n\r\nmodule Color\r\n  RED   = 0\r\n  BLUE  = 1\r\n  GREEN = 2\r\nend\r\nColor::RED       #=\u003e 0\r\nColor::BLUE      #=\u003e 1\r\nColor.constants  #=\u003e [:RED, :BLUE, :GREEN]\r\n# ...\r\n```\r\n\r\nWhy? Why not? Discuss.\r\n\r\n\r\nSee the [enums gem](enums) for a start on a enum class.\r\n\r\n\r\n\r\n#### The Missing Preludes / Quick Starters?\r\n\r\nAre there any auto-include quick-starter prelude \u0026 prolog gems\r\nout there in rubyland?\r\n\r\n\r\nYou could argue ruby is dead and rails is the \"All your base are belong to us\"\r\nprelude \u0026 prolog quick-starter gem.\r\n\r\nWhy not make the concept of\r\nauto-include quick-starter prelude \u0026 prolog gems\r\nmore popular and offer more options?\r\n\r\n\r\nSee the [cocos (code commons) gem](https://github.com/rubycocos/cocos) for a start on an (off-rails)\r\nauto-include quick-starter prelude \u0026 prolog gem.\r\n\r\n\r\n\r\n\r\n### Standard Gems / Libraries\r\n\r\n#### (Open) Tabular Data Formats - A Better CSV Gem (Or Better) Gems\r\n\r\nI have written a [seven part series on how the standard csv package\r\nin rubyland is broken years ago](https://github.com/rubycocos/csvreader/tree/master/docs) (some issues got fixed thanks to [Sutou Kouhei](https://github.com/kou) - you are a hero)\r\nbut others are \"unfixable\" evergreens.\r\n\r\nSee the [csvreader gem series](https://github.com/rubycocos/csvreader) for a start.\r\n\r\n\r\nBackground Reading:\r\n- [Mining for Gold Using the World's #1 and Most Popular Data Format (Spoiler: It's Comma-Separated Values (CSV))](https://github.com/geraldb/talks/blob/master/csv.md)\r\n\r\n\r\n### Standard Project Scaffolders\r\n\r\nDid you know?  In rubyland everyone rolls their own project scaffolder (bundler, hoe, rails, jekyll, etc.)  -  why not use a shared project scaffolder open to everyone?\r\n\r\n\r\nSee the [quik gem series](https://github.com/quikstart) for a start.\r\n\r\n\r\nBackground Reading:\r\n- [The Missing Project Scaffolder for Ruby - Quick Start Your Ruby Gems, Your Sinatra Apps, Your Jekyll Sites 'n' More](https://github.com/geraldb/talks/blob/master/quik.md)\r\n\r\n\r\n\r\n\u003c!--\r\n### Miscellaneous\r\n--\u003e\r\n\r\n\r\nTo be continued \u0026 updated...\r\n\r\n\r\nReminder:   Your questions and comments are more than welcome.\r\n\r\n\r\n\r\n\r\n\r\n## License\r\n\r\nThe scripts are dedicated to the public domain.\r\nUse it as you please with no restrictions whatsoever.\r\n\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubycocos%2Fcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubycocos%2Fcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubycocos%2Fcore/lists"}