Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

props

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

props

  • 1.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

props - Manage Settings Hierachies (Commandline, User, Home, Defaults, etc.)

  • home :: github.com/rubylibs/props
  • bugs :: github.com/rubylibs/props/issues
  • gem :: rubygems.org/gems/props
  • rdoc :: rubydoc.info/gems/props

Usage

Props

Example:

class Config

  DEFAULTS = { 'libs' => [ 'kramdown' ],
               'extnames' => [
                 '.markdown',
                 '.m',
                 '.mark',
                 '.mkdn',
                 '.md',
                 '.mdown',
                 '.markdn',
                 '.txt',
                 '.text' ],
                'redcarpet' => {
                 'extensions' => [
                    'no_intra_emphasis',
                    'fenced_code_blocks',
                    'tables',
                    'strikethrough' ] }
             }

  def initialize
    @props = @props_default = Props.new( DEFAULTS, 'DEFAULTS' )

    # check for user settings (markdown.yml) in home folder

    props_home_file = File.join( Env.home, 'markdown.yml' )
    if File.exists?( props_home_file )
      puts "Loading settings from '#{props_home_file}'..."
      @props = @props_home = Props.load_file( props_home_file, @props )
    end

    # check for user settings (markdown.yml) in working folder

    props_work_file = File.join( '.', 'markdown.yml' )
    if File.exists?( props_work_file )
      puts "Loading settings from '#{props_work_file}'..."
      @props = @props_work = Props.load_file( props_work_file, @props )
    end
  end

  def markdown_extnames
    @props.fetch( 'extnames', nil )
  end

  ...

end # class Config

Environment

Example:

puts Env.home
# => '/home/gerald'

Backstage the Env.home code looks something like:

path = if( ENV['HOME'] || ENV['USERPROFILE'] )
         ENV['HOME'] || ENV['USERPROFILE']
       elsif( ENV['HOMEDRIVE'] && ENV['HOMEPATH'] )
         "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
       else
         begin
            File.expand_path('~')
         rescue
            if File::ALT_SEPARATOR
               'C:/'
            else
               '/'
            end
         end
       end

Env.path returns ENV[ 'PATH' ] - splits all path entries w/ file separator (e.g. ; or :) and returns string array

puts Env.path
# => ['/usr/local/sbin',
#      '/usr/local/bin',
#      '/usr/sbin',
#      ...
#     ]

Install

Just install the gem:

$ gem install props

Real World Usage

The slideshow gem (also known as Slide Show (S9)) that lets you create slide shows and author slides in plain text using a wiki-style markup language that's easy-to-write and easy-to-read.

The pluto gem that lets you auto-build web pages from web feeds.

The markdown gem that lets you use your markdown library of choice.

License

The props scripts are dedicated to the public domain. Use it as you please with no restrictions whatsoever.

Questions? Comments?

Post them to the wwwmake forum. Thanks!

FAQs

Package last updated on 29 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc