• Stars
    star
    80
  • Rank 390,306 (Top 8 %)
  • Language
    Ruby
  • License
    Other
  • Created over 14 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pure ruby scoped configuration files.

configuration.rb¶ ↑

pure ruby scoped configuration files

Description¶ ↑

configuration.rb provides a mechanism for configuring ruby programs with ruby configuration files. a configuration.rb file, for example ‘config/app.rb’, can be written simply as

Configuration.for('app') {
  key 'value'
  foo 'bar'
  port 42
}

and loaded via the normal ruby require/load mechanism

Kernel.load 'config/app.rb'

or with a slightly augmented loading mechnanism which simply searches an extra set of paths in addition to the standard ones

Configuration.path = %w( config configuration )

Configuration.load 'app'

configurations are completely open

Configuration.for('app') {
  object_id 'very open'
}

support arbitrarily nested values

Configuration.for('app') {
  a { b { c { d 42 } } }
}

c = Configuration.for 'app'

p c.a.b.c.d #=> 42

allow POLS scoped lookup of vars

Configuration.for('config') {
  outer 'bar'

  inner {
    value 42
  }
}

c = Configuration.for 'config'

p c.outer       #=> 'bar'
p c.inner.value #=> 42
p c.inner.outer #=> 'bar'

allow default values

default = Configuration.for( 'default' ) {
  a 1
  b 2
}

c = Configuration.for( 'config', default ) {
 a 10
}

p c.a     #=> 10
p c.b     #=> 2

and not a whole lot else - configuration.rb is s very small library consisting of one file and < 150 loc

Samples¶ ↑

samples/a.rb¶ ↑

~ > cat samples/a.rb

  #
  # basic usage is quite, simple, load the config and use it's values.  the
  # config syntax is fairly obvious, i think, but note that it *is* ruby and any
  # ruby can be included.  also note that each config is named, allowing
  # multiple configs to be places in one file
  #
    require 'configuration'

    c = Configuration.load 'a'

    p c.a + c.b - c.c

~ > ruby samples/a.rb

  42

samples/b.rb¶ ↑

~ > cat samples/b.rb

  #
  # configuration.rb supports a very natural nesting syntax.  note how values
  # are scoped in a POLS fashion
  #
    require 'configuration'

    c = Configuration.for 'b'

    p c.www.url
    p c.db.url
    p c.mail.url

~ > ruby samples/b.rb

  "http://codeforpeople.com:80"
  "db://codeforpeople.com:5342"
  "mail://gmail.com:25"

samples/c.rb¶ ↑

~ > cat samples/c.rb

  #
  # configuration.rb let's you keep code very dry.
  #

    require 'configuration'

    Configuration.load 'c'

    p Configuration.for('development').db
    p Configuration.for('production').db
    p Configuration.for('testing').db

~ > ruby samples/c.rb

  "db/development"
  "db/production"
  "db/testing"

samples/d.rb¶ ↑

~ > cat samples/d.rb

  #
  # configuration.rb makes use of an external blank slate dsl, this means that
  # you Configuration objects do, in fact, have all built-in ruby methods such
  # as #inspect, etc, *unless* you configure over the top of them.  the effect
  # is a configuration object that behaves like a nice ruby object, but which
  # allows *any* key to be configured
  #
    require 'configuration'

    c = Configuration.for 'd'

    p c.object_id
    p c.inspect
    p c.p

~ > ruby samples/d.rb

  config/d.rb:2:in `object_id': wrong number of arguments (1 for 0) (ArgumentError)
    from config/d.rb:2
    from ./lib/configuration.rb:159:in `instance_eval'
    from ./lib/configuration.rb:159:in `call'
    from ./lib/configuration.rb:159:in `method_missing'
    from ./lib/configuration.rb:105:in `evaluate'
    from ./lib/configuration.rb:68:in `initialize'
    from ./lib/configuration.rb:29:in `new'
    from ./lib/configuration.rb:29:in `for'
    from config/d.rb:1
    from ./lib/configuration.rb:53:in `load'
    from ./lib/configuration.rb:53:in `load'
    from ./lib/configuration.rb:31:in `for'
    from samples/d.rb:10

samples/e.rb¶ ↑

~ > cat samples/e.rb

  #
  # configuration.rb uses a totally clean slate dsl for the block.  if you need
  # to access base Object methods you can do this
  #

    require 'configuration'

    c = Configuration.for 'e'

    p c.foo
    p c.bar
    p c.foobar

~ > ruby samples/e.rb

  42
  "forty-two"
  42.0

samples/f.rb¶ ↑

~ > cat samples/f.rb

  #
  # configuration.rb let's you inherit values from another configuration.
  # Like this, you keep your code very dry.
  #

    require 'configuration'

    Configuration.load 'f'

    p c.a
    p c.b

~ > ruby samples/f.rb

  10
  2

[email protected]

More Repositories

1

sekrets

sekrets is a command line tool and library used to securely manage encrypted files and settings in your rails' applications and git repositories.
Ruby
269
star
2

main

a class factory and dsl for generating command line programs real quick
Ruby
265
star
3

open4

open child process with handles on pid, stdin, stdout, and stderr: manage child processes and their io handles easily.
Ruby
195
star
4

map

the ruby container you've always wanted: an ordered string/symbol indifferent hash
Ruby
167
star
5

systemu

univeral capture of stdout and stderr and handling of child process pid for windows, *nix, etc.
Ruby
125
star
6

testy

a BDD testing framework for ruby that's mad at the world and plans to kick it's ass in 78 freakin lines of code
Ruby
98
star
7

forkoff

brain-dead simple parallel processing for ruby
Ruby
73
star
8

fattr

fattr.rb is a "fatter attr" for ruby and borrows heavily from the metakoans.rb ruby quiz
Ruby
73
star
9

session

session offers a persistent way to drive the shell (/bin/sh) via ruby
Ruby
63
star
10

dao

sa-weet data access object library for rails. top secret.
Ruby
61
star
11

lockfile

a ruby library for creating NFS safe lockfiles
Ruby
54
star
12

macaddr

cross platform mac address determination for ruby
Ruby
47
star
13

middleman-gibberish

password protect middleman pages - even on s3
JavaScript
47
star
14

threadify

threadify.rb makes it stupid easy to process a bunch of data using 'n' worker threads
Ruby
39
star
15

shared

shared.rb provides a super easy way to share code between classes or modules in a simple way.
Ruby
33
star
16

bj

Backgroundjob (Bj) is a brain dead simple, zero admin, background priority queue for Rails.
Ruby
31
star
17

tagz

tagz.rb generates html, xml, or any sgml variant like a small ninja running across the backs of a herd of giraffes swatting of heads like a mark-up weedwacker.
Ruby
31
star
18

demon

demon.rb - the ruby daemon library you've been waiting for
Ruby
29
star
19

slave

easy management of child process works over pipes and drb
Ruby
27
star
20

rails_build

A very small, very simple, very fast, and bullet proof static site generator built as a Rails 5 engine.
Ruby
25
star
21

objectpool

a simple, robust, generic thread-safe object pool for ruby
Ruby
20
star
22

rq

ruby queue is a zero-admin zero-configuration tool used to create instant unix clusters
Ruby
20
star
23

raptcha

low drain bamage, storage-less, session-less, plugin-less, zero admin, single-source-file secure captcha system for ruby and/or rails.
Ruby
19
star
24

arrayfields

allow keyword access to array instances.
Ruby
18
star
25

tumblr

a command line utility and library for the excellent tumblr blogging platform
Ruby
18
star
26

helene

helene is a plugin for writing rails applications on top of amazon's aws platform including sdb, s3, and sqs
Ruby
17
star
27

rego

run arbitrary commands easily when files change
Ruby
16
star
28

fbomb

fbomb is the dangerous flowdock bot
Ruby
16
star
29

fucking_favicons

fucking favicons fucking suck
Ruby
15
star
30

mongoid-haystack

a mongoid 3 zero-config, zero-integration, POLS pure mongo fulltext solution
Ruby
14
star
31

coxswain

encapsulate pre-forking master / worker pattern for ruby
Ruby
12
star
32

jquery.bires

bandwidth limited progressive image enhancement
JavaScript
12
star
33

hashish

awesome data access layer for rails/ruby projects
Ruby
12
star
34

rails_current

track current_STUFF mo betta
Ruby
9
star
35

assassin

no zombies ever, not even on `exit!` or `kill -9`
Ruby
9
star
36

default_url_options

all relative urls in rails all the time. even in mailers.
Ruby
8
star
37

forkhandle

a teeny library / design pattern for managing connections in a process and thread safe fashion
Ruby
7
star
38

rememberthemilk

simple (162 loc), json only, interface to the excellent RememberTheMilk API
Ruby
7
star
39

wrap

non-sucky :before and :after callbacks for any ruby class
Ruby
7
star
40

conducer

a model+view component for rails that combines the conductor and presenter pattern
Ruby
7
star
41

ro

ro is library for managing your site's content in git, as god intended.
Ruby
7
star
42

rails_default_url_options

you really can have default_url_options everywhere. even in mailers.
Ruby
7
star
43

options

options.rb handles keyword options in ruby in a simple and robust way
Ruby
6
star
44

rails_errors2html

simple and sane active_model error html rendering
Ruby
6
star
45

irbcp

irbcp gives access to your system's clipboard (copy and paste) from irb
Ruby
6
star
46

fukung

perhaps the most important ruby code EVAAARRR! gets random images from http://fukung.net.
Ruby
6
star
47

rails_nav

objectified navigation for rails
Ruby
5
star
48

pork

pork supports parallel programming in ruby using forked actors and durable sqlite message queues
Ruby
5
star
49

cssjs

a zero learning curve zero contraints dsl for writing css stylesheets in javascript
JavaScript
5
star
50

isolation

a small rails app to demonstrate what *you* don't understand about RDBMS transactions
Ruby
5
star
51

mongoid-fts

enable mongodb's new fulltext simply and quickly on your mongoid models, including pagination.
Ruby
4
star
52

terminator

an external timeout mechanism based on processes and signals
Ruby
4
star
53

lru_cache

a simple but efficient implementation of a size limited least recently used cache in ruby
Ruby
4
star
54

cdc

uber simple cross domain communication for javascript/iframes
JavaScript
4
star
55

coerce

a ruby library full of common cast/coercion operations
Ruby
4
star
56

rails_view

render views from anywhere. even without a controller context
Ruby
4
star
57

rails_helper

helper = Helper.new and helper.link_to(:foo)
Ruby
4
star
58

ggeocode

simple wrapper on google's new geocoding api
Ruby
4
star
59

suck

gem to show issues with gem/minigem load ordering
Shell
3
star
60

alpo

a library and design pattern for building sane web applications on top of the rails' stack
Ruby
3
star
61

backup.rake

rails' rake task for backup up and loading data+assets as yaml+files
Ruby
3
star
62

nfsutils

Ruby FileUtils for NFS
3
star
63

id3rename

id3rename is a program to do simple renaming of mp3 files
3
star
64

bookify

development moved to https://github.com/everlater/bookify
Ruby
3
star
65

senv

the 12-factor environment tool your mother told you to use
Ruby
3
star
66

codeforpeople

billions and billions of libs
3
star
67

ledis

a K.I.S.S auto-rotating redis logger for ruby/rails
Ruby
3
star
68

kgb

ultra lightweight javascript decision tree builder
JavaScript
3
star
69

image_cache

a small utility library to facility caching image uploads between form validation failures.
2
star
70

gnip-ruby

Ruby library for utilizing Gnip services.
Ruby
2
star
71

linked_list

a simple linked list implementation for ruby
Ruby
2
star
72

bucket

bucket is a command-line interface for amazon's s3 service
2
star
73

tmpdir_block

extends ruby's built-in Dir.tmpdir to accept a block.
Ruby
2
star
74

bestofyoutube

simple ruby library to grab some good video urls from http://bestofyoutube.com
Ruby
2
star
75

superhash

A general mechanism for defining attribute inheritance structures among objects of any type, not just classes
Ruby
2
star
76

testing.rb

adds the minimal features required in order to make test/unit not suck
Ruby
2
star
77

openobject

a simple property based container that's much more capable than a blankslate but far less polluted than ruby's built-in OpenStruct
Ruby
2
star
78

candy_store

hybrid session store that combines rails' built-in cookie based session store with its database backed one
Ruby
2
star
79

slug

a simple slug library. unicode prepared.
Ruby
2
star
80

mongoid-bolt

mongoid-bolt is a concrete lock implementation and mixin.
Ruby
2
star
81

markdown

my markdown script
Ruby
2
star
82

growltdf

growltdf is the greatest program evar. it let's you scrape http://cyclingnews.com for TDF updates and dump them into growl to you can keep up with the race while working.
2
star
83

nmap

narray + mmap = wicked fast persistent numerical arrays for ruby
Ruby
2
star
84

mob

background jobs for mongoid
Ruby
1
star
85

foobar

1
star
86

ydb

mo-betta the yaml/store.
Ruby
1
star
87

hrs

tracking teh hours from the cli
Ruby
1
star
88

mp3scrape

download shit-loads of mp3s from web pages
Ruby
1
star
89

wapp

golden.image
Ruby
1
star
90

forkify

forkify.rb makes it easy to process a bunch of data using 'n' worker processes
Ruby
1
star
91

upload_cache

a small utility library to facility caching http file uploads between form validation failures. designed for rails, but usable anywhere.
Ruby
1
star
92

campfire

a command line script for using 37signal's campfire chat room
1
star
93

ansible

magic unicorns for your deployz
Ruby
1
star
94

ey-cloud-recipes

A starter repo for custom chef recipes on EY's cloud platform
Ruby
1
star
95

cast

a collection of casting methods for ruby
1
star
96

fifo

a very simple javascript fifo queue / cache
JavaScript
1
star
97

test

1
star
98

one-click-hugo-cms

CSS
1
star
99

attributes

the implementation of attributes.rb borrows many of the best ideas from the metakoans.rb ruby quiz (ps. fattr >= attributes)
Ruby
1
star
100

gnip-expander

relay a gnip publisher stream to another, expanding shortened uris in the process
Ruby
1
star