#ruby - 09 February 2019
« Back 1 day Forward 1 day »
[15:55:43] al2o3-cr: any reason this might segfault, like, 1 in every 10 or so: https://gist.github.com/gr33n7007h/a152a88b3ed78b8d42cfc10f4adfc103
[19:03:59] jason479: haven wood the module i wish to publish is here : https://gist.github.com/wesley974/adba95ca1e1fcdff8020258857a9f85a if you can take a look
[19:05:31] havenwood: jason479: there's already a Needs gem, so you'd just need to pick a slightly different namespace if you want to publish to RubyGems
[19:10:39] jason479: but for now it is system related, i don't know how to test these 2 methods (:root & :release?(number))
[19:20:36] phaul: on testing root & release. it's kind of tricky because of the external dependency on etc. If you stub etc then you can control different etc behaviour for different test cases. But test stubbing and mocking is a bigger topic
[19:23:37] havenwood: jason479: Here's an example of Minitest specs for the #root method in your code: https://gist.github.com/havenwood/6a1f8e1c7e6b2a1831ef76f6459030de
[19:30:27] havenwood: jason479: If you have trouble with the gem layout or getting specs working in it, let us know and we can help.
[19:34:19] jason479: in fact i wish to publish multiple small gems like 'Needs' to be able use them to deploy for example a mailserver (scripting)
[19:35:43] jason479: if i publish OpenBSDHelper (openbsd_helper) as a namespace, publish a gem with the 'Needs' plugin, can i later update it and add for example a new plugin named 'Rcctl' ?
[19:37:38] havenwood: jason479: or Mailserver (mailserver) with Mailserver::Needs (mailserver-needs).
[19:38:46] havenwood: jason479: Yes. It's a pretty common pattern. Sometimes the root gem installs the plugins. Sometimes you cherrypick plugins.
[19:39:35] havenwood: jason479: Consider if they should always be used together. Is there an advantage in making it modular?
[19:41:51] jason479: but if i publish the gem OpenBSDHelper with for example only one module embedded like Needs, if i need to add a new module to the already published gem, how can i update that ?
[19:42:08] havenwood: jason479: OpenBSDHelper is lib/open_bsd_helper.rb and OpenBSDHelper::Needs is lib/open_bsd_helper/needs.rb.
[19:44:14] jason479: Now i want to use this gem, writing a script, i will need each time type : OpenBSDHelper::ModuleName.method ...
[20:10:46] jason479: but regarding the main file lib/open_bsd_helper.rb it will be also a module, yes ?
[20:21:59] phaul: jason479: you can create a directory structure that follows module nesting. lib/open_bsd_helper/needs.rb in this case. Whether you have a lib/open_bsd_helper.rb or not can depend on if there is any code going in there. Just for empty modules you don't have to create the source file
[23:47:48] phaul: Net: I read the code on RSpec lets. The anwer to whether lets are re-defined if defined in sub-contexts is yes. But technically that's not how they work.
[23:49:50] phaul: They achieve lazy and one time evaluation of let. Only lets that are needed for each example are run and only once. They are reset per examples.
[23:56:31] phaul: they are methods, and the block is used in define_method. Sub-contexting also means inheritance so sub-describe let would shadow parents method. I beleive calling super should work to get the outer let value.