havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.0, 2.6.5, 2.5.7: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
jenrzzz has joined #ruby
TCZ has quit [Quit: Bye Bye]
Swyper has quit [Remote host closed the connection]
greengriminal has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
alex`` has quit [Quit: WeeChat 2.7]
drincruz has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 260 seconds]
bmurt has joined #ruby
buckworst has joined #ruby
guardian has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
craz has joined #ruby
ur5us has joined #ruby
buckworst has quit [Quit: WeeChat 2.3]
buckworst has joined #ruby
mossplix has quit [Remote host closed the connection]
buckworst has quit [Quit: WeeChat 2.3]
buckworst has joined #ruby
turbo_choo has joined #ruby
DaRock has joined #ruby
buckworst has quit [Quit: WeeChat 2.3]
troulouliou_div2 has quit [Quit: Leaving]
im0nde has joined #ruby
im0nde_ has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
greenhat has quit [Ping timeout: 268 seconds]
Swyper has joined #ruby
buckworst has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
_whitelogger has joined #ruby
AJA4350 has quit [Quit: AJA4350]
wildtrees has quit [Quit: Leaving]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<havenwood> I guess nicer to just use two modules, or an anonymous module.
duderonomy has joined #ruby
<havenwood> I just wanted to: refine(_1) { include oneself } # >.>
jenrzzz has joined #ruby
rubydoc has joined #ruby
craz has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Read error: Connection reset by peer]
buckworst has quit [Quit: WeeChat 2.3]
jenrzzz has joined #ruby
bruce_lee has quit [Ping timeout: 260 seconds]
bruce_lee has joined #ruby
turbo_choo has quit [Ping timeout: 265 seconds]
turbo_choo has joined #ruby
Swyper has quit [Remote host closed the connection]
bruce_lee has quit [Ping timeout: 240 seconds]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
<havenwood> TIL https://rubyapi.org/
cthulchu_ has quit [Ping timeout: 268 seconds]
craz has joined #ruby
fphilipe has quit [Ping timeout: 268 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 260 seconds]
DaRock has quit [Ping timeout: 240 seconds]
DaRock has joined #ruby
guardian has quit [Ping timeout: 268 seconds]
Swyper has joined #ruby
<adam12> havenwood: Interesting :)
<adam12> havenwood: I was just browsing through the Camping source since it's always slightly entertaining and I came across this line. A Ruby 1.8'ism possibly? https://github.com/camping/camping/blob/f2820bbb103f9cfe225647339a4b939560314eec/lib/camping-unabridged.rb#L84
<adam12> &> ?? == 63
<rubydoc> parser error at position 0 around `>'
<havenwood> &>> ?? == "?"
<rubydoc> # => true (https://carc.in/#/r/8cz2)
<adam12> Interesting that it's not normally equal tho 63.chr is ??
<havenwood> adam12: Yup, in 1.9 the character literal switched from returning the ord to returning the chr.
<adam12> havenwood: I completely forgot about it. Intentionally blanked from memory.
<adam12> Back when `id` conflicted.
<havenwood> Hah, yeah, forgetting that one is a win for the brain. :)
jaequery has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
jaequery has joined #ruby
jaequery has quit [Ping timeout: 265 seconds]
buckworst has joined #ruby
buckworst has quit [Client Quit]
buckworst has joined #ruby
buckworst has quit [Client Quit]
xco has joined #ruby
SuperLag has quit [Ping timeout: 265 seconds]
gix- has joined #ruby
gix has quit [Disconnected by services]
SuperLag has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
GodFather has quit [Ping timeout: 265 seconds]
skryking has joined #ruby
nowhere_man has joined #ruby
GodFather has joined #ruby
nowhereman has quit [Ping timeout: 260 seconds]
hays has joined #ruby
hays has quit [Changing host]
hays has joined #ruby
xall has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
guardian has joined #ruby
guardian has quit [Ping timeout: 268 seconds]
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
hays has quit [Ping timeout: 260 seconds]
NODE has quit [Remote host closed the connection]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
skryking has quit [Quit: WeeChat 1.9.1]
NODE has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
NODE has quit [Quit: changing servers]
guardian has joined #ruby
NODE has joined #ruby
tris has quit [Ping timeout: 268 seconds]
NODE has quit [Remote host closed the connection]
guardian has quit [Ping timeout: 268 seconds]
NODE has joined #ruby
NODE has quit [Client Quit]
tris has joined #ruby
NODE has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
lineus has quit [Ping timeout: 240 seconds]
lineus has joined #ruby
jenrzzz has joined #ruby
tris has quit [Excess Flood]
tris has joined #ruby
guardian has joined #ruby
akemhp has quit [Quit: Leaving]
guardian has quit [Ping timeout: 240 seconds]
donofrio has quit [Remote host closed the connection]
xall has quit [Quit: xall]
andikr has joined #ruby
andikr has quit [Remote host closed the connection]
andikr has joined #ruby
CrazyEddy has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
jenrzzz has joined #ruby
gix- has quit [Ping timeout: 258 seconds]
vondruch has joined #ruby
TomyWork has joined #ruby
nowhere_man has quit [Read error: Connection reset by peer]
suukim has joined #ruby
fphilipe has joined #ruby
conta has joined #ruby
ur5us has joined #ruby
NL3limin4t0r_afk has quit [Ping timeout: 258 seconds]
NL3limin4t0r_afk has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
craz has quit [Quit: WeeChat 2.7]
Jonopoly has joined #ruby
conta has quit [Quit: conta]
william1 has joined #ruby
william1 has quit [Quit: WeeChat 1.9.1]
NL3limin4t0r_afk has quit [Ping timeout: 258 seconds]
NL3limin4t0r_afk has joined #ruby
chihhsin_ has quit [Ping timeout: 248 seconds]
emilych has joined #ruby
chihhsin has joined #ruby
<emilych> Hi
<emilych> How can I add elements from one array to a nested array? I have tweo arrays:
<emilych> How can I add elements from one array to a nested array? I have tweo arrays: ```months = ["2019-01-01", "2019-02-01", "2019-03-01", "2019-04-01"] baz = [ ["foo","2019-02-01: 186904","2019-03-01: 196961"], ["bar","2019-01-01: 8876","2019-04-01: 8694"] ]```
<emilych> How can I add elements from one array to a nested array? I have tweo arrays: ```months = ["2019-01-01", "2019-02-01", "2019-03-01", "2019-04-01"] baz = [ ["foo","2019-02-01: 186904","2019-03-01: 196961"], ["bar","2019-01-01: 8876","2019-04-01: 8694"] ]```
<emilych> How can I add elements from one array to a nested array? I have two arrays: ```months = ["2019-01-01", "2019-02-01", "2019-03-01", "2019-04-01"] baz = [ ["foo","2019-02-01: 186904","2019-03-01: 196961"], ["bar","2019-01-01: 8876","2019-04-01: 8694"] ]```
guardian has joined #ruby
NL3limin4t0r_afk is now known as NL3limin4t0r
<emilych> ah, sorry for multiple postings, I was trying to edit my prior post
<NL3limin4t0r> Where should the elements from `months` go? Is each element added to every nested array, or are the elements added to the nested array based on their index?
<emilych> the first: each element is added to every nested array.
<NL3limin4t0r> You can't edit something that is already send. If you want to provide a multiline example use https://dpaste.de
<NL3limin4t0r> then post an link here
<emilych> ah, ok! I'll do. thanks!
<NL3limin4t0r> You where on the right track, but I would use Array#map with Array#+
<NL3limin4t0r> emilych: ^
ur5us has quit [Ping timeout: 260 seconds]
<NL3limin4t0r> Note that the added elements in both nested arrays still refer to the same object, so don't use mutating methods on them.
Fusl has quit [Max SendQ exceeded]
<NL3limin4t0r> aka if you would `output[0][3].sub!("2019-01-01", "")` then both `output[0][3]` and `output[1][3]` will change.
Fusl has joined #ruby
<NL3limin4t0r> Since they both refer to the same `"2019-01-01"` string.
<emilych> oh, wow! thank you very much!!!
<NL3limin4t0r> &ri Array#map
<NL3limin4t0r> &ri Array#+
<NL3limin4t0r> np
<emilych> thanks for the links, I'll check them out!
mossplix has joined #ruby
<NL3limin4t0r> emilych: I've updated my gist. Your solution did already work, but mutates every array inside `monthly_doc_count_for_topic`. So you shouldn't use #map there, simply use #each.
<emilych> ah, I see! thanks for the update!
<NL3limin4t0r> But it works just fine with #map as well, however you shouldn't use the output of it since you're using Array#<< which is a mutating method.
<NL3limin4t0r> Since you've updated `monthly_doc_count_for_topic` you don't have to reasign to a variable.
<NL3limin4t0r> hope I don't make it too confusing
william1_ has joined #ruby
phaul has joined #ruby
<emilych> your explanations are great! thanks again :)
bsdbandit-01 has joined #ruby
renich has quit [Ping timeout: 268 seconds]
bsdbandit-01 has quit [Remote host closed the connection]
<NL3limin4t0r> emilych: If you're not familiar with the terms mutating and non-mutating you might want to give this article a look. https://launchschool.com/blog/mutating-and-non-mutating-methods
<emilych> oh yes, great link! i'll look into it.
bsdbandit-01 has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
ellcs has joined #ruby
bsdbandit-01 has quit [Remote host closed the connection]
bsdbandit-01 has joined #ruby
phaul has joined #ruby
phaul has quit [Client Quit]
Jonopoly has quit [Ping timeout: 240 seconds]
chalkmonster has joined #ruby
mossplix has quit [Remote host closed the connection]
DTZUZO has joined #ruby
mossplix has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
chalkmonster has joined #ruby
chalkmonster has quit [Remote host closed the connection]
chalkmonster has joined #ruby
conta has joined #ruby
turbo_choo has quit [Ping timeout: 240 seconds]
mossplix has quit [Remote host closed the connection]
TCZ has joined #ruby
turbo_choo has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
troulouliou_div2 has joined #ruby
greengriminal has joined #ruby
turbo_choo has quit [Ping timeout: 258 seconds]
turbo_choo has joined #ruby
donofrio has joined #ruby
mkaito_ is now known as mkaito
mkaito has joined #ruby
mkaito has quit [Changing host]
donofrio has quit [Remote host closed the connection]
Jonopoly has joined #ruby
donofrio has joined #ruby
akemhp has joined #ruby
<emilych> Hi, I'd like to extract the date from a string using gsub: "2019-01-01: foobar".gsub(/\d{4}-\d{2}-\d{2}/) but it returns: => #<Enumerator: "2019-01-01: 0":gsub(/\d{4}-\d{2}-\d{2}/)>I was expecting "2019-01-01". Why is it so?
<guzzlefry> emilych: It returns an enumerator unless you pass it a second argument or a code block. Don't ask me why. :)
<emilych> ah, ok! When I puts "2019-01-01: 0".gsub(/\d{4}-\d{2}-\d{2}/, '') it returns : 0
<emilych> what can i do to get "2019-01-01" as return value?
<guzzlefry> emilych: This seems to work, although you might want to do the usual safety checks: "2019-01-01: foobar".match(/\d{4}-\d{2}-\d{2}/)[0]
<emilych> yes, using #match is better!
<emilych> thank you very much!
<ytti> &>> DateTime.parse("2019-01-01: foobar").year
<rubydoc> stderr: -e:4:in `<main>': uninitialized constant DateTime (NameError)... check link for more (https://carc.in/#/r/8d2f)
<ytti> &>> require 'date'; DateTime.parse("2019-01-01: foobar").year
<rubydoc> # => 2019 (https://carc.in/#/r/8d2g)
<guzzlefry> you're welcome, docs with more examples are here: https://rubydoc.info/stdlib/core/String#match-instance_method
mossplix has joined #ruby
mossplix has quit [Read error: Connection reset by peer]
mossplix has joined #ruby
<emilych> great, thanks for the link!
cd has quit [Quit: cd]
<emilych> oh, @ytti DateTime.parse is more elegant, thanks!
greengriminal has quit [Quit: Leaving]
DaRock has quit [Ping timeout: 260 seconds]
emilych has quit [Remote host closed the connection]
alex`` has joined #ruby
emilych has joined #ruby
<emilych> Is it possible to remove an element in array by its value? for example %w[ foo bar baz].shift("bar") #shift expects an index in integer format but is there an alternative?
<emilych> ah, found #delete
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
AJA4350 has joined #ruby
mossplix has quit [Remote host closed the connection]
chalkmonster has joined #ruby
mossplix has joined #ruby
bsdband46 has joined #ruby
<guzzlefry> Anyone here using RubyMine? Completion seems lacking and I'm wondering if it's just a misconfiguration issue.
bsdbandit-01 has quit [Ping timeout: 268 seconds]
bsdbandit-01 has joined #ruby
bsdband5 has joined #ruby
phaul has joined #ruby
bsdband46 has quit [Ping timeout: 248 seconds]
bsdbandit-01 has quit [Ping timeout: 265 seconds]
<NL3limin4t0r> guzzlefry: What do you mean with "completion seems lacking"? Doesn't it work at all? Don't you see all all posible options?
<guzzlefry> NL3limin4t0r: It doesn't seem to realize that match returns MatchSet or `nil` given this: foobar".match(/\d{4}-\d{2}-\d{2}/)
<emilych> Hi, I have another question regarding array kungfu: https://dpaste.org/HkZV
<emilych> I'd like to remove elements with "ba" from an array by keeping it's structure. my attempt flattens the array
<emilych> given = [['yes', 'foo', 'bar'], ['no', 'baz', 'bazz']]; goal = [['yes', 'foo'],['no']]; temp_array = [] my_attempt = given.each do |topic| topic.map { |el| temp_array << remove_ba(el) } end.compact
hays has joined #ruby
hays has quit [Client Quit]
bsdband5 has quit [Ping timeout: 265 seconds]
<al2o3-cr> emilych: given.map { |a| a.reject { |e| e[/ba/] } }
<emilych> oh, wow! amazing! thank you very much!!!
<al2o3-cr> emilych: yw
turbo_choo has quit [Ping timeout: 260 seconds]
bsdbandit-01 has joined #ruby
turbo_choo has joined #ruby
xco has quit [Quit: Textual IRC Client: www.textualapp.com]
bmurt has joined #ruby
<phaul> or a.grep_v(/ba/) slightly more succint
<phaul> instead of the a.reject {...} part
TCZ has quit [Quit: Bye Bye]
<al2o3-cr> +1 phaul :)
<phaul> hi al2o3-cr :)
<al2o3-cr> o/
Tikku has joined #ruby
conta has quit [Quit: conta]
bsdbandit-01 has quit [Ping timeout: 258 seconds]
Tikku has quit [Quit: Leaving]
<guzzlefry> oof, Programming Ruby seems to be leaving out details. :P
<guzzlefry> I'm guessing Ruby is doing some sort of pattern matching for the variables passed to the block? [["for", 2], ["word", 2], ["use", 2], ["the", 3], ["a", 6]].each { |word, count| puts "#{word}: #{count}"}
suukim has quit [Quit: Konversation terminated!]
voker57_ has quit [Quit: voker57_]
voker57 has joined #ruby
bsdband95 has joined #ruby
alexherbo2 has joined #ruby
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
<emilych> ah, thanks Paul!
<NL3limin4t0r> guzzlefry: You can find all about the RubyMine code completion here: https://www.jetbrains.com/help/ruby/auto-completing-code.html , there is also a trouble shooting section for problems that can often occure
<NL3limin4t0r> guzzlefry: for that last part of your code, there is no pattern matching involved. as soon as you put a comma in the block parameters and the only thing passed to the block is an array it applies implicit array decomposition
<NL3limin4t0r> &>> proc { |element_1, element_2| "#{element_2} - #{element_1}" }.call(["a", "b", "c"])
<rubydoc> # => "b - a" (https://carc.in/#/r/8d35)
<NL3limin4t0r> &>> proc { |element_1, element_2| "#{element_2} - #{element_1}" }.call("a", "b", "c")
<rubydoc> # => "b - a" (https://carc.in/#/r/8d36)
<NL3limin4t0r> &>> proc { |element_1, element_2| "#{element_2} - #{element_1}" }.call("not only", ["an", "array"], "!")
<rubydoc> # => "[\"an\", \"array\"] - not only" (https://carc.in/#/r/8d37)
<NL3limin4t0r> ^ Maybe the above are better expresed using #then, but the point stays the same.
AJA4350 has quit [Read error: Connection reset by peer]
AJA4351 has joined #ruby
AJA4351 is now known as AJA4350
mossplix has quit [Remote host closed the connection]
jmcgnh has quit [Read error: Connection reset by peer]
troulouliou_div2 has quit [Remote host closed the connection]
jmcgnh has joined #ruby
drincruz has joined #ruby
mgxm has quit [Quit: ....]
mgxm has joined #ruby
<emilych> Hi, I'm still struggling with array manipulation: https://dpaste.org/T1OT
<guzzlefry> What's a colong?
vondruch has quit [Ping timeout: 260 seconds]
<emilych> colon
<emilych> `:`
<emilych> I want to transform given = [ "2019-01-01", "2019-02-01", "2019-02-01: 186904", "2019-03-01", "2019-03-01: 196961", "2019-04-01", "foo"]# remove date-string-element without a colon if a "twin" date-string-element with colong exists:goal = [ "2019-01-01", "2019-02-01: 186904", "2019-03-01: 196961", "2019-04-01", "foo"]
<emilych> goal = [ "2019-01-01", "2019-02-01: 186904", "2019-03-01: 196961", "2019-04-01", "foo"]
TomyWork has quit [Ping timeout: 256 seconds]
NEETzsche has joined #ruby
<NEETzsche> Hi there
<NEETzsche> So I know that Ruby has open classes, but is there a way to open up a class when the class is submitted as a variable?
<NEETzsche> Like in a module, where it's self.included(klass)
<NEETzsche> Can you klass.open_up do
<NEETzsche> Or something to that effect?
<NEETzsche> I know there's class_eval
<NEETzsche> But I'm trying to circumnavigate Rails 6.0's "Class level methods will no longer inherit scoping from" deprecation warning.
SeepingN has joined #ruby
<havenwood> emilych: Hmm, wondering if this meets the requirements?:
<havenwood> &>> given.group_by { |s| s[0..9] }.flat_map { |key, values| key.match?(/\d{4}-\d{2}-\d{2}/) ? [values.max_by(&:size)] : values }
<rubydoc> stderr: -e:4:in `<main>': undefined local variable or method `given' for main:Object (NameError)... check link for more (https://carc.in/#/r/8d48)
<havenwood> oh, right - I need coffee.
<havenwood> emilych: It satisfies the goal for the case you laid out, but not sure if the lack of checking colons is problematic.
<emilych> awesome, thank you very much!!!
<havenwood> emilych: you're welcome!
<havenwood> NEETzsche: I'm curious to see the code triggering the deprecation warning.
<emilych> havenwood do I understand it correct, that you filtering by size of the string?
<emilych> that's totally fine
<havenwood> emilych: Yup. I'm grouping by the first 10 characters, so dates stay together. Then from the ones that match the date regexp, taking the longest one, presuming it's the date with the colon and stuff.
cow[moo] has quit [Ping timeout: 268 seconds]
anveo has joined #ruby
bsdband95 has quit [Remote host closed the connection]
<emilych> cool, that's exactly what I needed! thanks again!
andikr has quit [Remote host closed the connection]
Swyper has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has quit [Quit: WeeChat 2.7]
alexherbo2 has quit [Remote host closed the connection]
<NEETzsche> havenwood: I can't post the exact code because it's proprietary but I can share something that functions similarly
<NEETzsche> # lib/modules/doohicky.rb
<NEETzsche> module Doohicky
<NEETzsche> def self.included (klass)
<NEETzsche> klass.scope :my_scope, , -> { klass.where(:col => [VAL_A, VAL_B]) }
<NEETzsche> end
<NEETzsche> end
<NEETzsche> # app/models/some_model.rb
<NEETzsche> class SomeModel < ActiveRecord::Base
<NEETzsche> include Doohicky
<NEETzsche> end
<NEETzsche> Oops, two commas after :my_scope.
cthulchu_ has joined #ruby
<NEETzsche> I figured it out. I'm stupid
<NEETzsche> I should be using klass.scope :my_scope, -> { where (:col => [VAL_A, VAL_B]) }
<NEETzsche> Instead of klass.scope :my_scope, -> { klass.where(:col => [VAL_A, VAL_B]) }
joast has quit [Quit: Leaving.]
lucasb has joined #ruby
dviola has joined #ruby
RiPuk_ has joined #ruby
RiPuk has quit [Ping timeout: 268 seconds]
joast has joined #ruby
Xiti` has joined #ruby
Mia has quit [Read error: Connection reset by peer]
vampirehunter has joined #ruby
Mia has joined #ruby
cthu| has joined #ruby
wildtrees has joined #ruby
wildtrees has quit [Max SendQ exceeded]
wildtrees has joined #ruby
cthulchu_ has quit [Ping timeout: 240 seconds]
kent\n has quit [Ping timeout: 240 seconds]
kent\n has joined #ruby
Xiti has quit [Ping timeout: 268 seconds]
Jonopoly has quit [Quit: WeeChat 2.5]
wildtrees has quit [Max SendQ exceeded]
wildtrees has joined #ruby
bmurt has joined #ruby
JoeA2552 has joined #ruby
akemhp_ has joined #ruby
akemhp has quit [Ping timeout: 258 seconds]
NODE has quit [Remote host closed the connection]
akemhp_ has quit [Ping timeout: 265 seconds]
suukim has joined #ruby
NODE has joined #ruby
akemhp has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
akemhp has quit [Ping timeout: 260 seconds]
anatolik has joined #ruby
<anatolik> Hello folks. I am trying to use gitlab with ruby2.7 and I have a weird issue that I do not understand. Here is the link to the error description https://gitlab.com/groups/gitlab-org/-/epics/2380#note_269347237
<anatolik> It says 'ArgumentError (wrong number of arguments (given 3, expected 1..2))' but the callee has exactly 3 arguments. What is wrong with the code?
ellcs has quit [Ping timeout: 260 seconds]
chalkmonster has joined #ruby
Mawhrin-Skel has joined #ruby
RiPuk_ has quit [Ping timeout: 240 seconds]
RiPuk has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
phaul has quit [Ping timeout: 265 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
fphilipe has quit [Ping timeout: 265 seconds]
RiPuk has quit [Ping timeout: 240 seconds]
RiPuk has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
<adam12> anatolik: Did it ever work? The issue is that the splat (*args) is more than 1 argument if the array contains more than 1 element.
<adam12> anatolik: Nothing changed in that regard from 2.6 to 2.7, at least that I can tell.
<havenwood> anatolik: A single arg in `*arg` would happen to work.
<havenwood> &>> def foo(realm = nil); p realm end; foo 1, 2, 3 # *args
<rubydoc> stderr: -e:4:in `foo': wrong number of arguments (given 3, expected 0..1) (ArgumentError)... check link for more (https://carc.in/#/r/8d6e)
<havenwood> anatolik: Like adam12 says, I'd have expected: *realms
<havenwood> anatolik: Or `arg` instead of `args`.
<havenwood> *args
<adam12> anatolik: I'd probably go up the tree a bit to find out where the Rack::OAuth2 middleware is being used, and see what it looks like. Something like `use Rack2::OAuth2, someargs`.
<adam12> s/tree/stack. I'm in tree mode over here apparently.
<havenwood> Climb the tree!
chalkmonster has joined #ruby
<adam12> O_O
greenhat has joined #ruby
jaequery has joined #ruby
drincruz_ has joined #ruby
drincruz has quit [Read error: Connection reset by peer]
drincruz has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
drincruz_ has quit [Ping timeout: 268 seconds]
<adam12> use Rack::OAuth2::Server::Resource::Bearer, 'The API' do |request|
<adam12> Single arg :\ Must be something else somewhere else that's mutating args.
burningserenity has joined #ruby
davispuh has joined #ruby
akemhp has joined #ruby
phaul has joined #ruby
<anatolik> Is there any way to get a more descriptive stack pointing where exactly the problem occures? I can modify the rails app if needed.
drincruz_ has joined #ruby
duderonomy has quit [Ping timeout: 258 seconds]
drincruz has quit [Ping timeout: 258 seconds]
phaul has quit [Ping timeout: 260 seconds]
davidw has joined #ruby
duderonomy has joined #ruby
Ven`` has joined #ruby
<adam12> anatolik: A few different methods. Are you familiar with byebug or pry at all? And are either of them dependencies in Gitlab (check Gemfile)
<havenwood> +1 pry-byebug
<havenwood> ?pry
<adam12> anatolik: You'd probably have to modify the rack-oauth2 dependency, find the `initialize` method, change it to accept multiple args. Then see what you're being passed. I'd probably start there, to get an idea if it's something stupid.
<adam12> havenwood: No ruby bot :O
nowhere_man has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gix has joined #ruby
Synthead has joined #ruby
<Synthead> Hey all, I'm looking to upgrade a gem because it doesn't build (grpc 1.19.0 on glib 2.30). It's a dependency to some other gems, and I'm trying to find what's pinning it at 1.19.0. Is there a way to check the gem dependency versions of other gems to figure this out?
<havenwood> Synthead: Can you tell from the Gemfile.lock?
vampirehunter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> Synthead: I guess I should back up. Are you using Bundler with a Gemfile?
<havenwood> Synthead: Show the command you're running and error output?
<adam12> grpc, the pain of all pain.
<Synthead> havenwood: I see this :)
<Synthead> grpc (1.19.0)
<Synthead> google-protobuf (~> 3.1)
<Synthead> googleapis-common-protos-types (~> 1.0.0)
<Synthead> I am using Bundler with a Gemfile :)
<Synthead> This is the PR I'm trying to use in a later version: https://github.com/grpc/grpc/pull/18950
<Synthead> there are two issues mentioned in the PR body that describes the issue
<Synthead> Basically, glibc provides its own gettid, which causes issues with grpc 1.19.0's own gettid
alex`` has joined #ruby
alexherbo2 has joined #ruby
<erikh> is grpc a pain in ruby?
<erikh> I'm doing some stuff around it in golang, but with the intention of helping others use it in other languages; wondering how it plays out
<erikh> (an API gateway you could use ruby to talk to)
sauvin has quit [Ping timeout: 265 seconds]
<erikh> is writing/generating a grpc client for a given set of protos a big pain in the rear?
<havenwood> erikh: It certainly works in Ruby. With large organization, GRPC protos sprawl, get weird, and then nobody maintains the C-extensions. :P
<erikh> ha
<erikh> strange that it doesn't build against a specific glibc though
<erikh> that locks it out of a lot of OSes and there usually isn't a good reason for it
<erikh> maybe the author needed strfry()
TCZ has joined #ruby
<erikh> Synthead: to answer your question -- unless rubygems has changed dramatically in the last few years -- you will have to run the mkmf.rb extensions for all the gems you bundle
<erikh> to test this linking
<Synthead> it was just a coincidence that glibc provided its own gettid, which broke stuff with grpc
<erikh> ohhhhh
<erikh> wait waht
<Synthead> erikh: that's no problem
<erikh> ok I'm going to just look past the fact there's a function called gettid in grpc at all
<erikh> oy
<erikh> I really doubt you will see this problem in other libs
<erikh> The gettid() system call first appeared on Linux in kernel 2.4.11. Library support was added in glibc 2.30.
<erikh> what version of linux are you on? are you comfortable answering that? gotta be at least RHEL5
<erikh> you may have other issues coming.
<erikh> ok I can't spend too much time on this, but good luck with your upgrade
SeepingN has joined #ruby
<Synthead> I'm on glibc 2.30 :)
<Synthead> arch linux
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jaequery has quit [Remote host closed the connection]
<adam12> erikh: My issue with grpc is probably because I run on FreeBSD and it often has a lot of Linux'isms in it. That said, I find Twirp from the Twitch folks very nice to work with if Ruby+Go is your stack.
<adam12> (grpc has the linuxisms, not Fbsd :)
<erikh> yeah, grpc probably has a ton of linux-isms in the server
fphilipe has joined #ruby
skryking has joined #ruby
<erikh> wait what
<erikh> sigh
cthu| has quit [Ping timeout: 258 seconds]
fphilipe has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
suukim has quit [Quit: Konversation terminated!]
troulouliou_div2 has joined #ruby
chalkmonster has joined #ruby
vampirehunter has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
bruce_lee has quit [Ping timeout: 265 seconds]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
jaequery has joined #ruby
vampirehunter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
jaequery has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alex`` has quit [Quit: WeeChat 2.7]
william1_ has quit [Ping timeout: 260 seconds]
davispuh has joined #ruby
<anatolik> wrt my previous message. I see somewhat suspicious warning:
<anatolik> /usr/share/webapps/gitlab/vendor/bundle/ruby/2.7.0/gems/rack-2.0.7/lib/rack/builder.rb:89: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
<anatolik> /usr/share/webapps/gitlab/vendor/bundle/ruby/2.7.0/gems/grape-1.1.0/lib/grape/middleware/base.rb:13: warning: The called method `initialize' is defined here
<anatolik> could it be related?
<anatolik> here is the Grape code
<anatolik> def initialize(app, **options)
<anatolik> @options = default_options.merge(**options)
<anatolik> @app_response = nil
<anatolik> @app = app
<anatolik> end
lucasb has quit [Quit: Connection closed for inactivity]
<adam12> anatolik: It's possible. Maybe try changing **options to `options = {}`? Not sure if that will work but changes it back to single argument.
turbo_choo has quit [Ping timeout: 258 seconds]
turbo_choo has joined #ruby
vampirehunter has joined #ruby
<jidar> Does anybody know about `Content-Type: application/octet-stream` when using File.open in Net::HTTP::Post? I think that may be causing my http post to fail against a jenkins server. I'm attempting to write a POST method to validate jenkinsfile and I can get it to work with curl, but the http 200 response I get back when using ruby is `No Jenkinsfile specified`
<jidar> https://gist.github.com/fd3bb44650414d49fead30c4e8d86201 method used to make http post
vampirehunter has quit [Client Quit]
<jidar> I can also post the gist of a working http session I captured when using curl
<jidar> oh, form_data is a array like so: [['jenkinsfile', File.open()]]
bmurt has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
jenrzzz has quit [Ping timeout: 268 seconds]
duderonomy has joined #ruby
skryking has quit [Quit: Konversation terminated!]
nfsnobody has quit [Ping timeout: 264 seconds]
jaequery has joined #ruby
nfsnobody has joined #ruby
duderonomy has quit [Ping timeout: 265 seconds]
<anatolik> adam12: I added a bunch of "puts" around the code and found that "def use(middleware, *args, &block)" from rack receives *args
<anatolik> "The API"
<anatolik> #<Proc:0x0000558105c72168 /usr/share/webapps/gitlab/lib/api/api_guard.rb:13>
<anatolik> i.e. *args includes 2 parameters
<anatolik> instead of "The API" is in args and then block
william1_ has joined #ruby
<anatolik> here is the caller
chalkmonster has joined #ruby
<anatolik> # OAuth2 Resource Server Authentication
<anatolik> use Rack::OAuth2::Server::Resource::Bearer, 'The API' do |request|
<anatolik> # The authenticator only fetches the raw token string
<anatolik> # Must yield access token to store it in the env
<anatolik> request.access_token
<anatolik> end
alex`` has joined #ruby
Synthead has quit [Ping timeout: 258 seconds]
skx86 has quit [Quit: Connection closed for inactivity]
ur5us has joined #ruby
stryek has joined #ruby
phaul has joined #ruby
<jidar> it looks like https://docs.ruby-lang.org/en/2.5.0/Net/HTTPGenericRequest.html#method-i-body-3D checks the following: `type = h[:content_type] || 'application/octet-stream'` so maybe there's a way to set content_type I'm missing
DTZUZO has quit [Ping timeout: 260 seconds]
burningserenity has quit [Quit: The Lounge - https://thelounge.chat]
DTZUZO_ has joined #ruby
alexherbo2 has joined #ruby
william1_ has quit [Ping timeout: 265 seconds]
Synthead has joined #ruby
<adam12> anatolik: Interesting :) out of curiosity, what happens if you use parens when calling use? use(Rack::OAuth2::Server::Resource::Bearer, "The API") do |request|
donofrio has quit [Remote host closed the connection]
Synthead has quit [Client Quit]
<anatolik> restarting service right now.... it takes ages
<anatolik> interesting enouth all other caller's args is just a single hash like
<anatolik> {:versions=>["v4"], :version_options=>{:using=>:path}, :prefix=>:api, :mount_path=>"/"}
<anatolik> adding parens does not change anything. args still includes the block
<anatolik> "The API"
<anatolik> #<Proc:0x0000562505a35590 /usr/share/webapps/gitlab/lib/api/api_guard.rb:14>
nullheroes has quit [Quit: WeeChat 2.5]
<adam12> Trippy.
william1_ has joined #ruby
<adam12> anatolik: if you can get a debugger to fire in the initialize method (binding.irb, binding.pry, byebug), maybe you can get a copy of the stack and determine what's calling it with that argument? Something has to be globbing the proc into that array.
jaequery has quit [Ping timeout: 240 seconds]
duderonomy has joined #ruby
<anatolik> I honestly total noob in this stuff. I'll check with gitlab folks, maybe they can debug the issue
duderonomy has quit [Client Quit]
<anatolik> will post the findings here https://gitlab.com/groups/gitlab-org/-/epics/2380
cthu| has joined #ruby
eddof13 has joined #ruby
duderonomy has joined #ruby
<adam12> anatolik: OK good luck.
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
emilych has quit [Remote host closed the connection]
william1_ has quit [Ping timeout: 268 seconds]
drincruz has joined #ruby
TCZ has quit [Quit: Bye Bye]
jenrzzz has joined #ruby
drincruz_ has quit [Ping timeout: 268 seconds]
ropeney has quit [Ping timeout: 240 seconds]
mkaito has quit [Quit: ZNC 1.7.5 - https://znc.in]
mkaito has joined #ruby
mkaito has quit [Changing host]
mkaito has joined #ruby
jack6 has joined #ruby
<jack6> Hi
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NODE has quit [Remote host closed the connection]
<jack6> Is it possible to mix ruby code into HTML, juste like PHP ??
<jack6> By using a apache module, such as mod_ruby
yokel has quit [Ping timeout: 240 seconds]
NODE has joined #ruby
Fusl has quit [Max SendQ exceeded]
yokel has joined #ruby
Fusl has joined #ruby
alexherbo20 has joined #ruby
<adam12> jack6: mod_ruby hasn't been recommended for a long time. It had thread safety issues last time I looked.
alex`` has quit [Ping timeout: 240 seconds]
<adam12> jack6: That's not to say you can't use Ruby with Apache, but you have to go further back in time than mod_php started, and get back to mod_cgi (the glorious 1990's)
sameerynho has joined #ruby
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo20 is now known as alexherbo2
<adam12> jack6: Ruby ships with a reasonably nice cgi library in stdlib, so you could get going immediately without any dependencies by just making a cgi-bin/your-ruby-script.rb and requiring "cgi".
Mia has quit [Read error: Connection reset by peer]
<adam12> jack6: The Rack library also includes a CGI handler, but CGI can be sometimes a bit quirky. Sometimes you need to do creative work-arounds which can be kind of a drag.
alex`` has joined #ruby
<adam12> jack6: I created a simple URL shortener with only a Rack dependency which runs as a CGI script. It's here: https://github.com/adam12/shorturl
<adam12> jack6: And Mike Perham blogged about something similar here: https://www.mikeperham.com/2015/01/05/cgi-rubys-bare-metal/
william1_ has joined #ruby
nowhere_man has quit [Ping timeout: 240 seconds]
<jack6> thanks
<jack6> so Is it not possible to mix ruby code into HTML ?
<jack6> without templating
william1_ has quit [Ping timeout: 268 seconds]
fphilipe has joined #ruby
jaequery has joined #ruby
<adam12> jack6: Nope.
<jack6> thank you
fphilipe has quit [Ping timeout: 248 seconds]
orbyt_ has joined #ruby
Ven`` has quit [Read error: Connection reset by peer]
jack6 has left #ruby [#ruby]
dkmueller has joined #ruby
skx86 has joined #ruby
jcalla has quit [Quit: Leaving]
turbo_choo has quit [Ping timeout: 268 seconds]
drincruz has quit [Read error: Connection reset by peer]
drincruz_ has joined #ruby
turbo_choo has joined #ruby
JoeA2552 has quit [Quit: Textual IRC Client: www.textualapp.com]
nowhere_man has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
akemhp has quit [Quit: Leaving]
akemhp has joined #ruby
endorama has joined #ruby
tryhard21 has joined #ruby
<leftylink> really good news! (I only took two years to discover this, when in fact this has been possible since 2.5)
<leftylink> you know if you mutate a hash key after having stored it, the key becomes inaccessible in the hash
<leftylink> &>> a = []; h = {a => 5}; a << 1; [h[a], h[[]], h[[1]], h[h.keys[0]]]
<rubydoc> # => [nil, nil, nil, nil] (https://carc.in/#/r/8d7f)
<leftylink> but there is a way to repair your hash!
dkmueller has quit [Quit: WeeChat 2.7]
<leftylink> &>> a = []; h = {a => 5}; a << 1; h.transform_keys!(&:itself); [h[a], h[[]], h[[1]], h[h.keys[0]]]
<rubydoc> # => [5, nil, 5, 5] (https://carc.in/#/r/8d7g)
<leftylink> great!!!!!!!!!!!!!
<leftylink> you cannot achieve the same effect with tranfsorm_values! so please do not try that.
<leftylink> &>> a = []; h = {a => 5}; a << 1; h.transform_values!(&:itself); [h[a], h[[]], h[[1]], h[h.keys[0]]]
<rubydoc> stderr: -e:4:in `transform_values!': can't add a new key into hash during iteration (RuntimeError)... check link for more (https://carc.in/#/r/8d7h)
<leftylink> merge!({}) will also not save you, but {}.merge(h) will.
<leftylink> assuming you assign that result back to h
markopasha has joined #ruby
<erikh> &>> [].hash
<rubydoc> # => 1412622445482097437 (https://carc.in/#/r/8d7i)
<leftylink> I am so happy that there is a way to repair your hash
<erikh> &>> a = []; p a.hash; a << 1; a.hash
<rubydoc> # => 3392237245996162351... check link for more (https://carc.in/#/r/8d7j)
markopasha has quit [Max SendQ exceeded]
<erikh> they are different hash values
<erikh> very important when dealing with ruby hashes
markopasha has joined #ruby
dinfuehr has quit [Ping timeout: 260 seconds]
guzzlefry has left #ruby ["Leaving"]
<erikh> I think the underlying lesson here is to not use mutable structures as hash keys
<erikh> but that's just me
<leftylink> h = h.to_h will have no effect, but h = h.to_a.to_h obviously will work
dinfuehr has joined #ruby
<leftylink> h.select! { true } will not help, but h = h.select { true } will (both of these results make sense)
<leftylink> doing the same with reject and false gives the same result
<erikh> ...
<leftylink> oh
<leftylink> in fact
<leftylink> &ri Hash#rehash
<erikh> Object#hash is the only thing hashes care about
<erikh> I think it's on Object at least
<leftylink> that is the method purpose-built for that purpose.
<erikh> if you mutate the key, it can't look up the item any more because the hash has changed
<leftylink> &ri Set#reset
<leftylink> and se wee that a set also has the same
<leftylink> it is sort of punny
<erikh> because sets are hashes
<leftylink> they're both re- plus the class name, and both are valid english words even after that prefix has been added
<leftylink> whereas obviously there is no such thing as, you know, reinteger or reobject
<leftylink> &ri Integer#reinteger
<rubydoc> Found no entry that matches class Integer instance method reinteger
<leftylink> of course not
<erikh> *facepalm*
erikh has left #ruby ["WeeChat 2.7"]
<leftylink> I am very glad to have discovered this great news today
bambanx has joined #ruby
jnoon has joined #ruby
<leftylink> in general I would expect anything creating a new hash to rehash the keys. so h = h.dup would also do so
vampirehunter has joined #ruby
craz has joined #ruby
Ai9zO5AP has quit [Quit: WeeChat 2.5]
<craz> Hi beginner question here again: I have these two files: https://pastebin.com/GwZCsgQP everything is working fine, and my /api/v1/.. endpoints are working. My question is how I can put all code in base.rb instead of including defaults.rb. If I just yank the code and put it in base.rb instead of the include, my endpoints stop working
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> craz: Do a `require_relative 'base'` in defaults.rb.
<havenwood> craz: By convention, the path structure should match the class namespace.
<havenwood> craz: API::Base should be in lib/api/base.rb
<havenwood> craz: Which is in the same directory as API::Defaults, which is: lib/api/defaults.rb
<havenwood> craz: If you setup $LOAD_PATH, like you would for a gem, you can just: require 'api/base'
<havenwood> craz: Alternatively, you can require it locally, and it's in the same directory so no path change: require_relative 'base'
william1_ has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
william1_ has quit [Ping timeout: 258 seconds]
davispuh has joined #ruby
eddof13 has quit [Quit: eddof13]
hays has joined #ruby
eddof13 has joined #ruby
sameerynho has quit [Ping timeout: 268 seconds]
eddof13 has quit [Client Quit]
hays has quit [Client Quit]
bvdw has quit [Read error: Connection reset by peer]
hays has joined #ruby
hays has quit [Changing host]
hays has joined #ruby
<Scriptonaut> hey all, I have ruby 2.3.0 installed and managed by rbenv. When I try to install bundler I get: bundler requires RubyGems version >= 2.5.2. Try 'gem update --system' to update RubyGems itself.
<Scriptonaut> I have another machine with the same environment and don't have this issue
<Scriptonaut> I can get passed it if I pass a --force flag, but then things break down later
bvdw has joined #ruby
<Scriptonaut> this is how that ruby version shipped, any idea what's going on?
<havenwood> Scriptonaut: First, Ruby 2.3 is past EoL and receives no security patches.
<Scriptonaut> I'm using a ruby gem that doesn't support anything past that
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<havenwood> Scriptonaut: It's normal to upgrade RubyGems separately from Ruby. If your Ruby can't use the modern RubyGems, use an older Bundler.
sh7d has quit [Quit: meh]
<havenwood> Scriptonaut: Can you just upgrade RubyGems?
<havenwood> Scriptonaut: What gem is it that requires Ruby 2.3??
<Scriptonaut> it's a standalone sinatra server and afaik it's the only thing that does what it does