Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rupkl

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rupkl

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version CI Maintainability codecov

RuPkl

A Pkl parser for Ruby.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add rupkl

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install rupkl

Usage

You can use the methods below to load a Pkl code into a Ruby structure:

  • RuPkl.load
    • Load the given Pkl code into a Ruby structure
  • RuPkl.load_file
    • Load a Pkl code read from the given file path into a Ruby structure
require 'rupkl'

pkl = <<~'PKL'
  // From:
  // https://pkl-lang.org/main/current/language-tutorial/01_basic_config.html
  name = "Pkl: Configure your Systems in New Ways"
  attendants = 100
  isInteractive = true
  amountLearned = 13.37
PKL

RuPkl.load(pkl)
# =>
# {:name=>"Pkl:Configure your Systems in New Ways",
#  :attendants=>100,
#  :isInteractive=>true,
#  :amountLearned=>13.37}

File.open('sample.pkl', 'w') do |f|
  f.write(<<~'PKL')
    // From:
    // https://pkl-lang.org/main/current/language-tutorial/01_basic_config.html
    bird {
      name = "Common wood pigeon"
      diet = "Seeds"
      taxonomy {
        species = "Columba palumbus"
      }
    }

    exampleObjectWithJustIntElements {
      100
      42
    }

    exampleObjectWithMixedElements {
      "Bird Breeder Conference"
      (2000 + 23)
      exampleObjectWithJustIntElements
    }

    pigeonShelter {
      ["bird"] {
        name = "Common wood pigeon"
        diet = "Seeds"
        taxonomy {
          species = "Columba palumbus"
        }
      }
      ["address"] = "355 Bird St."
    }

    birdCount {
      [pigeonShelter] = 42
    }
  PKL
end

RuPkl.load_file('sample.pkl')
# =>
# {:bird=>{:name=>"Common wood pigeon", :diet=>"Seeds", :taxonomy=>{:species=>"Columba palumbus"}},
#  :exampleObjectWithJustIntElements=>[100, 42],
#  :exampleObjectWithMixedElements=>["Bird Breeder Conference", 2023, [100, 42]],
#  :pigeonShelter=>
#   {"bird"=>{:name=>"Common wood pigeon", :diet=>"Seeds", :taxonomy=>{:species=>"Columba palumbus"}},
#    "address"=>"355 Bird St."},
#  :birdCount=>
#   {{"bird"=>{:name=>"Common wood pigeon", :diet=>"Seeds", :taxonomy=>{:species=>"Columba palumbus"}},
#     "address"=>"355 Bird St."}=>42}}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/taichi-ishitani/rupkl.

Notice

Pkl code snippets used for RSpec examples are originaly from:

Copyright © 2024 Taichi Ishitani. RuPkl is licensed under the terms of the MIT License, see LICENSE.txt for further details.

Code of Conduct

Everyone interacting in the RuPkl project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc