I'll write more about the method I used when I have a bit more time, but the latest version is here:
https://github.com/kennethdamica/Monocle
Again, Germanunkol's version has a much better interface, but I had a few issues with some of the changes he made (or I might just have not understood them), so I never merged in his fork.
https://github.com/Germanunkol/Monocle
EDIT: Okay, here goes:
1) Get the forward-facing edges and put them in a table. I didn't use a border edge and assumed that the world is enclosed because I got lazy. (Monocle:get_forward_edges)
2) Set the 'next' and 'previous' attributes of each edge based on the grid or some other way, if your edges are not grid based. (Monocle:link_edges)
3) Now, loop through your edges, and wherever an edge is missing a 'next' or 'previous', cast a ray. Store the info about the projected edges in a separate table 'edges_to_add'.
4) Sort 'edges_to_add' by their distance to the light (shortest distance). (3 & 4: Monocle:add_projections)
(Now the hard part)
5) In that order, add the projected edges to the table of edges. Whichever edge the far end of the projection hits, drop that edge from the table and insert two new edges, split by where the projection hit.
6) Depending on whether is was a 'back' edge or a 'front' edge (meaning, when you move clockwise, whether the edge is the first or second to be hit), set the previous and next attributes of the projected edge, the edge it was projected from, and the new edges that were created by the split. (5 & 6: add_projection_edge)
NOTES:
-Do not lose any information about the previous and next edges that were already attached. That backward edge that gets hit may seem useless right now, but another projection could hit it later, so it needs to be there.
-The special case here is when the projection hits an endpoint precisely. In this case, you do not need to split the edge. The 'precisely' part of this gave me some issues.
(Now it's easy again)
7) Now, starting from the closest edge to the player (which is guaranteed to be a forward edge) follow the 'next' attributes all the way around until you get back to your starting place. Each edge forms a triangle with the third point being the light source. I leave it to you to decide how you want to use these points. I just drew a bunch of white triangles onto a black canvas and multiplicatively drew it on my other canvas. Germanunkol does it differently (this method is where I disagreed with him. One is not necessarily better, it's just a matter of how you intend to use it). (Monocle:draw_triangles)
And that's basically it. This probably shouldn't have taken me as long as it did, but I made a few very subtle yet fatal errors in my initial design that took me a long time to figure out. Also, I never fully figured out the special case where the projection hits the corner. Sometimes it still messes up, so as a band-aid I just added a tiny random number to the light's position. The addition is not enough to be visible. This way, I could add a check in my game for when Monocle fails to return a complete polygon, and run it again in the next frame rather than wait for the light to move.
Hopefully this helps. Happy to answer more questions.