Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:01
    straight-shoota closed #11523
  • 13:35
    straight-shoota demilestoned #11515
  • 13:24
    beta-ziliani unlabeled #11529
  • 13:21
    beta-ziliani demilestoned #11454
  • 13:21
    beta-ziliani demilestoned #11513
  • 13:02
    straight-shoota labeled #11431
  • 13:02
    straight-shoota labeled #11431
  • 13:02
    straight-shoota labeled #11431
  • 13:00
    straight-shoota labeled #11349
  • 13:00
    straight-shoota labeled #11349
  • 12:59
    straight-shoota labeled #11321
  • 12:59
    straight-shoota labeled #11321
  • 12:14
    straight-shoota labeled #11548
  • 12:14
    straight-shoota opened #11548
  • 12:14
    straight-shoota labeled #11548
  • 11:16
    straight-shoota closed #11536
  • 09:44
    BlobCodes synchronize #11094
  • 09:32
    BlobCodes synchronize #11211
  • 07:49
    HertzDevil opened #11547
  • 07:49
    HertzDevil labeled #11547
George Dietrich
@Blacksmoke16
i dont see it on there so would prob need a PR to support it
From IRC (bridge bot)
@FromIRC
<delucks> thanks Blacksmoke16. Do you have any suggestions for how to debug this llvm compilation failure and get more info about where in the crystal codebase needs to be modified?
George Dietrich
@Blacksmoke16
from my understanding since this is a totally new arch, you'd need something like crystal-lang/crystal#3491
however that PR is quite old so im not sure if the exact implementation is still relevant
crystal-lang/crystal#9360 is a more recent example, but it's based on x86_64 as well, so it didn't need to define an abi for that arch
George Dietrich
@Blacksmoke16
granted im no expert on this, just basing things off stuff i read in past PRs/issues but the majority of platform support would be defining the related libC bindings in https://github.com/crystal-lang/crystal/tree/master/src/lib_c, then an abi like the ones https://github.com/crystal-lang/crystal/tree/master/src/llvm/abi, then letting the compiler know about this new target, then any other platform specifics
From IRC (bridge bot)
@FromIRC
<delucks> thanks, super helpful. is there a process for accepting new architectures like this, or would that be a discussion for a future PR?
George Dietrich
@Blacksmoke16
afaik the last one just made a PR
that would probably suffice
could prob reference the rust implementation of the abi as it also uses llvm
nanobowers
@nanobowers
Hello all, new to crystal and trying to migrate some ruby code to crystal in an attempt to learn it. I'm trying to port something that uses rspec yield matchers: https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/yield-matchers
and cannot seem to find a feature in Crystal's Spec that has equivalent functionality. Did I miss something, or is there a shard that does this?
George Dietrich
@Blacksmoke16
whats the thing you're wanting to test?
id just test that versus worrying about how many times something yields or something
nanobowers
@nanobowers
Also, if anyone knows of a cheat-sheet (mapping) of ruby stdlib to crystal stdlib, that would be helpful. There are a lot of similarities, but also plenty of differences and a lot of hunting to find the nearly equivalent thing
Jonathan Silverman
@mixflame
whew ok
Amber patch is perfect, 2 tests, working, and confirmed you don't have to use the hack anymore.
nanobowers
@nanobowers
@Blacksmoke16 For this particular thing i could creat an array and successively yield to construct it, but for some streaming cases maybe that wont work... In this particular case, i picked up a utility written in ruby with rspec tests that i didnt write and have little familiarity with - I was hoping to spend more time in the code and just migrate the tests as closely as possible, but now i'll have a chance to explore both in more detail.
George Dietrich
@Blacksmoke16
can you share the code?
Jonathan Silverman
@mixflame


require "../../../spec_helper"

module Amber
  describe Amber::WebSockets::Adapters::RedisAdapter do

    describe "#initialize" do
      it "should subscribe to CHANNEL_TOPIC_PATHS" do


        _, client_socket = create_user_socket
        _, client_socket2 = create_user_socket

        Amber::Server.pubsub_adapter = Amber::WebSockets::Adapters::RedisAdapter

        channel = UserSocket.channels[0][:channel]
        channel2 = UserSocket.channels[1][:channel]

        channel.subscribe_to_channel(client_socket, "{}")
        channel.subscribe_to_channel(client_socket2, "{}")

        channel2.subscribe_to_channel(client_socket2, "{}")
        channel2.subscribe_to_channel(client_socket, "{}")

        # channel.test_field.last.should eq "handle joined #{client_socket.id}"
        Amber::WebSockets::CHANNEL_TOPIC_PATHS.should eq ["user_room", "secondary_room"]

        redis_adapter = Amber::WebSockets::Adapters::RedisAdapter.new

        sleep 5.seconds

        redis_adapter.subscribed.should eq true
      end
    end

    describe "#publish" do
      it "should publish the message to the channel" do
        _, client_socket = create_user_socket
        _, client_socket2 = create_user_socket

        Amber::Server.pubsub_adapter = Amber::WebSockets::Adapters::RedisAdapter

        channel = UserSocket.channels[0][:channel]
        channel2 = UserSocket.channels[1][:channel]

        channel.subscribe_to_channel(client_socket, "{}")
        channel.subscribe_to_channel(client_socket2, "{}")

        channel2.subscribe_to_channel(client_socket2, "{}")
        channel2.subscribe_to_channel(client_socket, "{}")

        # channel.test_field.last.should eq "handle joined #{client_socket.id}"
        Amber::WebSockets::CHANNEL_TOPIC_PATHS.should eq ["user_room", "secondary_room"]

        redis_adapter = Amber::WebSockets::Adapters::RedisAdapter.new

        sleep 3.seconds

        redis_adapter.subscribed.should eq true

        channel = UserSocket.channels[0][:channel]
        message = JSON.parse({"event" => "message", "topic" => "user_room:123", "subject" => "msg:new", "payload" => {"message" => "hey guys"}}.to_json)
        channel.on_message("123", message)
        channel.test_field.last.should eq "hey guys"
      end
    end


  end
end
George Dietrich
@Blacksmoke16
sorry that was @nanobowers
Jonathan Silverman
@mixflame
oh, my bad
:)
George Dietrich
@Blacksmoke16
can you not just do like
it "with one item" do
  layout.each_line do |a, b|
    a.should eq [1]
    b.should eq 1
  end
end
or something along those lines?
wayy more readable imo
Layout.new*
or whatever the type is
nanobowers
@nanobowers
Yeah, probably so... I've used rspec for some time and never seen even half of the stuff i've seen used in this code.
George Dietrich
@Blacksmoke16
Spec module is deff a lot more simplistic than rspec, IMO for the better most of the time
nanobowers
@nanobowers
Are 'named' globals available? Saw very little discussion in the documentation and the compiler complains when the long-name versions of builtin globals are used e.g. $0 vs $PROGRAM_NAME and $? vs $CHILD_STATUS
George Dietrich
@Blacksmoke16
crystal doesn't have global vars
at least that the user can define on their own. The only real global vars are defined via the compiler, which are like $~ and $1, $n representing regex matches
nanobowers
@nanobowers
Makes sense, will need to add that to my list of things to find the Ruby equivalent for - I think i've figured out $? equiv vias Process.run()
Thanks for all of the help/advice
YusufCakan
@YusufCakan
how to people normally debug the crystal compiler. Are there any instructions on how to do this.
Jonathan Silverman
@mixflame
confirmed amber redis websocket adapter patch is stable and works with multiple amber processes :D
+tests added+
From IRC (bridge bot)
@FromIRC
<postmodern> is there an Enumerable method that finds the last occurance based on a block?
<jhass[m]> mmh, I don't think so but could maybe concort something with with_index and max?
Quinton Miller
@HertzDevil
you cannot traverse backwards with an Enumerable, but there's rindex for Indexable
From IRC (bridge bot)
@FromIRC
<jhass[m]> has some yet unhandled edge cases around the only match being the first one or no match of course
Quinton Miller
@HertzDevil
From IRC (bridge bot)
@FromIRC
<jhass[m]> Indexable#rfind could use reverse_each and break I guess
From IRC (bridge bot)
@FromIRC
<postmodern> how do i specify a literal ASCII string? "\xff\xfe" is being interpreted as a unicode string with one character instead of two
Ali Naqvi
@naqvis
"\u{ff}\u{fe}" if two separate chars
From IRC (bridge bot)
@FromIRC
<postmodern> ah, weird syntax but that seems to work