Page 1 of 2 | Next »
[18:15:48] LyndsySimon: I'm building a docker image for a Rails app I'm working with, and was a little stunned by something - the source for the app is 178kB, but the gem dependencies are 103MB.
[18:21:11] LyndsySimon: fschuindt: I totally expected the dependencies to be many times larger than the source - that's the point of a higher-level language, after all. I guess it shocked me a bit that they're ~500x larger.
[14:13:12] LyndsySimon: Bish: I've not touched it, other than to read the docs. I don't write Ruby outside of work, as a rule.
[15:19:10] LyndsySimon: Bish: because I'm honestly not a huge fan of Ruby, like I said. I am a fan of writing stuff I like, though, and this CSV gem is one of those things. Hence, I'm writing Ruby in my personal time even though it's not my preferred language and not something I would normally work in without a financial reason.
[15:41:17] LyndsySimon: It just doesn't fit the way I think about problems as well as many other languages. Personal preference is all.
[15:42:06] LyndsySimon: If I had to wrap my complaints into a single statement, I'd say: Ruby encourages developers to create things that behave in unexpected and difficult-to-debug ways.
[15:43:13] LyndsySimon: Metaprogramming, for instance. It's a pain in the ass in Python, and as a result while it's available it's something that isn't done much unless it's really the best solution. It's super-easy in Clojure, and as a result at least when you run in to it, it's more obvious what's happening and easier to debug.
[15:44:13] LyndsySimon: Ruby takes a more middle path. It's approachable for less-experienced developers, but it has a much steeper learning curve and it's not always obvious when you're dealing with something you don't fully understand.
[15:45:49] LyndsySimon: ... because it doesn't conform to the class syntax used elsewhere, and because classes in Ruby don't have metaclasses in the same way that other languages do ...
[15:53:41] LyndsySimon: havenwood: I don't think it's a bad idea, and I don't think Ruby is a bad language. I just prefer a different way of dealing with it :)
[15:54:29] LyndsySimon: Bish: It's more flexible without question. I just see the point of this sort of language to be to reduce the depth at which I have to think about things when I'm writing code. For me, Python does that much more effectively than Ruby
[15:54:48] LyndsySimon: I really miss Python decorators when I'm working in Ruby, much more than I miss blocks in Python.
[16:00:09] LyndsySimon: havenwood: Right - that's exactly my complaint with Ruby. It's not that it's lacking features, it's that it has too many features.
[15:56:33] LyndsySimon: I'm considering writing a gem to ease CSV parsing in Ruby - if you have a sec, I'd appreciate a quick review of the short README. I'm looking for community input before I decide whether or not writing it is worth my time: https://gitlab.com/lyndsysimon/ideas/blob/master/csv_parser.md
[15:59:58] LyndsySimon: Bish: Oh? I've honestly never used it. I came up with this idea after discussing options to reduce code duplication for CSV import scripts in a web app at work.
[16:00:34] LyndsySimon: I'm kind of on a kick writing DSLs right now, and it seemed like a natural fit. Too much work to justify it for work, but not if others find it useful.
[16:00:56] LyndsySimon: Bish: Yes, fields are defined by default in the order they are presented in the file.
[16:01:26] LyndsySimon: Bish: I've not yet thought much about title rows. I may just exclude them, or I may allow you to define fields based upon the titles in the title row.
[16:02:03] LyndsySimon: Bish: My favorite DSL I've written so far is for defining datatables. It's written on top of ajax-datatables-rails.
[16:04:33] LyndsySimon: Bish: It's still rough :) I planned to support using it as an object or a keyword, and to allow you to register new types as keywords.
[16:05:07] LyndsySimon: The "from: last_name" part, I was thinking that the field was named "last_name" in the CSV. Like I said, not fully formed, just trying to illustrate the overall idea.
[16:07:00] LyndsySimon: Bish: What about the idea of splitting out the process into several steps? i.e., schema definition, row validation, excluding rows, processing rows, etc.
[16:08:09] LyndsySimon: Bish: My general approach is to handle the 80% use case first, and by default. Only schema definition and per-row processing would actually be required.
[16:08:55] LyndsySimon: Ideally, I'd like most uses of my code to be only a few short, clear, concise lines. Only if things deviate from the norm should there be additional complexity exposed to the dev.
[16:10:08] LyndsySimon: Anyhow, thanks for letting me bounce the idea off you :) I have an inkling I may write the gem this week for fun.
[16:11:20] LyndsySimon: FWIW I'm not a huge fan of Ruby as a language. I come from a Python background mostly and have branching out into more functional languages, specifically those centered on immutable types. I've discovered that I really like Ruby for writing DSLs though.
[16:12:19] LyndsySimon: My problem is time. This gem seems like something I can whip up fairly quickly, and something that won't require a ton of ongoing maintenance.
[16:13:26] LyndsySimon: I've dabbled in Haskell. It fits the way I think, but I'm not yet fluent in the syntax. Every time I go back to it, I get to the point where I'm overwhelmed by the terminology that's used - monads, functors, et. al.
[16:14:01] LyndsySimon: Clojure fits me pretty well too, but I find that every time I get in the flow I have to reach back into Java for something and it breaks my flow.
[16:15:04] LyndsySimon: Nim is very, very interesting to me. The only real issue I have with it is that the standard library uses mutable types by default.
[16:19:25] LyndsySimon: I'm skimming the docs now. I love it. It's both simpler and more powerful that ActiveRecord.
[16:23:16] LyndsySimon: I will point out that you were just making fun of me for seeing this kind of thing as fun, though :)
[16:27:11] LyndsySimon: CSV is actually quite sane - it's the implementations that make you want to shoot yourself.
[16:28:10] LyndsySimon: Bish: I got a commit into the Nim core repo a while back! https://github.com/nim-lang/Nim/commit/8ea78b1bc9dc0b4d883b4f0750ee84e93605b82a#diff-172294a35ce6ecdb390ca1d591297682
[16:29:54] LyndsySimon: I want to say there's a problem where it only allows escaping quotes with `""`, instead of `\"`, or vice versa. It's been a while.
[19:21:03] LyndsySimon: There's a lookup table for methods, and another for variables in scope. Right?
[19:25:14] LyndsySimon: OK, I think I understand the eval.in - the existence of an in-scope variable `x` means that it shadows the method `x`, which is a method. Adding parens skips the lookup in the variable table(s), so it gets the actual object.
[19:25:53] LyndsySimon: My problem is that I need to assign the Integer - the callable - to a variable, then call it on another object later.
[19:26:29] LyndsySimon: `x` does in fact contain the object I want to call, but neither method allows me to actually call it. Is there another way to call it?
[19:30:00] LyndsySimon: dminuoso: ... but `Integer '`'` works. I assume there is something special in `Integer` that tells it to call `Integer()` if it's being called and not assigned to a variable?
[19:37:42] LyndsySimon: The DSL stuff I'm working on where I needed that piece of functionality is now working - thanks dminuoso and apeiros
[14:30:24] LyndsySimon: I'm working on a project where we have substantial manual QA testing, in addition to our automated tests that use Capybara. Does anyone have experience using Capybara to automate the setup to particular states for the purposes of manual testing?
[14:31:05] LyndsySimon: Basically, I'd like to run the user's browser for as long as it takes to do environment setup tasks - logging in, creating some stuff, then dropping them on a page and giving them back control.
[14:44:58] LyndsySimon: MrBusiness: Yes, it's a web app. The "state" would be a combination of client state (i.e., session, including cookies and LocalStorage) and server state (including database contents).
[14:46:06] LyndsySimon: Basically, I want to be able to run a test that's already using Capybara, but instead of executing the test I want to stop there and let a user take over.
[14:47:42] LyndsySimon: I'd like to wrap this in a GUI of some type - either a desktop app, a web interface or a browser extension. That would require that I split the test setup and teardown from the test suite and put it in a structure that's readable and usable for this as well. That should be possible.
[14:53:06] LyndsySimon: matthewd: Ideally, yeah. We're not going to be able to get away from manual testing completely, no matter what. The software is for the healthcare industry, so it's very important that we be as confident as possible that things in the UI in particular not break.
[14:53:36] LyndsySimon: In my experience, automated testing is awesome for making sure things don't break in the same way they have in the past. It's not as great for making sure they don't break in new and exciting ways.
[14:58:50] LyndsySimon: teatime: Actually, I was trying to be a bit more precise. Codifying the "happy path" of expected user interaction isn't technically regression testing, and that's the primary stuff I meant.
[14:59:05] LyndsySimon: matthewd: Yes, a visual diffing tool is on my list of things to incorporate.
[15:00:21] LyndsySimon: That's not *quite* what I'm looking for. I don't want to tell them what to do, that's sorta their job description.
[15:00:51] LyndsySimon: I just want to automate what they're already having to do by hand, and since I'm already having to do it for automated testing, I'd rather just put an additional interface over that existing code than do it twice.
[15:06:09] LyndsySimon: matthewd: The data are too big for a DB restore to be a viable solution, and a big part of this is going to be navigating them through the app to the right spot. There's also the part where they're testing against a deployed instance of the application with anonymized PHI data pre-loaded. Acting against the DB directly is not out of the question, but is a fairly high barrier.
[15:06:25] LyndsySimon: I've got some ideas how to do it now - it's just a matter of making it happen.
[12:46:41] LyndsySimon: I've been asked to move all of the models of a fairly mature Rails app into a gem so they can be used in other contexts. I've not been able to find where others have done this in the past - does anyone here know where I could start?
[14:15:12] LyndsySimon: tcopeland: Thanks :) I'll read that to file it away mentally, but I have found some stuff that will keep us from doing it and convinced the people who matter in this case that it's a bad idea.
[14:15:55] LyndsySimon: I mean it's a bad idea for us because it doesn't get us closer to accomplishing what we're trying to do, not because there is anything inherent wrong with the concept.
[14:01:59] LyndsySimon: I'm looking for a generic way to convert an objects externally accessible instance variables into a hash. Is there some way to introspect Object that I'm not seeing?
[14:07:29] LyndsySimon: matthewd: Maybe this will help - https://gist.github.com/lyndsysimon/dfa513f92d6711f6b55056763ba94f44
[14:08:01] LyndsySimon: matthewd: I'm well aware of the ability to "reach in to" objects and access instance variables directly. :)
[14:11:21] LyndsySimon: I get that, I'm just surprised that there isn't an Array kept somewhere of calls to attr_reader/attr_accessor
[14:21:28] LyndsySimon: dminuoso: I don't see how would help in this particular case... but yes, I would prefer static typing for this project.
[14:21:47] LyndsySimon: konsolebox: Yes. If there isn't a built-in method to do this, I can write one easily enough.
[14:30:06] LyndsySimon: Here's the solution I ended up with, for this one-off use case: https://gist.github.com/lyndsysimon/3ff4e6df02702ef4b4565bf1012e4962
[13:26:50] LyndsySimon: I know Ruby has the concept of "autoload", and that Rails has a similar concept and builds on it with "eager loading". I'm looking for a way to eager load all files in a directory, preferably without hooking into Rails' `config.eager_load_paths`, since I want it to happen even when Rails' eager loading is turned off (i.e., in local development).
[13:29:05] LyndsySimon: You know what? Scratch that. I was trying to strip out part of a complex problem I'm working on, and I think I just figured out a way to avoid it entirely.
[13:29:19] LyndsySimon: I'm still interested if someone has an answer, but it's not blocking me anymore :)
[14:47:50] LyndsySimon: ljarvis: Is there any easier way to "require all files in a directory" other than enumerating them and building the require statements dynamically?
[15:07:24] LyndsySimon: ljarvis: You don't happen to have that one-liner handy, do you? My head is full of other context and I'd like at least document this.
[14:27:14] LyndsySimon: I keep having issues with RVM. Is there a comparable tool out there I could use?
[14:49:09] LyndsySimon: rickumali: I hate to be a pain, but I'm setting up rbenv and am not seeing what I need in their docs.
[14:51:21] LyndsySimon: ljarvis: This is slightly beyond my knowledge at the moment. My background is in Python and I fully understand how virtualenvs work there. Does Ruby have a *need* for gemsets?
[14:52:02] LyndsySimon: I'm working on projects that have Gemfiles created by bundler. I've just never used them outside of rvm
[14:52:32] LyndsySimon: havenwood: How does that reconcile with what elomatreb said? Can I have multiple versions of the same gem installed concurrently?
[14:54:02] LyndsySimon: How does Bundler do that? If I call `rails console`, for instance, is the ruby interpreter that it's calling aware of the gemfiles and able to specific the gem versions that way?
[14:54:27] LyndsySimon: havenwood: Yep, I'm familiar with the file structure :) I just need to understand what it's doing so I can troubleshoot things.
[14:56:08] LyndsySimon: Ahh, OK. So with rvm, I don't have to prefix commands because it's shimming the shell commands. With rbenv, I have to use bundle's explicit management to do things in the "environment" (which in actuality is just Bundler loading and passing the specs from the gemfiles to Ruby before executing the commands I pass in)
[14:58:40] LyndsySimon: My system ruby is 2.4.1 (Installed via homebrew). My project's ruby is 2.3.1. I've installed it via rbenv. How do I use bundler now to install the gems from the gemfiles?
[15:00:04] LyndsySimon: Yes, my system ruby is 2.4.1. I've specified 2.3.1 in .ruby-version. rbenv installed it fine.
[15:02:29] LyndsySimon: Maybe this will help: I'm sharing my screen at this link: https://appear.in/how-to-ruby
[15:03:49] LyndsySimon: `ruby --version` is 2.3.1. Bundler says I'm using 2.4.1. That's because I have Bundler installed in my system ruby but not in the rbenv-controlled 2.3.1.
[15:04:06] LyndsySimon: There's a `bundle` command in my system ruby, but not one in my 2.3.1 environment, therefore it isn't shimmed.
[15:05:37] LyndsySimon: havenwood: I see that, and now I understand exactly what `rbenv rehash` does.
[15:06:13] LyndsySimon: You have to rehash not whenever a gem is installed, but whenever a gem is installed that includes executables you want to access from the shell.
[15:08:19] LyndsySimon: havenwood: That's a good idea, but there are other changes happening concurrently (upgrading rails). Instead, I plan to lead a project to migrate the whole team from rvm.
[15:09:16] LyndsySimon: Somewhat annoyingly, rvm requires the ruby version right now to be 'ruby-2.3.1', while rbenv wants it to be '2.3.1'. That means there's going to have to be a point where we all move over at once :(
[15:10:34] LyndsySimon: I'm comfortable doing that now. I already more fully understand rbenv than I ever did rvm. I hate magic.
[15:12:23] LyndsySimon: Heh. While I'm on macOS, I'll read the linux version first. I'm a Linux user using macOS, so it's easier for me to grok that way.
[15:17:55] LyndsySimon: valerauko: I can't speak for Ruby, but that's the approach I've taken in the past for other projects. Just be prepared for the PR to be rejected initially, and for the people who do so to be at least a bit gruff about it :)
[15:19:28] LyndsySimon: Feel free to shoot me a message if you want a quick code review before submitting your PR, I'd be happy to.
[15:41:27] LyndsySimon: sagax, havenwood: I'll also say that when I was playing with writing a cryptocurrency exchange, my model was to use an append-only log for all transactions. That helped me maintain an audit trail and know where I could divide work between workers concurrently and when it needed to be executed in series.
[15:44:35] LyndsySimon: havenwood: I've got chruby+ruby-install working now. So far so good - except that I need an equivalent to rehash :)
[15:45:11] LyndsySimon: havenwood: For instance, which I `gem install bundler`, I had to reload my shell session for `bundle` to point to the one I just installed. Same thing for rails.
[15:49:30] LyndsySimon: Doesn't seem to be. When I install bundler, it doesn't show up on my path under I reload.
[15:58:29] LyndsySimon: adaedra: I like monofur because the "e" is easy to read. I wish it was easier to distinguish multiple underscores, though.
[16:04:14] LyndsySimon: Yeah - it's gotta be something in my shell. It appears that chruby is doing the right thing, because it got added to the directory that's first in my path, it just doesn't resolve to that. I wonder if zsh is caching the location of the executable from the previous call or something.
[16:11:03] LyndsySimon: Well, of course. I just mean that it's like the symbol isn't available on Linux.
[16:14:32] LyndsySimon: AFK. I've been working from a diner, and my battery is low enough I should walk back to work. :(
[16:54:01] LyndsySimon: pupsicle: I would actually explain that differently. Foo.bar is calling "bar", a method of "Foo". Foo.new.bar is calling "bar", a method of "Foo.new", which of course is an instance of "Foo". It's not so much a matter of the order things are happening as it is becuase of the fact that an instance of a class is a discrete object, and doesn't share methods with the class from which it is derived.
[16:55:06] LyndsySimon: You know what, scratch that. I'm overcomplicating, and thought you had defined self.bar.
[15:28:42] LyndsySimon: When defining an ActiveSupport::Concern, should instance methods be defined inside the `included` block, or directly on the module?
[13:38:21] LyndsySimon: Is it a stupid idea to have a concern that is included in both models and controllers?
[13:38:45] LyndsySimon: It's for configuration handling, which on the app I'm working on is quite unique.
[13:41:29] LyndsySimon: Our config is a cascade, with "tenant" and "department" being the levels. The concern resolves the correct config object based upon the tenant and department in context for a model or controller instance.
[13:42:38] LyndsySimon: The config object is my own creation, and is where the vast majority of the business logic lives. The concern is just the way the correct config object is resolved. It provides hooks to specify the department to which an instance of a model belongs (or to which a controller belongs)
[13:46:43] LyndsySimon: I'm under time pressure at the moment, and there's too much business logic in there to share it at the moment.
[14:46:31] LyndsySimon: Pretend I've got a magical concern that tells me if the current model instance is "good", or "evil". I include that concern in my `ApplicationRecord`, so it's by extension included in all my models.
[14:47:43] LyndsySimon: In my controller, let's say I've assigned the instance variable `@foo` to an instance of a model. In my view, I can use `<%= @foo.alignment =>` and it'll return either 'good' or 'evil'.
[14:49:37] LyndsySimon: Now imagine that I want to create a view partial that is included on every page of my application that has the object's alignment as an overlay on the page. I can still call `@foo.alignment` of course, but on some pages there is no `@foo`. `FooController#show` sets `@foo`, but `BarController#show` sets `@bar`.
[14:50:25] LyndsySimon: Make sense? I'm looking for a generic way to reference the primary object for the page, be it an instance of a model or a queryset.
[15:09:56] LyndsySimon: I'm asking if there is a Rails convention for naming the generic object. It's looking like there isn't.
[15:15:02] LyndsySimon: ACTION points out that mordof is needed by someone, and that's more than many people can ever say about themselves :)