Project

self_data

0.01
Low commit activity in last 3 years
No release in over a year
It's like DATA but better
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

SelfData ยท Gem Version Build Status Coverage Status

It's like native ruby DATA but you can use it not only for main file.

Installation

# Gemfile
gem 'self_data'
$ bundle install
-- or --
$ gem install self_data
require 'self_data'

Synopsis

# main.rb

require 'self_data'
require './a.rb'

puts "DATA: #{A.native_data}"
puts "SelfData: #{A.self_data}"

__END__
main.rb data
# a.rb

module A
  module_function

  def native_data
    DATA.read
  end

  def self_data
    SelfData.read
  end
end

__END__
a.rb data

and if you execute it, you'll get:

$ ruby main.rb
DATA: main.rb data
SelfData: a.rb data

Usage and Notes

Use SelfData.read() to get text or use SelfData.load(*formats, **options) to get formatted data (like yaml, xml, erb, etc).

Look at the lib/self_data/config.rb for more details.

SelfData uses caller, it's not fast, that's why you shouldn't use SelfData in loops.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/self_data.

License

Released under MIT License.

Authors

Created by 7dr1v3

Supported by Umbrellio