#ruby - 22 August 2018
« Back 1 day Forward 1 day »
[00:05:44] thoraxe: soooo weird question. but i'm trying to look for some kind of ruby gem that "distills the dom" a'la https://chromium.googlesource.com/chromium/dom-distiller -- basically want to scrape a site but simplify its content for reader-type stuff
[00:22:11] mroutis: thoraxe: maybe you can run a headless chrome and call it as written on the documentation
[00:23:33] thoraxe: i could probably either make a flask python microservice or do some horrific python-from-ruby incantation
[02:23:33] mrush: saiyanprince: web development, domain specific languages, and systems integration 'glue' language are some of the more commonly cited areas of popular use
[07:21:32] mikhael_k33hl: I have a module Marz::Rsync.run, how do I mock it so I can test that it receives the correct paramters when invoked?>
[07:21:50] mikhael_k33hl: https://docs.ruby-lang.org/en/2.0.0/MiniTest/Mock.html Seems to mock the method directly
[07:39:14] fork_fx: I am executing an INSERT query, which obviously succeeds, but I only get "nil" as result.
[07:39:27] fork_fx: client = Mysql2::Client.new(:host => "localhost", :username => "bla", :password => "blub123", :database => "test")
[08:33:54] jlebrech: can you use vcr outside of tests? i'd like to record as i'm manual testing and replay my clicks in tests later
[08:35:57] mikhael_k33hl: rindolf: https://gist.github.com/marzdgzmn/f4c423327d56bfe37afea617d39d7152 Nope, trying to test if the method is receiving the correct arguments though
[08:39:20] rindolf: mikhael_k33hl: i'm not a ruby expert - see https://duckduckgo.com/?q=ruby+mock+modules&ia=qa
[08:43:15] fork_fx: rindolf: I do not know what you are trying to say to me with http://sscce.org. The posted link https://dpaste.de/GcqA is full executable ruby code. Of course i did not enclose a script to install a mysql database server and a create table for the database i am using. So in what way my question is lacking information here?
[08:46:16] mikhael_k33hl: rindolf: hmmm, tried this one https://gist.github.com/marzdgzmn/f4c423327d56bfe37afea617d39d7152 still can't make it work. Why am I getting the error: NoMethodError: undefined method `to_sym' for #<Marz::Rsync::Result:0x00000000019918c0> when I've mocked it?
[09:47:31] balo: Bish: yep, 1 seems to be the minimum and default if you don't specify worker_processes in your unicorn config https://bogomips.org/unicorn.git/tree/lib/unicorn/configurator.rb#n258
[10:24:53] mikhael_k33hl: rindolf: sorry about the late reply man, something came up that I needed to attend to
[10:43:00] mikhael_k33hl: Why am I getting a `undefined method 'to_sym'` for #<Marz::Rsync::Result:0x000000000124dd98> https://gist.github.com/marzdgzmn/518836865851d148abbdfc00e136bf01
[11:17:32] balo: Bish: nope. but you can set it to an envvar in the config file so you can run it like $ WORKERS=4 unicorn -c config/unicorn.rb
[11:19:30] balo: my personal recommendation would be to use a different appserver. puma, phusion or some jruby based
[11:20:39] balo: but we use unicorn for now as well because of _reasons_ and it with some experimenting with server numbers and sizes you can serve quite a lot of traffic with it
[11:22:31] mikhael_k33hl: Tried mocking my module method via mock.expect(Marz::Rsync.run, result, ['/foo1', 'firstname.lastname@example.org:/foo2', ['-a']]) but I'm getting an error: ArgumentError: wrong number of arguments (given 0, expected 2..3)
[11:37:13] mikhael_k33hl: I've selected minitest when I setup my gem, is there a way I can change it to rspec?
[12:49:49] MrGrymReaper: I'm currently wondering whether in Ruby you can do an array, but then have other variables which aren't sub arrays associated with it; for example string, integer, float etc?
[12:55:09] MrGrymReaper: Or some other place where this can come in handly. I managed to do something like this with the Visual Basic 6.0 in the past and really came in handy several times.
[12:57:17] MrGrymReaper: Though are interested in doing this with Ruby as it can be a useful caching method for data as ram is often faster than accessing it from elsewhere. For example hard disks, or from another remote system.
[13:03:26] MrGrymReaper: Or in Ruby game development where you have an inventory and you wish to create it from scratch. Using a array with multiple sub-variables (but not sub-arrays).
[13:06:51] MrGrymReaper: I would like to define an Array in Ruby, but then not create sub-arrays. Though have additional values stored through strings, floats, integer, boolean etc.
[13:10:58] MrGrymReaper: Yes. and no the structure I'm talking about under VB would go something like Define MyArray().Firstname As String etc. Is there something similar for Ruby.
[13:12:10] ineb: but if you dont need the full feature set of an array for your purpose you can look into forwardable
[13:12:50] MrGrymReaper: I'm new to Ruby is there any tutorials, documentation or code please - Gems?
[13:13:25] MrGrymReaper: I'm currently learning Ruby but coming from Microsoft Visual Basic 6.0 Professional.
[13:13:53] ineb: No problem, take a look at Ruby Interitance http://rubylearning.com/satishtalim/ruby_inheritance.html
[13:15:20] ineb: but i wanted to distill the question. and it looks like its boils down 'how to enrich an existing class with features'
[13:15:49] MrGrymReaper: When I do this is it possible for this to be considered for Ruby 2.6 as an additional feature of Array class. For the IO reasons I specified.
[13:16:31] apeiros: indeed. alternative forms of inheritance are (applicability depends of course on what exactly you want to do): refinements, Module#prepend, Object#extend and in rarer cases Module#include
[13:17:10] apeiros: (not entirely sure whether refinements actually truly belong into the inheritance "box")
[13:17:25] apeiros: but apart from refinements, inheritance should usually only be used for classes/objects you own
[13:17:37] ineb: MrGrymReaper: iam still not sure what feature you want to implement. if its something for inventory management in a game, then its unlikely that it will land in the standard libraries :)
[13:20:41] MrGrymReaper: I'm talking about the extending the Array Class in a fashion where you don't always have to use sub arrays. But can use strings, etc in a fashion similar to the VB example given but in a Ruby format. As I found this feature from VB very useful many times and for many different uses. I was wondering whether it would also help Ruby's arrays feature.
[13:22:56] ruby[bot]: ineb: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `' for nil:NilClass
[13:24:22] MrGrymReaper: I'm not talking about hashes which can be accessed by keys. The method I'm reffering to coming from VB was an Array - as it still uses indexes. Though each array could contain many values and many subvariables. In a similar fashion to a database but without actually creating an actual database.
[13:27:30] MrGrymReaper: The values themselves are stored in the subvariables and the array becomes like a database record.
[13:29:56] ineb: well, of course it does in c where you could just store an array of pointers instead of copying the actual value
[13:32:06] MrGrymReaper: In VB you could iterate through the array using a for loop or if you knew the index go straight to the value.
[14:20:54] apeiros: soooo… was this a bug in older rubies or is it a bug in newer rubies? ruby 2.3-: `FileUtils.rmdir(non_empty_dir)` -> no exception, ruby 2.4+: `FileUtils.rmdir(non_empty_dir)` -> Errno::ENOTEMPTY
[14:38:59] apeiros: so it's intentional: https://github.com/ruby/ruby/commit/2635984cf2b9b7632f8b35afa2f29d219aba104a
[14:39:20] apeiros: but I can't see it in NEWS (and since I can't find the file, neither in CHANGELOG)
[14:47:28] apeiros: so https://bugs.ruby-lang.org/issues/13889 is the relevant issue. for some reason I can't update https://bugs.ruby-lang.org/issues/3178 to reference that issue :-(
[15:14:08] mikhael_k33hl: rindolf: thanks man . . just can't seem to make the stub/mock work with modules I guess
[15:23:52] mikhael_k33hl: g-: I'll take a look, it's just video tutorials, based on my experience, gets your hands dirty asap, hehe
[15:36:28] mroutis: for example, I have a controller that does something like: `if resource.save?; send_info_to_third_party; notify_user; render... end`
[15:37:26] mroutis: with rspec, I can describe "POST #create", and before(:each) do "allow(controller).to receive(:sedn_info_to_third_party) and (:notify_user)"
[15:38:26] mroutis: and have a case: "when data is invalid, expect(controller).to_not have_received(:send_info_to_third_party)"
[15:42:06] mroutis: indeed, ineb, but something like `s/current_function/new_function/` will do the work
[15:42:40] ineb: just an example here, instead of send_info_to_third_party you could have an ThirdPartyInformant with #notify or something
[15:43:59] mroutis: yes, that's true, minitests encourages to being able to mock objects in order to add stubs to it
[15:44:50] ineb: its just what iam experiencing if iam using too much expects of have_received and so on
[15:47:45] mroutis: sure! also, if you are collaborating with more people, you need to take into account their skill level and their _code perspective_
[15:48:51] mroutis: sometimes, you are working with someone more "procedural", and they'll make horrible decisions if they are forced to write good OOP code
[15:53:20] mroutis: I guess that the best test suite / codebase is the one where all the involved can be as productive as possible
[16:04:25] mikhael_k33hl: Why am I getting a syntax error for a freshly generated spec_helper.rb from bundle gem
[16:05:43] apeiros_: mikhael_k33hl: you know, when you get exceptions, you *reeeally* should paste them along.
[16:07:25] mikhael_k33hl: apeiros_: Sorry about that, https://gist.github.com/marzdgzmn/c3d7af36c00e52387d50ae12df050e2a
[16:08:21] apeiros_: the error tells you that spec/marz/rsync_spec.rb:22 is where the syntax error is
[16:09:13] mikhael_k33hl: hmm, wait, let me see . . . it's the only file I have in my atom project view
[16:10:31] mikhael_k33hl: by the way, have you guys tried the pragmatic studio ruby/rails course? care to share your thoughts? is it good? :)