{"id":16724277,"url":"https://github.com/badboy/ruby-dzen","last_synced_at":"2025-04-10T10:21:47.361Z","repository":{"id":1053635,"uuid":"886084","full_name":"badboy/ruby-dzen","owner":"badboy","description":"A small wrapper for dzen2's in-text formatting ","archived":false,"fork":false,"pushed_at":"2010-10-03T17:16:39.000Z","size":100,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T06:22:44.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-09-03T16:29:12.000Z","updated_at":"2014-02-28T00:46:00.000Z","dependencies_parsed_at":"2022-07-06T04:01:07.101Z","dependency_job_id":null,"html_url":"https://github.com/badboy/ruby-dzen","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badboy%2Fruby-dzen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badboy%2Fruby-dzen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badboy%2Fruby-dzen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badboy%2Fruby-dzen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badboy","download_url":"https://codeload.github.com/badboy/ruby-dzen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199079,"owners_count":21063641,"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":[],"created_at":"2024-10-12T22:44:37.633Z","updated_at":"2025-04-10T10:21:47.324Z","avatar_url":"https://github.com/badboy.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ruby-dzen\n\nA small wrapper for [dzen2][dzen]'s in-text formatting\n\nYou can define what dzen2 displays by using pure ruby code.\n\nThe DSL is heavily inspired by [Sinatra][].\n\n## Simple DSL\nThere are just 4 methods you need to know: `app`, `configure`, `before_run` and `order`\n\nThe simplest way to use ruby-dzen is to define a simple app:\n\n    app :clock do\n      Time.now.strftime(\"%d.%m.%Y %H:%M\")\n    end\n\nEach of these `app` blocks must return a string to be displayed.\n\nYou can easily configure the output:\n\n    configure do |c|\n      c.interval = 3 \n    end\n\nThere are several options configurable. See [dzen/base.rb][base.rb] for the defaults. ruby-dzen comes with two pre-defined option sets: \n\n* One for real dzen2-formatted text including colors and delimiters. This is used by default.\n* One for simple text console output using escape sequences to display colors. Just define TERMINAL in your code or via commandline. (I will change this to a more ruby-ish way, soon)\n\nYou can define a handler to be run beforehand, for example to display a short loading message:\n\n    before_run do\n      \"--- Loading ---\"\n    end\n\nThe output order will either be in the order as the apps are defined in your app file or you can sort them using the `order` method:\n\n    order :clock, :loadavg\n\nIf you define an app but you don't define it in your order list, it won't be displayed at all.\n\nSee the [example file][example] for a already working script.\n\n## Run it!\n\nAs I'm to lazy for now to create a proper gem, just clone my repo and write your own small app collection.\n\nThen run it with\n\n    ruby -Ipath/to/ruby-dzen/lib yourscript.rb | dzen2\n\nMake sure you have the svn-Version of dzen2, as it has some extra things which are not in the released packages:\n\n    svn checkout http://dzen.googlecode.com/svn/trunk/ dzen\n\nYou can then set dzen2's output by its commandline options. For example change the used font with:\n\n    ... | dzen2 -fn \"-*-terminus-medium-r-normal--14-120-75-75-C-70-iso8859-1\"\n\nSee [dzen2's documentation][dzen] for all possible options.\n\nIf you want to use the text console output (for debugging or whatever) run it as:\n\n    TERMINAL=1 ruby -Ipath/to/ruby-dzen/lib yourscript.rb\n\nThis will change soon to a more ruby-ish way, I hope.\n\n## Helpers\n\nAs it is all pure ruby code, just define a method in your code and call it within your app module.\n\nI already wrote 2 small helper functions: `_color` and `color_critical`.\n\n`_color` colorizes a given string using the callbacks defined by DZEN::Base (or its subclass).\n\n`color_critical` colorizes a number value based on wether it's below a critical value or not.\n\nSee the docu for their arguments in [dzen/helpers.rb][helpers.rb].\n\nTo use them in your code just do the following in your script:\n\n    include DZEN::Helpers\n\nand use them in your apps.\n\n## New outputs\n\nTo define a new output class, just subclass DZEN::Base and make sure your class defines the `Config` constant overwriting the existent config keys.\n\nThis is exactly the way DZEN::Default and DZEN::Terminal are defined. See [dzen/base.rb][base.rb].\n\n## ToDo\n\n* caching of apps (nearly finished, just need a proper API)\n* more ruby-ish way to switch output class\n\nFeel free to implement what you need and let me know about your changes.\n\n## License\n\nThe code is released under the MIT license. See [LICENSE][].\n\n## Contribute\n\nIf you'd like to hack on ruby-dzen, start by forking my repo on GitHub:\n\nhttp://github.com/badboy/ruby-dzen\n\nruby-dzen has no external dependencies other than dzen2 itself.\n\n1. Clone down your fork\n1. Create a thoughtfully named topic branch to contain your change\n1. Hack away\n1. Add tests and make sure everything still passes by running `rake`\n1. If you are adding new functionality, document it in the README\n1. Do not change the version number, I will do that on my end\n1. If necessary, rebase your commits into logical chunks, without errors\n1. Push the branch up to GitHub\n1. Send me (badboy) a pull request for your branch\n\n[dzen]: http://dzen.geekmode.org/dwiki/doku.php\n[base.rb]: http://github.com/badboy/ruby-dzen/blob/master/lib/dzen/base.rb\n[helpers.rb]: http://github.com/badboy/ruby-dzen/blob/master/lib/dzen/helpers.rb\n[sinatra]: http://www.sinatrarb.com/\n[LICENSE]: http://github.com/badboy/ruby-dzen/blob/master/LICENSE\n[example]: http://github.com/badboy/ruby-dzen/blob/master/example/sample.rb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadboy%2Fruby-dzen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadboy%2Fruby-dzen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadboy%2Fruby-dzen/lists"}