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

Require 'Date' in date_extensions.rb #37

Merged
merged 1 commit into from
May 9, 2016
Merged

Conversation

ambirdsall
Copy link
Contributor

@ambirdsall ambirdsall commented May 8, 2016

I used tod to write a little command-line script that would return a different emoji for my terminal prompt based on the time of day (:coffee: in the AM, :beer: at 6:30, 🌒 when I need to go tf to bed, etc). I was getting the following error:

~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/tod-2.0.2/lib/tod/date_extensions.rb:15:in `<top (required)>': uninitialized constant Date (NameError)
    from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/tod-2.0.2/lib/tod/core_extensions.rb:1:in `<top (required)>'
    from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

This adds an explicit require 'Date' to the offending file so that this can be used in a self-contained way outside of environments like rails where the Date class comes preloaded.

cf. neo4jrb/activegraph#852

When calling gem from a little command-line script, I was getting the
following error:
```
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/tod-2.0.2/lib/tod/date_extensions.rb:15:in `<top (required)>': uninitialized constant Date (NameError)
	from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/tod-2.0.2/lib/tod/core_extensions.rb:1:in `<top (required)>'
	from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/ambirdsall/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
```

This adds an explicit `require 'Date'` to the offending file so that
this can be used outside of bundled environments where the `Date` class
is preloaded.
@jackc
Copy link
Owner

jackc commented May 9, 2016

Thanks!

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.

2 participants