Merge: Work on the Curl module
[nit.git] / contrib / benitlux / src / benitlux_daily.nit
index 8121683..1c1f4d6 100644 (file)
@@ -49,7 +49,7 @@ redef class Text
 
        # Return an `Array` of the non-empty lines in `self`
        #
-       #     assert ["a", "asdf", "", "  ", " ", "b"].to_clean_lines == ["a", "asdf", "b"]
+       #     assert ["a", "asdf", "", "  ", " ", "b"].join("\n").to_clean_lines == ["a", "asdf", "b"]
        fun to_clean_lines: Array[String]
        do
                var orig_lines = split_with("\n")
@@ -112,7 +112,7 @@ class Benitlux
                generate_email(beer_events)
 
                # Save as sample email to file
-               var f = new OFStream.open(sample_email_path)
+               var f = new FileWriter.open(sample_email_path)
                f.write email_title + "\n"
                for line in email_content do f.write line + "\n"
                f.close
@@ -129,14 +129,11 @@ class Benitlux
        # Fetch the Web page at `url`
        fun download_html_page: String
        do
-               var curl = new Curl
-
-               var request = new CurlHTTPRequest(url, curl)
+               var request = new CurlHTTPRequest(url)
                var response = request.execute
 
                if response isa CurlResponseSuccess then
                        var body = response.body_str
-                       curl.destroy
                        return body
                else if response isa CurlResponseFailed then
                        print "Failed downloading URL '{url}' with: {response.error_msg} ({response.error_code})"
@@ -230,11 +227,11 @@ if not opts.errors.is_empty or opts.help.value == true then
 end
 
 var ben = new Benitlux("sherbrooke")
-ben.run(opts.send_emails.value or else false)
+ben.run(opts.send_emails.value)
 
 # The parsing logic for the wellington locaiton is active (to gather data)
 # but the web interface do not allow to subscribe to its mailing list.
 #
 # TODO revamp mailing list Web interface
 ben = new Benitlux("wellington")
-ben.run(opts.send_emails.value or else false)
+ben.run(opts.send_emails.value)