roadie has quit [Remote host closed the connection]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
roadie has joined #ruby
FetidToot4 has joined #ruby
FetidToot has quit [Ping timeout: 272 seconds]
FetidToot4 is now known as FetidToot
shokohsc52 has joined #ruby
shokohsc5 has quit [Ping timeout: 272 seconds]
shokohsc52 is now known as shokohsc5
<ox1eef_>
adam12: Cool +1
TomyWork has quit [Remote host closed the connection]
TomyLobo has joined #ruby
Jojero has joined #ruby
<adam12>
happy friday!!
Jojero has quit [Client Quit]
<ox1eef_>
Same to you =]
Jojero has joined #ruby
<adam12>
ox1eef_: how goes
<adam12>
I've actually had a nice Thursday evening / Friday. Started with a developer meetup last night, and then today, a casual "co-working" with another developer at a coffee shop + lunch. Not a bad way to round out the week.
Jojero has quit [Ping timeout: 272 seconds]
<ox1eef_>
Quiet day. Still haven't solved streaming audio on iOS. Kind of works, though.
user23 has joined #ruby
<adam12>
ox1eef_: What language are you using for that? Swift?
<ox1eef_>
HTML5 + <audio> + TypeScript.
<adam12>
Ahh.s
<ox1eef_>
I have X tracks, and I want one to stream after another. But browsers won't start the stream until the user clicks a button or something like that. Works fine on my laptop, but on iOS it is hit and miss.
<adam12>
I guess an "infinite" stream is out of the question? Seems like it would require a server component you might not want to implement.
reset has joined #ruby
<ox1eef_>
Beforehand I was inserting one <audio> per track. That works on the laptop. On iOS you have to re-use the same audio tag (by updating its src), and that will keep the permissions. But it will get stuck (buffering I guess), and never recover properly.
<adam12>
Hmm :\
<adam12>
Can you use the `link` preload type stuff to maybe pre-load the next track before replacing the src?
<adam12>
Not sure that works with audio tracks.
<ox1eef_>
Yep, that's a good idea. I was holding off on that but it might be the best option in the end.
<ox1eef_>
I believe it does.
gabrielcsf has quit [Remote host closed the connection]
<John_Ivan_>
adam12, may I ask for some advice in regards to the nature of a particular problem in coding?
<John_Ivan_>
I'm dealing with parsing. in particular, a simple iniparser.
<John_Ivan_>
adam12, I'm writing tests. my functions take strings.
<ox1eef_>
First rule of IRC. Don't ask to ask. Just ask.
<John_Ivan_>
but I feel like, when two words, "parsing" and "strings" come together, it just overcomplicates programming so much that I get overwhelmed when it comes to testing because there's just so many ways things can break..
<John_Ivan_>
I have a mere 8 functions but I can write over 10 tests per function. realistically, 80 unit/integration tests would be necessary for something I'm working on that, really should be simple
<John_Ivan_>
a mere ADD/REMOVE/EDIT cli tool that takes in keys and values and manipulates them in a .ini file
<John_Ivan_>
adam12, I don't know if that's really the nature of this kind of problem, but I feel like it's far too... unreal for what it should be.
roadie has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
<adam12>
John_Ivan_: I'm more of a visual person. Do you have code examples?
<John_Ivan_>
adam12, I can but I don't know if it's going to help. I think it's best I give you the whole overview of the project. I'll provide code after; I just think it's best I give this overview.
<John_Ivan_>
adam12, I want to make a cli tool. call it "tag.exe"
<John_Ivan_>
it works with a .ini file
<John_Ivan_>
adam12, it's input is a file, and a string, as commandline arguments
<John_Ivan_>
it associates those two in the ini file, with the file path as the key. and the tags as a string.
<John_Ivan_>
adam12, that's it. that's really it
<John_Ivan_>
adam12, it has 5 operations. add, rem, set, del, list
<John_Ivan_>
e.g flags
<adam12>
John_Ivan_: Not sure what the question was. 80 tests doesn't seem unreasonable.
<John_Ivan_>
adding a tag, associating it with that file. adding more tags to the same file. removing them from the association. setting (overwriting the whole tags)
<adam12>
John_Ivan_: You could try to do mutation testing if you wanted, or some sort of meta programming.
<adam12>
But it seems pretty straight forward.
<John_Ivan_>
it's straight forward but it can break in so many ways and I just don't know what to do.
<John_Ivan_>
it "should be" straightforward**
<John_Ivan_>
adam12, let's take adding tags for example
<John_Ivan_>
the "add" operation can break if there's no ini file present. it can break if the ini file doesn't exist. that's 2 tests already. on 1 function.
<adam12>
Why should `add` care about the ini file?
<John_Ivan_>
adam12, because it's job is to insert data inside it.
<adam12>
Wouldn't that be the responsibility of the IniFile class?
<John_Ivan_>
adam12, yes but add uses the IniFile class.
<adam12>
which could be re-used by the methods to add/rem/set/del/list.
<adam12>
Right, but you don't need to necessarily test that function in IniFile.
<John_Ivan_>
I don't need to test the inifile itself per se. but I need to test that my function works correctly.
<John_Ivan_>
either manually. or with an integration test.
<adam12>
Without seeing code we're kinda spitballing here.
<John_Ivan_>
adam12, alright.
<adam12>
But if you have `add(tag)`, what does it do? The simplest thing woudl be to manipulate some sort of in-memory object.
<adam12>
Oh, I think I got it.
<adam12>
Your tag.exe does add as a command line?
<adam12>
tag.exe add foobar
<John_Ivan_>
adam12, correct. "tag.exe add "my tags here" file_path.txt"
<John_Ivan_>
let me show you my add function
<adam12>
There's a phrase "walking skeleton test", which is essentially, you acceptance test your tag.exe.
<adam12>
But you want the walking skeleton to be minimal, only testing happy paths and maybe 1 or 2 sad paths, because they are usually slower than unit tests.
<adam12>
Then make a smaller CLI wrapper that you can test by passing in ARGV.
<adam12>
ie. YourTagApp::CLI.new(argv).run. Then you can just simulate it through automated testing, no shell / exec involved.
<John_Ivan_>
adam12, but you see what I'm getting at? I can legit think of 80 ways to break my software, all coming from a few simple functions. it's annoying...
<adam12>
I gotta run, end of week meetings. But I'll try to answer when I can.
<John_Ivan_>
sure
<John_Ivan_>
thank you
<adam12>
John_Ivan_: The solution is to abstract that portion away and write the tests for that once.
<adam12>
Then everything else just receives a well tested object and works around it. `add` shouldn't care about the file, necessarily. The IniFile should. But this isn't really super explainable as pseudo code over IRC.
<adam12>
Extract your IO to one spot and that's your boundary. Everything else should be minimal and not require disk access/file/etc. Test IO extensively, and all the rest of your tests are likely simple.
<adam12>
ttyl.
<John_Ivan_>
bye
markong has quit [Ping timeout: 272 seconds]
duderonomy has quit [Remote host closed the connection]
duderonomy has joined #ruby
flambo74 has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
goldfish has joined #ruby
brokkoli_origin has quit [Ping timeout: 240 seconds]
brokkoli_origin has joined #ruby
brokkoli_origin has quit [Remote host closed the connection]
<weaksauce>
John_Ivan_ fwiw sqlite was written specifically to be an answer to what you're doing
<weaksauce>
namely they compete on fopen as one of their stated goals
<weaksauce>
Replacement for ad hoc disk files: Many programs use fopen(), fread(), and fwrite() to create and manage files of data in home-grown formats.
flambo74 has quit [Remote host closed the connection]
flambo74 has joined #ruby
_ht has quit [Quit: _ht]
perrierjouet has quit [Quit: WeeChat 4.0.1]
flambo74 has quit [Remote host closed the connection]
caedmon has quit [Ping timeout: 272 seconds]
smp has quit [Ping timeout: 245 seconds]
<John_Ivan_>
weaksauce, the issue is sqlite is that I have to introduce a foreign language.
<John_Ivan_>
with*
<weaksauce>
since when doesn't sqlite work with japanese?
<John_Ivan_>
weaksauce, I meant, it requires the SQL query format. **and** it's storage isn't a plain text file like ini that can be modified manually.
<weaksauce>
except you can modify it manually using a db tool
<weaksauce>
dbbeaver
<weaksauce>
or dbeaver actually
<John_Ivan_>
weaksauce, the whole purpose of the tool I'm creating was to encourage the lack of a sophisticated tool
<John_Ivan_>
no indexing. no sql. no binary format.
<John_Ivan_>
in fact
<John_Ivan_>
weaksauce, it originally was meant to be no "iniparser" either, but my code stretched to 250+ lines of code without it
<John_Ivan_>
who knew parsing was such a complicated task
<John_Ivan_>
weaksauce, even more originally, I was looking for a key-pair storage cli tool in the GNU toolbox
<John_Ivan_>
found nothing other than the ENV string, which, frankly, isn't for that.
<weaksauce>
that seems to be weak benefit for the extra work you incur for it
<John_Ivan_>
weaksauce, honestly, I'm conflicted.
<weaksauce>
a text editor is a tool just the same as a basic db browser
<John_Ivan_>
it was meant to be a simple project. with simple requirements.
<John_Ivan_>
weaksauce, and it is simple. I'm just, not good at coding parsers.
<John_Ivan_>
I have code written. i just, have anxiety on what I've written because this thing can break so easily
<John_Ivan_>
it works
<John_Ivan_>
it does the job
<John_Ivan_>
I just want to make it more resilient
<John_Ivan_>
but no matter how I look at it, to do that, would require a tremendous amount of tests
<weaksauce>
write those tests i guess
<John_Ivan_>
weaksauce, 80+ tests? no. not happening. not for a project with 8 functions lol
Linux_Kerio has quit [Ping timeout: 245 seconds]
<John_Ivan_>
weaksauce, I'd go with sql. I just don't want a separate tool to edit the database manually
<John_Ivan_>
and I really don't like depending on a separate language
<weaksauce>
a text editor is a separate tool
<weaksauce>
you do you but these seem pretty arbitrary as requirements go
<John_Ivan_>
weaksauce, it's so common that there's probably 20 of them on different platforms, than finding a specialized sqlite db browser
tomtmym has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
<John_Ivan_>
weaksauce, they're personal requirements. i like transparency and simplicity.
<John_Ivan_>
weaksauce, would you really solve this problem with sql?
<John_Ivan_>
or any storage problem in general?
<ox1eef_>
SQLite is simple, but that's relatively and subjectively speaking.
<John_Ivan_>
ox1eef_, I just want to know if sqlite is the defacto solution for all storage problems
<John_Ivan_>
because if it is, then what I'm doing here is... nonsense.
<John_Ivan_>
ox1eef_, and by "all", I don't mean specifics like nosql, hibernate, etc
<John_Ivan_>
I just mean, if sql is, in general, better than what I'm doing, from all points of view, even for a simple program like a tag storage cli
<ox1eef_>
It is a SQL database that's stored on disk. And common for application storage. I think some browsers use it for example.
<John_Ivan_>
yes but a browser is a megalodon of a project.
<ox1eef_>
INI files are more of a configuration format that's human-readable.
<John_Ivan_>
I needed something simple. key-pair dictionary. human readable.
<John_Ivan_>
file path associated with a string; containing words.
<John_Ivan_>
path:tags
<John_Ivan_>
didn't think for something that simple, I'd span over 250+ lines of code.
<John_Ivan_>
and I'm not even finished.
<ox1eef_>
There's JSON and YAML in the stdlib. I personally think that JSON is human-friendly, once you know the syntax.
<John_Ivan_>
ox1eef_, I have an exact project written with the same thing, just in json too
<John_Ivan_>
it too is large in size.
<John_Ivan_>
and yes, i wrote this like 3 times....
<John_Ivan_>
one in c#, one in ruby and one in erlang
<ox1eef_>
But how will it be smaller in size when you have to write your own INI parser, vs depend on json from the stdlib - which is done and ready.
<John_Ivan_>
ox1eef_, well, the iniparser project I have, already uses a iniparser and it still is 250+ lines of code
<John_Ivan_>
ox1eef_, maybe I should show some code
<ruby[bot]>
John_Ivan_: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<John_Ivan_>
I'd need an account for gist..
<ox1eef_>
Looks good and well-structured to me but that is not Ruby
<ox1eef_>
You can ignore ruby[bot]
<ox1eef_>
Mostly a nuisance bot with a political agenda.
<John_Ivan_>
ox1eef_, as you can see, **it uses** an iniparser already. and it's at 200 lines. and it isn't finished.
<John_Ivan_>
I find it a little ridiculous
<ox1eef_>
Ruby does not have an INI parser in the stdlib. But there odds are, there's a gem for it.
<weaksauce>
id use active record and be done in like 30 loc
<John_Ivan_>
ox1eef_, one reason I wrote this program 3 times is because, first, it was in ruby. and gems are what I've started to fear as I spent time in the ruby world
<John_Ivan_>
a lot are in pre-alpha stage
<John_Ivan_>
some are broken
<John_Ivan_>
and documentation is incomplete
<John_Ivan_>
that's when I switched to erlang
<John_Ivan_>
re-wrote it with a jsone parser (because erlang comes with an incorporated one)
<John_Ivan_>
ox1eef_, it stretched to 250+ lines as well.
<John_Ivan_>
and after trying to pack it with rebar3 (toolchain and package manager for erlang), I encountered some config issues and abandoned it
<John_Ivan_>
ox1eef_, now I'm in C#, doing the same thing. needing tests.
<John_Ivan_>
ox1eef_, there just doesn't seem to be a sweet spot sometimes.
<John_Ivan_>
always some inconvenience
<ox1eef_>
I don't know much of anything about C#
<John_Ivan_>
yeah, no worries.
<weaksauce>
active record and sqlite are both battle tested by zillions of apps
<John_Ivan_>
weaksauce, activerecord.... is that some ruby orm?
<weaksauce>
yeah it's rails' orn
<weaksauce>
orm*
<John_Ivan_>
I need the entire rails framework to use it?
<John_Ivan_>
I see. well.... since I'm already set on doing it in c#, I think I'll just have to find their orm equivalent.
<weaksauce>
eh you aren't going to write terse code in c#
<weaksauce>
if that's what you're after
<weaksauce>
regardless of some orm. in fact it'd probably be the same
<John_Ivan_>
weaksauce, I'm conflicted. i want to. but like I said, I believe this should be a simple program. it really shouldn't be longer than 100 loc.
<John_Ivan_>
so if orm/sql IS the way to do it properly
<John_Ivan_>
and it gets me that, then I think I'll go with that.
<ox1eef_>
It looks simple, and maintainable to me. I don't understand what the problem is.
<weaksauce>
same
<weaksauce>
other than the testing aspect
<John_Ivan_>
I'm just not used to writing programs where my function parameters are primarily strings. and my storage back end are strings too
<John_Ivan_>
it gives me the impression that anything can go wrong. and indeed it can.
<John_Ivan_>
I can't do proper error checking
<John_Ivan_>
because the possible flaws that can happen are stupendously numerous.
smp has joined #ruby
<John_Ivan_>
weaksauce, doesn't the orm bother you that you have to depend on a migration tool which handles your db?
<weaksauce>
it doesn't require the migration tool if you don't want to use it
dza has quit [Remote host closed the connection]
<weaksauce>
but no it doesn't bother me
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<John_Ivan_>
;/
<John_Ivan_>
I see
<John_Ivan_>
weaksauce, thanks
dza has joined #ruby
<weaksauce>
it's just as simple as require 'active_record'; class Movie< ActiveRecord; end; Movie.find(...) etc.
<weaksauce>
with a lil setup code
<weaksauce>
point it at the right db
<John_Ivan_>
weaksauce, I've used orms before. I'm just...
<John_Ivan_>
distrustful of big tools i guess
<John_Ivan_>
weaksauce, I encountered far too many broken or poorly documented technologies
<weaksauce>
you have to pick your battles
<John_Ivan_>
I've gotten... depressed over it
<weaksauce>
of course some version 0.05 is going to be shit
<weaksauce>
rails is used by huge companies
<John_Ivan_>
weaksauce, sure but I've met the reoccuring pattern in all languages
<John_Ivan_>
sometimes you wonder if it really is the 21st century
<John_Ivan_>
weaksauce, be it you needing a html parser in erlang. oh look, it's some prealpha broken github project
<John_Ivan_>
weaksauce, or some ruby gem which, oh look, it's documentation is incomplete
<John_Ivan_>
for iniparser
<John_Ivan_>
weaksauce, then you go for the more "official", microsoft languages, in the hope that they have a iniparser incorporated into .NET
<John_Ivan_>
weaksauce, to find that it's some nuget package written by the community
<John_Ivan_>
I'm getting very discouraged.
<John_Ivan_>
python is the same. ruby is the same. so is erlang, nodejs
<John_Ivan_>
;/
<John_Ivan_>
even the functional languages like ocaml and haskell
<John_Ivan_>
weaksauce, you sometimes wonder if people have or haven't been parsing html/xml/json/ini for the past 20 years
<weaksauce>
json is built into ruby my dude
<weaksauce>
html is hard
<weaksauce>
xml is hard
<weaksauce>
ini files are trivial
<weaksauce>
ini is not meant to be a database
<John_Ivan_>
I don't want to argue with your claims. I'm sure they're far more educated than mine are. but if ini files are trivial how come it's not in .NET and it's provided by a community nuget package? :(
<John_Ivan_>
and we're talking .NET/C#, "the" Microsoft stack, which "should" be, you know. "well baked"
<weaksauce>
i don't know? microsoft sucks?
<weaksauce>
ini is antiquated and not used by them much
<weaksauce>
it's a silly trivial file format
<weaksauce>
line.split("=") is basically all you need
<weaksauce>
check to see if there is a section
<weaksauce>
by testing for the first character
<John_Ivan_>
weaksauce, alright
<weaksauce>
when i think ini file it reminds me of like windows 3.1
buckwheat has joined #ruby
<adam12>
Could look at using YAMLStore
<adam12>
I can't get pastebin to load so not sure what the code looks like
<adam12>
I personally use sqlite everywhere. You can use extralite or something that packages sqlite with the gem, so it's basically dependency free.
user23 has quit [Remote host closed the connection]
<ox1eef_>
There's also pstore. Marshal-based format distributed with Ruby. Not human friendly, though.
<adam12>
I was thinking YAMLStore because it's human friendly(isH)