Git Product home page Git Product logo

nyml's People

Contributors

bung87 avatar erikwdev avatar georgelemon avatar jiro4989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nyml's Issues

Cannot use as library, marked as binary

Hi!

The nimble file contains the following:

bin           = @["nyml"]
binDir        = "bin"

which makes it so that we cannot use nyml as a library (cannot import nyml).
nimble install installs a binary nyml which is a program that simply tries to open sample.yaml which is not very helpful.

If this is intended to be a library, remove bin and binDir from the nimble file! If it is indeed intended to be both a binary AND a library, try creating a hybrid structure instead: https://github.com/nim-lang/nimble#hybrids

You can try to do nimble develop --verbose in the root of the project and you will get the following:

Error: Cannot develop packages that are binaries only.

Can't install with nimble

Seems tasks/dev not fetched by nimble.

โฏ nimble install nyml
Downloading https://github.com/openpeep/nyml using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Building nyml/nyml using c backend
/tmp/nimble_157926/githubcom_openpeepnyml/src/nyml/parser_json.nim(11, 9) Warning: imported and not used: 'sequtils' [UnusedImport]
/tmp/nimble_157926/githubcom_openpeepnyml/src/nyml.nim(10, 12) Warning: imported and not used: 'utils' [UnusedImport]
   Success: nyml installed successfully.
       Tip: 6 messages have been suppressed, use --verbose to show them.
     Error: Could not read package info file in /home/unikum/.nimble/pkgs/nyml-0.1.0/nyml.nimble;
        ...   Reading as ini file failed with: 
        ...     Invalid section: .
        ...   Evaluating as NimScript file failed with: 
        ...     /home/unikum/.nimble/pkgs/nyml-0.1.0/nyml.nimble(15, 16) Error: cannot open file: ./tasks/dev
        ... printPkgInfo() failed.
โฏ ls -1 /home/unikum/.nimble/pkgs/nyml-0.1.0/
nimblemeta.json
nyml*
nyml.nimble

Same with git repo.

Fails to parse "---" header in yaml files

https://stackoverflow.com/questions/50788277/why-3-dashes-hyphen-in-yaml-file

If someone's reading YAML files, it's because something else is choosing to emit YAML, and when that something else is Perl it adds a header by default:

% perl -MYAML=Dump -le 'print Dump({some => "content"})'
---
some: content

sample.yaml:

---
name: test
on:
  push:
    paths-ignore:
      - LICENSE
      - README.*
  pull_request:
    paths-ignore:
      - LICENSE
      - README.*
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        nim-version:
          - 'stable'
    steps:
      - uses: actions/checkout@v2
      - uses: jiro4989/setup-nim-action@v1
        with:
          nim-version: ${{ matrix.nim-version }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - run: nimble install -Y
      - run: nim --threads:on c -r src/tim.nim
      - run: nimble test

program.nim:

import nyml
echo readFile("sample.yaml").yaml.toJson

Output with sample.yaml:

/Users/jfondren/nim/bug/nymlbug/src/nymlbug.nim(3) nymlbug
/Users/jfondren/.nimble/pkgs/nyml-0.1.3/nyml.nim(38) toJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/json.nim(1035) parseJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/json.nim(952) parseJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/parsejson.nim(519) eat
/Users/jfondren/nim/nim-1.6.12/lib/pure/parsejson.nim(515) raiseParseErr
Error: unhandled exception: input(1, 3) Error: EOF expected [JsonParsingError]

Output with the same file absent the --- line:

(contents: {"name":"test","on":{"push":{"paths-ignore":["LICENSE","README.*"]},"pull_request":{"paths-ignore":["LICENSE","README.*"]}},"jobs":{"test":{"runs-on":"ubuntu-latest","strategy":{"matrix":{"nim-version":["stable"]}},"steps":[{"uses":"actions/checkout@v2"},{"uses":"jiro4989/setup-nim-action@v1","with":{"nim-version":"${{ matrix.nim-version }}","repo-token":"${{ secrets.GITHUB_TOKEN }}"}},{"run":"nimble install -Y"},{"run":"nim --threadson c -r src/tim.nim"},{"run":"nimble test"}]}}}, rules: @[], hasErrors: false, errors: @[])

Since I have files that I know have the --- header and are otherwise extremely simple, I have this workaround:

import nyml, std/[strutils, sugar]
echo readFile("sample.yaml").dup(removePrefix("---\n")).yaml.toJson

Or without sugar:

import nyml, std/strutils
var contents = readFile("sample.yaml")
contents.removePrefix("---\n")
echo contents.yaml.toJson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.