Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify custom SCORM API url and other minor tweaks #14

Closed
wants to merge 2 commits into from

Conversation

phallstrom
Copy link

  • Added the ability to specify a custom SCORM API url via an ENV var.

  • Added undercased versions of ENV vars so they are usable on the
    command line.

  • Replaced use of try which is Rails specific with Ruby begin/rescue
    handler.

  • Updated README to reflect above changes and fix some inaccuracies.

- Added the ability to specify a custom SCORM API url via an ENV var.

- Added undercased versions of ENV vars so they are usable on the
  command line.

- Replaced use of `try` which is Rails specific with Ruby begin/rescue
  handler.

- Updated README to reflect above changes and fix some inaccuracies.
@@ -6,19 +6,18 @@ class RequestError < Error
attr_reader :code, :msg, :url

def initialize(doc, url)
err = doc.elements["rsp"].try(:elements).try(:[], "err")
if err
err = doc.elements["rsp"].elements["err"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation for this change? I don't adore try which we were doing before, but an unscoped rescue is worse, in my view. We could rescue the specific errors you'd expected from line 9, but if we are going to do that, why not try? I could easily be missing something :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try doesn't exist outside of rails. When I was testing this change manually using the CLI app with a a bogus course id, the above code was triggered and failed because try is undefined. I could change that to use respond_to?(:elements) instead. I think I went with the bare rescue mostly to deal with multiple tries. Thoughts on flipping over to respond_to? ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, duh. I'm +1 on respond_to?. Consider splitting this to a few lines if needed with that solution. Clarity over brevity.

@mcwqy9
Copy link

mcwqy9 commented Feb 2, 2017

-1, see comment. Everything else looks good and useful. Thanks for contributing back to this.

- Added the ability to specify a custom SCORM API url via an ENV var.

- Added undercased versions of ENV vars so they are usable on the
  command line.

- Replaced use of `try` which is Rails specific with Ruby begin/rescue
  handler.

- Updated README to reflect above changes and fix some inaccuracies.
@phallstrom phallstrom closed this Feb 3, 2017
@phallstrom
Copy link
Author

@mcwqy9 messed up my patch. new one coming.

@phallstrom phallstrom deleted the api_url branch February 3, 2017 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants