Hi folks, I'm new to Nim, and statically-typed, compiled languages in general (my main language is Javascript).
To learn Nim, I've been making myself Microblogging web app, and I needed a module to parse syndicated feeds. I found Nim-RSS by Adam Chesak https://github.com/achesak/nim-rss, but it needed some updating and I needed Atom and JSONfeed support too.
So I've made a much expanded module based on Nim-RSS. I probably should have forked the Nim-RSS repository, but I'm a git and Github newb and didn't even think of it until it was too late.
Anyway, it's called FeedNim and it's on Github, if anyone is interested. I'd really appreciate any input (and pull requests!).
Just replying because that logo had me rotfl for about a minute.
Anyway, what SolitudeSF said: it's good to have a new project, but you should use the default nim package manager, nimble.
Download nimble, if you haven't already, run the command nimble init, follow the instructions and copy feed_nim.nim and all other modules into the newly created directory.
Welcome :)
Additional info, you can use to macro to simplify conversion from JsonNode to specified type ;)
Thanks everyone, I thought it would be better to write some tests and make sure it’s at least a little bit stable before submitting to Nimble - is that wrong?
@mashingan I’ve used the to(type) macro in other code, but is there a reason to use it over getStr()?
I’ve used the to(type) macro in other code, but is there a reason to use it over getStr()?
Well, it's convenience, because most of times it's unwieldly to get all the fields one by one
Just replying because that logo had me rotfl for about a minute.
This. That logo is wonderful, I love it. Great job @johnconway! :)
Thanks everyone, I thought it would be better to write some tests and make sure it’s at least a little bit stable before submitting to Nimble - is that wrong?
You can give it a nimble structure without submitting to nimble (basically don't do nimble publish). That would allow interested people to easily use your project with theirs (nimble can fetch arbitary packages that's not in the registry)
Great, thanks for the feedback - so I've given it a proper Nimble structure, and started writing some tests. My god the bugs.
One thing I've been wondering about is how to structure attributes vs contents.
Take a feed element like this:
<generator uri="https://github.com/dom96/jester" >Jester</generator>
The natural way to get at "Jester" in Nim code would simply be feed.generator - but there's an 'href' attribute too. I would like to avoid nesting the main content of elements in (say) feed.generator.text - which would make common accessors too verbose and unintuitive for my liking.
Is there any way in Nim I could have feed.generator give me "Jester" but feed.generator.href give me "https://github.com/dom96/jester"?
You can use a converter:
type
MyObj* = object
text*: string
uri*: string
converter toString (obj: MyObj): string =
result = obj.text
var
generator = MyObj(text: "test", uri: "the uri")
t: string = generator # because of the converter, anything expecting a string can convert the MyObj automatically
echo t
echo generator.uri
Or you could define $ proc