lib/figgy.rb in figgy-0.0.1 vs lib/figgy.rb in figgy-0.9.0
- old
+ new
@@ -6,13 +6,28 @@
require "figgy/configuration"
require "figgy/hash"
require "figgy/finder"
require "figgy/store"
+# An instance of Figgy is the object used to provide access to your
+# configuration files. This does very little but recognize missing
+# methods and go look them up as a configuration key.
+#
+# To create a new instance, you probably want to use +Figgy.build+:
+#
+# MyConfig = Figgy.build do |config|
+# config.root = '/path/to/my/configs'
+# end
+# MyConfig.foo.bar #=> read from /path/to/my/configs/foo.yml
+#
+# This should maybe be a BasicObject or similar, to provide as many
+# available configuration keys as possible. Maybe.
class Figgy
FileNotFound = Class.new(StandardError)
+ # @yield [Figgy::Configuration] an object to set things up with
+ # @return [Figgy] a Figgy instance using the configuration
def self.build(&block)
config = Configuration.new
block.call(config)
new(config)
end
@@ -27,7 +42,16 @@
end
end
def method_missing(m, *args, &block)
@store.get(m)
+ end
+
+ def inspect
+ if @store.size > 0
+ key_names = @store.keys.sort
+ "#<Figgy (#{@store.size} keys): #{key_names.join(' ')}>"
+ else
+ "#<Figgy (empty)>"
+ end
end
end