require "yaml"
require "__data__"
class Status
REASONS = YAML.load __DATA__
end
__END__
200: OK
404: Not Found
Last active
August 29, 2015 14:02
-
-
Save ixti/21b291cdb80574bf29a9 to your computer and use it in GitHub Desktop.
Ruby data inliner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def __DATA__ | |
s, m = "", false | |
::File.open caller.first.split(/:\d+:in/).first, "r" do |io| | |
io.each_line do |line| | |
next s << line if m | |
m = line =~ /^__END__$/ | |
end | |
end | |
fail NameError, "uninitialized constant __DATA__" unless m | |
s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment