Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:33
    HertzDevil labeled #11504
  • 16:33
    HertzDevil labeled #11504
  • 16:33
    HertzDevil labeled #11504
  • 16:32
    HertzDevil opened #11504
  • 14:42
    oprypin review_requested #11496
  • 14:41
    oprypin review_requested #11495
  • 14:41
    oprypin synchronize #11395
  • 14:28
    HertzDevil synchronize #11503
  • Nov 27 19:45
    mohd-akram synchronize #11439
  • Nov 27 19:14
    straight-shoota synchronize #11499
  • Nov 27 18:48
    mgomes ready_for_review #11482
  • Nov 27 18:20
    HertzDevil labeled #11482
  • Nov 27 18:20
    HertzDevil labeled #11482
  • Nov 27 18:17
    HertzDevil synchronize #11495
  • Nov 27 18:02
    HertzDevil labeled #11503
  • Nov 27 18:02
    HertzDevil labeled #11503
  • Nov 27 18:02
    HertzDevil labeled #11503
  • Nov 27 18:02
    HertzDevil opened #11503
  • Nov 27 17:42
    mgomes edited #11482
  • Nov 27 17:28
    mgomes synchronize #11482
From IRC (bridge bot)
@FromIRC
<mfiano> It might be about time for bed :⁠/
George Dietrich
@Blacksmoke16
but to answer your earlier question doing like shards build --release would also technically install dev dependencies, but is likely you're not requiring those in your main code anyway.
would want to use --production or --without-development, can do shards --help for more info
From IRC (bridge bot)
@FromIRC
<mfiano> Where is a good place to put such meta-code as the above?
George Dietrich
@Blacksmoke16
would need to go in your main entrypoint file, or some other file that requires it
oh i have an idea
have a debug.cr file that you put this stuff in
From IRC (bridge bot)
@FromIRC
<mfiano> Does it matter that it's before the main entry point's "require"s?
George Dietrich
@Blacksmoke16
then you can add a {% skip_file if flag?(:release) %} so that the code isn't processed in release mode
From IRC (bridge bot)
@FromIRC
<mfiano> Oh hmm...and where would that macro form go?
George Dietrich
@Blacksmoke16
first line of debug.cr
From IRC (bridge bot)
@FromIRC
<mfiano> Aha!
From IRC (bridge bot)
@FromIRC
<mfiano> I like that better. It probably means I have to explicitly require debug.cr before other requires for this to work properly, rather than an arbitrary *...or I could be wrong
George Dietrich
@Blacksmoke16
i would advise against using like require "./**"
From IRC (bridge bot)
@FromIRC
<mfiano> Yeah I would too
<mfiano> Though I must be doing something wrong here.
<mfiano> i did shards install, but get undefined constant Debug
George Dietrich
@Blacksmoke16
oh well you need to require the lib
require "debug" or whatever it's called
From IRC (bridge bot)
@FromIRC
<mfiano> Yeah I suppose that would help a tiny bit
<mfiano> Well there may be a problem with my crystalline setup or something
George Dietrich
@Blacksmoke16
i never used it so :shrug:
From IRC (bridge bot)
@FromIRC
<mfiano> I get editor error, saying it can't find file 'debug' on the line with require "debug", however, 'crystal run' works fine
George Dietrich
@Blacksmoke16
wonder if its conflicting with that file you just made
oh, or maybe it just doesnt know how to resolve deps like that? i never used it so ill defer to someone else
From IRC (bridge bot)
@FromIRC
<mfiano> That's out of the require path, in src. without a relative path it should only be looking in the stdlib or "lib"
<mfiano> so hmm
<mfiano> Ha you're right
George Dietrich
@Blacksmoke16
:ok_hand:
From IRC (bridge bot)
@FromIRC
<mfiano> and shards install makes a lib/debug/...
<mfiano> Renaming the above gist to debug2.cr and it works
<mfiano> how odd
<mfiano> I just have to keep in mind that I shouldn't have local files with the same name as 3rd party library directories or something
George Dietrich
@Blacksmoke16
pretty much yea
From IRC (bridge bot)
@FromIRC
<mfiano> nah that actually works fine. it seems to be a bug in that the errors in nvim's LSP are cached and not properly invalidated, even across restarts...
Jason Waldrip
@jwaldrip
Why would @type.subclasses return an empty list?
require "json"
require "yaml"

module Pyrite::Kubernetes
  abstract class Spec
    include ::JSON::Serializable
    include ::YAML::Serializable

    macro def_parser
      macro finalized
        {% if @type.abstract? %}
          {% puts @type.subclasses %}
          def self.new(pull : JSON::PullParser)
            location = pull.location

            {% begin %}
              string = pull.read_raw
              {% for subtype in @type.subclasses %}
                begin
                  return {{type}}.from_json(string)
                rescue JSON::ParseException
                  # Ignore
                end
              {% end %}
              raise JSON::ParseException.new("Couldn't parse #{self} from #{string}", *location)
            {% end %}
          end
        {% end %}
      end
    end

    macro inherited
      def_parser
    end

    def_parser
  end
end
is there a point in compilation where I have access to the subclasses?
George Dietrich
@Blacksmoke16
Try adding a \
\{% puts @type.subclasses %}
Jason Waldrip
@jwaldrip
there we go
Jason Waldrip
@jwaldrip
ya, i am very familiar... just been awile
too much time in elixir lately
❯ psykube status --cluster dev
NAME                    STATUS     RESTARTS    AGE
api-665c77fbb9-2dlk9    Running    0           23h2m
api-665c77fbb9-nwmx8    Running    0           23h1m
api-665c77fbb9-rjp6k    Running    0           23h1m
there we go
Jason Waldrip
@jwaldrip
Are there good examples of how the with syntax works with blocks