Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:34
    Blacksmoke16 labeled #11541
  • 15:27
    Blacksmoke16 closed #5636
  • 14:01
    asterite labeled #11541
  • 14:01
    asterite opened #11541
  • 10:11
    straight-shoota milestoned #11539
  • 04:46
    jgaskins opened #11540
  • Dec 04 22:54
    straight-shoota closed #11437
  • Dec 04 20:54
    BlobCodes synchronize #11211
  • Dec 04 20:51
    BlobCodes synchronize #11211
  • Dec 04 20:46
    BlobCodes synchronize #11211
  • Dec 04 17:55
    HertzDevil synchronize #11230
  • Dec 04 17:46
    BlobCodes synchronize #11211
  • Dec 04 17:44
    BlobCodes synchronize #11211
  • Dec 04 17:37
    BlobCodes synchronize #11211
  • Dec 04 16:10
    HertzDevil edited #11537
  • Dec 04 15:06
    HertzDevil synchronize #11230
  • Dec 04 15:03
    HertzDevil synchronize #11230
  • Dec 04 15:03
    BlobCodes synchronize #11211
  • Dec 04 14:13
    straight-shoota closed #11516
  • Dec 04 14:13
    straight-shoota closed #11492
From IRC (bridge bot)
@FromIRC
<mfiano> Right, I'm looking at debug.cr right now...they say you can call Debug.enabled = true if you don't want to set an env var, so I'm wondering if I can check some flag as to not call that in release builds
George Dietrich
@Blacksmoke16
{% unless flag? :release %}
  Debug.enabled = true
{% end %}
would be true whenever its built without --release
From IRC (bridge bot)
@FromIRC
<mfiano> You mean the inverse ;⁠)
<mfiano> But, thanks
George Dietrich
@Blacksmoke16
i mean Debug.enabled would be true w/o --release
From IRC (bridge bot)
@FromIRC
<mfiano> Oh yes you're right, I read your description wrong.
<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 %}