Coder Social home page Coder Social logo

self_data's Introduction

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

self_data's People

Contributors

7dr1v3 avatar tycooon avatar

Stargazers

Михаил avatar  avatar Rustam Ibragimov avatar Optimus Advocate avatar Nik Marchenko avatar Artem Saulenko avatar Alexandr Smirnov avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.