镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Invalid parsing of object, containing Procs and other nested objects #215

Description

@Mehonoshin

Hey there!
I found the following issue, it does not highlight all fields of such object.

I understand, that it can be complex problem, but maybe anyone has an idea how to solve this?

s = '<Result:false <Skill {"policy.default.eval"=>#<Proc:0x007fc73d75cfb8@/Users/mexx/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/trailblazer-2.0.7/lib/trailblazer/operation/guard.rb:14 (lambda)>, "policy.default"=>nil, "result.policy.default"=><Result:true {} >, "model.class"=>Blog::Post(id: integer, title: string, body: text, published: boolean, created_at: datetime, updated_at: datetime), "model.action"=>:new, "model"=>#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, "result.model"=><Result:true {} >, "contract.default"=>#<Blog::Post::Contracts::Create:0x007fc73aa66f18 @fields={"title"=>"test", "body"=>"123"}, @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, @mapper=#<#<Class:0x007fc73aa66450>:0x007fc73aa5cf18 @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>>, @_changes={"title"=>true, "body"=>true}, @errors=#<Reform::Contract::Errors:0x007fc73aa542c8 @errors={:body=>["size cannot be less than 9", "size cannot be less than 9"]}>>, "contract.default.params"=>{:title=>"test", :body=>"123"}, "representer.default.class"=>false, "result.contract.default"=>#<Blog::Post::Contracts::Create:0x007fc73aa66f18 @fields={"title"=>"test", "body"=>"123"}, @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, @mapper=#<#<Class:0x007fc73aa66450>:0x007fc73aa5cf18 @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>>, @_changes={"title"=>true, "body"=>true}, @errors=#<Reform::Contract::Errors:0x007fc73aa542c8 @errors={:body=>["size cannot be less than 9", "size cannot be less than 9"]}>>} {:current_user=>true, "params"=>{:blog_post=>{:title=>"test", :body=>"123"}}} {"pipetree"=>[>operation.new,>policy.default.eval,>Nested(Blog::Post::Create::Present),>contract.default.validate,>persist.save,>notify!]}> >'


irb(main):008:0> CodeRay.scan(s, :ruby).term

=> "<\e[35mResult\e[0m:\e[1;36mfalse\e[0m <\e[1;34;4mSkill\e[0m {\e[31m\e[1;31m\"\e[0m\e[31mpolicy.default.eval\e[1;31m\"\e[0m\e[31m\e[0m=>\e[1;30m#<Proc:0x007fc73d75cfb8@/Users/mexx/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/trailblazer-2.0.7/lib/trailblazer/operation/guard.rb:14 (lambda)>, \"policy.default\"=>nil, \"result.policy.default\"=><Result:true {} >, \"model.class\"=>Blog::Post(id: integer, title: string, body: text, published: boolean, created_at: datetime, updated_at: datetime), \"model.action\"=>:new, \"model\"=>#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, \"result.model\"=><Result:true {} >, \"contract.default\"=>#<Blog::Post::Contracts::Create:0x007fc73aa66f18 @fields={\"title\"=>\"test\", \"body\"=>\"123\"}, @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, @mapper=#<#<Class:0x007fc73aa66450>:0x007fc73aa5cf18 @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>>, @_changes={\"title\"=>true, \"body\"=>true}, @errors=#<Reform::Contract::Errors:0x007fc73aa542c8 @errors={:body=>[\"size cannot be less than 9\", \"size cannot be less than 9\"]}>>, \"contract.default.params\"=>{:title=>\"test\", :body=>\"123\"}, \"representer.default.class\"=>false, \"result.contract.default\"=>#<Blog::Post::Contracts::Create:0x007fc73aa66f18 @fields={\"title\"=>\"test\", \"body\"=>\"123\"}, @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>, @mapper=#<#<Class:0x007fc73aa66450>:0x007fc73aa5cf18 @model=#<Blog::Post id: nil, title: nil, body: nil, published: nil, created_at: nil, updated_at: nil>>, @_changes={\"title\"=>true, \"body\"=>true}, @errors=#<Reform::Contract::Errors:0x007fc73aa542c8 @errors={:body=>[\"size cannot be less than 9\", \"size cannot be less than 9\"]}>>} {:current_user=>true, \"params\"=>{:blog_post=>{:title=>\"test\", :body=>\"123\"}}} {\"pipetree\"=>[>operation.new,>policy.default.eval,>Nested(Blog::Post::Create::Present),>contract.default.validate,>persist.save,>notify!]}> >\e[0m"

It seems that problem is related to parsing #<Proc:0x007fc73d75cfb8@/Users/mexx/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/trailblazer-2.0.7/lib/trailblazer/operation/guard.rb:14 (lambda)> Procs and other nested objects.

Activity

  1. changed the title [-]Invalid highlight of complex ruby object[/-] [+]Invalid parsing of object, containing Procs and other nested objects[/+] on Sep 5, 2017
  2. korny commented on Sep 6, 2017

    @korny
    Member

    It looks like you're trying to highlight the output of #inspect as Ruby code. However, this isn't valid Ruby syntax – so it's not really CodeRay's fault ;)

  3. Mehonoshin commented on Sep 6, 2017

    @Mehonoshin
    Author

    Yeah, but I'm also trying to solve an issue with higher-level tools, like PRY.
    They use CodeRay for such things highlighting: https://monosnap.com/file/YQVmVscdkzgIkp4holKmq3LhmpQRPe

    And this results that the output is not very pretty.

    I understand that the primary goal of your tool is highlighting of sources, but probably we can implement inspect highlighting too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions