<zenspider>
that's a bad idea if I ever saw one...
<laanan>
haha
<laanan>
ok
artOfWar has quit [Remote host closed the connection]
<erikh>
zenspider: you should see what perftools.rb does..
andrewhl has quit [Remote host closed the connection]
<laanan>
so,ok, I thought debug was installed when I installed devkit
<laanan>
oops
<laanan>
so, do I need to change something with the ruby_core_source?
* zenspider
puts fingers in ears
<erikh>
laanan: I'd strongly suggest filing an issue report
<laanan>
ok
thone_ has quit [Ping timeout: 240 seconds]
<laanan>
I'll be back later to get more explanation, if you don't mind. That way I can file a proper issue report. But for now, I have yummy food to eat!
gsav has quit [Ping timeout: 240 seconds]
burgestrand has joined #ruby-lang
<laanan>
> finally succeeded. (The problem was that the install couldn't find
<S1kx>
how comes that in my capybara tests that use javascript (and thus selenium) I have to reload objects when I'm testing for example: expect { click_button "..." }.to change(user.followers, :count).by(1)?
<S1kx>
-possibly- associated to database_cleaner with :truncation for js tests, :transaction for others (that use rack-test)
diegoviola has quit [Ping timeout: 246 seconds]
gsav has joined #ruby-lang
bryancp has joined #ruby-lang
bfreeman has quit [Quit: bfreeman]
gsav has quit [Ping timeout: 248 seconds]
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
jsilver has quit [Remote host closed the connection]
mistym has quit [Remote host closed the connection]
enebo has joined #ruby-lang
andrewhl has joined #ruby-lang
thone has joined #ruby-lang
mistym has joined #ruby-lang
jsilver has joined #ruby-lang
srbartle_ has joined #ruby-lang
srbartlett has quit [Read error: Connection reset by peer]
perryh_away is now known as perryh
jsilver has quit [Remote host closed the connection]
msaffitz has quit [Quit: Computer has gone to sleep.]
perryh is now known as perry
jtoy has quit [Quit: jtoy]
gix has quit [Ping timeout: 248 seconds]
enebo has quit [Quit: enebo]
qpingu has quit [Quit: Leaving.]
ryanf has quit [Quit: leaving]
mistym has quit [Remote host closed the connection]
SteveG has quit [Ping timeout: 248 seconds]
gix has joined #ruby-lang
M4g1c5t0rM has joined #ruby-lang
kurko_ has quit [Quit: Saindo]
bryancp has quit [Remote host closed the connection]
awwaiid has quit [Read error: Connection reset by peer]
postmodern has joined #ruby-lang
banisterfiend has quit [Remote host closed the connection]
neoesque has joined #ruby-lang
cirenyc has joined #ruby-lang
T_Rex_ has quit [Quit: T_Rex_]
awwaiid has joined #ruby-lang
burgestrand has quit [Ping timeout: 240 seconds]
stardiviner has joined #ruby-lang
Sambalero has joined #ruby-lang
Sambalero has quit [Remote host closed the connection]
burgestrand has joined #ruby-lang
Sambalero has joined #ruby-lang
savage- has quit [Ping timeout: 240 seconds]
Y_Ichiro has quit [Read error: Connection reset by peer]
Y_Ichiro has joined #ruby-lang
banisterfiend has joined #ruby-lang
JustinCampbell has quit [Remote host closed the connection]
mistym has joined #ruby-lang
burgestrand has quit [Quit: Leaving.]
mistym has quit [Changing host]
mistym has joined #ruby-lang
andrewhl has quit [Remote host closed the connection]
towski has quit [Remote host closed the connection]
jstemmer has quit [Ping timeout: 260 seconds]
dvorak has quit [Quit: leaving]
ando has joined #ruby-lang
dv310p3r has joined #ruby-lang
seanstickle has quit [Quit: Nihil sub sole novum]
yugui_zzz is now known as yugui
mrsolo has quit [Quit: Leaving]
jstemmer has joined #ruby-lang
jperry2 has quit [Quit: jperry2]
Z33K|Lux has joined #ruby-lang
crankharder has quit [Remote host closed the connection]
seoaqua has joined #ruby-lang
jtoy has joined #ruby-lang
sepp2k has quit [Read error: Connection reset by peer]
laanan has quit [Ping timeout: 246 seconds]
savage- has joined #ruby-lang
andrewhl has joined #ruby-lang
savage- has quit [Remote host closed the connection]
alindeman has quit [Read error: Connection reset by peer]
alindeman has joined #ruby-lang
jtoy has quit [Quit: jtoy]
andrewhl has quit [Remote host closed the connection]
coryf has joined #ruby-lang
dc5ala has joined #ruby-lang
andrewhl has joined #ruby-lang
malev has joined #ruby-lang
postmodern has quit [Quit: Leaving]
coryf has quit [Remote host closed the connection]
dvorak has joined #ruby-lang
cirenyc has quit [Quit: Leaving...]
andrewhl has quit [Remote host closed the connection]
concernedcitizen has joined #ruby-lang
msaffitz has joined #ruby-lang
dvorak has quit [Quit: leaving]
dvorak has joined #ruby-lang
banisterfiend has quit [Remote host closed the connection]
brianpWins has quit [Quit: brianpWins]
M4g1c5t0rM has quit [Ping timeout: 246 seconds]
dv310p3r has quit [Quit: Leaving]
JoelMcCracken has quit [Ping timeout: 246 seconds]
banisterfiend has joined #ruby-lang
jtoy has joined #ruby-lang
kvirani has joined #ruby-lang
robbyoconnor has joined #ruby-lang
andrewhl has joined #ruby-lang
andrewhl has quit [Remote host closed the connection]
andrewhl has joined #ruby-lang
concernedcitizen has quit [Remote host closed the connection]
<whitequark>
parslet seems nice, except its unusual syntax, but I'm not sure of performance. If it isn't a memory hog like treetop it might be an option
tekin has quit [Quit: Computer has gone to sleep.]
<whitequark>
any other suggestions?
<yorickpeterse>
I've used Parslet in the past but I'm not sure about its performance
<whitequark>
yorickpeterse: well, it seems to at least allocate strings as single nodes
cantonic_ has joined #ruby-lang
cantonic has quit [Ping timeout: 265 seconds]
cantonic_ is now known as cantonic
<yorickpeterse>
It creates a node out of what you've defined but usually this will result in quite a few nodes
<yorickpeterse>
including whitespace ones
jperry2_ has joined #ruby-lang
<yorickpeterse>
Mind you it has been a while since I've used Parslet so things might've changed
<yorickpeterse>
I also wasn't a huge fan of the syntax
jarib has quit [Excess Flood]
jarib has joined #ruby-lang
dhruvasagar has quit [Ping timeout: 255 seconds]
<S1kx>
andrewvos: RSpe
<S1kx>
c
dhruvasagar has joined #ruby-lang
cirenyc has joined #ruby-lang
kristofferrr has quit [Quit: ❤]
Jade has joined #ruby-lang
tooky has joined #ruby-lang
thisirs has joined #ruby-lang
Axsuul has quit [Ping timeout: 240 seconds]
IPGlider has quit []
malev has joined #ruby-lang
bryancp has joined #ruby-lang
tommyvyo has joined #ruby-lang
woollyams has joined #ruby-lang
tekin has joined #ruby-lang
yannis has joined #ruby-lang
mistym has joined #ruby-lang
sailias has quit [Quit: Leaving.]
vesan_ has quit [Ping timeout: 248 seconds]
mistym has quit [Remote host closed the connection]
Mon_Ouie has quit [Ping timeout: 245 seconds]
Mon_Ouie has joined #ruby-lang
cirenyc has quit [Ping timeout: 265 seconds]
rippa has joined #ruby-lang
sepp2k has joined #ruby-lang
andrewhl has joined #ruby-lang
Jk3n has joined #ruby-lang
mztriz has joined #ruby-lang
dv310p3r has joined #ruby-lang
<yorickpeterse>
S1kx: that doesn't allow you to mock HTTP requests
<yorickpeterse>
andrewvos is well aware of rspec I assume :)
<S1kx>
no HTTP mocking involved here, just capybara as replacement for webrat
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
duper has joined #ruby-lang
cirenyc has joined #ruby-lang
hynkle has joined #ruby-lang
<S1kx>
and to solve my own problem: the issue was that it only waits and retries the assertions if you use a matcher on the page object (contrary to testing the AR object here), so to wait for the ajax request to complete, a wait_until { ... } block has to be added
<S1kx>
(so the problem was a different one afterall anyways)
VGoff is now known as VGoff_afk
ttilley is now known as ttilley_off
bryancp has quit [Remote host closed the connection]
brunocoelho has quit [Remote host closed the connection]
kvirani has quit [Remote host closed the connection]
Sambalero has joined #ruby-lang
zmack_ has joined #ruby-lang
zmack__ has joined #ruby-lang
<tef>
whitequark: write a parser by hand :-)
zmack has quit [Ping timeout: 246 seconds]
<tef>
whitequark: really it dependson %language name here%
zmack_ has quit [Ping timeout: 246 seconds]
mistym has quit [Remote host closed the connection]
<whitequark>
tef: liquor templating lang
<whitequark>
with some extensions to make it more general-purpose
Boondox has left #ruby-lang ["Leaving"]
hynkle has quit []
hynkle has joined #ruby-lang
hynkle has quit [Client Quit]
hynkle has joined #ruby-lang
<darix>
whitequark: dont you mean liquid?
<darix>
ah liquor exists too
<darix>
whitequark: if you want to write a parser look at ragel
<darix>
it can output ruby too
rking has quit [Quit: Upgrading to latest Weechat.]
enroxorz is now known as Paul-Atreides
rking has joined #ruby-lang
slyphon has joined #ruby-lang
kyrylo has quit [Quit: WeeChat 0.3.8]
kyrylo has joined #ruby-lang
kyrylo has quit [Changing host]
kyrylo has joined #ruby-lang
dominikh has joined #ruby-lang
jfelchner has joined #ruby-lang
<whitequark>
darix: yeah, it's a fork of liquid
<whitequark>
thanks for your suggestion, I'll look
cuttooth has left #ruby-lang [#ruby-lang]
bryancp has joined #ruby-lang
canton7 has joined #ruby-lang
enebo has joined #ruby-lang
crankharder has joined #ruby-lang
stamina has quit [Read error: Connection reset by peer]
stamina has joined #ruby-lang
JohnBat26 has quit [Ping timeout: 244 seconds]
mistym has joined #ruby-lang
kvirani has joined #ruby-lang
sailias has joined #ruby-lang
coryf has joined #ruby-lang
slyphon has quit [Quit: WeeChat 0.3.7]
Criztian has joined #ruby-lang
publicvoid__ has joined #ruby-lang
duper has left #ruby-lang [#ruby-lang]
ttilley_off is now known as ttilley
sockmonk has joined #ruby-lang
publicvoid_ has quit [Ping timeout: 264 seconds]
Rizzle has joined #ruby-lang
jxie has joined #ruby-lang
Natch has quit [Read error: Connection reset by peer]
kitallis has joined #ruby-lang
Natch_x has joined #ruby-lang
burgestrand has joined #ruby-lang
cirenyc has quit [Quit: Leaving...]
Natch_x is now known as Natch
Swimming_Bird has quit [Quit: Computer has gone to sleep.]
tbuehlmann has joined #ruby-lang
workmad3 has joined #ruby-lang
rhodee has joined #ruby-lang
msaffitz has joined #ruby-lang
msaffitz has quit [Client Quit]
Paul-Atreides has quit [Quit: Leaving]
<yorickpeterse>
erikh: probably said this before but nice work on that zlib patch
Swimming_Bird has joined #ruby-lang
<banisterfiend>
yorickpeterse: you mean drbrain?
|Vargas| has quit [Quit: ...]
<yorickpeterse>
Oh, that's drbrain?
<yorickpeterse>
Damn these nicknames
slyphon has joined #ruby-lang
<apeiros_>
are there nicer solutions than send to use Nokogiri::XML::Builder with namespaced elements?
<banisterfiend>
yorickpeterse: well drbrain is eric hodel i think
<apeiros_>
e.g. right now I have to do `Nokogiri::XML::Builder.new do |xml| xml.send('namespace:tag', attributes) do … end; end` - and I find that send there pretty ugly…
<apeiros_>
banisterfiend: yepp, he is
concernedcitizen has joined #ruby-lang
<apeiros_>
his whois even says so
concernedcitizen has quit [Remote host closed the connection]
concernedcitizen has joined #ruby-lang
zrail|home is now known as zrail
beiter has joined #ruby-lang
nazty has quit [Ping timeout: 265 seconds]
Xzyx987X has quit [Ping timeout: 245 seconds]
slyphon has quit [Ping timeout: 245 seconds]
slyphon has joined #ruby-lang
robotmay has joined #ruby-lang
robotmay_ has quit [Ping timeout: 248 seconds]
malev has quit [Remote host closed the connection]
Jk3n has quit [Ping timeout: 245 seconds]
andrewhl has quit [Remote host closed the connection]
Silowyi has joined #ruby-lang
cantonic has quit [Ping timeout: 244 seconds]
cirenyc has joined #ruby-lang
cantonic has joined #ruby-lang
<erikh>
banisterfiend: correct, drbrain is eric and I am erik
<erikh>
I am not the eric who wrote the zlib patches
<rue>
This is not the…ah, nevermind.
<erikh>
heh
<erikh>
eh, this happens once every 2 months or so
<erikh>
I get confused for liquid awesome.
<yorickpeterse>
liquid awesome? Sounds gross
<apeiros_>
<insert barney stinson joke>
<erikh>
wait until the money shot comes
<darix>
apeiros_: legen .. wait for it ... dary
akira989 has quit [Remote host closed the connection]
thisirs has quit [Remote host closed the connection]
robglees_ has quit [Remote host closed the connection]
malev has joined #ruby-lang
jtoy has joined #ruby-lang
Fretta has joined #ruby-lang
brianpWins has joined #ruby-lang
savage- has joined #ruby-lang
gregmore_ has quit [Ping timeout: 248 seconds]
gregmoreno has joined #ruby-lang
jtoy has quit [Ping timeout: 244 seconds]
carloslopes has quit [Quit: Leaving.]
fra000 has quit [Quit: Leaving]
fgomez has quit [Ping timeout: 255 seconds]
solars has joined #ruby-lang
dv310p3r has quit [Ping timeout: 246 seconds]
slyphon_ has joined #ruby-lang
slyphon has quit [Ping timeout: 244 seconds]
butchanton has joined #ruby-lang
dalton_ has joined #ruby-lang
slyphon_ has quit [Read error: Connection reset by peer]
slyphon has joined #ruby-lang
solars has quit [Ping timeout: 252 seconds]
slyphon has quit [Client Quit]
apeiros_ has quit [Remote host closed the connection]
slyphon has joined #ruby-lang
solars has joined #ruby-lang
dv310p3r has joined #ruby-lang
gnufied has quit [Quit: Leaving.]
chimkan_ has joined #ruby-lang
voker57 has quit [Read error: Connection reset by peer]
zmack__ has quit [Remote host closed the connection]
slyphon has quit [Quit: WeeChat 0.3.7]
autarch has joined #ruby-lang
kvirani has quit [Remote host closed the connection]
<autarch>
I'm writing a simple script as an example web client for my company's web services
yxhuvud has joined #ruby-lang
slyphon has joined #ruby-lang
<autarch>
I'm looking for some guidance on what the preferred http client and csv parsing libraries are
sailias has quit [Quit: Leaving.]
<canton7>
there's a CSV library built in. For simple http stuff, open-uri and net/http are fine. For more complex stuff (e.g. keeping cookies), RestClient seems popular
<autarch>
yeah, this is very simple stuff, so net/http should be enough
towski has joined #ruby-lang
<canton7>
top tip: open-uri is a wrapper around net/http (and some other things), and makes life a *lot* easier ;)
<autarch>
ok, easier sounds good
<autarch>
basically I want to write something reasonably idiomatic that gives ruby people an example they can build real code on
cdt has quit [Quit: Ex-Chat]
Jade has quit [Ping timeout: 264 seconds]
<autarch>
at some point we need to write actual client libraries, but that day is not today :(
<autarch>
how about command line option parsing?
<erikh>
optparse comes with ruby
<erikh>
other people prefer thor, slop, and trollop
zmack has quit [Remote host closed the connection]
Berglund has quit [Quit: Computer died.]
scampbell has quit [Remote host closed the connection]
rippa has quit [Read error: Connection reset by peer]
rippa has joined #ruby-lang
rippa has quit [Client Quit]
qpingu has joined #ruby-lang
jtoy has joined #ruby-lang
coryf has quit [Remote host closed the connection]
rippa has joined #ruby-lang
Sambalero has quit [Remote host closed the connection]
Sambalero has joined #ruby-lang
jtoy has quit [Quit: jtoy]
enebo has joined #ruby-lang
chimkan_ has quit [Quit: chimkan_]
cdt has joined #ruby-lang
ryanf has joined #ruby-lang
carloslopes has joined #ruby-lang
jtoy has joined #ruby-lang
kvirani has joined #ruby-lang
tomb has joined #ruby-lang
tommyvyo has quit [Ping timeout: 244 seconds]
xtagon has joined #ruby-lang
malev has quit [Remote host closed the connection]
HassanS has joined #ruby-lang
tommyvyo has joined #ruby-lang
bryancp has quit [Remote host closed the connection]
cdt has quit [Quit: Ex-Chat]
bglusman has joined #ruby-lang
sailias has joined #ruby-lang
solars has quit [Ping timeout: 250 seconds]
headius has quit [Quit: headius]
tekin has joined #ruby-lang
mztriz has quit [Quit: Leaving]
QaDeS has joined #ruby-lang
matti has quit [Quit: 8-X]
Natch has quit [Read error: Connection reset by peer]
Natch has joined #ruby-lang
<rue>
Thor isn’t an option parser
<autarch>
if I read the docs for optparse correctly, arguments default to being parsed as strings, but it seems like they're actually parsed as booleans
<erikh>
it depends on how you provide the options
soahccc` is now known as soahccc
Berglund has joined #ruby-lang
sora_h is now known as s0ra_h
<autarch>
erikh: how I provide them via the CLI or how I specify them to the OptionParser object?
<autarch>
I have this ... opts.on("-i", "--ip", String, "IP address to look up") do
<autarch>
but then it seems to parse as a boolean
<autarch>
or something else, I'm not really sure
Sambalero has quit [Remote host closed the connection]
<rue>
Don’t mix parsed as vs. parsed into :)
<autarch>
derr, I don't even know what that means
<rue>
That should be opts.on "-i", "--ip IPADDRESS", String, "IP address to look up"
<rue>
I think
<rue>
Otherwise it probably doesn’t understand it’s supposed to capture
<rue>
Or something
<autarch>
oh, so it parses the "--ip IPADDRESS" bit?
<erikh>
rue: correct
Natch has quit [Read error: Connection reset by peer]
banisterfiend has quit [Read error: Connection reset by peer]
Natch has joined #ruby-lang
<autarch>
wow, it does parse it
<autarch>
this is a crazy API!
<erikh>
yeah, that's why some people prefer others.
<autarch>
I take a list of options, except some of them are magic strings, and some are regular strings, and some are classes names, and some are ...
<andrewhl>
using rubyzip.sourceforge.net/classes/Zip/ZipFile.html, how might I loop through a zip file to find a file of a specific extension type (like .exe)?
<erikh>
autarch: well, that's on you I believe
<erikh>
although mixlib-cli can convert that stuff.
<erikh>
(which is what I prefer these days)
<autarch>
yeah, I was trying to stick with core libs if possible
<autarch>
this is for an example script on our website, not for internal use
ViperMaul has joined #ruby-lang
<autarch>
so I figured less deps is better all things being even
mdstunthamster has joined #ruby-lang
<erikh>
yeah, optparse is a fine library
<erikh>
it just takes some adjustment
mdstunthamster has quit [Client Quit]
banisterfiend has joined #ruby-lang
<autarch>
it's a little cute. I kind of hate cute
Rizzle has quit [Ping timeout: 252 seconds]
<rue>
Heh
<rue>
It’s sensible enough…the base form is "-s", "--short", "Description"
<rue>
Then if you want an argument, it’s "--yay ARGUMENTWHATEVERYOULIKEGOESHERE"
<rue>
If it’s optional, "--moo [OPTIONAL]"
<rue>
Etc. Just like you’d see in a usage listing
malev has joined #ruby-lang
Tearan has joined #ruby-lang
headius has joined #ruby-lang
<autarch>
yeah, I get it now
<autarch>
I just prefer explicit parameters rather than parsing strings
<autarch>
some Perl modules do the same thing and it drives me insane
<erikh>
I knew your nick sounded familiar
<autarch>
is it possible to zip two arrays into a hash?
<erikh>
Hash[*ary.zip(ary2)]
<yxhuvud>
hmm. I wonder how many times I've seen that question answered now
<autarch>
heh
<autarch>
I realized as soon as I asked that "possible" was the wrong phrasing
<autarch>
obviously it's possible
soahccc is now known as soahccc`
<Mon_Ouie>
yxhuvud: Personally, I saw it much less often than how to go from [:a, 1, :b, 2] to {:a => 1, :b => 2}
<autarch>
except I think that * is misplaced
<autarch>
Hash[fields.zip(response.body.parse_csv)] seems to do what I want
<yxhuvud>
Mon_Ouie: I think I havn't seen that one actually
Sambalero has joined #ruby-lang
* apeiros_
thinks Hash.from(keys, values) would warrant its own method
<apeiros_>
it's used often enough
<yxhuvud>
agreed, but it needs a better name than tat
<apeiros_>
agreed :)
<apeiros_>
Hash.zip(keys,values) ?
<yxhuvud>
or map, perhaps.
towski has quit [Remote host closed the connection]
<yxhuvud>
though I suppose Hash#map would confuse people.
<autarch>
is Iconv the right way to decode latin-1 data to utf-8?
<apeiros_>
autarch: for ruby 1.8, yes
<apeiros_>
for ruby 1.9, no
<autarch>
if I'm writing an example client script for our web service, is it reasonable to write it for 1.9 ?
<yxhuvud>
autarch: yes, unless your existing system has a lot of 1.8
<autarch>
and what's the blessed way to do it 1.9?
<autarch>
yxhuvud: this isn't for our internal use, this is for our customers to use as a starting point
<autarch>
so I don't care too much ;)
<autarch>
I just want to know what ruby people care about
<mistym>
Your Latin-1 text should be tagged with the Latin-1 encoding, in which case you can do str.encode("utf-8") to transform it into unicode.
<yxhuvud>
1.9 then. no reason to start something new in 1.8 unless you really have to.
<autarch>
ok, calling str.encode seems to work well
<diegoviola>
i'm having encoding issues with 1.8, like ruby is trying to insert data to a postgres db, but postgres expects utf8 and ruby is tryign to insert something else, should i just switch to 1.9 or?
<diegoviola>
*trying
IPGlider has joined #ruby-lang
mrsolo has joined #ruby-lang
<erikh>
diegoviola: ruby 1.8 uses byte strings
<erikh>
you have to manage the encodings yourself.
<erikh>
byte arrays*
dhruvasagar has quit [Ping timeout: 246 seconds]
headius has quit [Quit: headius]
<diegoviola>
where can i see more information about that?
<erikh>
it's a lack of context, not an addition
bryancp has joined #ruby-lang
dRbiG has quit [Ping timeout: 264 seconds]
solars has joined #ruby-lang
HassanS has quit [Ping timeout: 246 seconds]
jtoy has quit [Quit: jtoy]
HassanS has joined #ruby-lang
agilob has joined #ruby-lang
cjs226 has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
mytrile has joined #ruby-lang
banisterfiend has joined #ruby-lang
pajama has joined #ruby-lang
roblally has joined #ruby-lang
wmoxam has joined #ruby-lang
roblally has left #ruby-lang [#ruby-lang]
ilyam has joined #ruby-lang
malev has quit [Remote host closed the connection]
<autarch>
so is my ruby code really so beautiful that it can't be improved (I kind of doubt it) - https://gist.github.com/3100286
malev has joined #ruby-lang
<Mon_Ouie>
if ! omni[:error].nil? could just be if omni[:error]
<Mon_Ouie>
and generally if !(…) would be unless …
<autarch>
hmm, that part doesn't work at all (that if clause)
<autarch>
but this works - if omni["error"]
<autarch>
I totally don't understand the difference between those two
grandy has joined #ruby-lang
<grandy>
hello, i seem to be having great difficulty actually forcing a string to be utf8 and removing non utf8 chars
<grandy>
i have googled and tried various approaches recommended
<grandy>
anyone know an approach that can just let me be confident that the result only contains valid utf8?
<Mon_Ouie>
Oh, that's because you're using the wrong key. Your key is a String, so you should use a String, not a Symbol (i.e. "error" instead of :error)
<Mon_Ouie>
(Or alternatively you replace the strings of your fields array with symbols)
<grandy>
suppose s is a string containing non utf8 chars, s !~ /\S/ raises, even after I try force_encoding and use undef replace and invalid replace...
<burgestrand>
grandy: is your original string utf8 but has invalid characters?
Criztian has quit [Remote host closed the connection]
<grandy>
burgestrand: no it's some other charset
<zrail>
grandy: are you setting a replacement string?
<grandy>
zrail: i have tried a few approaches, let me be sure I am
<Mon_Ouie>
autarch: Symbols are interned strings (they're kind of like symbols in lisp for instance)
<burgestrand>
grandy: if you encode to utf8 when the string already is marked as utf8 (yourstring.encoding), ruby will optimize it away and do *nothing*
<grandy>
burgestrand: ahh interestingffff
<zrail>
even with force_encoding?
<burgestrand>
grandy: force_encoding does nothing more than setting the encoding on the string
mwjcomputing has quit [Quit: Leaving]
<burgestrand>
you can think of it as an attr_writer if you like, there is nothing happening
<burgestrand>
grandy: "any string".force_encoding("UTF-8").encoding # => UTF-8, but no translation happens here
<grandy>
burgestrand: would valid_encoding? return false though if all you did was set the encoding on a non utf8 string?
<Mon_Ouie>
It would indeed
<burgestrand>
grandy: if the string is invalid in utf8 it would
<burgestrand>
or, should, I’ve had invalid strings when it didn’t
<burgestrand>
was some kind of strange edge case
<grandy>
burgestrand: hmm, interesting...
<grandy>
so is undef: replace, :replace: '' the right approach? (but before force encoding?)
<drbrain>
grandy: actually, it depends on the contents. If it's from an ASCII-7bit compatible encoding and is ASCII-7bit-only, it will return true
<burgestrand>
grandy: thing is, ruby must know the origin encoding in order to properly encode it to utf8
<burgestrand>
if you already have an utf8 string that is invalid, there is no good way in ruby to just replace invalid characters
<drbrain>
grandy: and probably invalid: replace
<grandy>
burgestrand: ahh ok that is probably where thigns are getting out of whack then..
<burgestrand>
however, if you have a non-utf8 string that has characters that cannot be converted to utf8, that you can do
<burgestrand>
(or vice-versa)
<burgestrand>
but it does kind of force you to know the encoding of the string *before* conversion
<grandy>
burgestrand: ahh ok, there isn't a way to just tell it "make an educated guess what the encoding is and convert as much of it as possible to utf8 and remove the rest"
<burgestrand>
the thing with strings that most programmers simply ignore is that they are really just random bytes unless you know their encoding
<burgestrand>
grandy: not as far as I know, no, there are gems to guess encoding of strings that might help with that
<grandy>
burgestrand: i guess i know that in a theoretical sense but tend to get by on the coincidental similariteis of the encodings :)
<burgestrand>
grandy: rchardet is one, but I’m not sure how well it works on 1.9, I recall apeiros_ was related to it somehow, maybe he tried porting it to 1.9?
<burgestrand>
grandy: :)
<rue>
autarch: Use unless rather than if !
<apeiros_>
burgestrand: I was only ranting about it
<autarch>
rue: I just changed it to ... if omni["error"]
<autarch>
which I think makes the most sense
tbuehlmann has quit []
<apeiros_>
there's 3 versions of chardet, I don't remember which one was the 1.9 compatible
<grandy>
burgestrand: one example i saw appeared to try several encodes in a row
<autarch>
and unless ... else seems insane ;)
<apeiros_>
and it was bad at guessing the right charset too. my variant was better. but I had/have a very specific env
<burgestrand>
grandy: but I suppose you could try to guess the original encoding, then force_encode(guessed_encoding).encode("utf-8", options)
<burgestrand>
grandy: I believe you might be able to force_encoding("utf-8").encode("utf-32le", options).encode("utf-8") or something like that
<rue>
autarch: There’s no need for an else, since you’re #exiting
<autarch>
oh good point
enroxorz has quit [Quit: Leaving]
<grandy>
burgestrand: hmm interesting
<autarch>
but like I said, a straightforward "if error" works
<burgestrand>
apeiros_: guessing charsets is almost like russian roulette, but you get smilies instead of brain mush
<rue>
autarch: But, yes, typically unless…else means you could structure the code differently.